[MachineInstrBundle] Improvement the recognition of dead definitions.

Now, it is possible to know that partial definitions are dead definitions and
recognize that clobbered registers are also dead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267621 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Quentin Colombet 2016-04-26 23:14:24 +00:00
parent 5fcdfef145
commit b62e24784c
3 changed files with 12 additions and 5 deletions

View File

@ -187,6 +187,10 @@ public:
/// dead.
bool DeadDef;
/// Reg is Defined and all defs of reg or an overlapping register are
/// dead.
bool PartialDeadDef;
/// There is a use operand of reg or a super-register with kill flag set.
bool Killed;
};

View File

@ -293,7 +293,7 @@ MachineOperandIteratorBase::PhysRegInfo
MachineOperandIteratorBase::analyzePhysReg(unsigned Reg,
const TargetRegisterInfo *TRI) {
bool AllDefsDead = true;
PhysRegInfo PRI = {false, false, false, false, false, false, false};
PhysRegInfo PRI = {false, false, false, false, false, false, false, false};
assert(TargetRegisterInfo::isPhysicalRegister(Reg) &&
"analyzePhysReg not given a physical register!");
@ -332,8 +332,12 @@ MachineOperandIteratorBase::analyzePhysReg(unsigned Reg,
}
}
if (AllDefsDead && PRI.FullyDefined)
PRI.DeadDef = true;
if (AllDefsDead) {
if (PRI.FullyDefined || PRI.Clobbered)
PRI.DeadDef = true;
else
PRI.PartialDeadDef = true;
}
return PRI;
}

View File

@ -63,11 +63,10 @@ define i64 @test_intervening_call(i64* %foo, i64 %bar, i64 %baz) {
; x8664-sahf-NEXT: popq %rax
; x8664-sahf-NEXT: movq %rax, %rdi
; x8664-sahf-NEXT: callq bar
; x8664-sahf-NEXT: pushq %rax
; RAX is dead, no need to push and pop it.
; x8664-sahf-NEXT: movq [[FLAGS]], %rax
; x8664-sahf-NEXT: addb $127, %al
; x8664-sahf-NEXT: sahf
; x8664-sahf-NEXT: popq %rax
; x8664-sahf-NEXT: jne
%cx = cmpxchg i64* %foo, i64 %bar, i64 %baz seq_cst seq_cst