Move some logic to populateLTOPassManager.

This will avoid code duplication in the next commit which calls it directly
from the gold plugin.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216211 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2014-08-21 20:03:44 +00:00
parent 9db660ecaa
commit 7b4eb02b6d
4 changed files with 57 additions and 38 deletions

View File

@ -458,32 +458,21 @@ bool LTOCodeGenerator::generateObjectFile(raw_ostream &out,
// Instantiate the pass manager to organize the passes.
PassManager passes;
// Start off with a verification pass.
passes.add(createVerifierPass());
passes.add(createDebugInfoVerifierPass());
// Add an appropriate DataLayout instance for this module...
mergedModule->setDataLayout(TargetMach->getSubtargetImpl()->getDataLayout());
passes.add(new DataLayoutPass(mergedModule));
TargetMach->addAnalysisPasses(passes);
Triple TargetTriple(TargetMach->getTargetTriple());
// Enabling internalize here would use its AllButMain variant. It
// keeps only main if it exists and does nothing for libraries. Instead
// we create the pass ourselves with the symbol list provided by the linker.
if (!DisableOpt) {
PassManagerBuilder PMB;
PMB.DisableGVNLoadPRE = DisableGVNLoadPRE;
if (!DisableInline)
PMB.Inliner = createFunctionInliningPass();
PMB.LibraryInfo = new TargetLibraryInfo(TargetTriple);
PMB.populateLTOPassManager(passes);
}
PassManagerBuilder PMB;
PMB.DisableGVNLoadPRE = DisableGVNLoadPRE;
if (!DisableInline)
PMB.Inliner = createFunctionInliningPass();
PMB.LibraryInfo = new TargetLibraryInfo(TargetTriple);
if (DisableOpt)
PMB.OptLevel = 0;
PMB.VerifyInput = true;
PMB.VerifyOutput = true;
// Make sure everything is still good.
passes.add(createVerifierPass());
passes.add(createDebugInfoVerifierPass());
PMB.populateLTOPassManager(passes, TargetMach);
PassManager codeGenPasses;