diff options
author | Reid Kleckner <rnk@google.com> | 2020-03-28 11:03:14 -0700 |
---|---|---|
committer | tstellar <tstellar@redhat.com> | 2020-04-13 13:37:15 -0700 |
commit | 47e68d864420afd42d34fd25e97522e5c149de46 (patch) | |
tree | b8f3919844056575969b3bd2c7cffcaaf1dbfd72 /llvm/lib/CodeGen | |
parent | 68cd4f72beae67a9bdbc11c85fd745dec8fc0999 (diff) | |
download | bcm5719-llvm-47e68d864420afd42d34fd25e97522e5c149de46.tar.gz bcm5719-llvm-47e68d864420afd42d34fd25e97522e5c149de46.zip |
[CodeGen] Fix sinking local values in lpads with phis
There was already a test case for landingpads to handle this case, but I
had forgotten to consider PHI instructions preceding the EH_LABEL in the
landingpad.
PR45261
(cherry picked from commit e5bf5037d869c74bc2faf81fa1f58dfd827e8356)
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/FastISel.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp index 8294591b732..6ecde9b43c0 100644 --- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -225,6 +225,21 @@ static bool isRegUsedByPhiNodes(unsigned DefReg, return false; } +static bool isTerminatingEHLabel(MachineBasicBlock *MBB, MachineInstr &MI) { + // Ignore non-EH labels. + if (!MI.isEHLabel()) + return false; + + // Any EH label outside a landing pad must be for an invoke. Consider it a + // terminator. + if (!MBB->isEHPad()) + return true; + + // If this is a landingpad, the first non-phi instruction will be an EH_LABEL. + // Don't consider that label to be a terminator. + return MI.getIterator() != MBB->getFirstNonPHI(); +} + /// Build a map of instruction orders. Return the first terminator and its /// order. Consider EH_LABEL instructions to be terminators as well, since local /// values for phis after invokes must be materialized before the call. @@ -233,7 +248,7 @@ void FastISel::InstOrderMap::initialize( unsigned Order = 0; for (MachineInstr &I : *MBB) { if (!FirstTerminator && - (I.isTerminator() || (I.isEHLabel() && &I != &MBB->front()))) { + (I.isTerminator() || isTerminatingEHLabel(MBB, I))) { FirstTerminator = &I; FirstTerminatorOrder = Order; } |