From 84ef08bfeeb4ffdd2b5a179ae85211f7996ef6db Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Wed, 19 Sep 2007 00:11:01 +0000 Subject: [PATCH] Bail out early, before modifying anything. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42120 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/LoopIndexSplit.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/Transforms/Scalar/LoopIndexSplit.cpp b/lib/Transforms/Scalar/LoopIndexSplit.cpp index c2e9d500a93..92a6058b5a6 100644 --- a/lib/Transforms/Scalar/LoopIndexSplit.cpp +++ b/lib/Transforms/Scalar/LoopIndexSplit.cpp @@ -542,6 +542,11 @@ bool LoopIndexSplit::processOneIterationLoop(SplitInfo &SD) { if (!safeSplitCondition(SD)) return false; + BasicBlock *Latch = L->getLoopLatch(); + BranchInst *BR = dyn_cast(Latch->getTerminator()); + if (!BR) + return false; + // Update CFG. // Replace index variable with split value in loop body. Loop body is executed @@ -549,11 +554,7 @@ bool LoopIndexSplit::processOneIterationLoop(SplitInfo &SD) { IndVar->replaceAllUsesWith(SD.SplitValue); // Remove Latch to Header edge. - BasicBlock *Latch = L->getLoopLatch(); BasicBlock *LatchSucc = NULL; - BranchInst *BR = dyn_cast(Latch->getTerminator()); - if (!BR) - return false; Header->removePredecessor(Latch); for (succ_iterator SI = succ_begin(Latch), E = succ_end(Latch); SI != E; ++SI) {