aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2008-05-27 20:40:52 +0000
committerBill Wendling <isanbard@gmail.com>2008-05-27 20:40:52 +0000
commitb5746702004f4d5f49a290cad54223bd7f2e843b (patch)
tree0ca8be135adf64db1344577d66cbc010cd70a4dd /lib
parentcd45b3743101c1d80c0bdefaa831119133835816 (diff)
downloadexternal_llvm-b5746702004f4d5f49a290cad54223bd7f2e843b.zip
external_llvm-b5746702004f4d5f49a290cad54223bd7f2e843b.tar.gz
external_llvm-b5746702004f4d5f49a290cad54223bd7f2e843b.tar.bz2
Incorporated feedback: Check that the implicitly defined operands aren't used
before deleting the instruction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51609 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/TwoAddressInstructionPass.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/CodeGen/TwoAddressInstructionPass.cpp b/lib/CodeGen/TwoAddressInstructionPass.cpp
index 5bac6a6..145f80a 100644
--- a/lib/CodeGen/TwoAddressInstructionPass.cpp
+++ b/lib/CodeGen/TwoAddressInstructionPass.cpp
@@ -373,6 +373,8 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) {
}
if (EnableReMat) {
+ // Check to see if the instructions that we rematerialized are now dead. If
+ // they are, expunge them here.
SmallPtrSet<MachineInstr*, 8>::iterator I = ReMattedInstrs.begin();
SmallPtrSet<MachineInstr*, 8>::iterator E = ReMattedInstrs.end();
@@ -385,20 +387,17 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) {
if (!MO.isRegister())
continue;
unsigned MOReg = MO.getReg();
- if (!MOReg)
+
+ if (!MOReg || !MO.isDef() || (MO.isImplicit() && MO.isDead()))
continue;
- if (MO.isDef()) {
- if (MO.isImplicit())
- continue;
- if (MRI->use_begin(MOReg) != MRI->use_end()) {
- InstrDead = false;
- break;
- }
+ if (MRI->use_begin(MOReg) != MRI->use_end()) {
+ InstrDead = false;
+ break;
}
}
- if (InstrDead && MI->getNumOperands() > 0)
+ if (InstrDead)
MI->eraseFromParent();
}
}