-
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,26 +44,51 @@ 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 | ||
static uint32_t packProbeData(uint32_t Index, uint32_t Type, uint32_t Flags, | ||
uint32_t Factor) { | ||
// [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, | ||
std::optional<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 && | ||
*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 std::optional<uint32_t> extractDwarfBaseDiscriminator(uint32_t Value) { | ||
if (isDwarfBaseDiscriminatorEncoded(Value)) | ||
return (Value >> 16) & 0x7; | ||
return std::nullopt; | ||
} | ||
|
||
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) { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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"