; 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
///
//===----------------------------------------------------------------------===//
+#include "PassPrinters.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/IR/BasicBlock.h"
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");
//===----------------------------------------------------------------------===//
#include "NewPMDriver.h"
+#include "PassPrinters.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/CGSCCPassManager.h"
VerifierKind VK,
bool ShouldPreserveAssemblyUseListOrder,
bool ShouldPreserveBitcodeUseListOrder,
- bool EmitSummaryIndex, bool EmitModuleHash) {
+ bool EmitSummaryIndex, bool EmitModuleHash,
+ bool EnableDebugify) {
bool VerifyEachPass = VK == VK_VerifyEachPass;
Optional<PGOOptions> P;
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
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";
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) {
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
#ifndef LLVM_TOOLS_OPT_PASSPRINTERS_H
#define LLVM_TOOLS_OPT_PASSPRINTERS_H
+#include "llvm/IR/PassManager.h"
+
namespace llvm {
class BasicBlockPass;
class PassInfo;
class raw_ostream;
class RegionPass;
+class Module;
FunctionPass *createFunctionPassPrinter(const PassInfo *PI, raw_ostream &out,
bool Quiet);
} // 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
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);
OptRemarkFile.get(), PassPipeline, OK, VK,
PreserveAssemblyUseListOrder,
PreserveBitcodeUseListOrder, EmitSummaryIndex,
- EmitModuleHash)
+ EmitModuleHash, EnableDebugify)
? 0
: 1;
}