Skip to content

[Statepoint][NFC] Use uint16_t and add an assert #78717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions llvm/include/llvm/CodeGen/StackMaps.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class StatepointOpers {
class StackMaps {
public:
struct Location {
enum LocationType : unsigned short {
enum LocationType : uint16_t {
Unprocessed,
Register,
Direct,
Expand All @@ -268,24 +268,22 @@ class StackMaps {
ConstantIndex
};
LocationType Type = Unprocessed;
unsigned short Size = 0;
unsigned short Reg = 0;
uint16_t Size = 0;
uint16_t Reg = 0;
int32_t Offset = 0;

Location() = default;
Location(LocationType Type, unsigned short Size, unsigned short Reg,
int32_t Offset)
Location(LocationType Type, uint16_t Size, uint16_t Reg, int32_t Offset)
: Type(Type), Size(Size), Reg(Reg), Offset(Offset) {}
};

struct LiveOutReg {
unsigned short Reg = 0;
unsigned short DwarfRegNum = 0;
unsigned short Size = 0;
uint16_t Reg = 0;
uint16_t DwarfRegNum = 0;
uint16_t Size = 0;

LiveOutReg() = default;
LiveOutReg(unsigned short Reg, unsigned short DwarfRegNum,
unsigned short Size)
LiveOutReg(uint16_t Reg, uint16_t DwarfRegNum, uint16_t Size)
: Reg(Reg), DwarfRegNum(DwarfRegNum), Size(Size) {}
};

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/StackMaps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ static unsigned getDwarfRegNum(unsigned Reg, const TargetRegisterInfo *TRI) {
break;
}

assert(RegNum >= 0 && "Invalid Dwarf register number.");
assert(RegNum >= 0 && isUInt<16>(RegNum) && "Invalid Dwarf register number.");
return (unsigned)RegNum;
}

Expand Down