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 | fe7e397100edd4f2d618a1ff938dfa8624670ec1 (patch) | |
tree | e480a07b8a7250407d010f2378e81fc38bab8c7d /lib/CodeGen | |
parent | 170f2b9bef6da7a6a19c7aec37e30f30a41cb4d3 (diff) |
Tail merging wasn't working for predecessors of landing pads. PR 1496.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37427 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/BranchFolding.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/CodeGen/BranchFolding.cpp b/lib/CodeGen/BranchFolding.cpp index 2f25800cd0..ffde173e69 100644 --- a/lib/CodeGen/BranchFolding.cpp +++ b/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); |