https://github.com/melver created https://github.com/llvm/llvm-project/pull/169244
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. _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
