diff --git a/include/llvm/Transforms/IPO/PassManagerBuilder.h b/include/llvm/Transforms/IPO/PassManagerBuilder.h index 7c54ad6f64a..56a8f76d63a 100644 --- a/include/llvm/Transforms/IPO/PassManagerBuilder.h +++ b/include/llvm/Transforms/IPO/PassManagerBuilder.h @@ -145,7 +145,7 @@ public: /// populateModulePassManager - This sets up the primary pass manager. void populateModulePassManager(PassManagerBase &MPM); - void populateLTOPassManager(PassManagerBase &PM, bool RunInliner); + void populateLTOPassManager(PassManagerBase &PM); }; /// Registers a function for adding a standard set of passes. This should be diff --git a/lib/LTO/LTOCodeGenerator.cpp b/lib/LTO/LTOCodeGenerator.cpp index 2a195400e3b..1fdc5cf04dd 100644 --- a/lib/LTO/LTOCodeGenerator.cpp +++ b/lib/LTO/LTOCodeGenerator.cpp @@ -477,7 +477,9 @@ bool LTOCodeGenerator::generateObjectFile(raw_ostream &out, if (!DisableOpt) { PassManagerBuilder PMB; PMB.DisableGVNLoadPRE = DisableGVNLoadPRE; - PMB.populateLTOPassManager(passes, !DisableInline); + if (!DisableInline) + PMB.Inliner = createFunctionInliningPass(); + PMB.populateLTOPassManager(passes); } // Make sure everything is still good. diff --git a/lib/Transforms/IPO/PassManagerBuilder.cpp b/lib/Transforms/IPO/PassManagerBuilder.cpp index 301279fdc8f..07f46883600 100644 --- a/lib/Transforms/IPO/PassManagerBuilder.cpp +++ b/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -313,8 +313,7 @@ void PassManagerBuilder::populateModulePassManager(PassManagerBase &MPM) { addExtensionsToPM(EP_OptimizerLast, MPM); } -void PassManagerBuilder::populateLTOPassManager(PassManagerBase &PM, - bool RunInliner) { +void PassManagerBuilder::populateLTOPassManager(PassManagerBase &PM) { // Provide AliasAnalysis services for optimizations. addInitialAliasAnalysisPasses(PM); @@ -341,8 +340,11 @@ void PassManagerBuilder::populateLTOPassManager(PassManagerBase &PM, addExtensionsToPM(EP_Peephole, PM); // Inline small functions - if (RunInliner) - PM.add(createFunctionInliningPass()); + bool RunInliner = Inliner; + if (RunInliner) { + PM.add(Inliner); + Inliner = nullptr; + } PM.add(createPruneEHPass()); // Remove dead EH info. @@ -483,5 +485,11 @@ void LLVMPassManagerBuilderPopulateLTOPassManager(LLVMPassManagerBuilderRef PMB, LLVMBool RunInliner) { PassManagerBuilder *Builder = unwrap(PMB); PassManagerBase *LPM = unwrap(PM); - Builder->populateLTOPassManager(*LPM, RunInliner != 0); + + // A small backwards compatibility hack. populateLTOPassManager used to take + // an RunInliner option. + if (RunInliner && !Builder->Inliner) + Builder->Inliner = createFunctionInliningPass(); + + Builder->populateLTOPassManager(*LPM); } diff --git a/tools/bugpoint/bugpoint.cpp b/tools/bugpoint/bugpoint.cpp index 8a0d7aa4afb..a575861ede2 100644 --- a/tools/bugpoint/bugpoint.cpp +++ b/tools/bugpoint/bugpoint.cpp @@ -179,7 +179,8 @@ int main(int argc, char **argv) { if (StandardLinkOpts) { PassManagerBuilder Builder; - Builder.populateLTOPassManager(PM, /*RunInliner=*/true); + Builder.Inliner = createFunctionInliningPass(); + Builder.populateLTOPassManager(PM); } if (OptLevelO1 || OptLevelO2 || OptLevelO3) { diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index 538c18cc488..7655ec7036d 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -267,7 +267,9 @@ static void AddStandardLinkPasses(PassManagerBase &PM) { if (DisableOptimizations) return; PassManagerBuilder Builder; - Builder.populateLTOPassManager(PM, /*RunInliner=*/!DisableInline); + if (!DisableInline) + Builder.Inliner = createFunctionInliningPass(); + Builder.populateLTOPassManager(PM); } //===----------------------------------------------------------------------===//