[Polly][PM] Register polly passes with the opt tool for the new-pm path
authorPhilip Pfaffe <philip.pfaffe@gmail.com>
Fri, 4 Aug 2017 09:28:09 +0000 (09:28 +0000)
committerPhilip Pfaffe <philip.pfaffe@gmail.com>
Fri, 4 Aug 2017 09:28:09 +0000 (09:28 +0000)
Summary: When polly is linked into the tools because of the LLVM_POLLY_LINK_INTO_TOOLS option being set, we need to register its passes with the PassBuilder. Because polly is linked in, we can directly call its callback registration method, which registers the appropriate callbacks with the new PM's PassBuilder. This essentially follows exactly the way it worked with the legacy PM.

Reviewers: grosser, chandlerc, bollu

Reviewed By: grosser

Subscribers: pollydev, llvm-commits

Differential Revision: https://reviews.llvm.org/D36273

llvm-svn: 310043

llvm/tools/opt/NewPMDriver.cpp

index 32f71a5..f46d37e 100644 (file)
@@ -18,6 +18,7 @@
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/CGSCCPassManager.h"
 #include "llvm/Bitcode/BitcodeWriterPass.h"
+#include "llvm/Config/config.h"
 #include "llvm/IR/Dominators.h"
 #include "llvm/IR/IRPrintingPasses.h"
 #include "llvm/IR/LLVMContext.h"
@@ -160,6 +161,12 @@ static void registerEPCallbacks(PassBuilder &PB, bool VerifyEachPass,
     });
 }
 
+#ifdef LINK_POLLY_INTO_TOOLS
+namespace polly {
+void RegisterPollyPasses(PassBuilder &);
+}
+#endif
+
 bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
                            tool_output_file *Out,
                            tool_output_file *ThinLTOLinkOut,
@@ -190,6 +197,10 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
   PassBuilder PB(TM, P);
   registerEPCallbacks(PB, VerifyEachPass, DebugPM);
 
+#ifdef LINK_POLLY_INTO_TOOLS
+  polly::RegisterPollyPasses(PB);
+#endif
+
   // Specially handle the alias analysis manager so that we can register
   // a custom pipeline of AA passes with it.
   AAManager AA;