[PATCH] D75185: [RDA] Track implicit-defs
Sam Parker via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 26 08:23:43 PST 2020
samparker created this revision.
samparker added reviewers: SjoerdMeijer, dmgreen.
Herald added subscribers: hiraditya, kristof.beyls.
Herald added a project: LLVM.
Ensure that we're recording implicit defs, as well as visiting implicit uses and implicit defs when we're walking through operands. This requires a change to ARMLowOverheadLoops because RDA now knows that t2LoopEnd is set to define the CPSR.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D75185
Files:
llvm/lib/CodeGen/ReachingDefAnalysis.cpp
llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
llvm/test/CodeGen/Thumb2/LowOverheadLoops/dont-ignore-vctp.mir
Index: llvm/test/CodeGen/Thumb2/LowOverheadLoops/dont-ignore-vctp.mir
===================================================================
--- llvm/test/CodeGen/Thumb2/LowOverheadLoops/dont-ignore-vctp.mir
+++ llvm/test/CodeGen/Thumb2/LowOverheadLoops/dont-ignore-vctp.mir
@@ -95,12 +95,12 @@
; CHECK-LABEL: name: dont_ignore_vctp
; CHECK: bb.0.entry:
; CHECK: successors: %bb.1(0x80000000)
- ; CHECK: liveins: $lr, $r0, $r1, $r3, $r7
+ ; CHECK: liveins: $lr, $r0, $r1, $r2, $r7
; CHECK: frame-setup tPUSH 14 /* CC::al */, $noreg, killed $r7, killed $lr, implicit-def $sp, implicit $sp
; CHECK: frame-setup CFI_INSTRUCTION def_cfa_offset 8
; CHECK: frame-setup CFI_INSTRUCTION offset $lr, -4
; CHECK: frame-setup CFI_INSTRUCTION offset $r7, -8
- ; CHECK: tCMPi8 renamable $r3, 4, 14 /* CC::al */, $noreg, implicit-def dead $cpsr
+ ; CHECK: renamable $r3, dead $cpsr = tLSLri killed renamable $r2, 1, 14 /* CC::al */, $noreg
; CHECK: renamable $r2 = tLEApcrel %const.0, 14 /* CC::al */, $noreg
; CHECK: renamable $q0 = MVE_VLDRWU32 killed renamable $r2, 0, 0, $noreg :: (load 16 from constant-pool)
; CHECK: $lr = MVE_DLSTP_32 killed renamable $r3
Index: llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
===================================================================
--- llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
+++ llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
@@ -817,8 +817,12 @@
MachineBasicBlock *MBB = MI->getParent();
MachineInstr *Last = &MBB->back();
SmallPtrSet<MachineInstr*, 1> Ignore;
- if (Last->getOpcode() == ARM::t2LoopEnd)
- Ignore.insert(Last);
+ for (auto I = MachineBasicBlock::iterator(MI), E = MBB->end(); I != E; ++I) {
+ if (I->getOpcode() == ARM::t2LoopEnd) {
+ Ignore.insert(&*I);
+ break;
+ }
+ }
// If nothing defines CPSR between LoopDec and LoopEnd, use a t2SUBS.
bool SetFlags = RDA->isSafeToDefRegAt(MI, ARM::CPSR, Ignore);
Index: llvm/lib/CodeGen/ReachingDefAnalysis.cpp
===================================================================
--- llvm/lib/CodeGen/ReachingDefAnalysis.cpp
+++ llvm/lib/CodeGen/ReachingDefAnalysis.cpp
@@ -100,14 +100,9 @@
unsigned MBBNumber = MI->getParent()->getNumber();
assert(MBBNumber < MBBReachingDefs.size() &&
"Unexpected basic block number.");
- const MCInstrDesc &MCID = MI->getDesc();
- for (unsigned i = 0,
- e = MI->isVariadic() ? MI->getNumOperands() : MCID.getNumDefs();
- i != e; ++i) {
- MachineOperand &MO = MI->getOperand(i);
- if (!MO.isReg() || !MO.getReg())
- continue;
- if (MO.isUse())
+
+ for (auto &MO : MI->operands()) {
+ if (!MO.isReg() || !MO.getReg() || MO.isUse())
continue;
for (MCRegUnitIterator Unit(MO.getReg(), TRI); Unit.isValid(); ++Unit) {
// This instruction explicitly defines the current reg unit.
@@ -530,9 +525,12 @@
Dead.insert(MI);
auto IsDead = [this](MachineInstr *Def, int PhysReg) {
unsigned LiveDefs = 0;
- for (auto &MO : Def->defs())
+ for (auto &MO : Def->operands()) {
+ if (!MO.isReg() || !MO.getReg() || MO.isUse())
+ continue;
if (!MO.isDead())
++LiveDefs;
+ }
if (LiveDefs > 1)
return false;
@@ -542,8 +540,8 @@
return Uses.size() == 1;
};
- for (auto &MO : MI->uses()) {
- if (!MO.isReg() || MO.getReg() == 0 || !MO.isKill())
+ for (auto &MO : MI->operands()) {
+ if (!MO.isReg() || !MO.getReg() || !MO.isUse() || !MO.isKill())
continue;
if (MachineInstr *Def = getReachingLocalMIDef(MI, MO.getReg()))
if (IsDead(Def, MO.getReg()))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75185.246740.patch
Type: text/x-patch
Size: 3626 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200226/758e5d8a/attachment.bin>
More information about the llvm-commits
mailing list