X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FCodeGen%2FBranchFolding.cpp;h=af2b72501733bcd477e5576adf7ffccee3505be3;hb=1484089bbf960f7191215dfa6c0bb51c8e30794e;hp=0a6bd39ee6a984febf5db4128cf64a98d68718d6;hpb=f978a1db517749e91210b7df17b7f11b9a30ae47;p=oota-llvm.git diff --git a/lib/CodeGen/BranchFolding.cpp b/lib/CodeGen/BranchFolding.cpp index 0a6bd39ee6a..af2b7250173 100644 --- a/lib/CodeGen/BranchFolding.cpp +++ b/lib/CodeGen/BranchFolding.cpp @@ -96,7 +96,7 @@ static void ReplaceUsesOfBlockWith(MachineBasicBlock *BB, // If BB falls through into Old, insert an unconditional branch to New. MachineFunction::iterator BBSucc = BB; ++BBSucc; - if (&*BBSucc == Old) + if (BBSucc != BB->getParent()->end() && &*BBSucc == Old) TII.insertGoto(*BB, *New); std::vector Succs(BB->succ_begin(), BB->succ_end());