summaryrefslogtreecommitdiffstats
path: root/llvm/tools/opt/NewPMDriver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/opt/NewPMDriver.cpp')
-rw-r--r--llvm/tools/opt/NewPMDriver.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp
index bf512e0db84..d596103bebc 100644
--- a/llvm/tools/opt/NewPMDriver.cpp
+++ b/llvm/tools/opt/NewPMDriver.cpp
@@ -14,6 +14,7 @@
//===----------------------------------------------------------------------===//
#include "NewPMDriver.h"
+#include "PassPrinters.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/CGSCCPassManager.h"
@@ -185,7 +186,8 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
VerifierKind VK,
bool ShouldPreserveAssemblyUseListOrder,
bool ShouldPreserveBitcodeUseListOrder,
- bool EmitSummaryIndex, bool EmitModuleHash) {
+ bool EmitSummaryIndex, bool EmitModuleHash,
+ bool EnableDebugify) {
bool VerifyEachPass = VK == VK_VerifyEachPass;
Optional<PGOOptions> P;
@@ -208,6 +210,20 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
PassBuilder PB(TM, P);
registerEPCallbacks(PB, VerifyEachPass, DebugPM);
+ // Register a callback that creates the debugify passes as needed.
+ PB.registerPipelineParsingCallback(
+ [](StringRef Name, ModulePassManager &MPM,
+ ArrayRef<PassBuilder::PipelineElement>) {
+ if (Name == "debugify") {
+ MPM.addPass(NewPMDebugifyPass());
+ return true;
+ } else if (Name == "check-debugify") {
+ MPM.addPass(NewPMCheckDebugifyPass());
+ return true;
+ }
+ return false;
+ });
+
#ifdef LINK_POLLY_INTO_TOOLS
polly::RegisterPollyPasses(PB);
#endif
@@ -238,6 +254,8 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
ModulePassManager MPM(DebugPM);
if (VK > VK_NoVerifier)
MPM.addPass(VerifierPass());
+ if (EnableDebugify)
+ MPM.addPass(NewPMDebugifyPass());
if (!PB.parsePassPipeline(MPM, PassPipeline, VerifyEachPass, DebugPM)) {
errs() << Arg0 << ": unable to parse pass pipeline description.\n";
@@ -246,6 +264,8 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
if (VK > VK_NoVerifier)
MPM.addPass(VerifierPass());
+ if (EnableDebugify)
+ MPM.addPass(NewPMCheckDebugifyPass());
// Add any relevant output pass at the end of the pipeline.
switch (OK) {
OpenPOWER on IntegriCloud