Skip to content

[BOLT][NFCI] Use heuristic for matching split global functions #90429

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

Conversation

aaupov
Copy link
Contributor

@aaupov aaupov commented Apr 29, 2024

This change speeds up fragment matching for large BOLTed binaries where
all fragments of global parent functions are put under bolt-pseudo.o
file symbol:

  • before: iterating over symbols under bolt-pseudo.o only to fail
    to find a parent,
  • after: bail out immediately and use a global parent by name.

Test Plan: NFC, updated register-fragments-bolt-symbols.s

aaupov added 2 commits April 28, 2024 21:04
Created using spr 1.3.5
@llvmbot
Copy link
Member

llvmbot commented Apr 29, 2024

@llvm/pr-subscribers-llvm-binary-utilities

@llvm/pr-subscribers-bolt

Author: Amir Ayupov (aaupov)

Changes

There should be no functional change, only faster fragment matching for
large BOLTed binaries where all fragments of global parent functions
are put under bolt-pseudo.o file symbol.

Test Plan: NFC


Full diff: https://github.com/llvm/llvm-project/pull/90429.diff

1 Files Affected:

  • (modified) bolt/lib/Rewrite/RewriteInstance.cpp (+5)
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index 8eb2e5a9d9120a..d92775e16b7cf1 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -1511,6 +1511,11 @@ void RewriteInstance::registerFragments() {
 
     uint64_t ParentAddress{0};
 
+    // Check if containing FILE symbol is BOLT emitted synthetic symbol marking
+    // local fragments of global parents.
+    if (cantFail(FSI[-1].getName()) == getBOLTFileSymbolName())
+      goto registerParent;
+
     // BOLT split fragment symbols are emitted just before the main function
     // symbol.
     for (ELFSymbolRef NextSymbol = Symbol; NextSymbol < StopSymbol;

aaupov added 2 commits April 29, 2024 16:27
Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
@aaupov aaupov changed the base branch from users/spr/aaupov/main.boltnfci-use-heuristic-for-matching-split-global-functions to main May 8, 2024 20:53
@aaupov aaupov force-pushed the users/spr/aaupov/boltnfci-use-heuristic-for-matching-split-global-functions branch from f94b275 to 72bf9f9 Compare May 8, 2024 20:59
@aaupov aaupov changed the base branch from main to users/spr/aaupov/main.boltnfci-use-heuristic-for-matching-split-global-functions May 8, 2024 21:00
@aaupov aaupov changed the base branch from users/spr/aaupov/main.boltnfci-use-heuristic-for-matching-split-global-functions to main May 24, 2024 21:38
@aaupov aaupov changed the base branch from main to users/spr/aaupov/main.boltnfci-use-heuristic-for-matching-split-global-functions May 24, 2024 21:38
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.

lgtm

topperc and others added 2 commits June 20, 2025 10:57
Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
@aaupov aaupov changed the base branch from users/spr/aaupov/main.boltnfci-use-heuristic-for-matching-split-global-functions to main June 20, 2025 17:58
Created using spr 1.3.4
@aaupov aaupov merged commit 4959e8a into main Jun 20, 2025
7 checks passed
@aaupov aaupov deleted the users/spr/aaupov/boltnfci-use-heuristic-for-matching-split-global-functions branch June 20, 2025 19:46
Jaddyen pushed a commit to Jaddyen/llvm-project that referenced this pull request Jun 23, 2025
…90429)

This change speeds up fragment matching for large BOLTed binaries where
all fragments of global parent functions are put under `bolt-pseudo.o`
file symbol:
- before: iterating over symbols under `bolt-pseudo.o` only to fail
  to find a parent,
- after: bail out immediately and use a global parent by name.

Test Plan: NFC, updated register-fragments-bolt-symbols.s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants