[llvm] r325294 - [opt] Port the debugify passes to the new pass manager
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 15 13:14:37 PST 2018
Author: vedantk
Date: Thu Feb 15 13:14:36 2018
New Revision: 325294
URL: http://llvm.org/viewvc/llvm-project?rev=325294&view=rev
Log:
[opt] Port the debugify passes to the new pass manager
Modified:
llvm/trunk/test/DebugInfo/debugify.ll
llvm/trunk/tools/opt/Debugify.cpp
llvm/trunk/tools/opt/NewPMDriver.cpp
llvm/trunk/tools/opt/NewPMDriver.h
llvm/trunk/tools/opt/PassPrinters.h
llvm/trunk/tools/opt/opt.cpp
Modified: llvm/trunk/test/DebugInfo/debugify.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/debugify.ll?rev=325294&r1=325293&r2=325294&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/debugify.ll (original)
+++ llvm/trunk/test/DebugInfo/debugify.ll Thu Feb 15 13:14:36 2018
@@ -1,10 +1,17 @@
; RUN: opt -debugify -S -o - < %s | FileCheck %s
+; RUN: opt -passes=debugify -S -o - < %s | FileCheck %s
; RUN: opt -debugify -debugify -S -o - < %s 2>&1 | \
; RUN: FileCheck %s -check-prefix=CHECK-REPEAT
+; RUN: opt -passes=debugify,debugify -S -o - < %s 2>&1 | \
+; RUN: FileCheck %s -check-prefix=CHECK-REPEAT
; RUN: opt -debugify -check-debugify -S -o - < %s | \
; RUN: FileCheck %s -implicit-check-not="CheckDebugify: FAIL"
+; RUN: opt -passes=debugify,check-debugify -S -o - < %s | \
+; RUN: FileCheck %s -implicit-check-not="CheckDebugify: FAIL"
+; RUN: opt -enable-debugify -passes=verify -S -o - < %s | \
+; RUN: FileCheck %s -implicit-check-not="CheckDebugify: FAIL"
; RUN: opt -debugify -strip -check-debugify -S -o - < %s | \
; RUN: FileCheck %s -check-prefix=CHECK-FAIL
Modified: llvm/trunk/tools/opt/Debugify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/Debugify.cpp?rev=325294&r1=325293&r2=325294&view=diff
==============================================================================
--- llvm/trunk/tools/opt/Debugify.cpp (original)
+++ llvm/trunk/tools/opt/Debugify.cpp Thu Feb 15 13:14:36 2018
@@ -12,6 +12,7 @@
///
//===----------------------------------------------------------------------===//
+#include "PassPrinters.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/IR/BasicBlock.h"
@@ -206,8 +207,19 @@ struct CheckDebugifyPass : public Module
ModulePass *createDebugifyPass() { return new DebugifyPass(); }
+PreservedAnalyses NewPMDebugifyPass::run(Module &M, ModuleAnalysisManager &) {
+ applyDebugifyMetadata(M);
+ return PreservedAnalyses::all();
+}
+
ModulePass *createCheckDebugifyPass() { return new CheckDebugifyPass(); }
+PreservedAnalyses NewPMCheckDebugifyPass::run(Module &M,
+ ModuleAnalysisManager &) {
+ checkDebugifyMetadata(M);
+ return PreservedAnalyses::all();
+}
+
char DebugifyPass::ID = 0;
static RegisterPass<DebugifyPass> X("debugify",
"Attach debug info to everything");
Modified: llvm/trunk/tools/opt/NewPMDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/NewPMDriver.cpp?rev=325294&r1=325293&r2=325294&view=diff
==============================================================================
--- llvm/trunk/tools/opt/NewPMDriver.cpp (original)
+++ llvm/trunk/tools/opt/NewPMDriver.cpp Thu Feb 15 13:14:36 2018
@@ -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 Arg
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 Arg
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 Arg
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 Arg
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) {
Modified: llvm/trunk/tools/opt/NewPMDriver.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/NewPMDriver.h?rev=325294&r1=325293&r2=325294&view=diff
==============================================================================
--- llvm/trunk/tools/opt/NewPMDriver.h (original)
+++ llvm/trunk/tools/opt/NewPMDriver.h Thu Feb 15 13:14:36 2018
@@ -57,7 +57,8 @@ bool runPassPipeline(StringRef Arg0, Mod
opt_tool::OutputKind OK, opt_tool::VerifierKind VK,
bool ShouldPreserveAssemblyUseListOrder,
bool ShouldPreserveBitcodeUseListOrder,
- bool EmitSummaryIndex, bool EmitModuleHash);
-}
+ bool EmitSummaryIndex, bool EmitModuleHash,
+ bool EnableDebugify);
+} // namespace llvm
#endif
Modified: llvm/trunk/tools/opt/PassPrinters.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/PassPrinters.h?rev=325294&r1=325293&r2=325294&view=diff
==============================================================================
--- llvm/trunk/tools/opt/PassPrinters.h (original)
+++ llvm/trunk/tools/opt/PassPrinters.h Thu Feb 15 13:14:36 2018
@@ -15,6 +15,8 @@
#ifndef LLVM_TOOLS_OPT_PASSPRINTERS_H
#define LLVM_TOOLS_OPT_PASSPRINTERS_H
+#include "llvm/IR/PassManager.h"
+
namespace llvm {
class BasicBlockPass;
@@ -25,6 +27,7 @@ class LoopPass;
class PassInfo;
class raw_ostream;
class RegionPass;
+class Module;
FunctionPass *createFunctionPassPrinter(const PassInfo *PI, raw_ostream &out,
bool Quiet);
@@ -46,4 +49,17 @@ BasicBlockPass *createBasicBlockPassPrin
} // end namespace llvm
+llvm::ModulePass *createDebugifyPass();
+
+struct NewPMDebugifyPass : public llvm::PassInfoMixin<NewPMDebugifyPass> {
+ llvm::PreservedAnalyses run(llvm::Module &M, llvm::ModuleAnalysisManager &AM);
+};
+
+llvm::ModulePass *createCheckDebugifyPass();
+
+struct NewPMCheckDebugifyPass
+ : public llvm::PassInfoMixin<NewPMCheckDebugifyPass> {
+ llvm::PreservedAnalyses run(llvm::Module &M, llvm::ModuleAnalysisManager &AM);
+};
+
#endif // LLVM_TOOLS_OPT_PASSPRINTERS_H
Modified: llvm/trunk/tools/opt/opt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=325294&r1=325293&r2=325294&view=diff
==============================================================================
--- llvm/trunk/tools/opt/opt.cpp (original)
+++ llvm/trunk/tools/opt/opt.cpp Thu Feb 15 13:14:36 2018
@@ -257,9 +257,6 @@ static cl::opt<std::string>
cl::desc("YAML output filename for pass remarks"),
cl::value_desc("filename"));
-extern ModulePass *createDebugifyPass();
-extern ModulePass *createCheckDebugifyPass();
-
static inline void addPass(legacy::PassManagerBase &PM, Pass *P) {
// Add the pass to the pass manager...
PM.add(P);
@@ -555,7 +552,7 @@ int main(int argc, char **argv) {
OptRemarkFile.get(), PassPipeline, OK, VK,
PreserveAssemblyUseListOrder,
PreserveBitcodeUseListOrder, EmitSummaryIndex,
- EmitModuleHash)
+ EmitModuleHash, EnableDebugify)
? 0
: 1;
}
More information about the llvm-commits
mailing list