Skip to content

Commit

Permalink
[Debugfiy] Print the pass name next to the result
Browse files Browse the repository at this point in the history
CheckDebugify now prints the pass name right next to the result of the check.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332416 91177308-0d34-0410-b5e6-96231b3b80d8
gramanas committed May 15, 2018
1 parent b79d2cf commit d146023
Showing 5 changed files with 38 additions and 27 deletions.
20 changes: 10 additions & 10 deletions test/DebugInfo/debugify-each.ll
Original file line number Diff line number Diff line change
@@ -11,14 +11,14 @@ define void @bar() {

; Verify that the module & function (check-)debugify passes run at least twice.

; CHECK-DAG: CheckModuleDebugify: PASS
; CHECK-DAG: CheckFunctionDebugify: PASS
; CHECK-DAG: CheckFunctionDebugify: PASS
; CHECK-DAG: CheckFunctionDebugify: PASS
; CHECK-DAG: CheckFunctionDebugify: PASS
; CHECK-DAG: CheckModuleDebugify [{{.*}}]: PASS
; CHECK-DAG: CheckFunctionDebugify [{{.*}}]: PASS
; CHECK-DAG: CheckFunctionDebugify [{{.*}}]: PASS
; CHECK-DAG: CheckFunctionDebugify [{{.*}}]: PASS
; CHECK-DAG: CheckFunctionDebugify [{{.*}}]: PASS

; CHECK-DAG: CheckModuleDebugify: PASS
; CHECK-DAG: CheckFunctionDebugify: PASS
; CHECK-DAG: CheckFunctionDebugify: PASS
; CHECK-DAG: CheckFunctionDebugify: PASS
; CHECK-DAG: CheckFunctionDebugify: PASS
; CHECK-DAG: CheckModuleDebugify [{{.*}}]: PASS
; CHECK-DAG: CheckFunctionDebugify [{{.*}}]: PASS
; CHECK-DAG: CheckFunctionDebugify [{{.*}}]: PASS
; CHECK-DAG: CheckFunctionDebugify [{{.*}}]: PASS
; CHECK-DAG: CheckFunctionDebugify [{{.*}}]: PASS
4 changes: 2 additions & 2 deletions test/DebugInfo/debugify.ll
Original file line number Diff line number Diff line change
@@ -80,6 +80,6 @@ define weak_odr zeroext i1 @baz() {
; CHECK-FAIL: WARNING: Missing line 3
; CHECK-FAIL: WARNING: Missing line 4
; CHECK-FAIL: ERROR: Missing variable 1
; CHECK-FAIL: CheckModuleDebugify: FAIL
; CHECK-FAIL: CheckModuleDebugify [{{.*}}]: FAIL

; PASS: CheckModuleDebugify: PASS
; PASS: CheckModuleDebugify [{{.*}}]: PASS
28 changes: 17 additions & 11 deletions tools/opt/Debugify.cpp
Original file line number Diff line number Diff line change
@@ -126,6 +126,7 @@ bool applyDebugifyMetadata(Module &M,

bool checkDebugifyMetadata(Module &M,
iterator_range<Module::iterator> Functions,
StringRef NameOfWrappedPass,
StringRef Banner,
bool Strip) {
// Skip modules without debugify metadata.
@@ -190,7 +191,8 @@ bool checkDebugifyMetadata(Module &M,
outs() << "ERROR: Missing variable " << Idx + 1 << "\n";
HasErrors |= MissingVars.count() > 0;

outs() << Banner << (HasErrors ? "FAIL" : "PASS") << '\n';
outs() << Banner << " [" << NameOfWrappedPass << "]: "
<< (HasErrors ? "FAIL" : "PASS") << '\n';
if (HasErrors) {
outs() << "Module IR Dump\n";
M.print(outs(), nullptr, false);
@@ -245,16 +247,18 @@ struct DebugifyFunctionPass : public FunctionPass {
/// legacy module pass manager.
struct CheckDebugifyModulePass : public ModulePass {
bool runOnModule(Module &M) override {
return checkDebugifyMetadata(M, M.functions(), "CheckModuleDebugify: ",
Strip);
return checkDebugifyMetadata(M, M.functions(), NameOfWrappedPass,
"CheckModuleDebugify", Strip);
}

CheckDebugifyModulePass(bool Strip = false) : ModulePass(ID), Strip(Strip) {}
CheckDebugifyModulePass(bool Strip = false, StringRef NameOfWrappedPass = "")
: ModulePass(ID), Strip(Strip), NameOfWrappedPass(NameOfWrappedPass) {}

static char ID; // Pass identification.

private:
bool Strip;
StringRef NameOfWrappedPass;
};

/// FunctionPass for checking debug info inserted by -debugify-function, used
@@ -264,10 +268,11 @@ struct CheckDebugifyFunctionPass : public FunctionPass {
Module &M = *F.getParent();
auto FuncIt = F.getIterator();
return checkDebugifyMetadata(M, make_range(FuncIt, std::next(FuncIt)),
"CheckFunctionDebugify: ", Strip);
NameOfWrappedPass, "CheckFunctionDebugify", Strip);
}

CheckDebugifyFunctionPass(bool Strip = false) : FunctionPass(ID), Strip(Strip) {}
CheckDebugifyFunctionPass(bool Strip = false, StringRef NameOfWrappedPass = "")
: FunctionPass(ID), Strip(Strip), NameOfWrappedPass(NameOfWrappedPass) {}

void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesAll();
@@ -277,6 +282,7 @@ struct CheckDebugifyFunctionPass : public FunctionPass {

private:
bool Strip;
StringRef NameOfWrappedPass;
};

} // end anonymous namespace
@@ -294,17 +300,17 @@ PreservedAnalyses NewPMDebugifyPass::run(Module &M, ModuleAnalysisManager &) {
return PreservedAnalyses::all();
}

ModulePass *createCheckDebugifyModulePass(bool Strip) {
return new CheckDebugifyModulePass(Strip);
ModulePass *createCheckDebugifyModulePass(bool Strip, StringRef NameOfWrappedPass) {
return new CheckDebugifyModulePass(Strip, NameOfWrappedPass);
}

FunctionPass *createCheckDebugifyFunctionPass(bool Strip) {
return new CheckDebugifyFunctionPass(Strip);
FunctionPass *createCheckDebugifyFunctionPass(bool Strip, StringRef NameOfWrappedPass) {
return new CheckDebugifyFunctionPass(Strip, NameOfWrappedPass);
}

PreservedAnalyses NewPMCheckDebugifyPass::run(Module &M,
ModuleAnalysisManager &) {
checkDebugifyMetadata(M, M.functions(), "CheckModuleDebugify: ", false);
checkDebugifyMetadata(M, M.functions(), "", "CheckModuleDebugify", false);
return PreservedAnalyses::all();
}

9 changes: 7 additions & 2 deletions tools/opt/PassPrinters.h
Original file line number Diff line number Diff line change
@@ -56,8 +56,13 @@ struct NewPMDebugifyPass : public llvm::PassInfoMixin<NewPMDebugifyPass> {
llvm::PreservedAnalyses run(llvm::Module &M, llvm::ModuleAnalysisManager &AM);
};

llvm::ModulePass *createCheckDebugifyModulePass(bool Strip = false);
llvm::FunctionPass *createCheckDebugifyFunctionPass(bool Strip = false);
llvm::ModulePass *
createCheckDebugifyModulePass(bool Strip = false,
llvm::StringRef NameOfWrappedPass = "");

llvm::FunctionPass *
createCheckDebugifyFunctionPass(bool Strip = false,
llvm::StringRef NameOfWrappedPass = "");

struct NewPMCheckDebugifyPass
: public llvm::PassInfoMixin<NewPMCheckDebugifyPass> {
4 changes: 2 additions & 2 deletions tools/opt/opt.cpp
Original file line number Diff line number Diff line change
@@ -278,12 +278,12 @@ class OptCustomPassManager : public legacy::PassManager {
case PT_Function:
super::add(createDebugifyFunctionPass());
super::add(P);
super::add(createCheckDebugifyFunctionPass(true));
super::add(createCheckDebugifyFunctionPass(true, P->getPassName()));
break;
case PT_Module:
super::add(createDebugifyModulePass());
super::add(P);
super::add(createCheckDebugifyModulePass(true));
super::add(createCheckDebugifyModulePass(true, P->getPassName()));
break;
default:
super::add(P);

0 comments on commit d146023

Please sign in to comment.