[all-commits] [llvm/llvm-project] fe0519: [InstrProf] Encode linkage names in IRPGO counter ...

Ellis Hoag via All-commits all-commits at lists.llvm.org
Mon Aug 7 10:15:37 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fe051934cbb0aaf25d960d7d45305135635d650b
      https://github.com/llvm/llvm-project/commit/fe051934cbb0aaf25d960d7d45305135635d650b
  Author: Ellis Hoag <ellis.sparky.hoag at gmail.com>
  Date:   2023-08-07 (Mon, 07 Aug 2023)

  Changed paths:
    M llvm/include/llvm/ProfileData/InstrProf.h
    M llvm/include/llvm/ProfileData/InstrProfReader.h
    M llvm/lib/ProfileData/InstrProf.cpp
    M llvm/lib/ProfileData/InstrProfReader.cpp
    M llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
    M llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
    M llvm/test/Transforms/PGOProfile/comdat_internal.ll
    M llvm/test/Transforms/PGOProfile/criticaledge.ll
    M llvm/test/Transforms/PGOProfile/statics_counter_naming.ll
    M llvm/tools/llvm-profdata/llvm-profdata.cpp
    M llvm/unittests/ProfileData/InstrProfTest.cpp

  Log Message:
  -----------
  [InstrProf] Encode linkage names in IRPGO counter names

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.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D156569




More information about the All-commits mailing list