|
112 | 112 | #include "llvm/IR/Use.h"
|
113 | 113 | #include "llvm/IR/User.h"
|
114 | 114 | #include "llvm/IR/Value.h"
|
| 115 | +#include "llvm/IR/Verifier.h" |
115 | 116 | #include "llvm/Pass.h"
|
116 | 117 | #include "llvm/Support/Casting.h"
|
117 | 118 | #include "llvm/Support/CommandLine.h"
|
@@ -162,6 +163,11 @@ static cl::opt<bool>
|
162 | 163 | cl::desc("Verify no dangling value in ScalarEvolution's "
|
163 | 164 | "ExprValueMap (slow)"));
|
164 | 165 |
|
| 166 | +static cl::opt<bool> VerifyIR( |
| 167 | + "scev-verify-ir", cl::Hidden, |
| 168 | + cl::desc("Verify IR correctness when making sensitive SCEV queries (slow)"), |
| 169 | + cl::init(false)); |
| 170 | + |
165 | 171 | static cl::opt<unsigned> MulOpsInlineThreshold(
|
166 | 172 | "scev-mulops-inline-threshold", cl::Hidden,
|
167 | 173 | cl::desc("Threshold for inlining multiplication operands into a SCEV"),
|
@@ -9370,6 +9376,11 @@ ScalarEvolution::isLoopBackedgeGuardedByCond(const Loop *L,
|
9370 | 9376 | // (interprocedural conditions notwithstanding).
|
9371 | 9377 | if (!L) return true;
|
9372 | 9378 |
|
| 9379 | + if (VerifyIR) |
| 9380 | + assert(!verifyFunction(*L->getHeader()->getParent(), &dbgs()) && |
| 9381 | + "This cannot be done on broken IR!"); |
| 9382 | + |
| 9383 | + |
9373 | 9384 | if (isKnownViaNonRecursiveReasoning(Pred, LHS, RHS))
|
9374 | 9385 | return true;
|
9375 | 9386 |
|
@@ -9475,6 +9486,10 @@ ScalarEvolution::isLoopEntryGuardedByCond(const Loop *L,
|
9475 | 9486 | // (interprocedural conditions notwithstanding).
|
9476 | 9487 | if (!L) return false;
|
9477 | 9488 |
|
| 9489 | + if (VerifyIR) |
| 9490 | + assert(!verifyFunction(*L->getHeader()->getParent(), &dbgs()) && |
| 9491 | + "This cannot be done on broken IR!"); |
| 9492 | + |
9478 | 9493 | // Both LHS and RHS must be available at loop entry.
|
9479 | 9494 | assert(isAvailableAtLoopEntry(LHS, L) &&
|
9480 | 9495 | "LHS is not available at Loop Entry");
|
|
0 commit comments