summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorQuentin Colombet <qcolombet@apple.com>2016-05-03 18:09:06 +0000
committerQuentin Colombet <qcolombet@apple.com>2016-05-03 18:09:06 +0000
commit26dab3a48521e7db2b0db173999f47a1806e9922 (patch)
tree04e532875dff217a931cabc0c91c743b08b79ef4 /llvm/lib/CodeGen
parentf3a2b0e8f77041ff49441486e6cc296ff685af61 (diff)
downloadbcm5719-llvm-26dab3a48521e7db2b0db173999f47a1806e9922.tar.gz
bcm5719-llvm-26dab3a48521e7db2b0db173999f47a1806e9922.zip
[ImplicitNullChecks] Account for implicit-defs as well when updating the liveness.
The replaced load may have implicit-defs and those defs may be used in the block of the original load. Make sure to update the liveness accordingly. This is a generalization of r267817. llvm-svn: 268412
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/ImplicitNullChecks.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/ImplicitNullChecks.cpp b/llvm/lib/CodeGen/ImplicitNullChecks.cpp
index dfd1be8c8ea..9b2bedb52c0 100644
--- a/llvm/lib/CodeGen/ImplicitNullChecks.cpp
+++ b/llvm/lib/CodeGen/ImplicitNullChecks.cpp
@@ -398,13 +398,18 @@ void ImplicitNullChecks::rewriteNullChecks(
// control flow, we've just made it implicit.
MachineInstr *FaultingLoad =
insertFaultingLoad(NC.MemOperation, NC.CheckBlock, NC.NullSucc);
- // Now the value of the MemOperation, if any, is live-in of block
- // of MemOperation.
- unsigned Reg = FaultingLoad->getOperand(0).getReg();
- if (Reg) {
- MachineBasicBlock *MBB = NC.MemOperation->getParent();
- if (!MBB->isLiveIn(Reg))
- MBB->addLiveIn(Reg);
+ // Now the values defined by MemOperation, if any, are live-in of
+ // the block of MemOperation.
+ // The original load operation may define implicit-defs alongside
+ // the loaded value.
+ MachineBasicBlock *MBB = NC.MemOperation->getParent();
+ for (const MachineOperand &MO : FaultingLoad->operands()) {
+ if (!MO.isReg() || !MO.isDef())
+ continue;
+ unsigned Reg = MO.getReg();
+ if (!Reg || MBB->isLiveIn(Reg))
+ continue;
+ MBB->addLiveIn(Reg);
}
NC.MemOperation->eraseFromParent();
NC.CheckOperation->eraseFromParent();
OpenPOWER on IntegriCloud