From: Dale Johannesen Date: Sat, 2 Jun 2007 00:08:15 +0000 (+0000) Subject: Fix CorrectExtraCFGEdges to allow for multiple LandingPad targets. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=8e63bf375d18118f46f43910c6a093c824eb4a7d;p=oota-llvm.git Fix CorrectExtraCFGEdges to allow for multiple LandingPad targets. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37394 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/BranchFolding.cpp b/lib/CodeGen/BranchFolding.cpp index 8093b29791e..53cf0aabb9f 100644 --- a/lib/CodeGen/BranchFolding.cpp +++ b/lib/CodeGen/BranchFolding.cpp @@ -675,6 +675,9 @@ bool BranchFolder::OptimizeBranches(MachineFunction &MF) { /// CFG to be inserted. If we have proven that MBB can only branch to DestA and /// DestB, remove any other MBB successors from the CFG. DestA and DestB can /// be null. +/// Besides DestA and DestB, retain other edges leading to LandingPads (currently +/// there can be only one; we don't check or require that here). +/// Note it is possible that DestA and/or DestB are LandingPads. static bool CorrectExtraCFGEdges(MachineBasicBlock &MBB, MachineBasicBlock *DestA, MachineBasicBlock *DestB, @@ -700,25 +703,19 @@ static bool CorrectExtraCFGEdges(MachineBasicBlock &MBB, } MachineBasicBlock::succ_iterator SI = MBB.succ_begin(); - bool foundPad = false; + MachineBasicBlock *OrigDestA = DestA, *OrigDestB = DestB; while (SI != MBB.succ_end()) { if (*SI == DestA && DestA == DestB) { DestA = DestB = 0; - if ((*SI)->isLandingPad()) - foundPad = true; ++SI; } else if (*SI == DestA) { DestA = 0; - if ((*SI)->isLandingPad()) - foundPad = true; ++SI; } else if (*SI == DestB) { DestB = 0; - if ((*SI)->isLandingPad()) - foundPad = true; ++SI; - } else if ((*SI)->isLandingPad() && !foundPad) { - foundPad = true; + } else if ((*SI)->isLandingPad() && + *SI!=OrigDestA && *SI!=OrigDestB) { ++SI; } else { // Otherwise, this is a superfluous edge, remove it.