Fix PR1228 and CodeGen/Generic/2007-04-30-LandingPadBranchFolding.ll
authorChris Lattner <sabre@nondot.org>
Mon, 30 Apr 2007 23:35:00 +0000 (23:35 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 30 Apr 2007 23:35:00 +0000 (23:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36602 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/BranchFolding.cpp

index 1f5d6752b659a11ebc69de984d79205d4108e8be..33f96df302f8c800fcaf0c391c15dcc286244c00 100644 (file)
@@ -877,7 +877,7 @@ void BranchFolder::OptimizeBlock(MachineBasicBlock *MBB) {
     // Now we know that there was no fall-through into this block, check to
     // see if it has a fall-through into its successor.
     bool CurFallsThru = CanFallThrough(MBB, CurUnAnalyzable, CurTBB, CurFBB, 
-                                            CurCond);
+                                       CurCond);
 
     if (!MBB->isLandingPad()) {
       // Check all the predecessors of this block.  If one of them has no fall
@@ -914,7 +914,13 @@ void BranchFolder::OptimizeBlock(MachineBasicBlock *MBB) {
         MachineBasicBlock *SuccBB = *SI;
         MachineFunction::iterator SuccPrev = SuccBB; --SuccPrev;
         std::vector<MachineOperand> SuccPrevCond;
-        if (SuccBB != MBB && !CanFallThrough(SuccPrev)) {
+        
+        // If this block doesn't already fall-through to that successor, and if
+        // the succ doesn't already have a block that can fall through into it,
+        // and if the successor isn't an EH destination, we can arrange for the
+        // fallthrough to happen.
+        if (SuccBB != MBB && !CanFallThrough(SuccPrev) &&
+            !SuccBB->isLandingPad()) {
           MBB->moveBefore(SuccBB);
           MadeChange = true;
           return OptimizeBlock(MBB);