[lib/LTO] Factor out logic for running passes.

This is in preparation for adding an option
to run a custom pipeline with the new PM. It's
currently used in lld.

llvm-svn: 280258
This commit is contained in:
Davide Italiano 2016-08-31 17:02:44 +00:00
parent 48f814e8a3
commit 1e9d3d3b40
1 changed files with 7 additions and 4 deletions

View File

@ -114,10 +114,8 @@ createTargetMachine(Config &C, StringRef TheTriple, const Target *TheTarget) {
C.CodeModel, C.CGOptLevel));
}
bool opt(Config &C, TargetMachine *TM, unsigned Task, Module &M,
bool IsThinLto) {
M.setDataLayout(TM->createDataLayout());
static void runOldPMPasses(Config &C, Module &M, TargetMachine *TM,
bool IsThinLto) {
legacy::PassManager passes;
passes.add(createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis()));
@ -136,7 +134,12 @@ bool opt(Config &C, TargetMachine *TM, unsigned Task, Module &M,
else
PMB.populateLTOPassManager(passes);
passes.run(M);
}
bool opt(Config &C, TargetMachine *TM, unsigned Task, Module &M,
bool IsThinLto) {
M.setDataLayout(TM->createDataLayout());
runOldPMPasses(C, M, TM, IsThinLto);
if (C.PostOptModuleHook && !C.PostOptModuleHook(Task, M))
return false;