[llvm-commits] CVS: llvm/lib/CodeGen/BranchFolding.cpp

Dale Johannesen dalej at apple.com
Mon Jun 4 16:53:31 PDT 2007



Changes in directory llvm/lib/CodeGen:

BranchFolding.cpp updated: 1.64 -> 1.65
---
Log message:

Tail merging wasn't working for predecessors of landing pads.  PR 1496: http://llvm.org/PR1496 .


---
Diffs of the changes:  (+22 -0)

 BranchFolding.cpp |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+)


Index: llvm/lib/CodeGen/BranchFolding.cpp
diff -u llvm/lib/CodeGen/BranchFolding.cpp:1.64 llvm/lib/CodeGen/BranchFolding.cpp:1.65
--- llvm/lib/CodeGen/BranchFolding.cpp:1.64	Mon Jun  4 01:44:01 2007
+++ llvm/lib/CodeGen/BranchFolding.cpp	Mon Jun  4 18:52:54 2007
@@ -622,6 +622,28 @@
             if (!FBB)
               FBB = next(MachineFunction::iterator(PBB));
           }
+          // Failing case:  the only way IBB can be reached from PBB is via
+          // exception handling.  Happens for landing pads.  Would be nice
+          // to have a bit in the edge so we didn't have to do all this.
+          if (IBB->isLandingPad()) {
+            MachineFunction::iterator IP = PBB;  IP++;
+            MachineBasicBlock* PredNextBB = NULL;
+            if (IP!=MF.end())
+              PredNextBB = IP;
+            if (TBB==NULL) {
+              if (IBB!=PredNextBB)      // fallthrough
+                continue;
+            } else if (FBB) {
+              if (TBB!=IBB && FBB!=IBB)   // cbr then ubr
+                continue;
+            } else if (Cond.size() == 0) {
+              if (TBB!=IBB)               // ubr
+                continue;
+            } else {
+              if (TBB!=IBB && IBB!=PredNextBB)  // cbr
+                continue;
+            }
+          }
           // Remove the unconditional branch at the end, if any.
           if (TBB && (Cond.size()==0 || FBB)) {
             TII->RemoveBranch(*PBB);






More information about the llvm-commits mailing list