mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-03 07:04:53 +00:00
Revert commit 0e46b49de433 from llvm-project (by Matt Arsenault):
Reapply "RegisterCoalescer: Add implicit-def of super register when coalescing SUBREG_TO_REG"
This reverts commit c398fa009a47eb24f88383d5e911e59e70f8db86.
PPC backend was fixed in 2f82662ce901c6666fceb9c6c5e0de216a1c9667
Since it causes an assertion failure building /sys/dev/fb/vga.c:
https://github.com/llvm/llvm-project/issues/76416
PR: 276104
MFC after: 1 month
(cherry picked from commit edc2dc17b1
)
This commit is contained in:
parent
a205596100
commit
92d4d6f1f6
|
@ -305,11 +305,7 @@ namespace {
|
|||
/// number if it is not zero. If DstReg is a physical register and the
|
||||
/// existing subregister number of the def / use being updated is not zero,
|
||||
/// make sure to set it to the correct physical subregister.
|
||||
///
|
||||
/// If \p IsSubregToReg, we are coalescing a DstReg = SUBREG_TO_REG
|
||||
/// SrcReg. This introduces an implicit-def of DstReg on coalesced users.
|
||||
void updateRegDefsUses(Register SrcReg, Register DstReg, unsigned SubIdx,
|
||||
bool IsSubregToReg);
|
||||
void updateRegDefsUses(Register SrcReg, Register DstReg, unsigned SubIdx);
|
||||
|
||||
/// If the given machine operand reads only undefined lanes add an undef
|
||||
/// flag.
|
||||
|
@ -1347,7 +1343,8 @@ bool RegisterCoalescer::reMaterializeTrivialDef(const CoalescerPair &CP,
|
|||
if (DstReg.isPhysical()) {
|
||||
Register NewDstReg = DstReg;
|
||||
|
||||
unsigned NewDstIdx = TRI->composeSubRegIndices(CP.getSrcIdx(), DefSubIdx);
|
||||
unsigned NewDstIdx = TRI->composeSubRegIndices(CP.getSrcIdx(),
|
||||
DefMI->getOperand(0).getSubReg());
|
||||
if (NewDstIdx)
|
||||
NewDstReg = TRI->getSubReg(DstReg, NewDstIdx);
|
||||
|
||||
|
@ -1496,7 +1493,7 @@ bool RegisterCoalescer::reMaterializeTrivialDef(const CoalescerPair &CP,
|
|||
MRI->setRegClass(DstReg, NewRC);
|
||||
|
||||
// Update machine operands and add flags.
|
||||
updateRegDefsUses(DstReg, DstReg, DstIdx, false);
|
||||
updateRegDefsUses(DstReg, DstReg, DstIdx);
|
||||
NewMI.getOperand(0).setSubReg(NewIdx);
|
||||
// updateRegDefUses can add an "undef" flag to the definition, since
|
||||
// it will replace DstReg with DstReg.DstIdx. If NewIdx is 0, make
|
||||
|
@ -1816,7 +1813,7 @@ void RegisterCoalescer::addUndefFlag(const LiveInterval &Int, SlotIndex UseIdx,
|
|||
}
|
||||
|
||||
void RegisterCoalescer::updateRegDefsUses(Register SrcReg, Register DstReg,
|
||||
unsigned SubIdx, bool IsSubregToReg) {
|
||||
unsigned SubIdx) {
|
||||
bool DstIsPhys = DstReg.isPhysical();
|
||||
LiveInterval *DstInt = DstIsPhys ? nullptr : &LIS->getInterval(DstReg);
|
||||
|
||||
|
@ -1856,8 +1853,6 @@ void RegisterCoalescer::updateRegDefsUses(Register SrcReg, Register DstReg,
|
|||
if (DstInt && !Reads && SubIdx && !UseMI->isDebugInstr())
|
||||
Reads = DstInt->liveAt(LIS->getInstructionIndex(*UseMI));
|
||||
|
||||
bool FullDef = true;
|
||||
|
||||
// Replace SrcReg with DstReg in all UseMI operands.
|
||||
for (unsigned i = 0, e = Ops.size(); i != e; ++i) {
|
||||
MachineOperand &MO = UseMI->getOperand(Ops[i]);
|
||||
|
@ -1865,13 +1860,9 @@ void RegisterCoalescer::updateRegDefsUses(Register SrcReg, Register DstReg,
|
|||
// Adjust <undef> flags in case of sub-register joins. We don't want to
|
||||
// turn a full def into a read-modify-write sub-register def and vice
|
||||
// versa.
|
||||
if (SubIdx && MO.isDef()) {
|
||||
if (SubIdx && MO.isDef())
|
||||
MO.setIsUndef(!Reads);
|
||||
|
||||
if (!Reads)
|
||||
FullDef = false;
|
||||
}
|
||||
|
||||
// A subreg use of a partially undef (super) register may be a complete
|
||||
// undef use now and then has to be marked that way.
|
||||
if (MO.isUse() && !DstIsPhys) {
|
||||
|
@ -1903,25 +1894,6 @@ void RegisterCoalescer::updateRegDefsUses(Register SrcReg, Register DstReg,
|
|||
MO.substVirtReg(DstReg, SubIdx, *TRI);
|
||||
}
|
||||
|
||||
if (IsSubregToReg && !FullDef) {
|
||||
// If the coalesed instruction doesn't fully define the register, we need
|
||||
// to preserve the original super register liveness for SUBREG_TO_REG.
|
||||
//
|
||||
// We pretended SUBREG_TO_REG was a regular copy for coalescing purposes,
|
||||
// but it introduces liveness for other subregisters. Downstream users may
|
||||
// have been relying on those bits, so we need to ensure their liveness is
|
||||
// captured with a def of other lanes.
|
||||
|
||||
// FIXME: Need to add new subrange if tracking subranges. We could also
|
||||
// skip adding this if we knew the other lanes are dead, and only for
|
||||
// other lanes.
|
||||
|
||||
assert(!MRI->shouldTrackSubRegLiveness(DstReg) &&
|
||||
"this should update subranges");
|
||||
MachineInstrBuilder MIB(*MF, UseMI);
|
||||
MIB.addReg(DstReg, RegState::ImplicitDefine);
|
||||
}
|
||||
|
||||
LLVM_DEBUG({
|
||||
dbgs() << "\t\tupdated: ";
|
||||
if (!UseMI->isDebugInstr())
|
||||
|
@ -2121,8 +2093,6 @@ bool RegisterCoalescer::joinCopy(MachineInstr *CopyMI, bool &Again) {
|
|||
});
|
||||
}
|
||||
|
||||
const bool IsSubregToReg = CopyMI->isSubregToReg();
|
||||
|
||||
ShrinkMask = LaneBitmask::getNone();
|
||||
ShrinkMainRange = false;
|
||||
|
||||
|
@ -2190,12 +2160,9 @@ bool RegisterCoalescer::joinCopy(MachineInstr *CopyMI, bool &Again) {
|
|||
|
||||
// Rewrite all SrcReg operands to DstReg.
|
||||
// Also update DstReg operands to include DstIdx if it is set.
|
||||
if (CP.getDstIdx()) {
|
||||
assert(!IsSubregToReg && "can this happen?");
|
||||
updateRegDefsUses(CP.getDstReg(), CP.getDstReg(), CP.getDstIdx(), false);
|
||||
}
|
||||
updateRegDefsUses(CP.getSrcReg(), CP.getDstReg(), CP.getSrcIdx(),
|
||||
IsSubregToReg);
|
||||
if (CP.getDstIdx())
|
||||
updateRegDefsUses(CP.getDstReg(), CP.getDstReg(), CP.getDstIdx());
|
||||
updateRegDefsUses(CP.getSrcReg(), CP.getDstReg(), CP.getSrcIdx());
|
||||
|
||||
// Shrink subregister ranges if necessary.
|
||||
if (ShrinkMask.any()) {
|
||||
|
|
Loading…
Reference in a new issue