Skip to content

CodeGen: Remove TargetOptions::FloatABIType - #215796

Merged
arsenm merged 4 commits into
mainfrom
users/arsenm/codegen/remove-targetoptions-floatabi
Aug 18, 2026
Merged

CodeGen: Remove TargetOptions::FloatABIType#215796
arsenm merged 4 commits into
mainfrom
users/arsenm/codegen/remove-targetoptions-floatabi

Conversation

@arsenm

@arsenm arsenm commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

This is now fully replaced with the "float-abi" module flag.
If the module flag is not present, the default is computed
from the triple. Consumers are updated to read the module flag.

RuntimeLibraryAnalysis now defers analysis until run() on a Module,
instead of during the pass constructor as before. This requires copying
all of the remaining relevant TargetOptions so they are available
when the module is seen.

Unfortunately, ARM still depends on TargetOptions for determining
the float-abi. -target-abi=aapcs16 still changes the default float-abi,
but an explicit module flag wins.

Co-authored-by: Claude (Claude-Opus-4.8) noreply@anthropic.com

arsenm commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

@arsenm arsenm added llvm:codegen llvm:SelectionDAG SelectionDAGISel as well labels Aug 12, 2026 — with Graphite App
@arsenm
arsenm marked this pull request as ready for review August 12, 2026 13:05
@llvmorg-github-actions

llvmorg-github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown

@llvm/pr-subscribers-llvm-analysis
@llvm/pr-subscribers-lto
@llvm/pr-subscribers-llvm-transforms
@llvm/pr-subscribers-llvm-ir
@llvm/pr-subscribers-flang-driver
@llvm/pr-subscribers-backend-hexagon
@llvm/pr-subscribers-backend-arm

@llvm/pr-subscribers-llvm-selectiondag

Author: Matt Arsenault (arsenm)

Changes

This is now fully replaced with the "float-abi" module flag.
If the module flag is not present, the default is computed
from the triple. Consumers are updated to read the module flag.

RuntimeLibraryAnalysis now defers analysis until run() on a Module,
instead of during the pass constructor as before. This requires copying
all of the remaining relevant TargetOptions so they are available
when the module is seen.

Unfortunately, ARM still depends on TargetOptions for determining
the float-abi. -target-abi=aapcs16 still changes the default float-abi,
but an explicit module flag wins.

Co-authored-by: Claude (Claude-Opus-4.8) <noreply@anthropic.com>


Patch is 30.83 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/215796.diff

29 Files Affected:

  • (modified) clang/lib/CodeGen/BackendUtil.cpp (+3-14)
  • (modified) flang/lib/Frontend/FrontendActions.cpp (+4-4)
  • (modified) llvm/docs/ReleaseNotes.md (+3)
  • (modified) llvm/include/llvm/Analysis/RuntimeLibcallInfo.h (+19-17)
  • (modified) llvm/include/llvm/IR/Module.h (+1-1)
  • (modified) llvm/include/llvm/IR/RuntimeLibcalls.h (+10-1)
  • (modified) llvm/include/llvm/Target/TargetOptions.h (-8)
  • (modified) llvm/lib/Analysis/RuntimeLibcallInfo.cpp (+5-18)
  • (modified) llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp (+3-3)
  • (modified) llvm/lib/CodeGen/CommandFlags.cpp (-2)
  • (modified) llvm/lib/CodeGen/TargetLoweringBase.cpp (+2-1)
  • (modified) llvm/lib/IR/Module.cpp (+4-2)
  • (modified) llvm/lib/IR/RuntimeLibcalls.cpp (+6-4)
  • (modified) llvm/lib/LTO/LTOBackend.cpp (+1-2)
  • (modified) llvm/lib/Target/ARM/ARMAsmPrinter.cpp (+1-5)
  • (modified) llvm/lib/Target/ARM/ARMTargetMachine.cpp (+15-20)
  • (modified) llvm/lib/Target/ARM/ARMTargetMachine.h (+5)
  • (modified) llvm/lib/Target/CSKY/CSKYTargetMachine.cpp (-2)
  • (modified) llvm/test/CodeGen/Hexagon/autohvx/xqf-assertion1.ll (+2-2)
  • (modified) llvm/test/CodeGen/Hexagon/autohvx/xqf-handle-conv.ll (+2-2)
  • (modified) llvm/test/CodeGen/Hexagon/fmaximum.ll (+1-1)
  • (modified) llvm/test/CodeGen/Hexagon/fminimum.ll (+1-1)
  • (added) llvm/test/LTO/ARM/float-abi-module-flag.ll (+45)
  • (added) llvm/test/Transforms/Util/DeclareRuntimeLibcalls/float-abi-module-flag.ll (+28)
  • (modified) llvm/tools/llc/NewPMDriver.cpp (+2-4)
  • (modified) llvm/tools/llc/llc.cpp (+2-6)
  • (modified) llvm/tools/lli/lli.cpp (+6-2)
  • (modified) llvm/tools/opt/NewPMDriver.cpp (+1-2)
  • (modified) llvm/tools/opt/optdriver.cpp (+2-2)
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index e95552b7e9e06..16fb29d75be70 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -392,17 +392,6 @@ static bool initTargetOptions(const CompilerInstance &CI,
     break;
   }
 
