diff options
author | Snehasish Kumar <snehasishk@google.com> | 2020-09-16 21:40:00 -0700 |
---|---|---|
committer | Snehasish Kumar <snehasishk@google.com> | 2020-09-24 15:26:15 -0700 |
commit | d2696dec45cdcff791cd53b8b8288d33a0d8dddb (patch) | |
tree | 94c963c1c0b114cf06018a9396f32fef7466a729 /llvm/lib/CodeGen/BasicBlockSections.cpp | |
parent | a22814194e8ea8d581a26992bb27f808e53bbbde (diff) | |
download | llvm-d2696dec45cdcff791cd53b8b8288d33a0d8dddb.zip llvm-d2696dec45cdcff791cd53b8b8288d33a0d8dddb.tar.gz llvm-d2696dec45cdcff791cd53b8b8288d33a0d8dddb.tar.bz2 |
[llvm] Add -bbsections-cold-text-prefix to emit cold clusters to a different section.
This change adds an option to basic block sections to allow cold
clusters to be assigned a custom text prefix. With a custom prefix such
as ".text.split." (D87840), lld can place them in a separate output section.
The benefits are -
* Empirically shown to improve icache and itlb metrics by 3-5%
(absolute) compared to placing split parts in .text.unlikely.
* Mitigates against poor profiles, eg samplePGO profiles used with the
machine function splitter. Optimizations such as hugepage remapping can
make different decisions at the section granularity.
* Enables section granularity hotness monitoring (checking on the
decisions made during compilation vs sample data from production).
Differential Revision: https://reviews.llvm.org/D87813
Diffstat (limited to 'llvm/lib/CodeGen/BasicBlockSections.cpp')
-rw-r--r-- | llvm/lib/CodeGen/BasicBlockSections.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/BasicBlockSections.cpp b/llvm/lib/CodeGen/BasicBlockSections.cpp index 421c1d8..9692e9b 100644 --- a/llvm/lib/CodeGen/BasicBlockSections.cpp +++ b/llvm/lib/CodeGen/BasicBlockSections.cpp @@ -79,6 +79,15 @@ using llvm::StringMap; using llvm::StringRef; using namespace llvm; +// Placing the cold clusters in a separate section mitigates against poor +// profiles and allows optimizations such as hugepage mapping to be applied at a +// section granularity. Where necessary, users should set this to ".text.split." +// which is recognized by lld via the `-z keep-text-section-prefix` flag. +cl::opt<std::string> llvm::BBSectionsColdTextPrefix( + "bbsections-cold-text-prefix", + cl::desc("The text prefix to use for cold basic block clusters"), + cl::init(".text.unlikely."), cl::Hidden); + namespace { // This struct represents the cluster information for a machine basic block. |