-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[llvm][AsmPrinter] Call graph section format. #159866
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 4 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
3c805fd
Callgraph section format changes.
Prabhuk 6af8347
Fix tests.
Prabhuk 0ed5829
Update tests.
Prabhuk 7260b40
Fix size of direct callee count in tests.
Prabhuk b22ff59
More layout changes.
Prabhuk 7096aa4
Merge remote-tracking branch 'upstream/main' into callgraph_layout
Prabhuk 1676b4a
Fix tests to match new callgraph layout.
Prabhuk fa0dd18
Remove unnecessary comment.
Prabhuk 3fcec5a
Remove unnecessary newlines.
Prabhuk bf00b25
Add doc file to toctree
Prabhuk 6d0e8d3
Reorder toc tree to be alphabetical.
Prabhuk 90265cc
Fix formatting of inline comment.
Prabhuk 632cbbe
Make counts ULEB128. Omit count fields using Flags if they are zero.
Prabhuk 7df84eb
Merge remote-tracking branch 'upstream/main' into callgraph_layout
Prabhuk 4dffc8a
Reorder fields in callgraph section.
Prabhuk e399ae1
Add 32 bit tests.
Prabhuk 528c063
Address review comments.
Prabhuk 229e9d0
Add test for internal linkage with address taken regresstion test whi…
Prabhuk 4142fa7
Fix tests.
Prabhuk 2ef8845
Use llvm bitmask enum validation for flags.
Prabhuk 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# .callgraph Section Layout | ||
|
||
The `.callgraph` section is used to store call graph information for each function, which can be used for post-link analyses and optimizations. The section contains a series of records, with each record corresponding to a single function. | ||
|
||
For efficiency, we make a distinction between direct and indirect call data. For direct calls, we record the unique callees, not the location of each individual call. For indirect calls, we record the location of each call site and the type ID of the callee. Post link analysis scripts which utilize this information to reconstuct the program call graph can potentially receive more information regarding indirect callsites from the user to improve the precision of the call graph. | ||
Prabhuk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
## Per Function Record Layout | ||
|
||
Each record in the `.callgraph` section has the following binary layout: | ||
|
||
| Field | Type | Size (bits) | Description | | ||
| ---------------------------- | ------------- | ----------- | ------------------------------------------------------------------------------------------------------- | | ||
| Format Version | `uint32_t` | 32 | The version of the record format. The current version is 0. | | ||
| Function Entry PC | `uintptr_t` | 32/64 | The address of the function's entry point. | | ||
| Function Kind | `uint8_t` | 8 | An enum indicating the function's properties (e.g., if it's an indirect call target). | | ||
| Function Type ID | `uint64_t` | 64 | The type ID of the function. This field is **only** present if `Function Kind` is `INDIRECT_TARGET_KNOWN_TID`. | | ||
ilovepi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Number of Indirect Callsites | `uint32_t` | 32 | The number of indirect call sites within the function. | | ||
| Indirect Callsites Array | `Callsite[]` | Variable | An array of `Callsite` records, with a length of `Number of Indirect Callsites`. | | ||
| Number of Unique Direct Callees | `uint32_t` | 32 | The number of unique direct call destinations from this function. | | ||
| Direct Callees Array | `uintptr_t[]` | Variable | An array of unique direct callee entry point addresses, with a length of `Number of Direct Callees`. | | ||
|
||
### Indirect Callsite Record Layout | ||
|
||
Each record in the `Indirect Callsites Array` has the following layout: | ||
|
||
| Field | Type | Size (bits) | Description | | ||
| ----------------- | ----------- | ----------- | ----------------------------------------- | | ||
| Type ID | `uint64_t` | 64 | The type ID of the indirect call target. | | ||
| Callsite PC | `uintptr_t` | 32/64 | The address of the indirect call site. | |
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.
Uh oh!
There was an error while loading. Please reload this page.