[llvm] r267817 - [ImplicitNullChecks] Properly update the live-in of the block of the memory operation.

Quentin Colombet via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 27 16:26:41 PDT 2016


Author: qcolombet
Date: Wed Apr 27 18:26:40 2016
New Revision: 267817

URL: http://llvm.org/viewvc/llvm-project?rev=267817&view=rev
Log:
[ImplicitNullChecks] Properly update the live-in of the block of the memory operation.

We basically replace:
HoistBB:
cond_br NullBB, NotNullBB

NullBB:
  ...

NotNullBB:
  <reg> = load

into
HoistBB
<reg> = load_faulting_op NullBB
uncond_br NotNullBB

NullBB:
  ...

NotNullBB: ## <reg> is now live-in of NotNullBB
  ...

This partially fixes the machine verifier error for
test/CodeGen/X86/implicit-null-check.ll, but it still fails because
of the implicit CFG structure.

Modified:
    llvm/trunk/lib/CodeGen/ImplicitNullChecks.cpp

Modified: llvm/trunk/lib/CodeGen/ImplicitNullChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ImplicitNullChecks.cpp?rev=267817&r1=267816&r2=267817&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/ImplicitNullChecks.cpp (original)
+++ llvm/trunk/lib/CodeGen/ImplicitNullChecks.cpp Wed Apr 27 18:26:40 2016
@@ -397,7 +397,16 @@ void ImplicitNullChecks::rewriteNullChec
     // 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();
 




More information about the llvm-commits mailing list