[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 Oct 17 03:38:29 PDT 2018
mkazantsev updated this revision to Diff 169980.
mkazantsev added a comment.
Added notion of this option being slow. It can be later be turned on in EXPENSIVE_CHECKS mode along with the other two. I tried turning it on now and currently all three turned on fail 2 tests. Apparently a bug in there.
https://reviews.llvm.org/D52930
Files:
lib/Analysis/ScalarEvolution.cpp
unittests/Analysis/ScalarEvolutionTest.cpp
Index: unittests/Analysis/ScalarEvolutionTest.cpp
===================================================================
--- unittests/Analysis/ScalarEvolutionTest.cpp
+++ 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: lib/Analysis/ScalarEvolution.cpp
===================================================================
--- lib/Analysis/ScalarEvolution.cpp
+++ 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"
@@ -161,6 +162,10 @@
VerifySCEVMap("verify-scev-maps", cl::Hidden,
cl::desc("Verify no dangling value in ScalarEvolution's "
"ExprValueMap (slow)"));
+static cl::opt<bool> VerifyIR(
+ "scalar-evolution-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,
@@ -9375,6 +9380,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;
@@ -9480,6 +9490,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.169980.patch
Type: text/x-patch
Size: 2103 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181017/54890e53/attachment.bin>
More information about the llvm-commits
mailing list