Skip to content

Commit 4dddbcf

Browse files
committed
[ARM] IT block insertion needs to update kill flags
When forming an IT block from the first MOV here: %R2<def> = t2MOVr %R0, pred:1, pred:%CPSR, opt:%noreg %R3<def> = tMOVr %R0<kill>, pred:14, pred:%noreg the move in to R3 is moved out of the IT block so that later instructions on the same predicate can be inside this block, and we can share the IT instruction. However, when moving the R3 copy out of the IT block, we need to clear its kill flags for anything in use at this point in time, ie, R0 here. This appeases the machine verifier which thought that R0 wasn't defined when used. I have a test case, but its extremely register allocator specific. It would be too fragile to commit a test which depends on the register allocator here. llvm-svn: 236468
1 parent b5445cc commit 4dddbcf

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

llvm/lib/Target/ARM/Thumb2ITBlockPass.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,19 @@ static void TrackDefUses(MachineInstr *MI,
9090
}
9191
}
9292

93+
/// Clear kill flags for any uses in the given set. This will likely
94+
/// conservatively remove more kill flags than are necessary, but removing them
95+
/// is safer than incorrect kill flags remaining on instructions.
96+
static void ClearKillFlags(MachineInstr *MI, SmallSet<unsigned, 4> &Uses) {
97+
for (MIOperands MO(MI); MO.isValid(); ++MO) {
98+
if (!MO->isReg() || MO->isDef() || !MO->isKill())
99+
continue;
100+
if (!Uses.count(MO->getReg()))
101+
continue;
102+
MO->setIsKill(false);
103+
}
104+
}
105+
93106
static bool isCopy(MachineInstr *MI) {
94107
switch (MI->getOpcode()) {
95108
default:
@@ -222,6 +235,7 @@ bool Thumb2ITBlockPass::InsertITInstructions(MachineBasicBlock &MBB) {
222235
--MBBI;
223236
MBB.remove(NMI);
224237
MBB.insert(InsertPos, NMI);
238+
ClearKillFlags(MI, Uses);
225239
++NumMovedInsts;
226240
continue;
227241
}

0 commit comments

Comments
 (0)