diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2011-09-23 22:41:57 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2011-09-23 22:41:57 +0000 |
commit | bde81d5be9bdc3837c77f8f3c63c013b6e4bbc8d (patch) | |
tree | 2e46aa8f116ccb1cf681d64f572e7dc1c539968f /lib/CodeGen | |
parent | 4d2a00147d19b17d382644de0d6a1f0d3230e0e4 (diff) | |
download | external_llvm-bde81d5be9bdc3837c77f8f3c63c013b6e4bbc8d.zip external_llvm-bde81d5be9bdc3837c77f8f3c63c013b6e4bbc8d.tar.gz external_llvm-bde81d5be9bdc3837c77f8f3c63c013b6e4bbc8d.tar.bz2 |
PR10998: It is not legal to sink an instruction past the terminator of a block; make sure we don't do that.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140428 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/TwoAddressInstructionPass.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/CodeGen/TwoAddressInstructionPass.cpp b/lib/CodeGen/TwoAddressInstructionPass.cpp index dfd258d..d879378 100644 --- a/lib/CodeGen/TwoAddressInstructionPass.cpp +++ b/lib/CodeGen/TwoAddressInstructionPass.cpp @@ -177,6 +177,10 @@ char &llvm::TwoAddressInstructionPassID = TwoAddressInstructionPass::ID; bool TwoAddressInstructionPass::Sink3AddrInstruction(MachineBasicBlock *MBB, MachineInstr *MI, unsigned SavedReg, MachineBasicBlock::iterator OldPos) { + // FIXME: Shouldn't we be trying to do this before we three-addressify the + // instruction? After this transformation is done, we no longer need + // the instruction to be in three-address form. + // Check if it's safe to move this instruction. bool SeenStore = true; // Be conservative. if (!MI->isSafeToMove(TII, AA, SeenStore)) @@ -217,7 +221,11 @@ bool TwoAddressInstructionPass::Sink3AddrInstruction(MachineBasicBlock *MBB, break; } - if (!KillMI || KillMI->getParent() != MBB || KillMI == MI) + // If we find the instruction that kills SavedReg, and it is in an + // appropriate location, we can try to sink the current instruction + // past it. + if (!KillMI || KillMI->getParent() != MBB || KillMI == MI || + KillMI->getDesc().isTerminator()) return false; // If any of the definitions are used by another instruction between the |