mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-28 21:34:23 +00:00
Set sub-register <undef> flags more accurately.
When widening an existing <def,reads-undef> operand to a super-register, it may be necessary to clear the <undef> flag because the wider register is now read-modify-write through the instruction. Conversely, it may be necessary to add an <undef> flag when the coalescer turns a full-register def into a sub-register def, but the larger register wasn't live before the instruction. This happens in test/CodeGen/ARM/coalesce-subregs.ll, but the test is too small for the <undef> flags to affect the generated code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156951 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d938935dca
commit
07a267faec
@ -911,6 +911,7 @@ void RegisterCoalescer::updateRegDefsUses(unsigned SrcReg,
|
|||||||
unsigned DstReg,
|
unsigned DstReg,
|
||||||
unsigned SubIdx) {
|
unsigned SubIdx) {
|
||||||
bool DstIsPhys = TargetRegisterInfo::isPhysicalRegister(DstReg);
|
bool DstIsPhys = TargetRegisterInfo::isPhysicalRegister(DstReg);
|
||||||
|
LiveInterval &DstInt = LIS->getInterval(DstReg);
|
||||||
|
|
||||||
// Update LiveDebugVariables.
|
// Update LiveDebugVariables.
|
||||||
LDV->renameRegister(SrcReg, DstReg, SubIdx);
|
LDV->renameRegister(SrcReg, DstReg, SubIdx);
|
||||||
@ -934,17 +935,20 @@ void RegisterCoalescer::updateRegDefsUses(unsigned SrcReg,
|
|||||||
bool Reads, Writes;
|
bool Reads, Writes;
|
||||||
tie(Reads, Writes) = UseMI->readsWritesVirtualRegister(SrcReg, &Ops);
|
tie(Reads, Writes) = UseMI->readsWritesVirtualRegister(SrcReg, &Ops);
|
||||||
|
|
||||||
|
// If SrcReg wasn't read, it may still be the case that DstReg is live-in
|
||||||
|
// because SrcReg is a sub-register.
|
||||||
|
if (!Reads && SubIdx)
|
||||||
|
Reads = DstInt.liveAt(LIS->getInstructionIndex(UseMI));
|
||||||
|
|
||||||
// Replace SrcReg with DstReg in all UseMI operands.
|
// Replace SrcReg with DstReg in all UseMI operands.
|
||||||
for (unsigned i = 0, e = Ops.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Ops.size(); i != e; ++i) {
|
||||||
MachineOperand &MO = UseMI->getOperand(Ops[i]);
|
MachineOperand &MO = UseMI->getOperand(Ops[i]);
|
||||||
|
|
||||||
// Make sure we don't create read-modify-write defs accidentally. We
|
// Adjust <undef> flags in case of sub-register joins. We don't want to
|
||||||
// assume here that a SrcReg def cannot be joined into a live DstReg. If
|
// turn a full def into a read-modify-write sub-register def and vice
|
||||||
// RegisterCoalescer starts tracking partially live registers, we will
|
// versa.
|
||||||
// need to check the actual LiveInterval to determine if DstReg is live
|
if (SubIdx && MO.isDef())
|
||||||
// here.
|
MO.setIsUndef(!Reads);
|
||||||
if (SubIdx && !Reads)
|
|
||||||
MO.setIsUndef();
|
|
||||||
|
|
||||||
if (DstIsPhys)
|
if (DstIsPhys)
|
||||||
MO.substPhysReg(DstReg, *TRI);
|
MO.substPhysReg(DstReg, *TRI);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user