[Propeller] Promote functions with propeller profiles to .text.hot.
authorRahman Lavaee <rahmanl@google.com>
Tue, 24 May 2022 17:54:36 +0000 (10:54 -0700)
committerRahman Lavaee <rahmanl@google.com>
Thu, 26 May 2022 23:23:21 +0000 (16:23 -0700)
commit4d8d2580c53e130c3c3dd3877384301e3c495554
treea76dd51beda737860088ad99744aa89cf20b5d0f
parent36096c2b383ec78030aad47c6b9f479f34d571d7
[Propeller] Promote functions with propeller profiles to .text.hot.

Today, text section prefixes (none, .unlikely, .hot, and .unkown) are determined based on PGO profile. However, Propeller may deem a function hot when PGO doesn't. Besides, when `-Wl,-keep-text-section-prefix=true` Propeller cannot enforce a global section ordering as the linker can only reorder sections within each output section (.text, .text.hot, .text.unlikely).

This patch promotes all functions with Propeller profiles (functions listed in the basic-block-sections profile) to .text.hot. The feature is hidden behind the flag `--bbsections-guided-section-prefix` which defaults to `true`.

The new implementation refactors the parsing of basic block sections profile into a new `BasicBlockSectionsProfileReader` analysis pass. This allows us to use the information earlier in `CodeGenPrepare` in order to set the functions text prefix. `BasicBlockSectionsProfileReader` will be used both by `BasicBlockSections` pass and `CodeGenPrepare`.

Differential Revision: https://reviews.llvm.org/D122930
17 files changed:
llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h [new file with mode: 0644]
llvm/include/llvm/CodeGen/Passes.h
llvm/include/llvm/InitializePasses.h
llvm/lib/CodeGen/BasicBlockSections.cpp
llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp [new file with mode: 0644]
llvm/lib/CodeGen/CMakeLists.txt
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/CodeGen/TargetPassConfig.cpp
llvm/test/CodeGen/AArch64/O3-pipeline.ll
llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
llvm/test/CodeGen/PowerPC/O3-pipeline.ll
llvm/test/CodeGen/RISCV/O3-pipeline.ll
llvm/test/CodeGen/X86/basic-block-sections-cold.ll
llvm/test/CodeGen/X86/basic-block-sections-list.ll
llvm/test/CodeGen/X86/basic-block-sections-listbb.ll
llvm/test/CodeGen/X86/basic-block-sections-source-drift.ll
llvm/test/CodeGen/X86/opt-pipeline.ll