Handle inlining in populateLTOPassManager like in populateModulePassManager.

No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216178 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2014-08-21 13:35:30 +00:00
parent 63f5912959
commit 0b994a70b0
5 changed files with 22 additions and 9 deletions

View File

@ -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

View File

@ -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.

View File

@ -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);
}

View File

@ -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) {

View File

@ -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);
}
//===----------------------------------------------------------------------===//