[llvm] r268412 - [ImplicitNullChecks] Account for implicit-defs as well when updating the liveness.
Quentin Colombet via llvm-commits
llvm-commits at lists.llvm.org
Tue May 3 11:09:06 PDT 2016
Author: qcolombet
Date: Tue May 3 13:09:06 2016
New Revision: 268412
URL: http://llvm.org/viewvc/llvm-project?rev=268412&view=rev
Log:
[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.
Modified:
llvm/trunk/lib/CodeGen/ImplicitNullChecks.cpp
llvm/trunk/test/CodeGen/X86/implicit-null-check.ll
Modified: llvm/trunk/lib/CodeGen/ImplicitNullChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ImplicitNullChecks.cpp?rev=268412&r1=268411&r2=268412&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/ImplicitNullChecks.cpp (original)
+++ llvm/trunk/lib/CodeGen/ImplicitNullChecks.cpp Tue May 3 13:09:06 2016
@@ -398,13 +398,18 @@ void ImplicitNullChecks::rewriteNullChec
// 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();
Modified: llvm/trunk/test/CodeGen/X86/implicit-null-check.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/implicit-null-check.ll?rev=268412&r1=268411&r2=268412&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/implicit-null-check.ll (original)
+++ llvm/trunk/test/CodeGen/X86/implicit-null-check.ll Tue May 3 13:09:06 2016
@@ -1,4 +1,4 @@
-; RUN: llc -O3 -mtriple=x86_64-apple-macosx -enable-implicit-null-checks < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -O3 -mtriple=x86_64-apple-macosx -enable-implicit-null-checks < %s | FileCheck %s
; RUN: llc < %s -mtriple=x86_64-apple-macosx -enable-implicit-null-checks \
; RUN: | llvm-mc -triple x86_64-apple-macosx -filetype=obj -o - \
More information about the llvm-commits
mailing list