[llvm] 6144fc2 - [NewPM] Print pre-transformation IR name in --print-after-all
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 20 10:20:22 PDT 2021
Author: Arthur Eubanks
Date: 2021-07-20T10:20:10-07:00
New Revision: 6144fc2da1b87dc64ff887d73b60f7708f5cb0a4
URL: https://github.com/llvm/llvm-project/commit/6144fc2da1b87dc64ff887d73b60f7708f5cb0a4
DIFF: https://github.com/llvm/llvm-project/commit/6144fc2da1b87dc64ff887d73b60f7708f5cb0a4.diff
LOG: [NewPM] Print pre-transformation IR name in --print-after-all
Sometimes a transformation can change the name of some IR (e.g. an SCC
with functions added/removed). This can be confusing when debug logging
doesn't match the post-transformation name. The specific example I came
across was that --print-after-all said the inliner was working on an SCC
that only contained one function, but calls in multiple functions were
getting inlined. After all inlining, the current SCC only contained one
function.
Piggyback off of the existing logic to handle invalidated IR +
--print-module-scope. Simply always store the IR description and use
that.
Reviewed By: jamieschmeiser
Differential Revision: https://reviews.llvm.org/D106290
Added:
Modified:
llvm/include/llvm/Passes/StandardInstrumentations.h
llvm/lib/Passes/StandardInstrumentations.cpp
llvm/test/Other/loop-deletion-printer.ll
llvm/test/Other/scc-deleted-printer.ll
Removed:
################################################################################
diff --git a/llvm/include/llvm/Passes/StandardInstrumentations.h b/llvm/include/llvm/Passes/StandardInstrumentations.h
index 9011c52f20c1f..2f573585e766d 100644
--- a/llvm/include/llvm/Passes/StandardInstrumentations.h
+++ b/llvm/include/llvm/Passes/StandardInstrumentations.h
@@ -61,7 +61,6 @@ class PrintIRInstrumentation {
/// Stack of Module description, enough to print the module after a given
/// pass.
SmallVector<PrintModuleDesc, 2> ModuleDescStack;
- bool StoreModuleDesc = false;
};
class OptNoneInstrumentation {
diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp
index a03e0d4b597eb..5a48923bce8ab 100644
--- a/llvm/lib/Passes/StandardInstrumentations.cpp
+++ b/llvm/lib/Passes/StandardInstrumentations.cpp
@@ -709,7 +709,6 @@ PrintIRInstrumentation::~PrintIRInstrumentation() {
}
void PrintIRInstrumentation::pushModuleDesc(StringRef PassID, Any IR) {
- assert(StoreModuleDesc);
const Module *M = unwrapModule(IR);
ModuleDescStack.emplace_back(M, getIRName(IR), PassID);
}
@@ -730,7 +729,7 @@ void PrintIRInstrumentation::printBeforePass(StringRef PassID, Any IR) {
// Note: here we rely on a fact that we do not change modules while
// traversing the pipeline, so the latest captured module is good
// for all print operations that has not happen yet.
- if (StoreModuleDesc && shouldPrintAfterPass(PassID))
+ if (shouldPrintAfterPass(PassID))
pushModuleDesc(PassID, IR);
if (!shouldPrintBeforePass(PassID))
@@ -751,25 +750,22 @@ void PrintIRInstrumentation::printAfterPass(StringRef PassID, Any IR) {
if (!shouldPrintAfterPass(PassID))
return;
- if (StoreModuleDesc) {
- const Module *M;
- std::string IRName;
- StringRef StoredPassID;
- std::tie(M, IRName, StoredPassID) = popModuleDesc(PassID);
- assert(StoredPassID == PassID && "mismatched PassID");
- }
+ const Module *M;
+ std::string IRName;
+ StringRef StoredPassID;
+ std::tie(M, IRName, StoredPassID) = popModuleDesc(PassID);
+ assert(StoredPassID == PassID && "mismatched PassID");
if (!shouldPrintIR(IR))
return;
- dbgs() << "*** IR Dump After " << PassID << " on " << getIRName(IR)
- << " ***\n";
+ dbgs() << "*** IR Dump After " << PassID << " on " << IRName << " ***\n";
unwrapAndPrint(dbgs(), IR);
}
void PrintIRInstrumentation::printAfterPassInvalidated(StringRef PassID) {
StringRef PassName = PIC->getPassNameForClassName(PassID);
- if (!StoreModuleDesc || !shouldPrintAfterPass(PassName))
+ if (!shouldPrintAfterPass(PassName))
return;
if (isIgnored(PassID))
@@ -813,8 +809,7 @@ void PrintIRInstrumentation::registerCallbacks(
// BeforePass callback is not just for printing, it also saves a Module
// for later use in AfterPassInvalidated.
- StoreModuleDesc = forcePrintModuleIR() && shouldPrintAfterSomePass();
- if (shouldPrintBeforeSomePass() || StoreModuleDesc)
+ if (shouldPrintBeforeSomePass() || shouldPrintAfterSomePass())
PIC.registerBeforeNonSkippedPassCallback(
[this](StringRef P, Any IR) { this->printBeforePass(P, IR); });
diff --git a/llvm/test/Other/loop-deletion-printer.ll b/llvm/test/Other/loop-deletion-printer.ll
index 53971b8c0df6d..bce32dbeb52bd 100644
--- a/llvm/test/Other/loop-deletion-printer.ll
+++ b/llvm/test/Other/loop-deletion-printer.ll
@@ -6,13 +6,11 @@
; RUN: opt < %s -disable-output \
; RUN: -passes=loop-deletion,loop-instsimplify -print-after-all 2>&1 | FileCheck %s -check-prefix=DELETED
; RUN: opt < %s -disable-output \
-; RUN: -passes=loop-deletion,loop-instsimplify -print-after-all -print-module-scope 2>&1 | FileCheck %s -check-prefix=DELETED-BUT-PRINTED
+; RUN: -passes=loop-deletion,loop-instsimplify -print-after-all -print-module-scope 2>&1 | FileCheck %s -check-prefix=DELETED
;
; SIMPLIFY: IR Dump {{.*}} LoopInstSimplifyPass
+; DELETED: IR Dump {{.*}}LoopDeletionPass {{.*}}(invalidated)
; DELETED-NOT: IR Dump {{.*}}LoopInstSimplifyPass
-; DELETED-NOT: IR Dump {{.*}}LoopDeletionPass
-; DELETED-BUT-PRINTED: IR Dump {{.*}}LoopDeletionPass {{.*}}(invalidated)
-; DELETED-BUT-PRINTED-NOT: IR Dump {{.*}}LoopInstSimplifyPass
define void @deleteme() {
entry:
diff --git a/llvm/test/Other/scc-deleted-printer.ll b/llvm/test/Other/scc-deleted-printer.ll
index 05b2f4569ed0a..86171d914c19e 100644
--- a/llvm/test/Other/scc-deleted-printer.ll
+++ b/llvm/test/Other/scc-deleted-printer.ll
@@ -1,17 +1,12 @@
; RUN: opt < %s 2>&1 -disable-output \
-; RUN: -passes=inline -print-before-all -print-after-all | FileCheck %s -check-prefix=INL
+; RUN: -passes=inline -print-before-all -print-after-all | FileCheck %s
; RUN: opt < %s 2>&1 -disable-output \
-; RUN: -passes=inline -print-before-all -print-after-all -print-module-scope | FileCheck %s -check-prefix=INL-MOD
+; RUN: -passes=inline -print-before-all -print-after-all -print-module-scope | FileCheck %s
-; INL: IR Dump Before InlinerPass on (tester, foo)
-; INL-NOT: IR Dump After {{InlinerPass}}
-; INL: IR Dump Before InlinerPass on (tester)
-; INL: IR Dump After InlinerPass on (tester)
-
-; INL-MOD: IR Dump Before InlinerPass on (tester, foo)
-; INL-MOD: IR Dump After InlinerPass on (tester, foo) (invalidated)
-; INL-MOD: IR Dump Before InlinerPass on (tester)
-; INL-MOD: IR Dump After InlinerPass on (tester)
+; CHECK: IR Dump Before InlinerPass on (tester, foo)
+; CHECK: IR Dump After InlinerPass on (tester, foo) (invalidated)
+; CHECK: IR Dump Before InlinerPass on (tester)
+; CHECK: IR Dump After InlinerPass on (tester)
define void @tester() noinline {
More information about the llvm-commits
mailing list