From 745f68cc1a72f7cc5b149329f4a346cbf498a8e7 Mon Sep 17 00:00:00 2001 From: Sanjoy Das Date: Sun, 21 Feb 2016 17:11:59 +0000 Subject: [PATCH] [LoopDeletion] Add an assert that verifies LCSSA This is inspired by PR24804 -- had this assert been there before, isolating the root cause for PR24804 would have been far easier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@261481 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/LoopDeletion.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Transforms/Scalar/LoopDeletion.cpp b/lib/Transforms/Scalar/LoopDeletion.cpp index 498e7d64376..856c3ca5c6b 100644 --- a/lib/Transforms/Scalar/LoopDeletion.cpp +++ b/lib/Transforms/Scalar/LoopDeletion.cpp @@ -122,6 +122,9 @@ bool LoopDeletion::runOnLoop(Loop *L, LPPassManager &) { if (skipOptnoneFunction(L)) return false; + DominatorTree &DT = getAnalysis().getDomTree(); + assert(L->isLCSSAForm(DT) && "Expected LCSSA!"); + // We can only remove the loop if there is a preheader that we can // branch from after removing it. BasicBlock *preheader = L->getLoopPreheader(); @@ -194,7 +197,6 @@ bool LoopDeletion::runOnLoop(Loop *L, LPPassManager &) { // Update the dominator tree and remove the instructions and blocks that will // be deleted from the reference counting scheme. - DominatorTree &DT = getAnalysis().getDomTree(); SmallVector ChildNodes; for (Loop::block_iterator LI = L->block_begin(), LE = L->block_end(); LI != LE; ++LI) {