[PATCH] D84977: [NewPM] Only verify loop for nonskipped user loop pass

Yuanfang Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 30 12:47:26 PDT 2020


ychen created this revision.
ychen added reviewers: aeubanks, asbirlea, ebrevnov.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
ychen requested review of this revision.

No verification for pass mangers since it is not needed.
No verification for skipped loop pass since the asserted condition is not used.

Ideally, we should use add a BeforeNonSkippedPass callback for this. But
the callback API need to modification to pass required verification
argument. Let's defer this further until more similar needs arise so a
commonly useful API could be decided. One have in mind is MachineVerifier
which needs machine analysis manager to work.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84977

Files:
  llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
  llvm/test/Feature/optnone-opt.ll


Index: llvm/test/Feature/optnone-opt.ll
===================================================================
--- llvm/test/Feature/optnone-opt.ll
+++ llvm/test/Feature/optnone-opt.ll
@@ -34,7 +34,7 @@
   br label %while.cond
 
 while.end:                                        ; preds = %while.cond
-  ret i32 0
+  ret i32 %dec
 }
 
 attributes #0 = { optnone noinline }
Index: llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
===================================================================
--- llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
+++ llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
@@ -50,6 +50,7 @@
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/IR/Dominators.h"
+#include "llvm/IR/PassInstrumentation.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/Transforms/Utils/LCSSA.h"
 #include "llvm/Transforms/Utils/LoopSimplify.h"
@@ -303,21 +304,24 @@
       Updater.CurrentL = L;
       Updater.SkipCurrentLoop = false;
 
-#ifndef NDEBUG
-      // Save a parent loop pointer for asserts.
-      Updater.ParentL = L->getParentLoop();
-
-      // Verify the loop structure and LCSSA form before visiting the loop.
-      L->verifyLoop();
-      assert(L->isRecursivelyLCSSAForm(LAR.DT, LI) &&
-             "Loops must remain in LCSSA form!");
-#endif
       // Check the PassInstrumentation's BeforePass callbacks before running the
       // pass, skip its execution completely if asked to (callback returns
       // false).
       if (!PI.runBeforePass<Loop>(Pass, *L))
         continue;
 
+#ifndef NDEBUG
+      if (!isSpecialPass(Pass.name(), {"PassManager"})) {
+        // Save a parent loop pointer for asserts.
+        Updater.ParentL = L->getParentLoop();
+
+        // Verify the loop structure and LCSSA form before visiting the loop.
+        L->verifyLoop();
+        assert(L->isRecursivelyLCSSAForm(LAR.DT, LI) &&
+               "Loops must remain in LCSSA form!");
+      }
+#endif
+
       PreservedAnalyses PassPA;
       {
         TimeTraceScope TimeScope(Pass.name());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84977.282023.patch
Type: text/x-patch
Size: 2092 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200730/9a1c46a9/attachment.bin>


More information about the llvm-commits mailing list