[PM] Sink the population of the pass manager with target-specific

analyses back into the LTO code generator.

The pass manager builder (and the transforms library in general)
shouldn't be referencing the target machine at all.

This makes the LTO population work like the others -- the data layout
and target transform info need to be pre-populated.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227576 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chandler Carruth 2015-01-30 13:33:42 +00:00
parent 2ec788d43f
commit b4a44570f6
3 changed files with 6 additions and 9 deletions

View File

@ -151,7 +151,7 @@ public:
/// populateModulePassManager - This sets up the primary pass manager.
void populateModulePassManager(PassManagerBase &MPM);
void populateLTOPassManager(PassManagerBase &PM, TargetMachine *TM = nullptr);
void populateLTOPassManager(PassManagerBase &PM);
};
/// Registers a function for adding a standard set of passes. This should be

View File

@ -488,6 +488,9 @@ bool LTOCodeGenerator::generateObjectFile(raw_ostream &out,
// Add an appropriate DataLayout instance for this module...
mergedModule->setDataLayout(TargetMach->getDataLayout());
passes.add(new DataLayoutPass());
TargetMach->addAnalysisPasses(passes);
Triple TargetTriple(TargetMach->getTargetTriple());
PassManagerBuilder PMB;
PMB.DisableGVNLoadPRE = DisableGVNLoadPRE;
@ -501,7 +504,7 @@ bool LTOCodeGenerator::generateObjectFile(raw_ostream &out,
PMB.VerifyInput = true;
PMB.VerifyOutput = true;
PMB.populateLTOPassManager(passes, TargetMach);
PMB.populateLTOPassManager(passes);
PassManager codeGenPasses;

View File

@ -478,13 +478,7 @@ void PassManagerBuilder::addLTOOptimizationPasses(PassManagerBase &PM) {
PM.add(createMergeFunctionsPass());
}
void PassManagerBuilder::populateLTOPassManager(PassManagerBase &PM,
TargetMachine *TM) {
if (TM) {
PM.add(new DataLayoutPass());
TM->addAnalysisPasses(PM);
}
void PassManagerBuilder::populateLTOPassManager(PassManagerBase &PM) {
if (LibraryInfo)
PM.add(new TargetLibraryInfoWrapperPass(*LibraryInfo));