mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-21 03:32:21 +00:00
[Register Coalescer] Fix wrong live-range information with rematerialization.
When rematerializing an instruction that defines a super register that would be used by a physical subregisters we use the related physical super register for the definition. To keep the live-range information accurate, all the defined subregisters must be marked as dead def, otherwise the register allocation may miss some interferences. Working on a reduced test-case! <rdar://problem/16582185> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206060 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6e6126ac4c
commit
441d6d505b
@ -844,6 +844,27 @@ bool RegisterCoalescer::reMaterializeTrivialDef(CoalescerPair &CP,
|
||||
true /*IsDef*/,
|
||||
true /*IsImp*/,
|
||||
false /*IsKill*/));
|
||||
// Record small dead def live-ranges for all the subregisters
|
||||
// of the destination register.
|
||||
// Otherwise, variables that live through may miss some
|
||||
// interferences, thus creating invalid allocation.
|
||||
// E.g., i386 code:
|
||||
// vreg1 = somedef ; vreg1 GR8
|
||||
// vreg2 = remat ; vreg2 GR32
|
||||
// CL = COPY vreg2.sub_8bit
|
||||
// = somedef vreg1 ; vreg1 GR8
|
||||
// =>
|
||||
// vreg1 = somedef ; vreg1 GR8
|
||||
// ECX<def, dead> = remat ; CL<imp-def>
|
||||
// = somedef vreg1 ; vreg1 GR8
|
||||
// vreg1 will see the inteferences with CL but not with CH since
|
||||
// no live-ranges would have been created for ECX.
|
||||
// Fix that!
|
||||
SlotIndex NewMIIdx = LIS->getInstructionIndex(NewMI);
|
||||
for (MCRegUnitIterator Units(NewMI->getOperand(0).getReg(), TRI);
|
||||
Units.isValid(); ++Units)
|
||||
if (LiveRange *LR = LIS->getCachedRegUnit(*Units))
|
||||
LR->createDeadDef(NewMIIdx.getRegSlot(), LIS->getVNInfoAllocator());
|
||||
}
|
||||
|
||||
if (NewMI->getOperand(0).getSubReg())
|
||||
|
Loading…
x
Reference in New Issue
Block a user