bool isSpecialPass(StringRef PassID, const std::vector<StringRef> &Specials) {
size_t Pos = PassID.find('<');
- if (Pos == StringRef::npos)
- return false;
- StringRef Prefix = PassID.substr(0, Pos);
+ StringRef Prefix = PassID;
+ if (Pos != StringRef::npos)
+ Prefix = PassID.substr(0, Pos);
return any_of(Specials, [Prefix](StringRef S) { return Prefix.endswith(S); });
}
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Module.h"
+#include "llvm/IR/PassInstrumentation.h"
#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
return PreservedAnalyses::all();
}
+static bool isIgnoredPass(StringRef PassID) {
+ return isSpecialPass(PassID, {"PassManager", "PassAdaptor",
+ "AnalysisManagerProxy", "PrintFunctionPass",
+ "PrintModulePass", "BitcodeWriterPass",
+ "ThinLTOBitcodeWriterPass", "VerifierPass"});
+}
+
void DebugifyEachInstrumentation::registerCallbacks(
PassInstrumentationCallbacks &PIC) {
PIC.registerBeforeNonSkippedPassCallback([](StringRef P, Any IR) {
+ if (isIgnoredPass(P))
+ return;
if (any_isa<const Function *>(IR))
applyDebugify(*const_cast<Function *>(any_cast<const Function *>(IR)));
else if (any_isa<const Module *>(IR))
});
PIC.registerAfterPassCallback([this](StringRef P, Any IR,
const PreservedAnalyses &PassPA) {
+ if (isIgnoredPass(P))
+ return;
if (any_isa<const Function *>(IR)) {
auto &F = *const_cast<Function *>(any_cast<const Function *>(IR));
Module &M = *F.getParent();
; RUN: opt -O1 -debugify-each < %s | llvm-dis -o %t.after
; RUN: diff %t.before %t.after
+; Check that we only run debugify once per function per function pass.
+; This ensures that we don't run it for pass managers/verifiers/printers.
+; RUN: opt -debugify-each -passes=instsimplify -S -o /dev/null < %s 2> %t
+; RUN: FileCheck %s -input-file=%t -check-prefix=FUNCTION-PASS-ONE
+
+; Check that we only run debugify once per module pass
+; (plus the implicitly added begin/end verifier passes).
+; RUN: opt -debugify-each -passes=globalopt -S -o /dev/null < %s 2> %t
+; RUN: FileCheck %s -input-file=%t -check-prefix=MODULE-PASS-ONE
+
define void @foo(i32 %arg) {
call i32 asm "bswap $0", "=r,r"(i32 %arg)
ret void
; FUNCTION-PASS: CheckFunctionDebugify [{{.*}}]
; FUNCTION-PASS: CheckFunctionDebugify [{{.*}}]
; FUNCTION-PASS: CheckFunctionDebugify [{{.*}}]
+
+; MODULE-PASS-ONE: CheckModuleDebugify [{{.*}}]
+; MODULE-PASS-ONE-NOT: CheckModuleDebugify [{{.*}}]
+
+; FUNCTION-PASS-ONE: CheckFunctionDebugify [{{.*}}]
+; FUNCTION-PASS-ONE: CheckFunctionDebugify [{{.*}}]
+; FUNCTION-PASS-ONE-NOT: CheckFunctionDebugify [{{.*}}]
-; RUN: opt %s -disable-output -debugify-each -debugify-quiet -debugify-export - -enable-new-pm=0 | FileCheck %s
-; RUN: opt %s -disable-output -debugify-each -debugify-quiet -debugify-export - -enable-new-pm=1 | FileCheck %s
+; RUN: opt %s -disable-output -debugify-each -debugify-quiet -debugify-export - -globalopt | FileCheck %s
+; RUN: opt %s -disable-output -debugify-each -debugify-quiet -debugify-export - -passes=globalopt | FileCheck %s
; CHECK: Pass Name
; CHECK-SAME: # of missing debug values
; CHECK-SAME: Missing/Expected value ratio
; CHECK-SAME: Missing/Expected location ratio
-; CHECK: {{Module Verifier|VerifierPass}}
+; CHECK: {{Module Verifier|GlobalOptPass}}
; CHECK-SAME: 0,0,0.000000e+00,0.000000e+00
define void @foo() {
; RUN: opt < %s -instcombine -instcombine-infinite-loop-threshold=2 -S | FileCheck %s
; RUN: opt < %s -instcombine -S -debugify-each | FileCheck %s
+; RUN: opt < %s -passes=instcombine -S -debugify-each | FileCheck %s
declare void @llvm.experimental.guard(i1, ...)