-  // Set float ABI type.
-  assert((CodeGenOpts.FloatABI == "soft" || CodeGenOpts.FloatABI == "softfp" ||
-          CodeGenOpts.FloatABI == "hard" || CodeGenOpts.FloatABI.empty()) &&
-         "Invalid Floating Point ABI!");
-  Options.FloatABIType =
-      llvm::StringSwitch<llvm::FloatABI::ABIType>(CodeGenOpts.FloatABI)
-          .Case("soft", llvm::FloatABI::Soft)
-          .Case("softfp", llvm::FloatABI::Soft)
-          .Case("hard", llvm::FloatABI::Hard)
-          .Default(llvm::FloatABI::Default);
-
   // Set FP fusion mode.
   switch (LangOpts.getDefaultFPContractMode()) {
   case LangOptions::FPM_Off:
@@ -1275,9 +1264,9 @@ void EmitAssemblyHelper::RunCodegenPipelineLegacy(
   CodeGenPasses.add(new TargetLibraryInfoWrapperPass(*TLII));
 
   const llvm::TargetOptions &Options = TM->Options;
-  CodeGenPasses.add(new RuntimeLibraryInfoWrapper(
-      TargetTriple, Options.ExceptionModel, Options.FloatABIType,
-      Options.EABIVersion, Options.MCOptions.ABIName, Options.VecLib));
+  CodeGenPasses.add(
+      new RuntimeLibraryInfoWrapper(Options.ExceptionModel, Options.EABIVersion,
+                                    Options.MCOptions.ABIName, Options.VecLib));
 
   if (TM->addPassesToEmitFile(CodeGenPasses, *OS,
                               DwoOS ? &DwoOS->os() : nullptr, CGFT,
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index e21590cc9fa7f..7ecda651027e2 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -920,8 +920,8 @@ static void generateMachineCodeOrAssemblyImpl(
       llvm::driver::createTLII(triple, codeGenOpts.getVecLib());
   codeGenPasses.add(new llvm::TargetLibraryInfoWrapperPass(*tlii));
   codeGenPasses.add(new llvm::RuntimeLibraryInfoWrapper(
-      triple, tm.Options.ExceptionModel, tm.Options.FloatABIType,
-      tm.Options.EABIVersion, tm.Options.MCOptions.ABIName, tm.Options.VecLib));
+      tm.Options.ExceptionModel, tm.Options.EABIVersion,
+      tm.Options.MCOptions.ABIName, tm.Options.VecLib));
 
   std::unique_ptr<llvm::ToolOutputFile> dwoOS;
   if (!codeGenOpts.SplitDwarfOutput.empty()) {
@@ -1040,8 +1040,8 @@ void CodeGenAction::runOptimizationPipeline(llvm::raw_pwrite_stream &os) {
   fam.registerPass([&] { return llvm::TargetLibraryAnalysis(*tlii); });
   mam.registerPass([&] {
     return llvm::RuntimeLibraryAnalysis(
-        triple, targetMachine->Options.ExceptionModel,
-        targetMachine->Options.FloatABIType, targetMachine->Options.EABIVersion,
+        targetMachine->Options.ExceptionModel,
+        targetMachine->Options.EABIVersion,
         targetMachine->Options.MCOptions.ABIName,
         targetMachine->Options.VecLib);
   });
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index 40e0303f77e86..ee128b416463d 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -54,6 +54,9 @@ Makes programs 10x faster by doing Special New Thing.
 
 ### Changes to LLVM infrastructure
 
+* Removed `TargetOptions::FloatABIType`. The soft float ABI should be
+  controlled by setting the `"float-abi"` module flag.
+
 ### Changes to building LLVM
 
 ### Changes to TableGen
diff --git a/llvm/include/llvm/Analysis/RuntimeLibcallInfo.h b/llvm/include/llvm/Analysis/RuntimeLibcallInfo.h
index 3054177bc6cce..f4d81b2f1e057 100644
--- a/llvm/include/llvm/Analysis/RuntimeLibcallInfo.h
+++ b/llvm/include/llvm/Analysis/RuntimeLibcallInfo.h
@@ -11,6 +11,8 @@
 
 #include "llvm/IR/RuntimeLibcalls.h"
 #include "llvm/Pass.h"
+#include <optional>
+#include <string>
 
 namespace llvm {
 
@@ -20,24 +22,26 @@ class LLVM_ABI RuntimeLibraryAnalysis
   using Result = RTLIB::RuntimeLibcallsInfo;
 
   RuntimeLibraryAnalysis() = default;
-  RuntimeLibraryAnalysis(RTLIB::RuntimeLibcallsInfo &&BaselineInfoImpl)
-      : LibcallsInfo(std::move(BaselineInfoImpl)) {}
-  RuntimeLibraryAnalysis(
-      const Triple &TT,
-      ExceptionHandling ExceptionModel = ExceptionHandling::None,
-      FloatABI::ABIType FloatABI = FloatABI::Default,
-      EABI EABIVersion = EABI::Default, StringRef ABIName = "",
-      VectorLibrary VecLib = VectorLibrary::NoLibrary);
+  RuntimeLibraryAnalysis(ExceptionHandling ExceptionModel,
+                         EABI EABIVersion = EABI::Default,
+                         StringRef ABIName = "",
+                         VectorLibrary VecLib = VectorLibrary::NoLibrary)
+      : ExceptionModel(ExceptionModel), EABIVersion(EABIVersion),
+        ABIName(ABIName.str()), VecLib(VecLib) {}
 
   RTLIB::RuntimeLibcallsInfo run(const Module &M, ModuleAnalysisManager &);
 
-  operator bool() const { return LibcallsInfo.has_value(); }
-
 private:
   friend AnalysisInfoMixin<RuntimeLibraryAnalysis>;
   static AnalysisKey Key;
 
-  std::optional<RTLIB::RuntimeLibcallsInfo> LibcallsInfo;
+  // FIXME: These are TargetOptions values that are not yet represented in the
+  // IR, copied here so run() can forward them to the RuntimeLibcallsInfo Module
+  // constructor. Delete each one as they are migrated to module flags.
+  ExceptionHandling ExceptionModel = ExceptionHandling::None;
+  EABI EABIVersion = EABI::Default;
+  std::string ABIName;
+  VectorLibrary VecLib = VectorLibrary::NoLibrary;
 };
 
 class LLVM_ABI RuntimeLibraryInfoWrapper : public ImmutablePass {
@@ -47,12 +51,10 @@ class LLVM_ABI RuntimeLibraryInfoWrapper : public ImmutablePass {
 public:
   static char ID;
   RuntimeLibraryInfoWrapper();
-  RuntimeLibraryInfoWrapper(
-      const Triple &TT,
-      ExceptionHandling ExceptionModel = ExceptionHandling::None,
-      FloatABI::ABIType FloatABI = FloatABI::Default,
-      EABI EABIVersion = EABI::Default, StringRef ABIName = "",
-      VectorLibrary VecLib = VectorLibrary::NoLibrary);
+  RuntimeLibraryInfoWrapper(ExceptionHandling ExceptionModel,
+                            EABI EABIVersion = EABI::Default,
+                            StringRef ABIName = "",
+                            VectorLibrary VecLib = VectorLibrary::NoLibrary);
 
   const RTLIB::RuntimeLibcallsInfo &getRTLCI(const Module &M) {
     if (!RTLCI) {
diff --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h
index 53927e96a232e..6090644f7a12f 100644
--- a/llvm/include/llvm/IR/Module.h
+++ b/llvm/include/llvm/IR/Module.h
@@ -1066,7 +1066,7 @@ class LLVM_ABI Module {
   /// @{
 
   /// Returns the floating-point ABI recorded by the "float-abi" module flag, or
-  /// FloatABI::Default when the flag is absent (meaning the target default).
+  /// the ABI implied by the target triple when the flag is absent.
   FloatABI::ABIType getFloatABI() const;
   /// @}
 
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.h b/llvm/include/llvm/IR/RuntimeLibcalls.h
index 78b75f3e81c3b..8519100f9f80a 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.h
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.h
@@ -87,7 +87,16 @@ struct RuntimeLibcallsInfo {
       EABI EABIVersion = EABI::Default, StringRef ABIName = "",
       VectorLibrary VecLib = VectorLibrary::NoLibrary);
 
-  LLVM_ABI explicit RuntimeLibcallsInfo(const Module &M);
+  // FIXME: The floating-point ABI is read from the "float-abi" module flag, but
+  // the ExceptionModel/EABIVersion/ABIName/VecLib parameters are still
+  // TargetOptions values that are not yet represented in the IR. Delete these
+  // parameters (and build everything from the Module) once those fields are
+  // migrated to module flags.
+  LLVM_ABI explicit RuntimeLibcallsInfo(
+      const Module &M,
+      ExceptionHandling ExceptionModel = ExceptionHandling::None,
+      EABI EABIVersion = EABI::Default, StringRef ABIName = "",
+      VectorLibrary VecLib = VectorLibrary::NoLibrary);
 
   LLVM_ABI bool invalidate(Module &M, const PreservedAnalyses &PA,
                            ModuleAnalysisManager::Invalidator &);
diff --git a/llvm/include/llvm/Target/TargetOptions.h b/llvm/include/llvm/Target/TargetOptions.h
index dc8b2ebceee46..f6c862e99b98f 100644
--- a/llvm/include/llvm/Target/TargetOptions.h
+++ b/llvm/include/llvm/Target/TargetOptions.h
@@ -358,14 +358,6 @@ class TargetOptions {
   /// If greater than 0, override TargetLoweringBase::PrefLoopAlignment.
   unsigned LoopAlignment = 0;
 
-  /// FloatABIType - This setting is set by -float-abi=xxx option is specfied
-  /// on the command line. This setting may either be Default, Soft, or Hard.
-  /// Default selects the target's default behavior. Soft selects the ABI for
-  /// software floating point, but does not indicate that FP hardware may not
-  /// be used. Such a combination is unfortunately popular (e.g.
-  /// arm-apple-darwin). Hard presumes that the normal FP ABI is used.
-  FloatABI::ABIType FloatABIType = FloatABI::Default;
-
   /// AllowFPOpFusion - This flag is set by the -fp-contract=xxx option.
   /// This controls the creation of fused FP ops that store intermediate
   /// results in higher precision than IEEE allows (E.g. FMAs).
diff --git a/llvm/lib/Analysis/RuntimeLibcallInfo.cpp b/llvm/lib/Analysis/RuntimeLibcallInfo.cpp
index 1c5a1cc75b7bd..23dca93c4d884 100644
--- a/llvm/lib/Analysis/RuntimeLibcallInfo.cpp
+++ b/llvm/lib/Analysis/RuntimeLibcallInfo.cpp
@@ -13,34 +13,21 @@ using namespace llvm;
 
 AnalysisKey RuntimeLibraryAnalysis::Key;
 
-RuntimeLibraryAnalysis::RuntimeLibraryAnalysis(const Triple &TT,
-                                               ExceptionHandling ExceptionModel,
-                                               FloatABI::ABIType FloatABI,
-                                               EABI EABIVersion,
-                                               StringRef ABIName,
-                                               VectorLibrary VecLib)
-    : LibcallsInfo(std::in_place, TT, ExceptionModel, FloatABI, EABIVersion,
-                   ABIName, VecLib) {}
-
 RTLIB::RuntimeLibcallsInfo
 RuntimeLibraryAnalysis::run(const Module &M, ModuleAnalysisManager &) {
-  if (!LibcallsInfo)
-    LibcallsInfo = RTLIB::RuntimeLibcallsInfo(M);
-  return *LibcallsInfo;
+  return RTLIB::RuntimeLibcallsInfo(M, ExceptionModel, EABIVersion, ABIName,
+                                    VecLib);
 }
 
 INITIALIZE_PASS(RuntimeLibraryInfoWrapper, "runtime-library-info",
                 "Runtime Library Function Analysis", false, true)
 
-RuntimeLibraryInfoWrapper::RuntimeLibraryInfoWrapper()
-    : ImmutablePass(ID), RTLA(RTLIB::RuntimeLibcallsInfo(Triple())) {}
+RuntimeLibraryInfoWrapper::RuntimeLibraryInfoWrapper() : ImmutablePass(ID) {}
 
 RuntimeLibraryInfoWrapper::RuntimeLibraryInfoWrapper(
-    const Triple &TT, ExceptionHandling ExceptionModel,
-    FloatABI::ABIType FloatABI, EABI EABIVersion, StringRef ABIName,
+    ExceptionHandling ExceptionModel, EABI EABIVersion, StringRef ABIName,
     VectorLibrary VecLib)
-    : ImmutablePass(ID), RTLCI(std::in_place, TT, ExceptionModel, FloatABI,
-                               EABIVersion, ABIName, VecLib) {}
+    : ImmutablePass(ID), RTLA(ExceptionModel, EABIVersion, ABIName, VecLib) {}
 
 char RuntimeLibraryInfoWrapper::ID = 0;
 
diff --git a/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp b/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp
index b66e1027e64c2..d869c123c2046 100644
--- a/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp
+++ b/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp
@@ -129,9 +129,9 @@ addPassesToGenerateCode(CodeGenTargetMachineImpl &TM, PassManagerBase &PM,
   const TargetOptions &Options = TM.Options;
   TargetLibraryInfoImpl TLII(TM.getTargetTriple(), Options.VecLib);
   PM.add(new TargetLibraryInfoWrapperPass(TLII));
-  PM.add(new RuntimeLibraryInfoWrapper(
-      TM.getTargetTriple(), Options.ExceptionModel, Options.FloatABIType,
-      Options.EABIVersion, Options.MCOptions.ABIName, Options.VecLib));
+  PM.add(
+      new RuntimeLibraryInfoWrapper(Options.ExceptionModel, Options.EABIVersion,
+                                    Options.MCOptions.ABIName, Options.VecLib));
 
   invokeGlobalTargetPassConfigCallbacks(TM, PM, PassConfig);
 
diff --git a/llvm/lib/CodeGen/CommandFlags.cpp b/llvm/lib/CodeGen/CommandFlags.cpp
index 88987d0bc5558..24d46c6dcfe94 100644
--- a/llvm/lib/CodeGen/CommandFlags.cpp
+++ b/llvm/lib/CodeGen/CommandFlags.cpp
@@ -590,8 +590,6 @@ codegen::InitTargetOptionsFromCodeGenFlags(const Triple &TheTriple) {
 
   Options.HonorSignDependentRoundingFPMathOption =
       getEnableHonorSignDependentRoundingFPMath();
-  if (getFloatABIForCalls() != FloatABI::Default)
-    Options.FloatABIType = getFloatABIForCalls();
   Options.EnableAIXExtendedAltivecABI = getEnableAIXExtendedAltivecABI();
   Options.NoZerosInBSS = getDontPlaceZerosInBSS();
   Options.GuaranteedTailCallOpt = getEnableGuaranteedTailCallOpt();
diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp
index 71eda1048bc11..3213788b71dc8 100644
--- a/llvm/lib/CodeGen/TargetLoweringBase.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp
@@ -944,7 +944,8 @@ TargetLoweringBase::TargetLoweringBase(const TargetMachine &tm,
                                        const TargetSubtargetInfo &STI)
     : TM(tm),
       RuntimeLibcallInfo(TM.getTargetTriple(), TM.Options.ExceptionModel,
-                         TM.Options.FloatABIType, TM.Options.EABIVersion,
+                         TM.getTargetTriple().getDefaultFloatABI(),
+                         TM.Options.EABIVersion,
                          TM.Options.MCOptions.getABIName(), TM.Options.VecLib),
       Libcalls(RuntimeLibcallInfo, STI) {
   initActions();
diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp
index 2ae76b80ccd57..510d33c0ad295 100644
--- a/llvm/lib/IR/Module.cpp
+++ b/llvm/lib/IR/Module.cpp
@@ -700,8 +700,10 @@ void Module::setLongDoubleFormat(LongDoubleFormat Format) {
 
 FloatABI::ABIType Module::getFloatABI() const {
   if (auto *Val = dyn_cast_or_null<MDString>(getModuleFlag("float-abi")))
-    return FloatABI::parseABIType(Val->getString()).value_or(FloatABI::Default);
-  return FloatABI::Default;
+    return *FloatABI::parseABIType(Val->getString());
+  // Without an explicit flag, fall back to the ABI implied by the target
+  // triple.
+  return getTargetTriple().getDefaultFloatABI();
 }
 
 std::optional<uint64_t> Module::getLargeDataThreshold() const {
diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp
index ad7d3320f8928..d8069e207d3ef 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -101,10 +101,12 @@ RuntimeLibcallsInfo::RuntimeLibcallsInfo(const Triple &TT,
   }
 }
 
-RuntimeLibcallsInfo::RuntimeLibcallsInfo(const Module &M)
-    : RuntimeLibcallsInfo(M.getTargetTriple()) {
-  // TODO: Consider module flags
-}
+RuntimeLibcallsInfo::RuntimeLibcallsInfo(const Module &M,
+                                         ExceptionHandling ExceptionModel,
+                                         EABI EABIVersion, StringRef ABIName,
+                                         VectorLibrary VecLib)
+    : RuntimeLibcallsInfo(M.getTargetTriple(), ExceptionModel, M.getFloatABI(),
+                          EABIVersion, ABIName, VecLib) {}
 
 /// Set default libcall names. If a target wants to opt-out of a libcall it
 /// should be placed here.
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index 73697a9d0d446..69bc3fdae6c57 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -485,8 +485,7 @@ static void codegen(const Config &Conf, TargetMachine *TM,
     TargetLibraryInfoImpl TLII(Mod.getTargetTriple(), TM->Options.VecLib);
     CodeGenPasses.add(new TargetLibraryInfoWrapperPass(TLII));
     CodeGenPasses.add(new RuntimeLibraryInfoWrapper(
-        Mod.getTargetTriple(), TM->Options.ExceptionModel,
-        TM->Options.FloatABIType, TM->Options.EABIVersion,
+        TM->Options.ExceptionModel, TM->Options.EABIVersion,
         TM->Options.MCOptions.ABIName, TM->Options.VecLib));
 
     // No need to make index available if the module is empty.
diff --git a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp
index 59ad547dc26d7..11f7929cb6dbe 100644
--- a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp
+++ b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp
@@ -698,11 +698,7 @@ void ARMAsmPrinter::emitAttributes() {
   }
   const ARMBaseTargetMachine &ATM =
       static_cast<const ARMBaseTargetMachine &>(TM);
-  // The float ABI comes from the "float-abi" module flag if present, otherwise
-  // from the legacy -float-abi target option.
-  FloatABI::ABIType FloatABI = MMI->getModule()->getFloatABI();
-  if (FloatABI == FloatABI::Default)
-    FloatABI = ATM.Options.FloatABIType;
+  FloatABI::ABIType FloatABI = ATM.getFloatABI(*MMI->getModule());
   const ARMSubtarget STI(TT, std::string(CPU), ArchFS, ATM,
                          ATM.isLittleEndian(), FloatABI);
 
diff --git a/llvm/lib/Target/ARM/ARMTargetMachine.cpp b/llvm/lib/Target/ARM/ARMTargetMachine.cpp
index 3d388a7db6687..a1ced45a83e63 100644
--- a/llvm/lib/Target/ARM/ARMTargetMachine.cpp
+++ b/llvm/lib/Target/ARM/ARMTargetMachine.cpp
@@ -156,16 +156,6 @@ ARMBaseTargetMachine::ARMBaseTargetMachine(const Target &T, const Triple &TT,
       TargetABI(ARM::computeTargetABI(TT, Options.MCOptions.ABIName)),
       TLOF(createTLOF(getTargetTriple())), isLittle(TT.isLittleEndian()) {
 
-  // Default to triple-appropriate float ABI. -target-abi=aapcs16 forces hard
-  // float regardless of the triple default.
-  if (Options.FloatABIType == FloatABI::Default) {
-    if (TargetABI == ARM::ARM_ABI_AAPCS16 ||
-        TT.getDefaultFloatABI() == FloatABI::Hard)
-      this->Options.FloatABIType = FloatABI::Hard;
-    else
-      this->Options.FloatABIType = FloatABI::Soft;
-  }
-
   // Default to triple-appropriate EABI
   if (Options.EABIVersion == EABI::Default ||
       Options.EABIVersion == EABI::Unknown) {
@@ -207,6 +197,20 @@ MachineFunctionInfo *ARMBaseTargetMachine::createMachineFunctionInfo(
       Allocator, F, static_cast<const ARMSubtarget *>(STI));
 }
 
+FloatABI::ABIType ARMBaseTargetMachine::getFloatABI(const Module &M) const {
+  // An explicit "float-abi" module flag always wins, even for AAPCS16.
+  if (auto *Val = dyn_cast_or_null<MDString>(M.getModuleFlag("float-abi")))
+    return *FloatABI::parseABIType(Val->getString());
+
+  // With no explicit ABI, an explicit -target-abi=aapcs16 forces hard float
+  // even on triples whose default float ABI is soft (the triple default only
+  // detects AAPCS16 when it is the triple's own default ABI).
+  if (TargetABI == ARM::ARM_ABI_AAPCS16)
+    return FloatABI::Hard;
+  // Otherwise fall back to the ABI implied by the target triple.
+  return M.getTargetTriple().getDefaultFloatABI();
+}
+
 const ARMSubtarget *
 ARMBaseTargetMachine::getSubtargetImpl(const Function &F) const {
   Attribute CPUAttr = F.getFnAttribute("target-cpu");
@@ -238,16 +242,7 @@ ARMBaseTargetMachine::getSubtargetImpl(const Function &F) const {
   if (DM != DenormalMode::getIEEE())
     Key += "denormal-fp-math=" + DM.str();
 
-  // The float ABI comes from the "float-abi" module flag if present, otherwise
-  // from the legacy -float-abi target option (which the constructor seeded from
-  // the target triple).
-  FloatABI::ABIType FloatABI = F.getParent()->getFloatABI();
-  if (FloatABI == FloatABI::Default) {
-    FloatABI = Options.FloatABIType;
-    assert(FloatABI != FloatABI::Default &&
-           "expected TargetMachine constructor to overwrite default float abi");
-  }
-
+  FloatABI::ABIType FloatABI = getFloatABI(*F.getParent());
   // It is legal to have FloatABI::Hard with +soft-float for targets with SIMD
   // registers, but no floating-point hardware (mve+nofp)
   Key += FloatABI == FloatABI::Hard ? "+hard-float-abi" : "+soft-float-abi";
diff --git a/llvm/lib/Target/ARM/ARMTargetMachine.h b/llvm/lib/Target/ARM/ARMTargetMachine.h
index 1d373e65978f9..81dc7a5965f6f 100644
--- a/llvm/lib/Target/ARM/ARMTargetMachine.h
+++ b/llvm/lib/Target/ARM/ARMTargetMachine.h
@@ -52,6 +52,11 @@ class ARMBaseTargetMachine : public CodeGenTargetMachineImpl {
   const ARMSubtarget *getSubtargetImpl() const = delete;
   bool isLittleEndian() const { return isLittle; }
 
+  /// Returns the floating-point ABI ...
[truncated]

@llvmorg-github-actions llvmorg-github-actions Bot added backend:ARM backend:Hexagon clang:codegen IR generation bugs: mangling, exceptions, etc. flang:driver flang Flang issues not falling into any other category backend:CSKY LTO Link time optimization (regular/full LTO or ThinLTO) llvm:ir llvm:analysis Includes value tracking, cost tables and constant folding llvm:transforms labels Aug 12, 2026
@arsenm
arsenm force-pushed the users/arsenm/codegen/remove-targetoptions-floatabi branch from 771defe to 6355d80 Compare August 13, 2026 09:52
@arsenm
arsenm force-pushed the users/arsenm/float-abi-synthesize-from-cl-opt branch from 05a4564 to 2fac20d Compare August 13, 2026 09:52
@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown

🐧 Linux x64 Test Results

  • 211678 tests passed
  • 6843 tests skipped

✅ The build succeeded and all tests passed.

@arsenm
arsenm force-pushed the users/arsenm/float-abi-synthesize-from-cl-opt branch from 2fac20d to 00fb3f7 Compare August 13, 2026 17:49
@arsenm
arsenm force-pushed the users/arsenm/codegen/remove-targetoptions-floatabi branch from 6355d80 to 33237f7 Compare August 13, 2026 17:49
arsenm and others added 3 commits August 17, 2026 08:41
This is now fully replaced with the "float-abi" module flag.
If the module flag is not present, the default is computed
from the triple. Consumers are updated to read the module flag.

RuntimeLibraryAnalysis now defers analysis until run() on a Module,
instead of during the pass constructor as before. This requires copying
all of the remaining relevant TargetOptions so they are available
when the module is seen.

Unfortunately, ARM still depends on TargetOptions for determining
the float-abi. -target-abi=aapcs16 still changes the default float-abi,
but an explicit module flag wins.

Co-authored-by: Claude (Claude-Opus-4.8) <noreply@anthropic.com>
@arsenm
arsenm force-pushed the users/arsenm/float-abi-synthesize-from-cl-opt branch from 6d7e249 to c24ac2f Compare August 17, 2026 06:47
@arsenm
arsenm force-pushed the users/arsenm/codegen/remove-targetoptions-floatabi branch from e6be2fd to 274d957 Compare August 17, 2026 06:47
Base automatically changed from users/arsenm/float-abi-synthesize-from-cl-opt to main August 18, 2026 15:33

@ilovepi ilovepi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a nice cleanup.

@arsenm
arsenm merged commit 7e0416d into main Aug 18, 2026
16 of 23 checks passed
@arsenm
arsenm deleted the users/arsenm/codegen/remove-targetoptions-floatabi branch August 18, 2026 15:49
ronlieb pushed a commit to ROCm/llvm-project that referenced this pull request Aug 18, 2026
This is now fully replaced with the "float-abi" module flag.
If the module flag is not present, the default is computed
from the triple. Consumers are updated to read the module flag.

RuntimeLibraryAnalysis now defers analysis until run() on a Module,
instead of during the pass constructor as before. This requires copying
all of the remaining relevant TargetOptions so they are available
when the module is seen.

Unfortunately, ARM still depends on TargetOptions for determining
the float-abi. -target-abi=aapcs16 still changes the default float-abi,
but an explicit module flag wins.

Co-authored-by: Claude (Claude-Opus-4.8) <noreply@anthropic.com>
@rorth

rorth commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

This patch broke the Solaris/sparcv9 buildbot.

@mikaelholmen

Copy link
Copy Markdown
Contributor

I noticed that with this patch llvm complains about llvm-stress generated output, e.g.

llvm-stress -size 300 -seed 17184 | llc -march=x86-64 -mcpu=corei7 -o /dev/null

fails with

error: no libcall available for frem

Is that as expected?

@arsenm

arsenm commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

I noticed that with this patch llvm complains about llvm-stress generated output, e.g.

llvm-stress -size 300 -seed 17184 | llc -march=x86-64 -mcpu=corei7 -o /dev/null

fails with

error: no libcall available for frem

Is that as expected?

Kind of, it's a side effect. There are 2 things going on here. The short answer is stop using -march, and only use -mtriple. We should probably remove -march, it inherits the other triple fields from the host which is bad for reproducibility. The host must be missing the matching call, so it now fails. That it fails is a different bug, which is ExpandIRInsts doesn't appear to be consulting the libcall action

@mikaelholmen

Copy link
Copy Markdown
Contributor

I noticed that with this patch llvm complains about llvm-stress generated output, e.g.

llvm-stress -size 300 -seed 17184 | llc -march=x86-64 -mcpu=corei7 -o /dev/null

fails with

error: no libcall available for frem

Is that as expected?

Kind of, it's a side effect. There are 2 things going on here. The short answer is stop using -march, and only use -mtriple. We should probably remove -march, it inherits the other triple fields from the host which is bad for reproducibility. The host must be missing the matching call, so it now fails. That it fails is a different bug, which is ExpandIRInsts doesn't appear to be consulting the libcall action

Ok good, then I'll just switch from -march to -mtriple in those tests.
Thanks!

@arsenm

arsenm commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

This patch broke the Solaris/sparcv9 buildbot.

This is the same problem as #203725 so this should just xfail sparc

@arsenm

arsenm commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

This patch broke the Solaris/sparcv9 buildbot.

This is the same problem as #203725 so this should just xfail sparc

#217264

@evodius96

Copy link
Copy Markdown
Contributor

This commit results in massive failures with existing LIT tests for our downstream toolchains, especially for Arm, similar to what others have reported above. We do use our own driver code, but I'm not sure where to begin to pinpoint what needs to be changed. Can you point me where to get started?

@evodius96

Copy link
Copy Markdown
Contributor

This commit results in massive failures with existing LIT tests for our downstream toolchains, especially for Arm, similar to what others have reported above. We do use our own driver code, but I'm not sure where to begin to pinpoint what needs to be changed. Can you point me where to get started?

Many of the failures are for Generic, which I think you also noted as being problematic, e.g.:

******************* TEST 'LLVM :: DebugInfo/Generic/linkage-name-abstract.ll' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
./bin/llc -O0 -filetype=obj -dwarf-linkage-names=Abstract < /scratch/aphipps/triage_repo/tools/llvm_cgt/llvm-project/llvm/test/DebugInfo/Generic/linkage-name-abstract.ll | ./bin/llvm-dwarfdump -debug-info - > ./test/ARM_LLVM/DebugInfo/Generic/Output/linkage-name-abstract.ll.tmp
# executed command: ./bin/llc -O0 -filetype=obj -dwarf-linkage-names=Abstract
# .---command stderr------------
# | error: linkage-name-abstract-static.cpp:2:0: in function _Z2f2v void (): calling convention is hard-float, but floating-point registers are unavailable
# |
# | error: linkage-name-abstract-static.cpp:5:0: in function _Z2f3v void (): calling convention is hard-float, but floating-point registers are unavailable
# |
# | error: linkage-name-abstract-static.cpp:12:0: in function _ZN2F42f5Ev void (): calling convention is hard-float, but floating-point registers are unavailable
# |
# | error: linkage-name-abstract-static.cpp:15:0: in function _Z2f6v void (): calling convention is hard-float, but floating-point registers are unavailable
# |
# `-----------------------------
# error: command failed with exit status: 1
# executed command: ./bin/llvm-dwarfdump -debug-info -
# .---command stderr------------
# | error: -: The file was not recognized as a valid object file
# `-----------------------------
# error: command failed with exit status: 1

@arsenm

arsenm commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

This commit results in massive failures with existing LIT tests for our downstream toolchains, especially for Arm, similar to what others have reported above. We do use our own driver code, but I'm not sure where to begin to pinpoint what needs to be changed. Can you point me where to get started?

Many of the failures are for Generic, which I think you also noted as being problematic, e.g.:

Yes, generic is broken and I think all of these would be resolved by #203725

So the solutions are:

  1. Stop using -march, only -mtriple
  2. Stop using "Generic" codegen tests with no target specified. We should shard these into all the backends, but the short term here is unsupported=archname like I did in SPARC: Disable generic codegen tests that depend on libcalls #217264
  3. Merge [llc] set canonical triple in module #203725

@vvereschaka

Copy link
Copy Markdown
Contributor

Hi @arsenm,

These two LLVM tests get crashed with the memory access violation exception after these changes on Armv7 cross builder:

  • LLVM::print-arith-int.ll
  • LLVM::BasicInstrs.ll

https://lab.llvm.org/buildbot/#/builders/38/builds/10659

The crash dump with debug info:

-- Testing: 1 of 68274 tests, 1 workers --
FAIL: LLVM :: CodeGen/Generic/print-arith-int.ll (1 of 1)
******************** TEST 'LLVM :: CodeGen/Generic/print-arith-int.ll' FAILED ********************
Exit Code: 3221225477

Command Output (stdout):
--
# RUN: at line 1
c:\buildbot\temp\build-arm\bin\llc.exe < C:\buildbot\temp\llvm-project\llvm\test\CodeGen\Generic\print-arith-int.ll
# executed command: 'c:\buildbot\temp\build-arm\bin\llc.exe'
# .---command stderr------------
# | PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
# | Stack dump:
# | 0.  Program arguments: c:\\buildbot\\temp\\build-arm\\bin\\llc.exe
# | 1.  Running pass 'Function Pass Manager' on module '<stdin>'.
# | 2.  Running pass 'ARM Instruction Selection' on function '@main'
# | Exception Code: 0xC0000005
# |  #0 0x00007ff9b8105301 (C:\Windows\System32\ucrtbase.dll+0x25301)
# |  #1 0x00007ff630944e3f std::basic_string<char,std::char_traits<char>,std::allocator<char> >::{ctor} C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\xstring:769:0
# |  #2 0x00007ff630944e3f std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,unsigned int>::{ctor} C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\utility:274:0
# |  #3 0x00007ff630944e3f llvm::SelectionDAG::getTargetExternalSymbol(char const *, struct llvm::EVT, unsigned int) C:\buildbot\temp\llvm-project\llvm\lib\CodeGen\SelectionDAG\SelectionDAG.cpp:2171:0
# |  #4 0x00007ff62f01b4ed llvm::ARMTargetLowering::LowerCall(struct llvm::TargetLowering::CallLoweringInfo &, class llvm::SmallVectorImpl<class llvm::SDValue> &) const C:\buildbot\temp\llvm-project\llvm\lib\Target\ARM\ARMISelLowering.cpp:2585:0
# |  #5 0x00007ff630ab64b2 llvm::TargetLowering::LowerCallTo(struct llvm::TargetLowering::CallLoweringInfo &) const C:\buildbot\temp\llvm-project\llvm\lib\CodeGen\SelectionDAG\SelectionDAGBuilder.cpp:11719:0
# |  #6 0x00007ff62f0218a0 llvm::ARMTargetLowering::LowerDivRem(class llvm::SDValue, class llvm::SelectionDAG &) const C:\buildbot\temp\llvm-project\llvm\lib\Target\ARM\ARMISelLowering.cpp:21003:0
# |  #7 0x00007ff62f0303ba llvm::ARMTargetLowering::LowerOperation(class llvm::SDValue, class llvm::SelectionDAG &) const C:\buildbot\temp\llvm-project\llvm\lib\Target\ARM\ARMISelLowering.cpp:10669:0
# |  #8 0x00007ff630b80dfe `anonymous namespace'::SelectionDAGLegalize::LegalizeOp C:\buildbot\temp\llvm-project\llvm\lib\CodeGen\SelectionDAG\LegalizeDAG.cpp:1349:0
# |  #9 0x00007ff630b7c929 llvm::SelectionDAG::Legalize(void) C:\buildbot\temp\llvm-project\llvm\lib\CodeGen\SelectionDAG\LegalizeDAG.cpp:6356:0
# | #10 0x00007ff630834b0e llvm::TimeRegion::{dtor} C:\buildbot\temp\llvm-project\llvm\include\llvm\Support\Timer.h:167:0
# | #11 0x00007ff630834b0e llvm::SelectionDAGISel::CodeGenAndEmitDAG(void) C:\buildbot\temp\llvm-project\llvm\lib\CodeGen\SelectionDAG\SelectionDAGISel.cpp:1109:0
# | #12 0x00007ff63083e813 llvm::SelectionDAGISel::SelectAllBasicBlocks(class llvm::Function const &) C:\buildbot\temp\llvm-project\llvm\lib\CodeGen\SelectionDAG\SelectionDAGISel.cpp:1952:0
# | #13 0x00007ff630851370 llvm::SelectionDAGISel::runOnMachineFunction(class llvm::MachineFunction &) C:\buildbot\temp\llvm-project\llvm\lib\CodeGen\SelectionDAG\SelectionDAGISel.cpp:647:0
# | #14 0x00007ff62f103c84 `anonymous namespace'::ARMDAGToDAGISel::runOnMachineFunction C:\buildbot\temp\llvm-project\llvm\lib\Target\ARM\ARMISelDAGToDAG.cpp:69:0
# | #15 0x00007ff63085350a llvm::SelectionDAGISelLegacy::runOnMachineFunction(class llvm::MachineFunction &) C:\buildbot\temp\llvm-project\llvm\lib\CodeGen\SelectionDAG\SelectionDAGISel.cpp:395:0
# | #16 0x00007ff62f74e1e9 llvm::MachineFunctionPass::runOnFunction(class llvm::Function &) C:\buildbot\temp\llvm-project\llvm\lib\CodeGen\MachineFunctionPass.cpp:96:0
# | #17 0x00007ff62fe9b89b llvm::FPPassManager::runOnFunction(class llvm::Function &) C:\buildbot\temp\llvm-project\llvm\lib\IR\LegacyPassManager.cpp:1426:0
# | #18 0x00007ff62fe9bded llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Function,1,0,void,0,void>,0,0>::operator++ C:\buildbot\temp\llvm-project\llvm\include\llvm\ADT\ilist_iterator.h:187:0
# | #19 0x00007ff62fe9bded llvm::FPPassManager::runOnModule(class llvm::Module &) C:\buildbot\temp\llvm-project\llvm\lib\IR\LegacyPassManager.cpp:1469:0
# | #20 0x00007ff62fe9c203 `anonymous namespace'::MPPassManager::runOnModule C:\buildbot\temp\llvm-project\llvm\lib\IR\LegacyPassManager.cpp:1568:0
# | #21 0x00007ff62fe9b3d8 llvm::legacy::PassManagerImpl::run(class llvm::Module &) C:\buildbot\temp\llvm-project\llvm\lib\IR\LegacyPassManager.cpp:534:0
# | #22 0x00007ff62ef2c9ae compileModule C:\buildbot\temp\llvm-project\llvm\tools\llc\llc.cpp:886:0
# | #23 0x00007ff62ef30c3b main C:\buildbot\temp\llvm-project\llvm\tools\llc\llc.cpp:460:0
# | #24 0x00007ff6320696a4 invoke_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78:0
# | #25 0x00007ff6320696a4 __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288:0
# | #26 0x00007ff9b9587ac4 (C:\Windows\System32\KERNEL32.DLL+0x17ac4)
# | #27 0x00007ff9bbdea8c1 (C:\Windows\SYSTEM32\ntdll.dll+0x5a8c1)
# `-----------------------------
# error: command failed with exit status: 0xc0000005

Would you take care of it?

@arsenm

arsenm commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Would you take care of it?

It's the same as all the others, I hit merge on #203725

There's just an ARM specific bonus bug that it doesn't validate the library call exists before calling it, which indirectly results in the null use

kieroxide pushed a commit to kieroxide/llvm-project that referenced this pull request Aug 21, 2026
This is now fully replaced with the "float-abi" module flag.
If the module flag is not present, the default is computed
from the triple. Consumers are updated to read the module flag.

RuntimeLibraryAnalysis now defers analysis until run() on a Module,
instead of during the pass constructor as before. This requires copying
all of the remaining relevant TargetOptions so they are available
when the module is seen.

Unfortunately, ARM still depends on TargetOptions for determining
the float-abi. -target-abi=aapcs16 still changes the default float-abi,
but an explicit module flag wins.

Co-authored-by: Claude (Claude-Opus-4.8) <noreply@anthropic.com>
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 21, 2026
LLVM 24: configure float-abi via module flag

`TargetOptions::FloatABIType` was removed in llvm/llvm-project#215796

See llvm/llvm-project#212985 for the corresponding clang change.

The `ModuleFlagMergeBehavior::Error` was copied from the clang implementation.

This currently relies on the string representation of Rust's [`FloatAbi` "target_spec_enum"](https://github.com/rust-lang/rust/blob/e71c0f1e3395b10a8c331317be1a5c107bdf7b2e/compiler/rustc_target/src/spec/mod.rs#L978-L986) matching LLVM. This seemed reasonable to me since the representation is quite straightforward ("soft" and "hard"), but let me know if you'd like an explicit `to_llvm_float_abi_str`, either defined in Rust or forwarding to `llvm::FloatABI::getABITypeName`.

Contrary to the clang implementation which only sets the module flag if it differs from the target default, we set it whenever the Rust target has an explicit float ABI set. See also discussion in [#t-compiler/llvm > float-abi module flag behavior](https://rust-lang.zulipchat.com/#narrow/channel/187780-t-compiler.2Fllvm/topic/float-abi.20module.20flag.20behavior/with/617279073).

The added test won't actually run on Rust's own CI until that updates to LLVM 24.

@rustbot label llvm-main
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 21, 2026
LLVM 24: configure float-abi via module flag

`TargetOptions::FloatABIType` was removed in llvm/llvm-project#215796

See llvm/llvm-project#212985 for the corresponding clang change.

The `ModuleFlagMergeBehavior::Error` was copied from the clang implementation.

This currently relies on the string representation of Rust's [`FloatAbi` "target_spec_enum"](https://github.com/rust-lang/rust/blob/e71c0f1e3395b10a8c331317be1a5c107bdf7b2e/compiler/rustc_target/src/spec/mod.rs#L978-L986) matching LLVM. This seemed reasonable to me since the representation is quite straightforward ("soft" and "hard"), but let me know if you'd like an explicit `to_llvm_float_abi_str`, either defined in Rust or forwarding to `llvm::FloatABI::getABITypeName`.

Contrary to the clang implementation which only sets the module flag if it differs from the target default, we set it whenever the Rust target has an explicit float ABI set. See also discussion in [#t-compiler/llvm > float-abi module flag behavior](https://rust-lang.zulipchat.com/#narrow/channel/187780-t-compiler.2Fllvm/topic/float-abi.20module.20flag.20behavior/with/617279073).

The added test won't actually run on Rust's own CI until that updates to LLVM 24.

@rustbot label llvm-main
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 21, 2026
LLVM 24: configure float-abi via module flag

`TargetOptions::FloatABIType` was removed in llvm/llvm-project#215796

See llvm/llvm-project#212985 for the corresponding clang change.

The `ModuleFlagMergeBehavior::Error` was copied from the clang implementation.

This currently relies on the string representation of Rust's [`FloatAbi` "target_spec_enum"](https://github.com/rust-lang/rust/blob/e71c0f1e3395b10a8c331317be1a5c107bdf7b2e/compiler/rustc_target/src/spec/mod.rs#L978-L986) matching LLVM. This seemed reasonable to me since the representation is quite straightforward ("soft" and "hard"), but let me know if you'd like an explicit `to_llvm_float_abi_str`, either defined in Rust or forwarding to `llvm::FloatABI::getABITypeName`.

Contrary to the clang implementation which only sets the module flag if it differs from the target default, we set it whenever the Rust target has an explicit float ABI set. See also discussion in [#t-compiler/llvm > float-abi module flag behavior](https://rust-lang.zulipchat.com/#narrow/channel/187780-t-compiler.2Fllvm/topic/float-abi.20module.20flag.20behavior/with/617279073).

The added test won't actually run on Rust's own CI until that updates to LLVM 24.

@rustbot label llvm-main
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 21, 2026
LLVM 24: configure float-abi via module flag

`TargetOptions::FloatABIType` was removed in llvm/llvm-project#215796

See llvm/llvm-project#212985 for the corresponding clang change.

The `ModuleFlagMergeBehavior::Error` was copied from the clang implementation.

This currently relies on the string representation of Rust's [`FloatAbi` "target_spec_enum"](https://github.com/rust-lang/rust/blob/e71c0f1e3395b10a8c331317be1a5c107bdf7b2e/compiler/rustc_target/src/spec/mod.rs#L978-L986) matching LLVM. This seemed reasonable to me since the representation is quite straightforward ("soft" and "hard"), but let me know if you'd like an explicit `to_llvm_float_abi_str`, either defined in Rust or forwarding to `llvm::FloatABI::getABITypeName`.

Contrary to the clang implementation which only sets the module flag if it differs from the target default, we set it whenever the Rust target has an explicit float ABI set. See also discussion in [#t-compiler/llvm > float-abi module flag behavior](https://rust-lang.zulipchat.com/#narrow/channel/187780-t-compiler.2Fllvm/topic/float-abi.20module.20flag.20behavior/with/617279073).

The added test won't actually run on Rust's own CI until that updates to LLVM 24.

@rustbot label llvm-main
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Aug 21, 2026
Rollup merge of #161317 - TimNN:float-abi-flag, r=khyperia

LLVM 24: configure float-abi via module flag

`TargetOptions::FloatABIType` was removed in llvm/llvm-project#215796

See llvm/llvm-project#212985 for the corresponding clang change.

The `ModuleFlagMergeBehavior::Error` was copied from the clang implementation.

This currently relies on the string representation of Rust's [`FloatAbi` "target_spec_enum"](https://github.com/rust-lang/rust/blob/e71c0f1e3395b10a8c331317be1a5c107bdf7b2e/compiler/rustc_target/src/spec/mod.rs#L978-L986) matching LLVM. This seemed reasonable to me since the representation is quite straightforward ("soft" and "hard"), but let me know if you'd like an explicit `to_llvm_float_abi_str`, either defined in Rust or forwarding to `llvm::FloatABI::getABITypeName`.

Contrary to the clang implementation which only sets the module flag if it differs from the target default, we set it whenever the Rust target has an explicit float ABI set. See also discussion in [#t-compiler/llvm > float-abi module flag behavior](https://rust-lang.zulipchat.com/#narrow/channel/187780-t-compiler.2Fllvm/topic/float-abi.20module.20flag.20behavior/with/617279073).

The added test won't actually run on Rust's own CI until that updates to LLVM 24.

@rustbot label llvm-main
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Aug 22, 2026
LLVM 24: configure float-abi via module flag

`TargetOptions::FloatABIType` was removed in llvm/llvm-project#215796

See llvm/llvm-project#212985 for the corresponding clang change.

The `ModuleFlagMergeBehavior::Error` was copied from the clang implementation.

This currently relies on the string representation of Rust's [`FloatAbi` "target_spec_enum"](https://github.com/rust-lang/rust/blob/e71c0f1e3395b10a8c331317be1a5c107bdf7b2e/compiler/rustc_target/src/spec/mod.rs#L978-L986) matching LLVM. This seemed reasonable to me since the representation is quite straightforward ("soft" and "hard"), but let me know if you'd like an explicit `to_llvm_float_abi_str`, either defined in Rust or forwarding to `llvm::FloatABI::getABITypeName`.

Contrary to the clang implementation which only sets the module flag if it differs from the target default, we set it whenever the Rust target has an explicit float ABI set. See also discussion in [#t-compiler/llvm > float-abi module flag behavior](https://rust-lang.zulipchat.com/#narrow/channel/187780-t-compiler.2Fllvm/topic/float-abi.20module.20flag.20behavior/with/617279073).

The added test won't actually run on Rust's own CI until that updates to LLVM 24.

@rustbot label llvm-main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend:ARM backend:CSKY backend:Hexagon clang:codegen IR generation bugs: mangling, exceptions, etc. flang:driver flang Flang issues not falling into any other category llvm:analysis Includes value tracking, cost tables and constant folding llvm:codegen llvm:ir llvm:SelectionDAG SelectionDAGISel as well llvm:transforms LTO Link time optimization (regular/full LTO or ThinLTO)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants