[llvm] r341347 - [NFC] Add assert to detect LCSSA breaches early

Max Kazantsev via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 3 23:34:40 PDT 2018


Author: mkazantsev
Date: Mon Sep  3 23:34:40 2018
New Revision: 341347

URL: http://llvm.org/viewvc/llvm-project?rev=341347&view=rev
Log:
[NFC] Add assert to detect LCSSA breaches early

Modified:
    llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=341347&r1=341346&r2=341347&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Mon Sep  3 23:34:40 2018
@@ -645,6 +645,16 @@ void IndVarSimplify::rewriteLoopExitValu
           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<Instruction>(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);
       }




More information about the llvm-commits mailing list