Skip to content

Commit 7abef41

Browse files
committed
[NewPM] Print 'Skipping pass' as pass instrumentation
If OptNoneInstrumentation prints it instead, 'Skipping pass' will print for even required passes. Reviewed By: ychen Differential Revision: https://reviews.llvm.org/D85493
1 parent cbd8ec9 commit 7abef41

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

llvm/include/llvm/Passes/StandardInstrumentations.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,11 @@ class PrintIRInstrumentation {
5656

5757
class OptNoneInstrumentation {
5858
public:
59-
OptNoneInstrumentation(bool DebugLogging) : DebugLogging(DebugLogging) {}
59+
OptNoneInstrumentation() {}
6060
void registerCallbacks(PassInstrumentationCallbacks &PIC);
6161

6262
private:
6363
bool skip(StringRef PassID, Any IR);
64-
bool DebugLogging;
6564
};
6665

6766
// Debug logging for transformation and analysis passes.
@@ -83,8 +82,7 @@ class StandardInstrumentations {
8382
OptNoneInstrumentation OptNone;
8483

8584
public:
86-
StandardInstrumentations(bool DebugLogging)
87-
: PrintPass(DebugLogging), OptNone(DebugLogging) {}
85+
StandardInstrumentations(bool DebugLogging) : PrintPass(DebugLogging) {}
8886

8987
void registerCallbacks(PassInstrumentationCallbacks &PIC);
9088

llvm/lib/Passes/StandardInstrumentations.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,7 @@ bool OptNoneInstrumentation::skip(StringRef PassID, Any IR) {
297297
} else if (any_isa<const Loop *>(IR)) {
298298
F = any_cast<const Loop *>(IR)->getHeader()->getParent();
299299
}
300-
if (F && F->hasOptNone()) {
301-
if (DebugLogging)
302-
dbgs() << "Skipping pass: " << PassID << " (optnone)\n";
303-
return false;
304-
}
305-
return true;
300+
return !(F && F->hasOptNone());
306301
}
307302

308303
void PrintPassInstrumentation::registerCallbacks(
@@ -314,6 +309,15 @@ void PrintPassInstrumentation::registerCallbacks(
314309
if (!DebugPMVerbose)
315310
SpecialPasses.emplace_back("PassAdaptor");
316311

312+
PIC.registerBeforeSkippedPassCallback(
313+
[SpecialPasses](StringRef PassID, Any IR) {
314+
assert(!isSpecialPass(PassID, SpecialPasses) &&
315+
"Unexpectedly skipping special pass");
316+
317+
dbgs() << "Skipping pass: " << PassID << " on ";
318+
unwrapAndPrint(IR, "", false, true);
319+
});
320+
317321
PIC.registerBeforeNonSkippedPassCallback(
318322
[SpecialPasses](StringRef PassID, Any IR) {
319323
if (isSpecialPass(PassID, SpecialPasses))

llvm/test/Feature/optnone-opt.ll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ attributes #0 = { optnone noinline }
5050
; O1-DAG: Skipping pass 'Reassociate expressions'
5151
; O1-DAG: Skipping pass 'Simplify the CFG'
5252
; O1-DAG: Skipping pass 'Sparse Conditional Constant Propagation'
53-
; NPM-O1-DAG: Skipping pass: SimplifyCFGPass
53+
; NPM-O1-DAG: Skipping pass: SimplifyCFGPass on {{.*}}foo
5454
; NPM-O1-DAG: Skipping pass: SROA
5555
; NPM-O1-DAG: Skipping pass: EarlyCSEPass
5656
; NPM-O1-DAG: Skipping pass: LowerExpectIntrinsicPass
@@ -80,7 +80,9 @@ attributes #0 = { optnone noinline }
8080
; LOOP-DAG: Skipping pass 'Simplify instructions in loops'
8181
; LOOP-DAG: Skipping pass 'Unroll loops'
8282
; LOOP-DAG: Skipping pass 'Unswitch loops'
83-
; NPM-LOOP-DAG: Skipping pass: LoopSimplifyPass
83+
; LoopPassManager should not be skipped over an optnone function
84+
; NPM-LOOP-NOT: Skipping pass: PassManager
85+
; NPM-LOOP-DAG: Skipping pass: LoopSimplifyPass on {{.*}}foo
8486
; NPM-LOOP-DAG: Skipping pass: LCSSAPass
8587
; NPM-LOOP-DAG: Skipping pass: IndVarSimplifyPass
8688
; NPM-LOOP-DAG: Skipping pass: SimpleLoopUnswitchPass

0 commit comments

Comments
 (0)