summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/ARM/Thumb2ITBlockPass.cpp
diff options
context:
space:
mode:
authorPete Cooper <peter_cooper@apple.com>2015-05-04 22:44:47 +0000
committerPete Cooper <peter_cooper@apple.com>2015-05-04 22:44:47 +0000
commit4dddbcfbb1cfae9b2adbd417a6e58b640bdeb1a0 (patch)
tree1d82369e7102e5680a7cde10c9a3ca1335fe9d3f /llvm/lib/Target/ARM/Thumb2ITBlockPass.cpp
parentb5445cce73885246fb8711a815b70e2cec839dfa (diff)
downloadbcm5719-llvm-4dddbcfbb1cfae9b2adbd417a6e58b640bdeb1a0.tar.gz
bcm5719-llvm-4dddbcfbb1cfae9b2adbd417a6e58b640bdeb1a0.zip
[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
Diffstat (limited to 'llvm/lib/Target/ARM/Thumb2ITBlockPass.cpp')
-rw-r--r--llvm/lib/Target/ARM/Thumb2ITBlockPass.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/Thumb2ITBlockPass.cpp b/llvm/lib/Target/ARM/Thumb2ITBlockPass.cpp
index 7bb226510a2..b62ae2e3429 100644
--- a/llvm/lib/Target/ARM/Thumb2ITBlockPass.cpp
+++ b/llvm/lib/Target/ARM/Thumb2ITBlockPass.cpp
@@ -90,6 +90,19 @@ static void TrackDefUses(MachineInstr *MI,
}
}
+/// Clear kill flags for any uses in the given set. This will likely
+/// conservatively remove more kill flags than are necessary, but removing them
+/// is safer than incorrect kill flags remaining on instructions.
+static void ClearKillFlags(MachineInstr *MI, SmallSet<unsigned, 4> &Uses) {
+ for (MIOperands MO(MI); MO.isValid(); ++MO) {
+ if (!MO->isReg() || MO->isDef() || !MO->isKill())
+ continue;
+ if (!Uses.count(MO->getReg()))
+ continue;
+ MO->setIsKill(false);
+ }
+}
+
static bool isCopy(MachineInstr *MI) {
switch (MI->getOpcode()) {
default:
@@ -222,6 +235,7 @@ bool Thumb2ITBlockPass::InsertITInstructions(MachineBasicBlock &MBB) {
--MBBI;
MBB.remove(NMI);
MBB.insert(InsertPos, NMI);
+ ClearKillFlags(MI, Uses);
++NumMovedInsts;
continue;
}
OpenPOWER on IntegriCloud