aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineInstr.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-06-18 23:28:01 +0000
committerDan Gohman <gohman@apple.com>2010-06-18 23:28:01 +0000
commit86936504220e7769cf95c2c18e1ee38cdc1b7428 (patch)
tree49497263f665639a79e468655a9d3dc46bffaf06 /llvm/lib/CodeGen/MachineInstr.cpp
parent0bf5ee74c473a394e0a484ad8b979f0972c75345 (diff)
downloadllvm-86936504220e7769cf95c2c18e1ee38cdc1b7428.zip
llvm-86936504220e7769cf95c2c18e1ee38cdc1b7428.tar.gz
llvm-86936504220e7769cf95c2c18e1ee38cdc1b7428.tar.bz2
Teach regular and fast isel to set dead flags on unused implicit defs
on calls and similar instructions. llvm-svn: 106353
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineInstr.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp
index 7e60c32..9e7d392 100644
--- a/llvm/lib/CodeGen/MachineInstr.cpp
+++ b/llvm/lib/CodeGen/MachineInstr.cpp
@@ -1461,6 +1461,25 @@ void MachineInstr::addRegisterDefined(unsigned IncomingReg,
true /*IsImp*/));
}
+void MachineInstr::setPhysRegsDeadExcept(const SmallVectorImpl<unsigned> &UsedRegs,
+ const TargetRegisterInfo &TRI) {
+ for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
+ MachineOperand &MO = getOperand(i);
+ if (!MO.isReg() || !MO.isDef()) continue;
+ unsigned Reg = MO.getReg();
+ if (Reg == 0) continue;
+ bool Dead = true;
+ for (SmallVectorImpl<unsigned>::const_iterator I = UsedRegs.begin(),
+ E = UsedRegs.end(); I != E; ++I)
+ if (TRI.regsOverlap(*I, Reg)) {
+ Dead = false;
+ break;
+ }
+ // If there are no uses, including partial uses, the def is dead.
+ if (Dead) MO.setIsDead();
+ }
+}
+
unsigned
MachineInstrExpressionTrait::getHashValue(const MachineInstr* const &MI) {
unsigned Hash = MI->getOpcode() * 37;