1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00

[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
This commit is contained in:
Quentin Colombet 2016-05-03 18:09:06 +00:00
parent eb11e92994
commit 5074b3866a
2 changed files with 13 additions and 8 deletions

View File

@ -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();

View File

@ -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 - \