From c099906b133d0014bcc0636d9d4316fc1cd297b4 Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Thu, 13 Apr 2017 20:05:37 +0000 Subject: [PATCH] [LCSSA] Assert that we always have a valid loop. We could otherwise add BBs not belonging to a loop in `formLCSSA` and later crash when trying to iterate the loop blocks. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300244 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Utils/LCSSA.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Transforms/Utils/LCSSA.cpp b/lib/Transforms/Utils/LCSSA.cpp index 99f8759ebdd..493c7c085af 100644 --- a/lib/Transforms/Utils/LCSSA.cpp +++ b/lib/Transforms/Utils/LCSSA.cpp @@ -87,6 +87,7 @@ bool llvm::formLCSSAForInstructions(SmallVectorImpl &Worklist, Instruction *I = Worklist.pop_back_val(); BasicBlock *InstBB = I->getParent(); Loop *L = LI.getLoopFor(InstBB); + assert(L && "Instruction belongs to a BB that's not part of a loop"); if (!LoopExitBlocks.count(L)) L->getExitBlocks(LoopExitBlocks[L]); assert(LoopExitBlocks.count(L));