Skip to content

Commit 9df9f61

Browse files
s-barannikovgithub-actions[bot]
authored andcommitted
Automerge: [CodeGen] Use VirtRegOrUnit/MCRegUnit in MachineTraceMetrics (NFC) (#167859)
2 parents 540ecd2 + 0b5f388 commit 9df9f61

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

llvm/include/llvm/CodeGen/MachineTraceMetrics.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ class TargetRegisterInfo;
7373
// direction instructions are scanned, it could be the operand that defined the
7474
// regunit, or the highest operand to read the regunit.
7575
struct LiveRegUnit {
76-
unsigned RegUnit;
76+
MCRegUnit RegUnit;
7777
unsigned Cycle = 0;
7878
const MachineInstr *MI = nullptr;
7979
unsigned Op = 0;
8080

8181
unsigned getSparseSetIndex() const { return RegUnit; }
8282

83-
LiveRegUnit(unsigned RU) : RegUnit(RU) {}
83+
explicit LiveRegUnit(MCRegUnit RU) : RegUnit(RU) {}
8484
};
8585

8686
using LiveRegUnitSet = SparseSet<LiveRegUnit>;
@@ -158,13 +158,14 @@ class MachineTraceMetrics {
158158
/// successors.
159159
struct LiveInReg {
160160
/// The virtual register required, or a register unit.
161-
Register Reg;
161+
VirtRegOrUnit VRegOrUnit;
162162

163163
/// For virtual registers: Minimum height of the defining instruction.
164164
/// For regunits: Height of the highest user in the trace.
165165
unsigned Height;
166166

167-
LiveInReg(Register Reg, unsigned Height = 0) : Reg(Reg), Height(Height) {}
167+
explicit LiveInReg(VirtRegOrUnit VRegOrUnit, unsigned Height = 0)
168+
: VRegOrUnit(VRegOrUnit), Height(Height) {}
168169
};
169170

170171
/// Per-basic block information that relates to a specific trace through the

llvm/lib/CodeGen/MachineTraceMetrics.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -800,9 +800,10 @@ computeCrossBlockCriticalPath(const TraceBlockInfo &TBI) {
800800
assert(TBI.HasValidInstrHeights && "Missing height info");
801801
unsigned MaxLen = 0;
802802
for (const LiveInReg &LIR : TBI.LiveIns) {
803-
if (!LIR.Reg.isVirtual())
803+
if (!LIR.VRegOrUnit.isVirtualReg())
804804
continue;
805-
const MachineInstr *DefMI = MTM.MRI->getVRegDef(LIR.Reg);
805+
const MachineInstr *DefMI =
806+
MTM.MRI->getVRegDef(LIR.VRegOrUnit.asVirtualReg());
806807
// Ignore dependencies outside the current trace.
807808
const TraceBlockInfo &DefTBI = BlockInfo[DefMI->getParent()->getNumber()];
808809
if (!DefTBI.isUsefulDominator(TBI))
@@ -1019,7 +1020,7 @@ addLiveIns(const MachineInstr *DefMI, unsigned DefOp,
10191020
return;
10201021
TraceBlockInfo &TBI = BlockInfo[MBB->getNumber()];
10211022
// Just add the register. The height will be updated later.
1022-
TBI.LiveIns.push_back(Reg);
1023+
TBI.LiveIns.emplace_back(VirtRegOrUnit(Reg));
10231024
}
10241025
}
10251026

@@ -1056,15 +1057,16 @@ computeInstrHeights(const MachineBasicBlock *MBB) {
10561057
if (MBB) {
10571058
TraceBlockInfo &TBI = BlockInfo[MBB->getNumber()];
10581059
for (LiveInReg &LI : TBI.LiveIns) {
1059-
if (LI.Reg.isVirtual()) {
1060+
if (LI.VRegOrUnit.isVirtualReg()) {
10601061
// For virtual registers, the def latency is included.
1061-
unsigned &Height = Heights[MTM.MRI->getVRegDef(LI.Reg)];
1062+
unsigned &Height =
1063+
Heights[MTM.MRI->getVRegDef(LI.VRegOrUnit.asVirtualReg())];
10621064
if (Height < LI.Height)
10631065
Height = LI.Height;
10641066
} else {
10651067
// For register units, the def latency is not included because we don't
10661068
// know the def yet.
1067-
RegUnits[LI.Reg.id()].Cycle = LI.Height;
1069+
RegUnits[LI.VRegOrUnit.asMCRegUnit()].Cycle = LI.Height;
10681070
}
10691071
}
10701072
}
@@ -1159,14 +1161,15 @@ computeInstrHeights(const MachineBasicBlock *MBB) {
11591161
// height because the final height isn't known until now.
11601162
LLVM_DEBUG(dbgs() << printMBBReference(*MBB) << " Live-ins:");
11611163
for (LiveInReg &LIR : TBI.LiveIns) {
1162-
const MachineInstr *DefMI = MTM.MRI->getVRegDef(LIR.Reg);
1164+
Register Reg = LIR.VRegOrUnit.asVirtualReg();
1165+
const MachineInstr *DefMI = MTM.MRI->getVRegDef(Reg);
11631166
LIR.Height = Heights.lookup(DefMI);
1164-
LLVM_DEBUG(dbgs() << ' ' << printReg(LIR.Reg) << '@' << LIR.Height);
1167+
LLVM_DEBUG(dbgs() << ' ' << printReg(Reg) << '@' << LIR.Height);
11651168
}
11661169

11671170
// Transfer the live regunits to the live-in list.
11681171
for (const LiveRegUnit &RU : RegUnits) {
1169-
TBI.LiveIns.push_back(LiveInReg(RU.RegUnit, RU.Cycle));
1172+
TBI.LiveIns.emplace_back(VirtRegOrUnit(RU.RegUnit), RU.Cycle);
11701173
LLVM_DEBUG(dbgs() << ' ' << printRegUnit(RU.RegUnit, MTM.TRI) << '@'
11711174
<< RU.Cycle);
11721175
}

0 commit comments

Comments
 (0)