@@ -391,7 +391,7 @@ class RegAllocFastImpl {
391
391
bool mayLiveOut (Register VirtReg);
392
392
bool mayLiveIn (Register VirtReg);
393
393
394
- bool isInlineAsmBrSpill (const MachineInstr &MI) const ;
394
+ bool mayBeSpillFromInlineAsmBr (const MachineInstr &MI) const ;
395
395
396
396
void dumpState () const ;
397
397
};
@@ -493,17 +493,18 @@ static bool dominates(InstrPosIndexes &PosIndexes, const MachineInstr &A,
493
493
return IndexA < IndexB;
494
494
}
495
495
496
- bool RegAllocFastImpl::isInlineAsmBrSpill (const MachineInstr &MI) const {
496
+ // / Returns true if \p MI is a spill of a live-in physical register in a block
497
+ // / targeted by an INLINEASM_BR. Such spills must precede reloads of live-in
498
+ // / virtual registers, so that we do not reload from an uninitialized stack
499
+ // / slot.
500
+ bool RegAllocFastImpl::mayBeSpillFromInlineAsmBr (const MachineInstr &MI) const {
497
501
int FI;
498
502
auto *MBB = MI.getParent ();
499
503
if (MBB->isInlineAsmBrIndirectTarget () && TII->isStoreToStackSlot (MI, FI) &&
500
- MFI->isSpillSlotObjectIndex (FI)) {
504
+ MFI->isSpillSlotObjectIndex (FI))
501
505
for (const auto &Op : MI.operands ())
502
- if (Op.isReg () && any_of (MBB->liveins (), [&](const auto &RegP) {
503
- return Op.getReg () == RegP.PhysReg ;
504
- }))
506
+ if (Op.isReg () && MBB->isLiveIn (Op.getReg ()))
505
507
return true ;
506
- }
507
508
return false ;
508
509
}
509
510
@@ -665,7 +666,7 @@ MachineBasicBlock::iterator RegAllocFastImpl::getMBBBeginInsertionPoint(
665
666
}
666
667
667
668
// Skip prologues and inlineasm_br spills to place reloads afterwards.
668
- if (!TII->isBasicBlockPrologue (*I) && !isInlineAsmBrSpill (*I))
669
+ if (!TII->isBasicBlockPrologue (*I) && !mayBeSpillFromInlineAsmBr (*I))
669
670
break ;
670
671
671
672
// However if a prolog instruction reads a register that needs to be
@@ -752,7 +753,7 @@ bool RegAllocFastImpl::displacePhysReg(MachineInstr &MI, MCRegister PhysReg) {
752
753
assert (LRI != LiveVirtRegs.end () && " datastructures in sync" );
753
754
MachineBasicBlock::iterator ReloadBefore =
754
755
std::next ((MachineBasicBlock::iterator)MI.getIterator ());
755
- while (isInlineAsmBrSpill (*ReloadBefore))
756
+ while (mayBeSpillFromInlineAsmBr (*ReloadBefore))
756
757
++ReloadBefore;
757
758
reload (ReloadBefore, VirtReg, LRI->PhysReg );
758
759
0 commit comments