From 26dab3a48521e7db2b0db173999f47a1806e9922 Mon Sep 17 00:00:00 2001 From: Quentin Colombet Date: Tue, 3 May 2016 18:09:06 +0000 Subject: [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 --- llvm/lib/CodeGen/ImplicitNullChecks.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'llvm/lib/CodeGen') 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(); -- cgit v1.2.3