diff options
author | Francis Visoiu Mistrih <fvisoiumistrih@apple.com> | 2017-05-15 23:13:35 +0000 |
---|---|---|
committer | Francis Visoiu Mistrih <fvisoiumistrih@apple.com> | 2017-05-15 23:13:35 +0000 |
commit | ebbc7159e9b2bee125e819b8da3452fb6b3d5b53 (patch) | |
tree | 3e187be16e1c9b7b87c59ece6db1a0dccf118d37 /llvm/lib/CodeGen | |
parent | cbb1fdf350bcac9b7b8618e431dfe0b5309fbefe (diff) | |
download | bcm5719-llvm-ebbc7159e9b2bee125e819b8da3452fb6b3d5b53.tar.gz bcm5719-llvm-ebbc7159e9b2bee125e819b8da3452fb6b3d5b53.zip |
[ShrinkWrapping] Handle restores on no-return paths
Shrink-wrapping uses post-dominators to find a restore point that
post-dominates all the uses of CSR / stack.
The way dominator trees are modeled in LLVM today is that unreachable
blocks are not present in a generic dominator tree, so, an unreachable node is
dominated by anything: include/llvm/Support/GenericDomTree.h:467.
Since for post-dominators, a no-return block is considered
"unreachable", calling findNearestCommonDominator on an unreachable node
A and a non-unreachable node B, will return B, which can be false. If we
find such node, we bail out since there is no good restore point
available.
rdar://problem/30186931
llvm-svn: 303130
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/ShrinkWrap.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/ShrinkWrap.cpp b/llvm/lib/CodeGen/ShrinkWrap.cpp index 4837495777d..e9df915bad1 100644 --- a/llvm/lib/CodeGen/ShrinkWrap.cpp +++ b/llvm/lib/CodeGen/ShrinkWrap.cpp @@ -282,8 +282,14 @@ void ShrinkWrap::updateSaveRestorePoints(MachineBasicBlock &MBB, if (!Restore) Restore = &MBB; - else + else if (MPDT->getNode(&MBB)) // If the block is not in the post dom tree, it + // means the block never returns. If that's the + // case, we don't want to call + // `findNearestCommonDominator`, which will + // return `Restore`. Restore = MPDT->findNearestCommonDominator(Restore, &MBB); + else + Restore = nullptr; // Abort, we can't find a restore point in this case. // Make sure we would be able to insert the restore code before the // terminator. @@ -293,7 +299,7 @@ void ShrinkWrap::updateSaveRestorePoints(MachineBasicBlock &MBB, continue; // One of the terminator needs to happen before the restore point. if (MBB.succ_empty()) { - Restore = nullptr; + Restore = nullptr; // Abort, we can't find a restore point in this case. break; } // Look for a restore point that post-dominates all the successors. |