[clang] e6e102a - [Passes] Add DisableSimplifyLibCalls flag to runCodeGenPipeline (#222430)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 10 07:17:37 PDT 2026
Author: Aiden Grossman
Date: 2026-09-10T07:17:32-07:00
New Revision: e6e102aa9ee5f8163d6d300614734b6c009aec34
URL: https://github.com/llvm/llvm-project/commit/e6e102aa9ee5f8163d6d300614734b6c009aec34
DIFF: https://github.com/llvm/llvm-project/commit/e6e102aa9ee5f8163d6d300614734b6c009aec34.diff
LOG: [Passes] Add DisableSimplifyLibCalls flag to runCodeGenPipeline (#222430)
This enables this abstraction to be a drop-in replacement for rustc
after some minor refactoring.
Added:
Modified:
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/Passes/RunCodeGen.h
llvm/lib/Passes/RunCodeGen.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index c09a8f7c0d679..737760c4b7db1 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1243,7 +1243,8 @@ void EmitAssemblyHelper::RunCodegenPipeline(
TimeCodegenPasses([&]() {
Error CodeGenError = runCodeGenPipeline(
*TM, *TheModule, *OS, DwoOS, CGFT, PrintPipelinePasses.has_value(),
- !CodeGenOpts.VerifyModule, CI.getVirtualFileSystemPtr());
+ !CodeGenOpts.VerifyModule, /*DisableSimplifyLibCalls=*/false,
+ CI.getVirtualFileSystemPtr());
if (CodeGenError)
Diags.Report(diag::err_fe_unable_to_interface_with_target);
});
diff --git a/llvm/include/llvm/Passes/RunCodeGen.h b/llvm/include/llvm/Passes/RunCodeGen.h
index 713b46b465ceb..4834b99dbe6fb 100644
--- a/llvm/include/llvm/Passes/RunCodeGen.h
+++ b/llvm/include/llvm/Passes/RunCodeGen.h
@@ -20,6 +20,7 @@ Error runCodeGenPipeline(
TargetMachine &TM, Module &M, raw_pwrite_stream &OS,
std::unique_ptr<ToolOutputFile> &DwoOS, CodeGenFileType CGFT,
bool PrintPipelinePasses = false, bool DisableVerify = true,
+ bool DisableSimplifyLibCalls = false,
IntrusiveRefCntPtr<vfs::FileSystem> VFS = vfs::getRealFileSystem());
} // namespace llvm
diff --git a/llvm/lib/Passes/RunCodeGen.cpp b/llvm/lib/Passes/RunCodeGen.cpp
index 66e48b802416d..adcebe0d6ad20 100644
--- a/llvm/lib/Passes/RunCodeGen.cpp
+++ b/llvm/lib/Passes/RunCodeGen.cpp
@@ -31,17 +31,18 @@ static cl::opt<cl::boolOrDefault>
"option will default to what the target prefers."),
cl::init(cl::boolOrDefault::BOU_UNSET));
-static Error runCodeGenPipelineLegacy(TargetMachine &TM, Module &M,
- raw_pwrite_stream &OS,
- std::unique_ptr<ToolOutputFile> &DwoOS,
- CodeGenFileType CGFT,
- bool PrintPipelinePasses,
- bool DisableVerify) {
+static Error
+runCodeGenPipelineLegacy(TargetMachine &TM, Module &M, raw_pwrite_stream &OS,
+ std::unique_ptr<ToolOutputFile> &DwoOS,
+ CodeGenFileType CGFT, bool PrintPipelinePasses,
+ bool DisableVerify, bool DisableSimplifyLibCalls) {
legacy::PassManager CodeGenPasses;
CodeGenPasses.add(
createTargetTransformInfoWrapperPass(TM.getTargetIRAnalysis()));
// Add LibraryInfo.
TargetLibraryInfoImpl TLII(TM.getTargetTriple(), TM.Options.VecLib);
+ if (DisableSimplifyLibCalls)
+ TLII.disableAllFunctions();
CodeGenPasses.add(new TargetLibraryInfoWrapperPass(TLII));
const TargetOptions &Options = TM.Options;
@@ -98,7 +99,7 @@ Error llvm::runCodeGenPipeline(TargetMachine &TM, Module &M,
raw_pwrite_stream &OS,
std::unique_ptr<ToolOutputFile> &DwoOS,
CodeGenFileType CGFT, bool PrintPipelinePasses,
- bool DisableVerify,
+ bool DisableVerify, bool DisableSimplifyLibCalls,
IntrusiveRefCntPtr<vfs::FileSystem> VFS) {
if (ForceNewPM == cl::boolOrDefault::BOU_TRUE ||
(TM.shouldDefaultToNewPM() &&
@@ -107,5 +108,5 @@ Error llvm::runCodeGenPipeline(TargetMachine &TM, Module &M,
}
return runCodeGenPipelineLegacy(TM, M, OS, DwoOS, CGFT, PrintPipelinePasses,
- DisableVerify);
+ DisableVerify, DisableSimplifyLibCalls);
}
More information about the cfe-commits
mailing list