[clang] [KeyInstr] Enable -gkey-instructions by default if optimisations are enabled (PR #149509)

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 26 11:10:35 PDT 2025


rnk wrote:

Hi Orlando, I wanted to share that we detected a significant (~0.4%) `.text` size regression when building an internal binary with sample PGO (AFDO) and ThinLTO. My initial recommendation was to disable the feature with `-gno-key-instructions` to debug further, but this didn't appear to fully mitigate the regression.

I looked at the code in this PR, and it has special handling for IR inputs, and I suspect that the reason is that we're using LTO, which has two compilation actions: One with C(++) source inputs, one with IR inputs, and I assume we need to pass `-gno-key-instructions` to both compilation steps to control the backend behavior in `llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp`. We haven't yet confirmed that this mitigates the regression, but I'm ~66% confident that it will. If you have any theories about the regression, we're interested. :)

I fully expect that key instructions will disturb the source locations in a way that increases source code drift, making old profiles from old binaries less accurate when rebuilding new binaries with key instructions enabled, so I expect a temporary regression. However, I think we will have to disable the feature internally temporarily to study this interaction further to confirm that the regression goes away after reprofiling. Other sample PGO users may have a similar experience, so I wanted to share ours.

cc various AFDO stakeholders: @snehasish @amharc @alanzhao1 @mtrofin  @asmok-g 

https://github.com/llvm/llvm-project/pull/149509


More information about the cfe-commits mailing list