diff --git a/llvm/lib/Transforms/IPO/Inliner.cpp b/llvm/lib/Transforms/IPO/Inliner.cpp --- a/llvm/lib/Transforms/IPO/Inliner.cpp +++ b/llvm/lib/Transforms/IPO/Inliner.cpp @@ -99,6 +99,10 @@ "by inlining from cgscc inline remarks."), cl::Hidden); +static cl::opt + EnableRegularCGSCCInline("enable-cgscc-inline", cl::init(true), cl::Hidden, + cl::desc("Enable CGSCC Inlining")); + LegacyInlinerBase::LegacyInlinerBase(char &ID) : CallGraphSCCPass(ID) {} LegacyInlinerBase::LegacyInlinerBase(char &ID, bool InsertLifetime) @@ -1006,7 +1010,8 @@ // because it makes profile annotation in the backend inaccurate. if (MandatoryFirst) PM.addPass(InlinerPass(/*OnlyMandatory*/ true)); - PM.addPass(InlinerPass()); + if (EnableRegularCGSCCInline) + PM.addPass(InlinerPass()); } PreservedAnalyses ModuleInlinerWrapperPass::run(Module &M, diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp --- a/llvm/lib/Transforms/IPO/SampleProfile.cpp +++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp @@ -177,6 +177,10 @@ "order of call graph during sample profile loading. It only " "works for new pass manager. ")); +static cl::opt EnableSampleProfileInline( + "enable-sample-profile-inline", cl::Hidden, cl::init(true), + cl::desc("Enable Inlining from sample profile loader.")); + static cl::opt ProfileSizeInline( "sample-profile-inline-size", cl::Hidden, cl::init(false), cl::desc("Inline cold call sites in profile loader if it's beneficial " @@ -1341,6 +1345,11 @@ bool SampleProfileLoader::tryInlineCandidate( InlineCandidate &Candidate, SmallVector *InlinedCallSites) { + // Disable only the inlining part of sample profile loader, and still + // perform profile annotation, ICP as well as computing import GUIDs for + // ThinLTO's pre-link. + if (!EnableSampleProfileInline) + return false; CallBase &CB = *Candidate.CallInstr; Function *CalledFunction = CB.getCalledFunction();