-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[PseudoProbe] Make probe discriminator compatible with dwarf base discriminator #94506
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,26 +44,52 @@ struct PseudoProbeDwarfDiscriminator { | |
// 32-bit integer which is organized as: | ||
// [2:0] - 0x7, this is reserved for regular discriminator, | ||
// see DWARF discriminator encoding rule | ||
// [18:3] - probe id | ||
// if the [28:28] bit is zero: | ||
// [18:3] for probe id. | ||
// else: | ||
// [15:3] for probe id, [18:16] for dwarf base discriminator. | ||
// [25:19] - probe distribution factor | ||
// [28:26] - probe type, see PseudoProbeType | ||
// [31:29] - reserved for probe attributes | ||
// [27:26] - probe type, see PseudoProbeType | ||
// [28:28] - indicates whether dwarf base discriminator is encoded. | ||
// [30:29] - reserved for probe attributes | ||
static uint32_t packProbeData(uint32_t Index, uint32_t Type, uint32_t Flags, | ||
uint32_t Factor) { | ||
uint32_t Factor, | ||
uint32_t DwarfBaseDiscriminator) { | ||
assert(Index <= 0xFFFF && "Probe index too big to encode, exceeding 2^16"); | ||
assert(Type <= 0x7 && "Probe type too big to encode, exceeding 7"); | ||
assert(Type <= 0x3 && "Probe type too big to encode, exceeding 3"); | ||
assert(Flags <= 0x7); | ||
assert(Factor <= 100 && | ||
"Probe distribution factor too big to encode, exceeding 100"); | ||
return (Index << 3) | (Factor << 19) | (Type << 26) | 0x7; | ||
uint32_t V = (Index << 3) | (Factor << 19) | (Type << 26) | 0x7; | ||
// If both the probe id and dwarf base discriminator is small, the probe id | ||
// space is shared with the dwarf base discriminator, this is to make the | ||
// probe-based build to be compatible with the dwarf-based profile. Pack the | ||
// dwarf base discriminator into [18:16] and set the [28:28] bit. | ||
if (Index <= 0x1FFF && DwarfBaseDiscriminator <= 0x7) | ||
V |= (1 << 28) | (DwarfBaseDiscriminator << 16); | ||
return V; | ||
} | ||
|
||
static uint32_t extractProbeIndex(uint32_t Value) { | ||
if (isDwarfBaseDiscriminatorEncoded(Value)) | ||
return (Value >> 3) & 0x1FFF; | ||
return (Value >> 3) & 0xFFFF; | ||
} | ||
|
||
static uint32_t extractDwarfBaseDiscriminator(uint32_t Value) { | ||
if (isDwarfBaseDiscriminatorEncoded(Value)) | ||
return (Value >> 16) & 0x7; | ||
// Return an invalid value to indicate the dwarf base discriminator is not | ||
// encoded. | ||
return 0xFFFFFFFF; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we always expect There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just changed the return type to |
||
} | ||
|
||
static uint32_t isDwarfBaseDiscriminatorEncoded(uint32_t Value) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given this is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, fixed. |
||
return (Value >> 28) & 0x1; | ||
} | ||
|
||
static uint32_t extractProbeType(uint32_t Value) { | ||
return (Value >> 26) & 0x7; | ||
return (Value >> 26) & 0x3; | ||
} | ||
|
||
static uint32_t extractProbeAttributes(uint32_t Value) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove "to be"