Skip to content

Conversation

@melver
Copy link
Contributor

@melver melver commented Nov 23, 2025

The AllocToken pass was running in the Pre-Link pipeline, which caused a
conflict with PGHO in ThinLTO builds because AllocToken rewrites
allocations (e.g. _Znam -> __alloc_token__Znam) before PGHO can see
it in the backend, preventing optimization.

Defer the execution of AllocTokenPass to the LTO Backend (Post-Link)
when ThinLTO is enabled by:

  1. Adding a PassBuilderCallback hook to lto::Config and invoking it
    in LTOBackend.cpp.

  2. Using this hook in BackendUtil.cpp to register AllocTokenPass
    into the LTO backend pipeline via registerOptimizerLastEPCallback.

  3. Skipping AllocTokenPass in the Pre-Link phase if
    PrepareForThinLTO is set.

This ensures PGHO optimization (in InstCombine) runs first in the
backend, followed by AllocToken instrumentation on hot/cold new.

Created using spr 1.3.8-beta.1
@melver melver changed the title [Clang][LTO] Wire up AllocToken pass to run in LTO backend [Clang][ThinLTO] Wire up AllocToken pass to run in ThinLTO backend Nov 23, 2025
@github-actions
Copy link

github-actions bot commented Nov 23, 2025

🐧 Linux x64 Test Results

  • 192893 tests passed
  • 6194 tests skipped

Created using spr 1.3.8-beta.1
@melver
Copy link
Contributor Author

melver commented Nov 24, 2025

Superseded by #169360

@melver melver closed this Nov 24, 2025
@melver melver deleted the users/melver/spr/clanglto-wire-up-alloctoken-pass-to-run-in-lto-backend branch November 24, 2025 16:41
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