[llvm] 7abef41 - [NewPM] Print 'Skipping pass' as pass instrumentation

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 7 15:02:14 PDT 2020


Author: Arthur Eubanks
Date: 2020-08-07T15:02:02-07:00
New Revision: 7abef41674249cbc2e23a800762dc8f98013de66

URL: https://github.com/llvm/llvm-project/commit/7abef41674249cbc2e23a800762dc8f98013de66
DIFF: https://github.com/llvm/llvm-project/commit/7abef41674249cbc2e23a800762dc8f98013de66.diff

LOG: [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

Added: 
    

Modified: 
    llvm/include/llvm/Passes/StandardInstrumentations.h
    llvm/lib/Passes/StandardInstrumentations.cpp
    llvm/test/Feature/optnone-opt.ll

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Passes/StandardInstrumentations.h b/llvm/include/llvm/Passes/StandardInstrumentations.h
index fc0f21e404010..795e2770bbe18 100644
--- a/llvm/include/llvm/Passes/StandardInstrumentations.h
+++ b/llvm/include/llvm/Passes/StandardInstrumentations.h
@@ -56,12 +56,11 @@ class PrintIRInstrumentation {
 
 class OptNoneInstrumentation {
 public:
-  OptNoneInstrumentation(bool DebugLogging) : DebugLogging(DebugLogging) {}
+  OptNoneInstrumentation() {}
   void registerCallbacks(PassInstrumentationCallbacks &PIC);
 
 private:
   bool skip(StringRef PassID, Any IR);
-  bool DebugLogging;
 };
 
 // Debug logging for transformation and analysis passes.
@@ -83,8 +82,7 @@ class StandardInstrumentations {
   OptNoneInstrumentation OptNone;
 
 public:
-  StandardInstrumentations(bool DebugLogging)
-      : PrintPass(DebugLogging), OptNone(DebugLogging) {}
+  StandardInstrumentations(bool DebugLogging) : PrintPass(DebugLogging) {}
 
   void registerCallbacks(PassInstrumentationCallbacks &PIC);
 

diff  --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp
index d4a6784985a23..9e9caa1557b40 100644
--- a/llvm/lib/Passes/StandardInstrumentations.cpp
+++ b/llvm/lib/Passes/StandardInstrumentations.cpp
@@ -297,12 +297,7 @@ bool OptNoneInstrumentation::skip(StringRef PassID, Any IR) {
   } else if (any_isa<const Loop *>(IR)) {
     F = any_cast<const Loop *>(IR)->getHeader()->getParent();
   }
-  if (F && F->hasOptNone()) {
-    if (DebugLogging)
-      dbgs() << "Skipping pass: " << PassID << " (optnone)\n";
-    return false;
-  }
-  return true;
+  return !(F && F->hasOptNone());
 }
 
 void PrintPassInstrumentation::registerCallbacks(
@@ -314,6 +309,15 @@ void PrintPassInstrumentation::registerCallbacks(
   if (!DebugPMVerbose)
     SpecialPasses.emplace_back("PassAdaptor");
 
+  PIC.registerBeforeSkippedPassCallback(
+      [SpecialPasses](StringRef PassID, Any IR) {
+        assert(!isSpecialPass(PassID, SpecialPasses) &&
+               "Unexpectedly skipping special pass");
+
+        dbgs() << "Skipping pass: " << PassID << " on ";
+        unwrapAndPrint(IR, "", false, true);
+      });
+
   PIC.registerBeforeNonSkippedPassCallback(
       [SpecialPasses](StringRef PassID, Any IR) {
         if (isSpecialPass(PassID, SpecialPasses))

diff  --git a/llvm/test/Feature/optnone-opt.ll b/llvm/test/Feature/optnone-opt.ll
index b9129a0c37450..1c8790f8bcb78 100644
--- a/llvm/test/Feature/optnone-opt.ll
+++ b/llvm/test/Feature/optnone-opt.ll
@@ -50,7 +50,7 @@ attributes #0 = { optnone noinline }
 ; O1-DAG: Skipping pass 'Reassociate expressions'
 ; O1-DAG: Skipping pass 'Simplify the CFG'
 ; O1-DAG: Skipping pass 'Sparse Conditional Constant Propagation'
-; NPM-O1-DAG: Skipping pass: SimplifyCFGPass
+; NPM-O1-DAG: Skipping pass: SimplifyCFGPass on {{.*}}foo
 ; NPM-O1-DAG: Skipping pass: SROA
 ; NPM-O1-DAG: Skipping pass: EarlyCSEPass
 ; NPM-O1-DAG: Skipping pass: LowerExpectIntrinsicPass
@@ -80,7 +80,9 @@ attributes #0 = { optnone noinline }
 ; LOOP-DAG: Skipping pass 'Simplify instructions in loops'
 ; LOOP-DAG: Skipping pass 'Unroll loops'
 ; LOOP-DAG: Skipping pass 'Unswitch loops'
-; NPM-LOOP-DAG: Skipping pass: LoopSimplifyPass
+; LoopPassManager should not be skipped over an optnone function
+; NPM-LOOP-NOT: Skipping pass: PassManager
+; NPM-LOOP-DAG: Skipping pass: LoopSimplifyPass on {{.*}}foo
 ; NPM-LOOP-DAG: Skipping pass: LCSSAPass
 ; NPM-LOOP-DAG: Skipping pass: IndVarSimplifyPass
 ; NPM-LOOP-DAG: Skipping pass: SimpleLoopUnswitchPass


        


More information about the llvm-commits mailing list