diff options
| author | Dale Johannesen <dalej@apple.com> | 2007-06-04 23:52:54 +0000 |
|---|---|---|
| committer | Dale Johannesen <dalej@apple.com> | 2007-06-04 23:52:54 +0000 |
| commit | 0558dda319411d041e87cefa51cd1dfe512a681e (patch) | |
| tree | 4e0916e88495e853203ef370b3dae72ad2fd5590 /llvm/lib/CodeGen/BranchFolding.cpp | |
| parent | b3adb9876a5fac75af9ea86ca4a61854941e8bfe (diff) | |
| download | bcm5719-llvm-0558dda319411d041e87cefa51cd1dfe512a681e.tar.gz bcm5719-llvm-0558dda319411d041e87cefa51cd1dfe512a681e.zip | |
Tail merging wasn't working for predecessors of landing pads. PR 1496.
llvm-svn: 37427
Diffstat (limited to 'llvm/lib/CodeGen/BranchFolding.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/BranchFolding.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp index 2f25800cd0b..ffde173e695 100644 --- a/llvm/lib/CodeGen/BranchFolding.cpp +++ b/llvm/lib/CodeGen/BranchFolding.cpp @@ -622,6 +622,28 @@ bool BranchFolder::TailMergeBlocks(MachineFunction &MF) { 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); |

