Skip to content

[BOLT] Emit intra-function control flow in YAMLBAT #76911

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

Conversation

aaupov
Copy link
Contributor

@aaupov aaupov commented Jan 4, 2024

Attach branch counters to YAML profile, covering intra-function control
flow.

Depends on: #86353

Test Plan: Updated bolt/test/X86/bolt-address-translation-yaml.test

aaupov added 16 commits January 3, 2024 21:25
Created using spr 1.3.4
Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
aaupov added a commit that referenced this pull request Mar 21, 2024
Relax assumptions that YAML output is not supported in BAT mode.
Set up basic infrastructure for emitting YAML for functions not covered
by BAT, such as from `.bolt.org.text` section (code identical to input binary
sans external refs), or non-rewritten functions in non-relocation mode (where
the function stays in the same section but BAT mapping is not emitted).

This diff only produces YAML profile for non-BAT functions (skipped,
non-simple). YAML profile for BAT functions is added in follow-up diffs:
- #76911 emits YAML profile with
  internal control flow information only (branch profile),
- #76896 adds cross-function profile
  (calls profile).

Test Plan: Added bolt/test/X86/bolt-address-translation-yaml.test

Reviewers: ayermolo, dcci, maksfb, rafaelauler

Reviewed By: rafaelauler

Pull Request: #76910
aaupov and others added 2 commits March 21, 2024 16:37
Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
using BBHashMap = std::map<uint32_t, std::pair<unsigned, size_t>>;
/// Return a mapping from basic block input offset to hash and block index for a given function.
const BBHashMap &getBBHashMap(uint64_t OutputAddress) const {
return FuncHashes.at(OutputAddress).second;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized you used "at" a number of times now in this stack of diffs. Isn't this supposed to throw exceptions? Isn't LLVM codebase exception free?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing out. You're right, it does throw an exception: https://en.cppreference.com/w/cpp/container/map/at

I had code with find and assert but switched to at for conciseness. Let me unwind that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in #86353. Will rebase this and follow-up diffs shortly.

Copy link
Contributor

@rafaelauler rafaelauler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG

chencha3 pushed a commit to chencha3/llvm-project that referenced this pull request Mar 23, 2024
Relax assumptions that YAML output is not supported in BAT mode.
Set up basic infrastructure for emitting YAML for functions not covered
by BAT, such as from `.bolt.org.text` section (code identical to input binary
sans external refs), or non-rewritten functions in non-relocation mode (where
the function stays in the same section but BAT mapping is not emitted).

This diff only produces YAML profile for non-BAT functions (skipped,
non-simple). YAML profile for BAT functions is added in follow-up diffs:
- llvm#76911 emits YAML profile with
  internal control flow information only (branch profile),
- llvm#76896 adds cross-function profile
  (calls profile).

Test Plan: Added bolt/test/X86/bolt-address-translation-yaml.test

Reviewers: ayermolo, dcci, maksfb, rafaelauler

Reviewed By: rafaelauler

Pull Request: llvm#76910
aaupov and others added 2 commits March 23, 2024 16:13
Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
@aaupov aaupov changed the base branch from users/aaupov/spr/main.bolt-emit-intra-function-control-flow-in-yamlbat to main March 24, 2024 02:11
@aaupov aaupov merged commit d7d2f7c into main Mar 24, 2024
@aaupov aaupov deleted the users/aaupov/spr/bolt-emit-intra-function-control-flow-in-yamlbat branch March 24, 2024 02:11
aaupov added a commit that referenced this pull request Mar 25, 2024
Provide secondary entry points for `EntryDiscriminator` call info field
in YAML profile.

Increases BAT section size to:
- large binary: 39655300 bytes (1.03x the original),
- medium binary: 3834328 bytes (0.65x),
- small binary: 924 bytes (0.64x).

Depends on: #76911

Test Plan:
- Updated bolt-address-translation{,-yaml}.test
- Added openssl test: rafaelauler/bolt-tests#30

Reviewers: dcci, rafaelauler, maksfb, ayermolo

Reviewed By: rafaelauler

Pull Request: #86218
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants