Skip to content

Commit 0388ab3

Browse files
authored
[Statepoint][NFC] Use uint16_t and add an assert (#78717)
Use a fixed width integer type and assert that DwarRegNum fits the 16 bits. This is a follow up to review comments on #78600.
1 parent 5954b9d commit 0388ab3

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

llvm/include/llvm/CodeGen/StackMaps.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ class StatepointOpers {
259259
class StackMaps {
260260
public:
261261
struct Location {
262-
enum LocationType : unsigned short {
262+
enum LocationType : uint16_t {
263263
Unprocessed,
264264
Register,
265265
Direct,
@@ -268,24 +268,22 @@ class StackMaps {
268268
ConstantIndex
269269
};
270270
LocationType Type = Unprocessed;
271-
unsigned short Size = 0;
272-
unsigned short Reg = 0;
271+
uint16_t Size = 0;
272+
uint16_t Reg = 0;
273273
int32_t Offset = 0;
274274

275275
Location() = default;
276-
Location(LocationType Type, unsigned short Size, unsigned short Reg,
277-
int32_t Offset)
276+
Location(LocationType Type, uint16_t Size, uint16_t Reg, int32_t Offset)
278277
: Type(Type), Size(Size), Reg(Reg), Offset(Offset) {}
279278
};
280279

281280
struct LiveOutReg {
282-
unsigned short Reg = 0;
283-
unsigned short DwarfRegNum = 0;
284-
unsigned short Size = 0;
281+
uint16_t Reg = 0;
282+
uint16_t DwarfRegNum = 0;
283+
uint16_t Size = 0;
285284

286285
LiveOutReg() = default;
287-
LiveOutReg(unsigned short Reg, unsigned short DwarfRegNum,
288-
unsigned short Size)
286+
LiveOutReg(uint16_t Reg, uint16_t DwarfRegNum, uint16_t Size)
289287
: Reg(Reg), DwarfRegNum(DwarfRegNum), Size(Size) {}
290288
};
291289

llvm/lib/CodeGen/StackMaps.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ static unsigned getDwarfRegNum(unsigned Reg, const TargetRegisterInfo *TRI) {
200200
break;
201201
}
202202

203-
assert(RegNum >= 0 && "Invalid Dwarf register number.");
203+
assert(RegNum >= 0 && isUInt<16>(RegNum) && "Invalid Dwarf register number.");
204204
return (unsigned)RegNum;
205205
}
206206

0 commit comments

Comments
 (0)