From: Max Kazantsev Date: Tue, 4 Sep 2018 06:34:40 +0000 (+0000) Subject: [NFC] Add assert to detect LCSSA breaches early X-Git-Tag: llvmorg-8.0.0-rc1~9532 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f34115c6278eee013fee497b6d69528edb58c51c;p=platform%2Fupstream%2Fllvm.git [NFC] Add assert to detect LCSSA breaches early llvm-svn: 341347 --- diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp index 372ea61..0683636 100644 --- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -645,6 +645,16 @@ void IndVarSimplify::rewriteLoopExitValues(Loop *L, SCEVExpander &Rewriter) { continue; } +#ifndef NDEBUG + // If we reuse an instruction from a loop which is neither L nor one of + // its containing loops, we end up breaking LCSSA form for this loop by + // creating a new use of its instruction. + if (auto *ExitInsn = dyn_cast(ExitVal)) + if (auto *EVL = LI->getLoopFor(ExitInsn->getParent())) + if (EVL != L) + assert(EVL->contains(L) && "LCSSA breach detected!"); +#endif + // Collect all the candidate PHINodes to be rewritten. RewritePhiSet.emplace_back(PN, i, ExitVal, HighCost); }