Skip to content

Conversation

mingmingl-llvm
Copy link
Contributor

@mingmingl-llvm mingmingl-llvm commented Dec 11, 2023

When merging instrFDO profiles with afdo profile as supplementary, instrFDO counters for static functions are stored with function's PGO name (with filename.cpp; prefix).

…colon as delimiter for local-linkage varibles.

Commit fe05193 (phab D156569), IRPGO names uses format
'[<filepath>;]<linkage-name>' while prior format is
[<filepath>:<linkage-name>'. The format change would break the use caes
demonstrated in (updated)
llvm/test/Transforms/PGOProfile/thinlto_indirect_call_promotion.ll

This patch changes GlobalValues::getGlobalIdentifer to use the
semicolon.

To elaborate on the scenario how things break without this PR
1. IRPGO raw profiles stores (compressed) IRPGO names of functions in
   one section, and per-function profile data in another section. One
   field in per-function profile data is the MD5 hash of IRPGO names.
2. When raw profiles are converted to indexed format profiles, the
   profiled address is mapped to the MD5 hash of the callee.
3. In thin-lto prelink pipeline, MD5 hash of IRPGO names will be
   annotated as value profiles, and used to import indirect-call-prom
   candidates. If the annotated MD5 hash is computed from the new format
   while import uses the prior format, the callee cannot be imported.

The updated test case Transforms/PGOProfile/thinlto_indirect_call_promotion.ll exercise the following path
- Annotate raw profiles and generate import summaries. Using the
  imported summaries, it tests that functions are correctly imported and
  ICP transformations happened.
- Add thinlto indirect-call-promotion regression test as a compiler-rt
  test and remove the original IR test.
  - `clangxx_pgouse` is added in complier-rt lit config for test use.
- In lib/IR/Globals.cpp, use '+=' operator for previous 'append' calls.
- In llvm/ProfileData/InstrProf.h, update a few function comments. These
  comments used to refer to `getPGOFuncName` while the actual name could
  be returned by `getPGOFuncName` (clang instrumentation) or
  `getIRPGOFuncName` (ir instrumentation).
@mingmingl-llvm mingmingl-llvm merged commit 665e46c into llvm:main Jan 4, 2024
@mingmingl-llvm mingmingl-llvm deleted the llvm-profdata branch January 4, 2024 23:03
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