diff options
author | Quentin Colombet <qcolombet@apple.com> | 2018-03-20 02:44:40 +0000 |
---|---|---|
committer | Quentin Colombet <qcolombet@apple.com> | 2018-03-20 02:44:40 +0000 |
commit | 508f68233d060987951ab1699ca9cf03110e92b0 (patch) | |
tree | 7729e260f53e871fdf070ef8a51f78ad3326ffde /llvm/lib/CodeGen/ShrinkWrap.cpp | |
parent | f27d705d15195fed96d236245518aa2dc4af0631 (diff) | |
download | bcm5719-llvm-508f68233d060987951ab1699ca9cf03110e92b0.tar.gz bcm5719-llvm-508f68233d060987951ab1699ca9cf03110e92b0.zip |
[ShrinkWrap] Take into account landing pad
When scanning the function for CSRs uses and defs, also check if
the basic block are landing pads.
Consider that landing pads needs the CSRs to be properly set.
That way we force the prologue/epilogue to always be pushed out
of the problematic "throw" region. The "throw" region is
problematic because the jumps are not properly modeled.
Fixes PR36513
llvm-svn: 327942
Diffstat (limited to 'llvm/lib/CodeGen/ShrinkWrap.cpp')
-rw-r--r-- | llvm/lib/CodeGen/ShrinkWrap.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/ShrinkWrap.cpp b/llvm/lib/CodeGen/ShrinkWrap.cpp index 85117775bd6..2d854d6b43f 100644 --- a/llvm/lib/CodeGen/ShrinkWrap.cpp +++ b/llvm/lib/CodeGen/ShrinkWrap.cpp @@ -447,6 +447,22 @@ bool ShrinkWrap::runOnMachineFunction(MachineFunction &MF) { return false; } + if (MBB.isEHPad()) { + // Push the prologue and epilogue outside of + // the region that may throw by making sure + // that all the landing pads are at least at the + // boundary of the save and restore points. + // The problem with exceptions is that the throw + // is not properly modeled and in particular, a + // basic block can jump out from the middle. + updateSaveRestorePoints(MBB, RS.get()); + if (!ArePointsInteresting()) { + DEBUG(dbgs() << "EHPad prevents shrink-wrapping\n"); + return false; + } + continue; + } + for (const MachineInstr &MI : MBB) { if (!useOrDefCSROrFI(MI, RS.get())) continue; |