mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-21 18:22:53 +01:00
[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
This commit is contained in:
parent
43d4e670a4
commit
d577e2748f
@ -61,7 +61,6 @@ private:
|
||||
/// Stack of Module description, enough to print the module after a given
|
||||
/// pass.
|
||||
SmallVector<PrintModuleDesc, 2> ModuleDescStack;
|
||||
bool StoreModuleDesc = false;
|
||||
};
|
||||
|
||||
class OptNoneInstrumentation {
|
||||
|
@ -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); });
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user