[lib/LTO] Factor out logic for running passes.
authorDavide Italiano <davide@freebsd.org>
Wed, 31 Aug 2016 17:02:44 +0000 (17:02 +0000)
committerDavide Italiano <davide@freebsd.org>
Wed, 31 Aug 2016 17:02:44 +0000 (17:02 +0000)
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

llvm/lib/LTO/LTOBackend.cpp

index f5574c9..5f17c65 100644 (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;