https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/223971
Source the exception model in the RuntimeLibcallsInfo(Module) constructor from the "exception-model" module flag via Module::getExceptionModel(), instead of forwarding it from TargetOptions. An absent flag resolves to Default and then to the triple default; an explicit "none" disables exceptions. Since the model now comes from the module, drop the ExceptionModel that RuntimeLibraryAnalysis carried and forwarded, and its argument at every construction site. Co-authored-by: Claude (Claude-Opus-4.8) <[email protected]> >From 27ae2466fc93e0abed2dea37fb9699d82fea72b8 Mon Sep 17 00:00:00 2001 From: Matt Arsenault <[email protected]> Date: Wed, 2 Sep 2026 12:06:38 +0200 Subject: [PATCH] RuntimeLibcalls: Read exception model from the module flag Source the exception model in the RuntimeLibcallsInfo(Module) constructor from the "exception-model" module flag via Module::getExceptionModel(), instead of forwarding it from TargetOptions. An absent flag resolves to Default and then to the triple default; an explicit "none" disables exceptions. Since the model now comes from the module, drop the ExceptionModel that RuntimeLibraryAnalysis carried and forwarded, and its argument at every construction site. Co-authored-by: Claude (Claude-Opus-4.8) <[email protected]> --- llvm/include/llvm/Analysis/RuntimeLibcallInfo.h | 10 +++------- llvm/include/llvm/IR/RuntimeLibcalls.h | 11 +++++------ llvm/lib/Analysis/RuntimeLibcallInfo.cpp | 8 ++++---- llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp | 4 ++-- llvm/lib/IR/RuntimeLibcalls.cpp | 8 +++----- llvm/lib/LTO/LTOBackend.cpp | 3 +-- llvm/lib/Passes/RunCodeGen.cpp | 4 ++-- llvm/tools/llc/lib/NewPMDriver.cpp | 3 +-- llvm/tools/llc/lib/llcdriver.cpp | 3 +-- llvm/tools/opt/NewPMDriver.cpp | 3 +-- llvm/tools/opt/optdriver.cpp | 4 ++-- 11 files changed, 25 insertions(+), 36 deletions(-) diff --git a/llvm/include/llvm/Analysis/RuntimeLibcallInfo.h b/llvm/include/llvm/Analysis/RuntimeLibcallInfo.h index 2742e5ba4a348..b7e0f69c3f7b1 100644 --- a/llvm/include/llvm/Analysis/RuntimeLibcallInfo.h +++ b/llvm/include/llvm/Analysis/RuntimeLibcallInfo.h @@ -22,11 +22,9 @@ class LLVM_ABI RuntimeLibraryAnalysis using Result = RTLIB::RuntimeLibcallsInfo; RuntimeLibraryAnalysis() = default; - RuntimeLibraryAnalysis(ExceptionHandling ExceptionModel, - StringRef ABIName = "", + RuntimeLibraryAnalysis(StringRef ABIName, VectorLibrary VecLib = VectorLibrary::NoLibrary) - : ExceptionModel(ExceptionModel), ABIName(ABIName.str()), VecLib(VecLib) { - } + : ABIName(ABIName.str()), VecLib(VecLib) {} RTLIB::RuntimeLibcallsInfo run(const Module &M, ModuleAnalysisManager &); @@ -37,7 +35,6 @@ class LLVM_ABI RuntimeLibraryAnalysis // 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; std::string ABIName; VectorLibrary VecLib = VectorLibrary::NoLibrary; }; @@ -49,8 +46,7 @@ class LLVM_ABI RuntimeLibraryInfoWrapper : public ImmutablePass { public: static char ID; RuntimeLibraryInfoWrapper(); - RuntimeLibraryInfoWrapper(ExceptionHandling ExceptionModel, - StringRef ABIName = "", + RuntimeLibraryInfoWrapper(StringRef ABIName, VectorLibrary VecLib = VectorLibrary::NoLibrary); const RTLIB::RuntimeLibcallsInfo &getRTLCI(const Module &M) { diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.h b/llvm/include/llvm/IR/RuntimeLibcalls.h index 3227583f23430..a366a01d12755 100644 --- a/llvm/include/llvm/IR/RuntimeLibcalls.h +++ b/llvm/include/llvm/IR/RuntimeLibcalls.h @@ -92,13 +92,12 @@ struct RuntimeLibcallsInfo { VectorLibrary VecLib = VectorLibrary::NoLibrary); // FIXME: The floating-point ABI is read from the "float-abi" module flag, but - // the ExceptionModel/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. + // the 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, - StringRef ABIName = "", VectorLibrary VecLib = VectorLibrary::NoLibrary); + const Module &M, StringRef ABIName = "", + VectorLibrary VecLib = VectorLibrary::NoLibrary); LLVM_ABI bool invalidate(Module &M, const PreservedAnalyses &PA, ModuleAnalysisManager::Invalidator &); diff --git a/llvm/lib/Analysis/RuntimeLibcallInfo.cpp b/llvm/lib/Analysis/RuntimeLibcallInfo.cpp index ce79008539ca3..a226e6b4128ea 100644 --- a/llvm/lib/Analysis/RuntimeLibcallInfo.cpp +++ b/llvm/lib/Analysis/RuntimeLibcallInfo.cpp @@ -15,7 +15,7 @@ AnalysisKey RuntimeLibraryAnalysis::Key; RTLIB::RuntimeLibcallsInfo RuntimeLibraryAnalysis::run(const Module &M, ModuleAnalysisManager &) { - return RTLIB::RuntimeLibcallsInfo(M, ExceptionModel, ABIName, VecLib); + return RTLIB::RuntimeLibcallsInfo(M, ABIName, VecLib); } INITIALIZE_PASS(RuntimeLibraryInfoWrapper, "runtime-library-info", @@ -23,9 +23,9 @@ INITIALIZE_PASS(RuntimeLibraryInfoWrapper, "runtime-library-info", RuntimeLibraryInfoWrapper::RuntimeLibraryInfoWrapper() : ImmutablePass(ID) {} -RuntimeLibraryInfoWrapper::RuntimeLibraryInfoWrapper( - ExceptionHandling ExceptionModel, StringRef ABIName, VectorLibrary VecLib) - : ImmutablePass(ID), RTLA(ExceptionModel, ABIName, VecLib) {} +RuntimeLibraryInfoWrapper::RuntimeLibraryInfoWrapper(StringRef ABIName, + VectorLibrary VecLib) + : ImmutablePass(ID), RTLA(ABIName, VecLib) {} char RuntimeLibraryInfoWrapper::ID = 0; diff --git a/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp b/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp index f4b4cf9d893fe..6e65091c408b3 100644 --- a/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp +++ b/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp @@ -126,8 +126,8 @@ 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( - Options.ExceptionModel, Options.MCOptions.ABIName, Options.VecLib)); + PM.add( + new RuntimeLibraryInfoWrapper(Options.MCOptions.ABIName, Options.VecLib)); invokeGlobalTargetPassConfigCallbacks(TM, PM, PassConfig); diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp index 9bc4bd18ee2d3..d55d1c4ac5883 100644 --- a/llvm/lib/IR/RuntimeLibcalls.cpp +++ b/llvm/lib/IR/RuntimeLibcalls.cpp @@ -101,12 +101,10 @@ RuntimeLibcallsInfo::RuntimeLibcallsInfo(const Triple &TT, } // TODO: Consider the remaining module flags. -RuntimeLibcallsInfo::RuntimeLibcallsInfo(const Module &M, - ExceptionHandling ExceptionModel, - StringRef ABIName, +RuntimeLibcallsInfo::RuntimeLibcallsInfo(const Module &M, StringRef ABIName, VectorLibrary VecLib) - : RuntimeLibcallsInfo(M.getTargetTriple(), ExceptionModel, M.getFloatABI(), - ABIName, VecLib) {} + : RuntimeLibcallsInfo(M.getTargetTriple(), M.getExceptionModel(), + M.getFloatABI(), ABIName, VecLib) {} bool RuntimeLibcallsInfo::isLibraryAvailable(StringRef LibraryName) const { // TODO: Drive this from module-level state (e.g. the linked runtime). For now diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index 11c9b2f61988b..3ab145ad1fe71 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( - TM->Options.ExceptionModel, TM->Options.MCOptions.ABIName, - TM->Options.VecLib)); + TM->Options.MCOptions.ABIName, TM->Options.VecLib)); // No need to make index available if the module is empty. // In theory these passes should not use the index for an empty diff --git a/llvm/lib/Passes/RunCodeGen.cpp b/llvm/lib/Passes/RunCodeGen.cpp index aae30c47389c2..0ba67d01c3a9b 100644 --- a/llvm/lib/Passes/RunCodeGen.cpp +++ b/llvm/lib/Passes/RunCodeGen.cpp @@ -46,8 +46,8 @@ runCodeGenPipelineLegacy(TargetMachine &TM, Module &M, raw_pwrite_stream &OS, CodeGenPasses.add(new TargetLibraryInfoWrapperPass(TLII)); const TargetOptions &Options = TM.Options; - CodeGenPasses.add(new RuntimeLibraryInfoWrapper( - Options.ExceptionModel, Options.MCOptions.ABIName, Options.VecLib)); + CodeGenPasses.add( + new RuntimeLibraryInfoWrapper(Options.MCOptions.ABIName, Options.VecLib)); if (TM.addPassesToEmitFile(CodeGenPasses, OS, DwoOS ? &DwoOS->os() : nullptr, CGFT, DisableVerify)) diff --git a/llvm/tools/llc/lib/NewPMDriver.cpp b/llvm/tools/llc/lib/NewPMDriver.cpp index 475608de5500a..3eac9bd15355e 100644 --- a/llvm/tools/llc/lib/NewPMDriver.cpp +++ b/llvm/tools/llc/lib/NewPMDriver.cpp @@ -137,8 +137,7 @@ int llvm::compileModuleWithNewPM( MAM.registerPass([&] { const TargetOptions &Options = Target->Options; - return RuntimeLibraryAnalysis(Options.ExceptionModel, - Options.MCOptions.ABIName, Options.VecLib); + return RuntimeLibraryAnalysis(Options.MCOptions.ABIName, Options.VecLib); }); MAM.registerPass([&] { return MachineModuleAnalysis(MMI); }); diff --git a/llvm/tools/llc/lib/llcdriver.cpp b/llvm/tools/llc/lib/llcdriver.cpp index 94d204ed1424a..54410c33a23a4 100644 --- a/llvm/tools/llc/lib/llcdriver.cpp +++ b/llvm/tools/llc/lib/llcdriver.cpp @@ -754,8 +754,7 @@ static int compileModule(char **argv, SmallVectorImpl<PassPlugin> &PluginList, // Build up all of the passes that we want to do to the module. legacy::PassManager PM; PM.add(new TargetLibraryInfoWrapperPass(TLII)); - PM.add(new RuntimeLibraryInfoWrapper(Target->Options.ExceptionModel, - Options.MCOptions.ABIName, + PM.add(new RuntimeLibraryInfoWrapper(Options.MCOptions.ABIName, Target->Options.VecLib)); { diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp index ebe6bd7c5f341..a920f154db21c 100644 --- a/llvm/tools/opt/NewPMDriver.cpp +++ b/llvm/tools/opt/NewPMDriver.cpp @@ -452,8 +452,7 @@ bool llvm::runPassPipeline( MAM.registerPass([&] { const TargetOptions &Options = TM->Options; - return RuntimeLibraryAnalysis(Options.ExceptionModel, - Options.MCOptions.ABIName, Options.VecLib); + return RuntimeLibraryAnalysis(Options.MCOptions.ABIName, Options.VecLib); }); } diff --git a/llvm/tools/opt/optdriver.cpp b/llvm/tools/opt/optdriver.cpp index bcbf7190783ee..46c6833515e18 100644 --- a/llvm/tools/opt/optdriver.cpp +++ b/llvm/tools/opt/optdriver.cpp @@ -847,8 +847,8 @@ optMain(int argc, char **argv, (VerifyDebugInfoPreserve && !VerifyEachDebugInfoPreserve); Passes.add(new TargetLibraryInfoWrapperPass(TLII)); - Passes.add(new RuntimeLibraryInfoWrapper( - Options->ExceptionModel, Options->MCOptions.ABIName, Options->VecLib)); + Passes.add(new RuntimeLibraryInfoWrapper(Options->MCOptions.ABIName, + Options->VecLib)); // Add internal analysis passes from the target machine. Passes.add(createTargetTransformInfoWrapperPass(TM ? TM->getTargetIRAnalysis() _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
