diff options
-rw-r--r-- | llvm/lib/CodeGen/ImplicitNullChecks.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/ImplicitNullChecks.cpp b/llvm/lib/CodeGen/ImplicitNullChecks.cpp index 2c03f72601c..c923ddd9471 100644 --- a/llvm/lib/CodeGen/ImplicitNullChecks.cpp +++ b/llvm/lib/CodeGen/ImplicitNullChecks.cpp @@ -397,7 +397,16 @@ void ImplicitNullChecks::rewriteNullChecks( // check earlier ensures that this bit of code motion is legal. We do not // touch the successors list for any basic block since we haven't changed // control flow, we've just made it implicit. - insertFaultingLoad(NC.MemOperation, NC.CheckBlock, HandlerLabel); + MachineInstr *FaultingLoad = + insertFaultingLoad(NC.MemOperation, NC.CheckBlock, HandlerLabel); + // 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); + } NC.MemOperation->eraseFromParent(); NC.CheckOperation->eraseFromParent(); |