[llvm] [AsmPrinter][ELF] Support profile-guided section prefix for jump tables' (read-only) data sections (PR #122215)

Mingming Liu via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 28 16:04:05 PST 2025


================
@@ -669,7 +671,15 @@ getELFSectionNameForGlobal(const GlobalObject *GO, SectionKind Kind,
 
   bool HasPrefix = false;
   if (const auto *F = dyn_cast<Function>(GO)) {
-    if (std::optional<StringRef> Prefix = F->getSectionPrefix()) {
+    // Jump table hotness takes precedence over its enclosing function's hotness
+    // if both are available.
+    if (JTE) {
+      if (JTE->Hotness == MachineFunctionDataHotness::Hot) {
+        raw_svector_ostream(Name) << ".hot";
+      } else if (JTE->Hotness == MachineFunctionDataHotness::Cold) {
+        raw_svector_ostream(Name) << ".unlikely";
+      }
----------------
mingmingl-llvm wrote:

It makes sense. Done.

The updated PR has `@bar` for test coverage.

https://github.com/llvm/llvm-project/pull/122215


More information about the llvm-commits mailing list