mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-08 19:25:47 +00:00
Fix for PR1257. Bug in live range shortening as a result of copy coalescing
where the destination is dead. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35252 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -924,14 +924,14 @@ bool LiveIntervals::JoinCopy(MachineInstr *CopyMI,
|
|||||||
MachineOperand *mopd = CopyMI->findRegisterDefOperand(DstReg);
|
MachineOperand *mopd = CopyMI->findRegisterDefOperand(DstReg);
|
||||||
bool isDead = mopd->isDead();
|
bool isDead = mopd->isDead();
|
||||||
bool isShorten = false;
|
bool isShorten = false;
|
||||||
unsigned SrcStart = 0;
|
unsigned SrcStart = 0, RemoveStart = 0;
|
||||||
unsigned SrcEnd = 0;
|
unsigned SrcEnd = 0, RemoveEnd = 0;
|
||||||
if (isDead) {
|
if (isDead) {
|
||||||
unsigned CopyIdx = getInstructionIndex(CopyMI);
|
unsigned CopyIdx = getInstructionIndex(CopyMI);
|
||||||
LiveInterval::iterator SrcLR =
|
LiveInterval::iterator SrcLR =
|
||||||
SrcInt.FindLiveRangeContaining(getUseIndex(CopyIdx));
|
SrcInt.FindLiveRangeContaining(getUseIndex(CopyIdx));
|
||||||
SrcStart = SrcLR->start;
|
RemoveStart = SrcStart = SrcLR->start;
|
||||||
SrcEnd = SrcLR->end;
|
RemoveEnd = SrcEnd = SrcLR->end;
|
||||||
// The instruction which defines the src is only truly dead if there are
|
// The instruction which defines the src is only truly dead if there are
|
||||||
// no intermediate uses and there isn't a use beyond the copy.
|
// no intermediate uses and there isn't a use beyond the copy.
|
||||||
// FIXME: find the last use, mark is kill and shorten the live range.
|
// FIXME: find the last use, mark is kill and shorten the live range.
|
||||||
@@ -939,18 +939,16 @@ bool LiveIntervals::JoinCopy(MachineInstr *CopyMI,
|
|||||||
isDead = false;
|
isDead = false;
|
||||||
else {
|
else {
|
||||||
MachineOperand *MOU;
|
MachineOperand *MOU;
|
||||||
MachineInstr *LastUse =
|
MachineInstr *LastUse= lastRegisterUse(repSrcReg, SrcStart, CopyIdx, MOU);
|
||||||
lastRegisterUse(repSrcReg, SrcStart, CopyIdx, MOU);
|
|
||||||
if (LastUse) {
|
if (LastUse) {
|
||||||
// Shorten the liveinterval to the end of last use.
|
// Shorten the liveinterval to the end of last use.
|
||||||
MOU->setIsKill();
|
MOU->setIsKill();
|
||||||
isDead = false;
|
isDead = false;
|
||||||
isShorten = true;
|
isShorten = true;
|
||||||
SrcEnd = getUseIndex(getInstructionIndex(LastUse));
|
RemoveStart = getDefIndex(getInstructionIndex(LastUse));
|
||||||
|
RemoveEnd = SrcEnd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isDead)
|
|
||||||
isShorten = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to be careful about coalescing a source physical register with a
|
// We need to be careful about coalescing a source physical register with a
|
||||||
@@ -1030,10 +1028,10 @@ TryJoin:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isShorten) {
|
if (isShorten || isDead) {
|
||||||
// Shorten the live interval.
|
// Shorten the live interval.
|
||||||
LiveInterval &LiveInInt = (repSrcReg == DestInt.reg) ? DestInt : SrcInt;
|
LiveInterval &LiveInInt = (repSrcReg == DestInt.reg) ? DestInt : SrcInt;
|
||||||
LiveInInt.removeRange(SrcStart, SrcEnd);
|
LiveInInt.removeRange(RemoveStart, RemoveEnd);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Coallescing failed.
|
// Coallescing failed.
|
||||||
|
Reference in New Issue
Block a user