Skip to content

Commit 11c617c

Browse files
committed
[LiveDebugValues] Add LocIndex::u32_{location,index}_t types for readability, NFC
This is per Adrian's suggestion in https://reviews.llvm.org/D80684.
1 parent 2ecaf93 commit 11c617c

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

llvm/lib/CodeGen/LiveDebugValues.cpp

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -138,24 +138,27 @@ using VarLocSet = CoalescingBitVector<uint64_t>;
138138
/// to find the open VarLocs killed by a register def very quickly. This is a
139139
/// performance-critical operation for LiveDebugValues.
140140
struct LocIndex {
141-
uint32_t Location; // Physical registers live in the range [1;2^30) (see
142-
// \ref MCRegister), so we have plenty of range left here
143-
// to encode non-register locations.
144-
uint32_t Index;
141+
using u32_location_t = uint32_t;
142+
using u32_index_t = uint32_t;
143+
144+
u32_location_t Location; // Physical registers live in the range [1;2^30) (see
145+
// \ref MCRegister), so we have plenty of range left
146+
// here to encode non-register locations.
147+
u32_index_t Index;
145148

146149
/// The first location greater than 0 that is not reserved for VarLocs of
147150
/// kind RegisterKind.
148-
static constexpr uint32_t kFirstInvalidRegLocation = 1 << 30;
151+
static constexpr u32_location_t kFirstInvalidRegLocation = 1 << 30;
149152

150153
/// A special location reserved for VarLocs of kind SpillLocKind.
151-
static constexpr uint32_t kSpillLocation = kFirstInvalidRegLocation;
154+
static constexpr u32_location_t kSpillLocation = kFirstInvalidRegLocation;
152155

153156
/// A special location reserved for VarLocs of kind EntryValueBackupKind and
154157
/// EntryValueCopyBackupKind.
155-
static constexpr uint32_t kEntryValueBackupLocation =
158+
static constexpr u32_location_t kEntryValueBackupLocation =
156159
kFirstInvalidRegLocation + 1;
157160

158-
LocIndex(uint32_t Location, uint32_t Index)
161+
LocIndex(u32_location_t Location, u32_index_t Index)
159162
: Location(Location), Index(Index) {}
160163

161164
uint64_t getAsRawInteger() const {
@@ -166,7 +169,8 @@ struct LocIndex {
166169
static_assert(std::is_unsigned<IntT>::value &&
167170
sizeof(ID) == sizeof(uint64_t),
168171
"Cannot convert raw integer to LocIndex");
169-
return {static_cast<uint32_t>(ID >> 32), static_cast<uint32_t>(ID)};
172+
return {static_cast<u32_location_t>(ID >> 32),
173+
static_cast<u32_index_t>(ID)};
170174
}
171175

172176
/// Get the start of the interval reserved for VarLocs of kind RegisterKind
@@ -177,7 +181,8 @@ struct LocIndex {
177181

178182
/// Return a range covering all set indices in the interval reserved for
179183
/// \p Location in \p Set.
180-
static auto indexRangeForLocation(const VarLocSet &Set, uint32_t Location) {
184+
static auto indexRangeForLocation(const VarLocSet &Set,
185+
u32_location_t Location) {
181186
uint64_t Start = LocIndex(Location, 0).getAsRawInteger();
182187
uint64_t End = LocIndex(Location + 1, 0).getAsRawInteger();
183188
return Set.half_open_range(Start, End);
@@ -490,14 +495,14 @@ class LiveDebugValues : public MachineFunctionPass {
490495
class VarLocMap {
491496
/// Map a VarLoc to an index within the vector reserved for its location
492497
/// within Loc2Vars.
493-
std::map<VarLoc, uint32_t> Var2Index;
498+
std::map<VarLoc, LocIndex::u32_index_t> Var2Index;
494499

495500
/// Map a location to a vector which holds VarLocs which live in that
496501
/// location.
497-
SmallDenseMap<uint32_t, std::vector<VarLoc>> Loc2Vars;
502+
SmallDenseMap<LocIndex::u32_location_t, std::vector<VarLoc>> Loc2Vars;
498503

499504
/// Determine the 32-bit location reserved for \p VL, based on its kind.
500-
static uint32_t getLocationForVar(const VarLoc &VL) {
505+
static LocIndex::u32_location_t getLocationForVar(const VarLoc &VL) {
501506
switch (VL.Kind) {
502507
case VarLoc::RegisterKind:
503508
assert((VL.Loc.RegNo < LocIndex::kFirstInvalidRegLocation) &&
@@ -516,8 +521,8 @@ class LiveDebugValues : public MachineFunctionPass {
516521
public:
517522
/// Retrieve a unique LocIndex for \p VL.
518523
LocIndex insert(const VarLoc &VL) {
519-
uint32_t Location = getLocationForVar(VL);
520-
uint32_t &Index = Var2Index[VL];
524+
LocIndex::u32_location_t Location = getLocationForVar(VL);
525+
LocIndex::u32_index_t &Index = Var2Index[VL];
521526
if (!Index) {
522527
auto &Vars = Loc2Vars[Location];
523528
Vars.push_back(VL);

0 commit comments

Comments
 (0)