summaryrefslogtreecommitdiff
path: root/lib/CodeGen/MachineInstr.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2008-03-03 23:57:28 +0000
committerBill Wendling <isanbard@gmail.com>2008-03-03 23:57:28 +0000
commit405abffd5eb1ad1841491e51943b598c935f309b (patch)
tree3490d8d7a14b7533726aa6bbf69068134a4d32e0 /lib/CodeGen/MachineInstr.cpp
parent220a823f8d044b7e9484999c9ec73e3cbe6d251c (diff)
downloadllvm-405abffd5eb1ad1841491e51943b598c935f309b.tar.gz
llvm-405abffd5eb1ad1841491e51943b598c935f309b.tar.bz2
llvm-405abffd5eb1ad1841491e51943b598c935f309b.tar.xz
Miscellaneous clean-ups based on Evan's feedback:
- Cleaned up how the prologue-epilogue inserter loops over the instructions. - Instead of restarting the processing of an instruction if we remove an implicit kill, just update the end iterator and make sure that the iterator isn't incremented. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47870 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineInstr.cpp')
-rw-r--r--lib/CodeGen/MachineInstr.cpp50
1 files changed, 27 insertions, 23 deletions
diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp
index b0a225831c..600e790aad 100644
--- a/lib/CodeGen/MachineInstr.cpp
+++ b/lib/CodeGen/MachineInstr.cpp
@@ -680,37 +680,40 @@ bool MachineInstr::addRegisterKilled(unsigned IncomingReg,
bool AddIfNotFound) {
// Go through the machine instruction's operands to eliminate any potentially
// illegal conditions. I.e., a super- and sub-register both marked "kill".
- Restart:
- for (unsigned i = 0, e = getNumOperands(); i < e; ++i) {
+ for (unsigned i = 0, e = getNumOperands(); i < e;) {
MachineOperand &MO = getOperand(i);
-
if (MO.isRegister() && MO.isUse()) {
unsigned Reg = MO.getReg();
if (!Reg || IncomingReg == Reg ||
!TargetRegisterInfo::isPhysicalRegister(Reg) ||
- !TargetRegisterInfo::isPhysicalRegister(IncomingReg))
+ !TargetRegisterInfo::isPhysicalRegister(IncomingReg)) {
+ ++i;
continue;
+ }
- if (RegInfo->isSubRegister(IncomingReg, Reg)) {
- if (MO.isKill()) {
- if (MO.isImplicit()) {
- // Remove this implicit use that marks the sub-register "kill". Let
- // the super-register take care of this information.
- RemoveOperand(i);
- goto Restart; // Instruction was modified, redo checking.
- } else {
- // The super-register is going to take care of this kill
- // information.
- MO.setIsKill(false);
- }
- }
- } else if (RegInfo->isSuperRegister(IncomingReg, Reg) && MO.isKill()) {
+ if (RegInfo->isSuperRegister(IncomingReg, Reg) && MO.isKill())
// The kill information is already handled by a super-register. Don't
// add this sub-register as a kill.
return true;
+
+ if (RegInfo->isSubRegister(IncomingReg, Reg) && MO.isKill()) {
+ if (MO.isImplicit()) {
+ // Remove this implicit use that marks the sub-register
+ // "kill". Let the super-register take care of this
+ // information.
+ RemoveOperand(i);
+ e = getNumOperands();
+ continue;
+ } else {
+ // The super-register is going to take care of this kill
+ // information.
+ MO.setIsKill(false);
+ }
}
}
+
+ ++i;
}
// If the register already exists, then make sure it or its super-register is
@@ -725,13 +728,14 @@ bool MachineInstr::addRegisterKilled(unsigned IncomingReg,
if (Reg == IncomingReg) {
MO.setIsKill();
return true;
- } else if (TargetRegisterInfo::isPhysicalRegister(Reg) &&
- TargetRegisterInfo::isPhysicalRegister(IncomingReg) &&
- RegInfo->isSuperRegister(IncomingReg, Reg) &&
- MO.isKill()) {
+ }
+
+ if (TargetRegisterInfo::isPhysicalRegister(Reg) &&
+ TargetRegisterInfo::isPhysicalRegister(IncomingReg) &&
+ RegInfo->isSuperRegister(IncomingReg, Reg) &&
+ MO.isKill())
// A super-register kill already exists.
return true;
- }
}
}