mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-11 21:56:15 +00:00
MachineCSE: Clear dead-def flag on CSE.
In case CSE reuses a previoulsy unused register the dead-def flag has to be cleared on the def operand, as exposed by the arm64-cse.ll test. This fixes PR22439 and the corresponding rdar://19694987 Differential Revision: http://reviews.llvm.org/D7395 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228178 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7724d08fc6
commit
a602c10686
@ -1048,6 +1048,9 @@ public:
|
||||
bool addRegisterDead(unsigned Reg, const TargetRegisterInfo *RegInfo,
|
||||
bool AddIfNotFound = false);
|
||||
|
||||
/// Clear all dead flags on operands defining register @p Reg.
|
||||
void clearRegisterDeads(unsigned Reg);
|
||||
|
||||
/// Mark all subregister defs of register @p Reg with the undef flag.
|
||||
/// This function is used when we determined to have a subregister def in an
|
||||
/// otherwise undefined super register.
|
||||
|
@ -580,8 +580,15 @@ bool MachineCSE::ProcessBlock(MachineBasicBlock *MBB) {
|
||||
// Actually perform the elimination.
|
||||
if (DoCSE) {
|
||||
for (unsigned i = 0, e = CSEPairs.size(); i != e; ++i) {
|
||||
MRI->replaceRegWith(CSEPairs[i].first, CSEPairs[i].second);
|
||||
MRI->clearKillFlags(CSEPairs[i].second);
|
||||
unsigned OldReg = CSEPairs[i].first;
|
||||
unsigned NewReg = CSEPairs[i].second;
|
||||
// OldReg may have been unused but is used now, clear the Dead flag
|
||||
MachineInstr *Def = MRI->getUniqueVRegDef(NewReg);
|
||||
assert(Def != nullptr && "CSEd register has no unique definition?");
|
||||
Def->clearRegisterDeads(NewReg);
|
||||
// Replace with NewReg and clear kill flags which may be wrong now.
|
||||
MRI->replaceRegWith(OldReg, NewReg);
|
||||
MRI->clearKillFlags(NewReg);
|
||||
}
|
||||
|
||||
// Go through implicit defs of CSMI and MI, if a def is not dead at MI,
|
||||
|
@ -1889,6 +1889,14 @@ bool MachineInstr::addRegisterDead(unsigned Reg,
|
||||
return true;
|
||||
}
|
||||
|
||||
void MachineInstr::clearRegisterDeads(unsigned Reg) {
|
||||
for (MachineOperand &MO : operands()) {
|
||||
if (!MO.isReg() || !MO.isDef() || MO.getReg() != Reg)
|
||||
continue;
|
||||
MO.setIsDead(false);
|
||||
}
|
||||
}
|
||||
|
||||
void MachineInstr::addRegisterDefReadUndef(unsigned Reg) {
|
||||
for (MachineOperand &MO : operands()) {
|
||||
if (!MO.isReg() || !MO.isDef() || MO.getReg() != Reg || MO.getSubReg() == 0)
|
||||
|
@ -1,4 +1,4 @@
|
||||
; RUN: llc -O3 < %s -aarch64-atomic-cfg-tidy=0 -aarch64-gep-opt=false | FileCheck %s
|
||||
; RUN: llc -O3 < %s -aarch64-atomic-cfg-tidy=0 -aarch64-gep-opt=false -verify-machineinstrs | FileCheck %s
|
||||
target triple = "arm64-apple-ios"
|
||||
|
||||
; rdar://12462006
|
||||
|
Loading…
Reference in New Issue
Block a user