mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-30 08:56:40 +00:00
Mark all uses as <undef> when joining a copy.
This way, shrinkToUses() will ignore the instruction that is about to be deleted, and we avoid leaving invalid live ranges that SplitKit doesn't like. Fix a misunderstanding in MachineVerifier about <def,undef> operands. The <undef> flag is valid on def operands where it has the same meaning as <undef> on a use operand. It only applies to sub-register defines which also read the full register. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128642 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
48a36158ec
commit
8e53aca51a
@ -602,9 +602,7 @@ MachineVerifier::visitMachineOperand(const MachineOperand *MO, unsigned MONum) {
|
|||||||
// Check Live Variables.
|
// Check Live Variables.
|
||||||
if (MI->isDebugValue()) {
|
if (MI->isDebugValue()) {
|
||||||
// Liveness checks are not valid for debug values.
|
// Liveness checks are not valid for debug values.
|
||||||
} else if (MO->isUndef()) {
|
} else if (MO->isUse() && !MO->isUndef()) {
|
||||||
// An <undef> doesn't refer to any register, so just skip it.
|
|
||||||
} else if (MO->isUse()) {
|
|
||||||
regsLiveInButUnused.erase(Reg);
|
regsLiveInButUnused.erase(Reg);
|
||||||
|
|
||||||
bool isKill = false;
|
bool isKill = false;
|
||||||
@ -675,8 +673,7 @@ MachineVerifier::visitMachineOperand(const MachineOperand *MO, unsigned MONum) {
|
|||||||
MInfo.vregsLiveIn.insert(std::make_pair(Reg, MI));
|
MInfo.vregsLiveIn.insert(std::make_pair(Reg, MI));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else if (MO->isDef()) {
|
||||||
assert(MO->isDef());
|
|
||||||
// Register defined.
|
// Register defined.
|
||||||
// TODO: verify that earlyclobber ops are not used.
|
// TODO: verify that earlyclobber ops are not used.
|
||||||
if (MO->isDead())
|
if (MO->isDead())
|
||||||
|
@ -104,6 +104,18 @@ void SimpleRegisterCoalescing::getAnalysisUsage(AnalysisUsage &AU) const {
|
|||||||
MachineFunctionPass::getAnalysisUsage(AU);
|
MachineFunctionPass::getAnalysisUsage(AU);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimpleRegisterCoalescing::markAsJoined(MachineInstr *CopyMI) {
|
||||||
|
/// Joined copies are not deleted immediately, but kept in JoinedCopies.
|
||||||
|
JoinedCopies.insert(CopyMI);
|
||||||
|
|
||||||
|
/// Mark all register operands of CopyMI as <undef> so they won't affect dead
|
||||||
|
/// code elimination.
|
||||||
|
for (MachineInstr::mop_iterator I = CopyMI->operands_begin(),
|
||||||
|
E = CopyMI->operands_end(); I != E; ++I)
|
||||||
|
if (I->isReg())
|
||||||
|
I->setIsUndef(true);
|
||||||
|
}
|
||||||
|
|
||||||
/// AdjustCopiesBackFrom - We found a non-trivially-coalescable copy with IntA
|
/// AdjustCopiesBackFrom - We found a non-trivially-coalescable copy with IntA
|
||||||
/// being the source and IntB being the dest, thus this defines a value number
|
/// being the source and IntB being the dest, thus this defines a value number
|
||||||
/// in IntB. If the source value number (in IntA) is defined by a copy from B,
|
/// in IntB. If the source value number (in IntA) is defined by a copy from B,
|
||||||
@ -471,7 +483,7 @@ bool SimpleRegisterCoalescing::RemoveCopyByCommutingDef(const CoalescerPair &CP,
|
|||||||
DEBUG(dbgs() << "\t\tnoop: " << DefIdx << '\t' << *UseMI);
|
DEBUG(dbgs() << "\t\tnoop: " << DefIdx << '\t' << *UseMI);
|
||||||
assert(DVNI->def == DefIdx);
|
assert(DVNI->def == DefIdx);
|
||||||
BValNo = IntB.MergeValueNumberInto(BValNo, DVNI);
|
BValNo = IntB.MergeValueNumberInto(BValNo, DVNI);
|
||||||
JoinedCopies.insert(UseMI);
|
markAsJoined(UseMI);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extend BValNo by merging in IntA live ranges of AValNo. Val# definition
|
// Extend BValNo by merging in IntA live ranges of AValNo. Val# definition
|
||||||
@ -1070,7 +1082,7 @@ bool SimpleRegisterCoalescing::JoinCopy(CopyRec &TheCopy, bool &Again) {
|
|||||||
if (!CP.isPartial()) {
|
if (!CP.isPartial()) {
|
||||||
if (AdjustCopiesBackFrom(CP, CopyMI) ||
|
if (AdjustCopiesBackFrom(CP, CopyMI) ||
|
||||||
RemoveCopyByCommutingDef(CP, CopyMI)) {
|
RemoveCopyByCommutingDef(CP, CopyMI)) {
|
||||||
JoinedCopies.insert(CopyMI);
|
markAsJoined(CopyMI);
|
||||||
DEBUG(dbgs() << "\tTrivial!\n");
|
DEBUG(dbgs() << "\tTrivial!\n");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1090,7 +1102,7 @@ bool SimpleRegisterCoalescing::JoinCopy(CopyRec &TheCopy, bool &Again) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remember to delete the copy instruction.
|
// Remember to delete the copy instruction.
|
||||||
JoinedCopies.insert(CopyMI);
|
markAsJoined(CopyMI);
|
||||||
|
|
||||||
UpdateRegDefsUses(CP);
|
UpdateRegDefsUses(CP);
|
||||||
|
|
||||||
|
@ -176,6 +176,9 @@ namespace llvm {
|
|||||||
/// cycles Start and End or NULL if there are no uses.
|
/// cycles Start and End or NULL if there are no uses.
|
||||||
MachineOperand *lastRegisterUse(SlotIndex Start, SlotIndex End,
|
MachineOperand *lastRegisterUse(SlotIndex Start, SlotIndex End,
|
||||||
unsigned Reg, SlotIndex &LastUseIdx) const;
|
unsigned Reg, SlotIndex &LastUseIdx) const;
|
||||||
|
|
||||||
|
/// markAsJoined - Remember that CopyMI has already been joined.
|
||||||
|
void markAsJoined(MachineInstr *CopyMI);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
; RUN: llc < %s -mtriple=x86_64-apple-darwin10.0 -relocation-model=pic -disable-fp-elim -stats |& grep asm-printer | grep 79
|
; RUN: llc < %s -mtriple=x86_64-apple-darwin10.0 -relocation-model=pic -disable-fp-elim -stats |& grep asm-printer | grep 77
|
||||||
; rdar://6802189
|
; rdar://6802189
|
||||||
|
|
||||||
; Test if linearscan is unfavoring registers for allocation to allow more reuse
|
; Test if linearscan is unfavoring registers for allocation to allow more reuse
|
||||||
|
Loading…
x
Reference in New Issue
Block a user