Skip to content

Commit e751be3

Browse files
author
git apple-llvm automerger
committed
Merge commit '5eef98ba319a' from llvm.org/main into next
2 parents 654fa1b + 5eef98b commit e751be3

File tree

4 files changed

+27
-18
lines changed

4 files changed

+27
-18
lines changed

llvm/include/llvm/CodeGen/SlotIndexes.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,16 +467,27 @@ class raw_ostream;
467467
return getMBBRange(mbb).first;
468468
}
469469

470-
/// Returns the last index in the given basic block number.
470+
/// Returns the index past the last valid index in the given basic block.
471471
SlotIndex getMBBEndIdx(unsigned Num) const {
472472
return getMBBRange(Num).second;
473473
}
474474

475-
/// Returns the last index in the given basic block.
475+
/// Returns the index past the last valid index in the given basic block.
476476
SlotIndex getMBBEndIdx(const MachineBasicBlock *mbb) const {
477477
return getMBBRange(mbb).second;
478478
}
479479

480+
/// Returns the last valid index in the given basic block.
481+
/// This index corresponds to the dead slot of the last non-debug
482+
/// instruction and can be used to find live-out ranges of the block. Note
483+
/// that getMBBEndIdx returns the start index of the next block, which is
484+
/// also used as the start index for segments with phi-def values. If the
485+
/// basic block doesn't contain any non-debug instructions, this returns
486+
/// the same as getMBBStartIdx.getDeadSlot().
487+
SlotIndex getMBBLastIdx(const MachineBasicBlock *MBB) const {
488+
return getMBBEndIdx(MBB).getPrevSlot();
489+
}
490+
480491
/// Iterator over the idx2MBBMap (sorted pairs of slot index of basic block
481492
/// begin and basic block)
482493
using MBBIndexIterator = SmallVectorImpl<IdxMBBPair>::const_iterator;

llvm/lib/Target/AMDGPU/GCNRegPressure.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ bool GCNRegPressurePrinter::runOnMachineFunction(MachineFunction &MF) {
905905
OS << ":\n";
906906

907907
SlotIndex MBBStartSlot = LIS.getSlotIndexes()->getMBBStartIdx(&MBB);
908-
SlotIndex MBBEndSlot = LIS.getSlotIndexes()->getMBBEndIdx(&MBB);
908+
SlotIndex MBBLastSlot = LIS.getSlotIndexes()->getMBBLastIdx(&MBB);
909909

910910
GCNRPTracker::LiveRegSet LiveIn, LiveOut;
911911
GCNRegPressure RPAtMBBEnd;
@@ -931,7 +931,7 @@ bool GCNRegPressurePrinter::runOnMachineFunction(MachineFunction &MF) {
931931
}
932932
} else {
933933
GCNUpwardRPTracker RPT(LIS);
934-
RPT.reset(MRI, MBBEndSlot);
934+
RPT.reset(MRI, MBBLastSlot);
935935

936936
LiveOut = RPT.getLiveRegs();
937937
RPAtMBBEnd = RPT.getPressure();
@@ -966,14 +966,14 @@ bool GCNRegPressurePrinter::runOnMachineFunction(MachineFunction &MF) {
966966

967967
OS << PFX " Live-out:" << llvm::print(LiveOut, MRI);
968968
if (UseDownwardTracker)
969-
ReportLISMismatchIfAny(LiveOut, getLiveRegs(MBBEndSlot, LIS, MRI));
969+
ReportLISMismatchIfAny(LiveOut, getLiveRegs(MBBLastSlot, LIS, MRI));
970970

971971
GCNRPTracker::LiveRegSet LiveThrough;
972972
for (auto [Reg, Mask] : LiveIn) {
973973
LaneBitmask MaskIntersection = Mask & LiveOut.lookup(Reg);
974974
if (MaskIntersection.any()) {
975975
LaneBitmask LTMask = getRegLiveThroughMask(
976-
MRI, LIS, Reg, MBBStartSlot, MBBEndSlot, MaskIntersection);
976+
MRI, LIS, Reg, MBBStartSlot, MBBLastSlot, MaskIntersection);
977977
if (LTMask.any())
978978
LiveThrough[Reg] = LTMask;
979979
}

llvm/lib/Target/AMDGPU/GCNRegPressure.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ class GCNUpwardRPTracker : public GCNRPTracker {
313313

314314
/// reset tracker to the end of the \p MBB.
315315
void reset(const MachineBasicBlock &MBB) {
316-
reset(MBB.getParent()->getRegInfo(),
317-
LIS.getSlotIndexes()->getMBBEndIdx(&MBB));
316+
SlotIndex MBBLastSlot = LIS.getSlotIndexes()->getMBBLastIdx(&MBB);
317+
reset(MBB.getParent()->getRegInfo(), MBBLastSlot);
318318
}
319319

320320
/// reset tracker to the point just after \p MI (in program order).

llvm/test/CodeGen/AMDGPU/regpressure_printer.mir

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -510,14 +510,14 @@ body: |
510510
; RPU-NEXT: 0 0 $sgpr0 = S_BUFFER_LOAD_DWORD_IMM $sgpr0_sgpr1_sgpr2_sgpr3, 0, 0
511511
; RPU-NEXT: 0 0
512512
; RPU-NEXT: 0 1 undef %0.sub5:vreg_512 = V_MOV_B32_e32 5, implicit $exec
513-
; RPU-NEXT: 0 0
514-
; RPU-NEXT: 0 0 S_CMP_GT_U32 $sgpr0, 15, implicit-def $scc
515-
; RPU-NEXT: 0 0
516-
; RPU-NEXT: 0 0 S_CBRANCH_SCC1 %bb.2, implicit $scc
517-
; RPU-NEXT: 0 0
518-
; RPU-NEXT: 0 0 S_BRANCH %bb.1
519-
; RPU-NEXT: 0 0
520-
; RPU-NEXT: Live-out:
513+
; RPU-NEXT: 0 1
514+
; RPU-NEXT: 0 1 S_CMP_GT_U32 $sgpr0, 15, implicit-def $scc
515+
; RPU-NEXT: 0 1
516+
; RPU-NEXT: 0 1 S_CBRANCH_SCC1 %bb.2, implicit $scc
517+
; RPU-NEXT: 0 1
518+
; RPU-NEXT: 0 1 S_BRANCH %bb.1
519+
; RPU-NEXT: 0 1
520+
; RPU-NEXT: Live-out: %0:0000000000000C00
521521
; RPU-NEXT: Live-thr:
522522
; RPU-NEXT: 0 0
523523
; RPU-NEXT: bb.1:
@@ -571,8 +571,6 @@ body: |
571571
; RPD-NEXT: 0 1 S_BRANCH %bb.1
572572
; RPD-NEXT: 0 1
573573
; RPD-NEXT: Live-out: %0:0000000000000C00
574-
; RPD-NEXT: mis LIS:
575-
; RPD-NEXT: %0:L0000000000000C00 isn't found in LIS reported set
576574
; RPD-NEXT: Live-thr:
577575
; RPD-NEXT: 0 0
578576
; RPD-NEXT: bb.1:

0 commit comments

Comments
 (0)