Skip to content

Commit 675ba5e

Browse files
alex-tkzhuravl
authored andcommitted
Revert "[AMDGPU] RA inserted scalar instructions can be at the BB top (llvm#72140)"
This reverts commit ce7fd49. Change-Id: Iafb1f24fad78c477d3168a69cd8f9ccde6bc5038
1 parent 53c4610 commit 675ba5e

File tree

8 files changed

+15
-32
lines changed

8 files changed

+15
-32
lines changed

llvm/include/llvm/CodeGen/MachineBasicBlock.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -846,10 +846,8 @@ class MachineBasicBlock
846846

847847
/// Return the first instruction in MBB after I that is not a PHI, label or
848848
/// debug. This is the correct point to insert copies at the beginning of a
849-
/// basic block. \p Reg is the register being used by a spill or defined for a
850-
/// restore/split during register allocation.
851-
iterator SkipPHIsLabelsAndDebug(iterator I, Register Reg = Register(),
852-
bool SkipPseudoOp = true);
849+
/// basic block.
850+
iterator SkipPHIsLabelsAndDebug(iterator I, bool SkipPseudoOp = true);
853851

854852
/// Returns an iterator to the first terminator instruction of this basic
855853
/// block. If a terminator does not exist, it returns end().

llvm/include/llvm/CodeGen/TargetInstrInfo.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,10 +2013,8 @@ class TargetInstrInfo : public MCInstrInfo {
20132013

20142014
/// True if the instruction is bound to the top of its basic block and no
20152015
/// other instructions shall be inserted before it. This can be implemented
2016-
/// to prevent register allocator to insert spills for \p Reg before such
2017-
/// instructions.
2018-
virtual bool isBasicBlockPrologue(const MachineInstr &MI,
2019-
Register Reg = Register()) const {
2016+
/// to prevent register allocator to insert spills before such instructions.
2017+
virtual bool isBasicBlockPrologue(const MachineInstr &MI) const {
20202018
return false;
20212019
}
20222020

llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,7 @@ class StatepointState {
461461

462462
if (EHPad && !RC.hasReload(Reg, RegToSlotIdx[Reg], EHPad)) {
463463
RC.recordReload(Reg, RegToSlotIdx[Reg], EHPad);
464-
auto EHPadInsertPoint =
465-
EHPad->SkipPHIsLabelsAndDebug(EHPad->begin(), Reg);
464+
auto EHPadInsertPoint = EHPad->SkipPHIsLabelsAndDebug(EHPad->begin());
466465
insertReloadBefore(Reg, EHPadInsertPoint, EHPad);
467466
LLVM_DEBUG(dbgs() << "...also reload at EHPad "
468467
<< printMBBReference(*EHPad) << "\n");

llvm/lib/CodeGen/InlineSpiller.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ bool InlineSpiller::hoistSpillInsideBB(LiveInterval &SpillLI,
463463
MachineBasicBlock *MBB = LIS.getMBBFromIndex(SrcVNI->def);
464464
MachineBasicBlock::iterator MII;
465465
if (SrcVNI->isPHIDef())
466-
MII = MBB->SkipPHIsLabelsAndDebug(MBB->begin(), SrcReg);
466+
MII = MBB->SkipPHIsLabelsAndDebug(MBB->begin());
467467
else {
468468
MachineInstr *DefMI = LIS.getInstructionFromIndex(SrcVNI->def);
469469
assert(DefMI && "Defining instruction disappeared");

llvm/lib/CodeGen/MachineBasicBlock.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,13 @@ MachineBasicBlock::SkipPHIsAndLabels(MachineBasicBlock::iterator I) {
223223

224224
MachineBasicBlock::iterator
225225
MachineBasicBlock::SkipPHIsLabelsAndDebug(MachineBasicBlock::iterator I,
226-
Register Reg, bool SkipPseudoOp) {
226+
bool SkipPseudoOp) {
227227
const TargetInstrInfo *TII = getParent()->getSubtarget().getInstrInfo();
228228

229229
iterator E = end();
230230
while (I != E && (I->isPHI() || I->isPosition() || I->isDebugInstr() ||
231231
(SkipPseudoOp && I->isPseudoProbe()) ||
232-
TII->isBasicBlockPrologue(*I, Reg)))
232+
TII->isBasicBlockPrologue(*I)))
233233
++I;
234234
// FIXME: This needs to change if we wish to bundle labels / dbg_values
235235
// inside the bundle.

llvm/lib/CodeGen/SplitKit.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -807,10 +807,8 @@ SlotIndex SplitEditor::leaveIntvAtTop(MachineBasicBlock &MBB) {
807807
return Start;
808808
}
809809

810-
unsigned RegIdx = 0;
811-
Register Reg = LIS.getInterval(Edit->get(RegIdx)).reg();
812-
VNInfo *VNI = defFromParent(RegIdx, ParentVNI, Start, MBB,
813-
MBB.SkipPHIsLabelsAndDebug(MBB.begin(), Reg));
810+
VNInfo *VNI = defFromParent(0, ParentVNI, Start, MBB,
811+
MBB.SkipPHIsLabelsAndDebug(MBB.begin()));
814812
RegAssign.insert(Start, VNI->def, OpenIdx);
815813
LLVM_DEBUG(dump());
816814
return VNI->def;

llvm/lib/Target/AMDGPU/SIInstrInfo.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8918,25 +8918,16 @@ unsigned SIInstrInfo::getLiveRangeSplitOpcode(Register SrcReg,
89188918
return AMDGPU::COPY;
89198919
}
89208920

8921-
bool SIInstrInfo::isBasicBlockPrologue(const MachineInstr &MI,
8922-
Register Reg) const {
8921+
bool SIInstrInfo::isBasicBlockPrologue(const MachineInstr &MI) const {
89238922
// We need to handle instructions which may be inserted during register
89248923
// allocation to handle the prolog. The initial prolog instruction may have
89258924
// been separated from the start of the block by spills and copies inserted
8926-
// needed by the prolog. However, the insertions for scalar registers can
8927-
// always be placed at the BB top as they are independent of the exec mask
8928-
// value.
8929-
bool IsNullOrVectorRegister = true;
8930-
if (Reg) {
8931-
const MachineRegisterInfo &MRI = MI.getParent()->getParent()->getRegInfo();
8932-
IsNullOrVectorRegister = !RI.isSGPRClass(RI.getRegClassForReg(MRI, Reg));
8933-
}
8934-
8925+
// needed by the prolog.
89358926
uint16_t Opc = MI.getOpcode();
8927+
89368928
// FIXME: Copies inserted in the block prolog for live-range split should also
89378929
// be included.
8938-
return IsNullOrVectorRegister &&
8939-
(isSpillOpcode(Opc) || (!MI.isTerminator() && Opc != AMDGPU::COPY &&
8930+
return (isSpillOpcode(Opc) || (!MI.isTerminator() && Opc != AMDGPU::COPY &&
89408931
MI.modifiesRegister(AMDGPU::EXEC, &RI)));
89418932
}
89428933

llvm/lib/Target/AMDGPU/SIInstrInfo.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,8 +1283,7 @@ class SIInstrInfo final : public AMDGPUGenInstrInfo {
12831283
unsigned getLiveRangeSplitOpcode(Register Reg,
12841284
const MachineFunction &MF) const override;
12851285

1286-
bool isBasicBlockPrologue(const MachineInstr &MI,
1287-
Register Reg = Register()) const override;
1286+
bool isBasicBlockPrologue(const MachineInstr &MI) const override;
12881287

12891288
MachineInstr *createPHIDestinationCopy(MachineBasicBlock &MBB,
12901289
MachineBasicBlock::iterator InsPt,

0 commit comments

Comments
 (0)