diff options
author | David Majnemer <david.majnemer@gmail.com> | 2016-04-25 14:31:32 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2016-04-25 14:31:32 +0000 |
commit | dd215236530c9f643220f1c6e928dd39254a7b3d (patch) | |
tree | 787fe15de5cb8bdd2634b804c155527633df0fc8 /llvm/lib | |
parent | 82d04260b71939da9fd7918555232796d2873a79 (diff) | |
download | bcm5719-llvm-dd215236530c9f643220f1c6e928dd39254a7b3d.tar.gz bcm5719-llvm-dd215236530c9f643220f1c6e928dd39254a7b3d.zip |
[WinEH] Update SplitAnalysis::computeLastSplitPoint to cope with multiple EH successors
We didn't have logic to correctly handle CFGs where there was more than
one EH-pad successor (these are novel with WinEH).
There were situations where a register was live in one exceptional
successor but not another but the code as written would only consider
the first exceptional successor it found.
This resulted in split points which were insufficiently early if an
invoke was present.
This fixes PR27501.
N.B. This removes getLandingPadSuccessor.
llvm-svn: 267412
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/MachineBasicBlock.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SplitKit.cpp | 16 |
2 files changed, 12 insertions, 14 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index 318a2aa69d4..8b3f01fe58c 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -198,16 +198,6 @@ MachineBasicBlock::iterator MachineBasicBlock::getLastNonDebugInstr() { return end(); } -const MachineBasicBlock *MachineBasicBlock::getLandingPadSuccessor() const { - // A block with a landing pad successor only has one other successor. - if (succ_size() > 2) - return nullptr; - for (const_succ_iterator I = succ_begin(), E = succ_end(); I != E; ++I) - if ((*I)->isEHPad()) - return *I; - return nullptr; -} - bool MachineBasicBlock::hasEHPadSuccessor() const { for (const_succ_iterator I = succ_begin(), E = succ_end(); I != E; ++I) if ((*I)->isEHPad()) diff --git a/llvm/lib/CodeGen/SplitKit.cpp b/llvm/lib/CodeGen/SplitKit.cpp index 436d5bb21d9..8bf139156ee 100644 --- a/llvm/lib/CodeGen/SplitKit.cpp +++ b/llvm/lib/CodeGen/SplitKit.cpp @@ -57,11 +57,14 @@ void SplitAnalysis::clear() { SlotIndex SplitAnalysis::computeLastSplitPoint(unsigned Num) { const MachineBasicBlock *MBB = MF.getBlockNumbered(Num); - // FIXME: Handle multiple EH pad successors. - const MachineBasicBlock *LPad = MBB->getLandingPadSuccessor(); std::pair<SlotIndex, SlotIndex> &LSP = LastSplitPoint[Num]; SlotIndex MBBEnd = LIS.getMBBEndIdx(MBB); + SmallVector<const MachineBasicBlock *, 1> EHPadSucessors; + for (const MachineBasicBlock *SMBB : MBB->successors()) + if (SMBB->isEHPad()) + EHPadSucessors.push_back(SMBB); + // Compute split points on the first call. The pair is independent of the // current live interval. if (!LSP.first.isValid()) { @@ -72,7 +75,7 @@ SlotIndex SplitAnalysis::computeLastSplitPoint(unsigned Num) { LSP.first = LIS.getInstructionIndex(*FirstTerm); // If there is a landing pad successor, also find the call instruction. - if (!LPad) + if (EHPadSucessors.empty()) return LSP.first; // There may not be a call instruction (?) in which case we ignore LPad. LSP.second = LSP.first; @@ -88,7 +91,12 @@ SlotIndex SplitAnalysis::computeLastSplitPoint(unsigned Num) { // If CurLI is live into a landing pad successor, move the last split point // back to the call that may throw. - if (!LPad || !LSP.second || !LIS.isLiveInToMBB(*CurLI, LPad)) + if (!LSP.second) + return LSP.first; + + if (none_of(EHPadSucessors, [&](const MachineBasicBlock *EHPad) { + return LIS.isLiveInToMBB(*CurLI, EHPad); + })) return LSP.first; // Find the value leaving MBB. |