[llvm-branch-commits] [llvm-branch] r73400 - in /llvm/branches/Apple/Bender: lib/CodeGen/BranchFolding.cpp test/CodeGen/X86/2009-05-11-tailmerge-crash.ll

Bill Wendling isanbard at gmail.com
Mon Jun 15 11:37:22 PDT 2009


Author: void
Date: Mon Jun 15 13:37:22 2009
New Revision: 73400

URL: http://llvm.org/viewvc/llvm-project?rev=73400&view=rev
Log:
--- Merging r71478 into '.':
A    test/CodeGen/X86/2009-05-11-tailmerge-crash.ll
U    lib/CodeGen/BranchFolding.cpp

Fix PR4188. TailMerging can't tolerate inexact sucessor info.

This also fixes part of <rdar://problem/6968283>.

Added:
    llvm/branches/Apple/Bender/test/CodeGen/X86/2009-05-11-tailmerge-crash.ll
      - copied unchanged from r71478, llvm/trunk/test/CodeGen/X86/2009-05-11-tailmerge-crash.ll
Modified:
    llvm/branches/Apple/Bender/lib/CodeGen/BranchFolding.cpp

Modified: llvm/branches/Apple/Bender/lib/CodeGen/BranchFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Bender/lib/CodeGen/BranchFolding.cpp?rev=73400&r1=73399&r2=73400&view=diff

==============================================================================
--- llvm/branches/Apple/Bender/lib/CodeGen/BranchFolding.cpp (original)
+++ llvm/branches/Apple/Bender/lib/CodeGen/BranchFolding.cpp Mon Jun 15 13:37:22 2009
@@ -1092,6 +1092,21 @@
             } else {
               DidChange = true;
               PMBB->ReplaceUsesOfBlockWith(MBB, CurTBB);
+              // If this change resulted in PMBB ending in a conditional
+              // branch where both conditions go to the same destination,
+              // change this to an unconditional branch (and fix the CFG).
+              MachineBasicBlock *NewCurTBB = 0, *NewCurFBB = 0;
+              SmallVector<MachineOperand, 4> NewCurCond;
+              bool NewCurUnAnalyzable = TII->AnalyzeBranch(*PMBB, NewCurTBB,
+                      NewCurFBB, NewCurCond, true);
+              if (!NewCurUnAnalyzable && NewCurTBB && NewCurTBB == NewCurFBB) {
+                TII->RemoveBranch(*PMBB);
+                NewCurCond.clear(); 
+                TII->InsertBranch(*PMBB, NewCurTBB, 0, NewCurCond);
+                MadeChange = true;
+                ++NumBranchOpts;
+                PMBB->CorrectExtraCFGEdges(NewCurTBB, NewCurFBB, false);
+              }
             }
           }
 





More information about the llvm-branch-commits mailing list