[PATCH] D52930: [SCEV][NFC] Verify IR in isLoop[Entry, Backedge]GuardedByCond

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 7 21:11:08 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL346389: [SCEV][NFC] Verify IR in isLoop[Entry,Backedge]GuardedByCond (authored by mkazantsev, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52930?vs=169980&id=173118#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52930

Files:
  llvm/trunk/lib/Analysis/ScalarEvolution.cpp
  llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp


Index: llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp
===================================================================
--- llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp
+++ llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp
@@ -701,7 +701,7 @@
     PN->addIncoming(Dec, IncBB);
     BranchInst::Create(CondBB, IncBB);
 
-    Accum = GetElementPtrInst::Create(I8Ty, Accum, Dec, "gep", EndBB);
+    Accum = GetElementPtrInst::Create(I8Ty, Accum, PN, "gep", EndBB);
 
     PrevBB = CondBB;
     CondBB = NextBB;
Index: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp
@@ -112,6 +112,7 @@
 #include "llvm/IR/Use.h"
 #include "llvm/IR/User.h"
 #include "llvm/IR/Value.h"
+#include "llvm/IR/Verifier.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/CommandLine.h"
@@ -162,6 +163,11 @@
                   cl::desc("Verify no dangling value in ScalarEvolution's "
                            "ExprValueMap (slow)"));
 
+static cl::opt<bool> VerifyIR(
+    "scev-verify-ir", cl::Hidden,
+    cl::desc("Verify IR correctness when making sensitive SCEV queries (slow)"),
+    cl::init(false));
+
 static cl::opt<unsigned> MulOpsInlineThreshold(
     "scev-mulops-inline-threshold", cl::Hidden,
     cl::desc("Threshold for inlining multiplication operands into a SCEV"),
@@ -9370,6 +9376,11 @@
   // (interprocedural conditions notwithstanding).
   if (!L) return true;
 
+  if (VerifyIR)
+    assert(!verifyFunction(*L->getHeader()->getParent(), &dbgs()) &&
+           "This cannot be done on broken IR!");
+
+
   if (isKnownViaNonRecursiveReasoning(Pred, LHS, RHS))
     return true;
 
@@ -9475,6 +9486,10 @@
   // (interprocedural conditions notwithstanding).
   if (!L) return false;
 
+  if (VerifyIR)
+    assert(!verifyFunction(*L->getHeader()->getParent(), &dbgs()) &&
+           "This cannot be done on broken IR!");
+
   // Both LHS and RHS must be available at loop entry.
   assert(isAvailableAtLoopEntry(LHS, L) &&
          "LHS is not available at Loop Entry");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52930.173118.patch
Type: text/x-patch
Size: 2185 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181108/4c26c44d/attachment-0001.bin>


More information about the llvm-commits mailing list