[PATCH] D156569: [InstrProf] Encode linkage names in IRPGO counter names
Ellis Hoag via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 28 13:12:37 PDT 2023
ellis created this revision.
Herald added subscribers: hoy, wlei, Enna1, wenlei, hiraditya.
Herald added a project: All.
ellis edited the summary of this revision.
ellis added reviewers: MaskRay, kyulee, wenlei, davidxl, tejohnson.
ellis edited the summary of this revision.
ellis published this revision for review.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Prior to this diff, names in the `__llvm_prf_names` section had the format `[<filepath>:]<function-name>`, e.g., `main.cpp:foo`, `bar`. `<filepath>` is used to discriminate between possibly identical function names when linkage is local and `<function-name>` simply comes from `F.getName()`. This has two problems:
- `:` is commonly found in Objective-C functions so that names like `main.mm:-[C foo::]` and `-[C bar::]` are difficult to parse
- `<function-name>` might be different from the linkage name, so it cannot be used to pass a function order to the linker via `-symbol-ordering-file` or `-order_file` (see https://discourse.llvm.org/t/rfc-temporal-profiling-extension-for-irpgo/68068)
Instead, this diff changes the format to `[<filepath>;]<linkage-name>`, e.g., `main.cpp;_foo`, `_bar`. The hope is that `;` won't realistically be found in either `<filepath>` or `<linkage-name>`.
To prevent invalidating all prior IRPGO profiles, we also lookup the prior name format when a record is not found (see `InstrProfSymtab::create()`, `readMemprof()`, and `getInstrProfRecord()`). It seems that Swift and Clang FE-PGO rely on the original `getPGOFuncName()`, so we cannot simply replace it.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D156569
Files:
llvm/include/llvm/ProfileData/InstrProf.h
llvm/include/llvm/ProfileData/InstrProfReader.h
llvm/lib/ProfileData/InstrProf.cpp
llvm/lib/ProfileData/InstrProfReader.cpp
llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
llvm/test/Transforms/PGOProfile/comdat_internal.ll
llvm/test/Transforms/PGOProfile/criticaledge.ll
llvm/test/Transforms/PGOProfile/statics_counter_naming.ll
llvm/tools/llvm-profdata/llvm-profdata.cpp
llvm/unittests/ProfileData/InstrProfTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156569.545255.patch
Type: text/x-patch
Size: 26310 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230728/65c17500/attachment.bin>
More information about the llvm-commits
mailing list