[llvm] [NFCI][StaticDataLayout] Introduce an LLVM option to control the emission of `.hot` data section prefix. (PR #158172)
Mingming Liu via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 12 13:48:22 PDT 2025
https://github.com/mingmingl-llvm updated https://github.com/llvm/llvm-project/pull/158172
>From 0db80c8fa118a59ae232fbe2c9ad6a87c931034b Mon Sep 17 00:00:00 2001
From: mingmingl <mingmingl at google.com>
Date: Thu, 11 Sep 2025 11:44:21 -0700
Subject: [PATCH 1/2] Introduce an LLVM option to keep hot data section prefix
---
llvm/lib/Analysis/StaticDataProfileInfo.cpp | 7 ++-
.../CodeGen/TargetLoweringObjectFileImpl.cpp | 43 +++++++++++++------
2 files changed, 37 insertions(+), 13 deletions(-)
diff --git a/llvm/lib/Analysis/StaticDataProfileInfo.cpp b/llvm/lib/Analysis/StaticDataProfileInfo.cpp
index b036b2dde770e..ebe32383fc5a1 100644
--- a/llvm/lib/Analysis/StaticDataProfileInfo.cpp
+++ b/llvm/lib/Analysis/StaticDataProfileInfo.cpp
@@ -6,6 +6,11 @@
#include "llvm/ProfileData/InstrProf.h"
using namespace llvm;
+
+cl::opt<bool> PreserveHotDataSectionPrefix(
+ "preserve-hot-data-section-prefix", cl::Hidden, cl::init(true),
+ cl::desc("If true, hot data section prefixes are preserved"));
+
void StaticDataProfileInfo::addConstantProfileCount(
const Constant *C, std::optional<uint64_t> Count) {
if (!Count) {
@@ -36,7 +41,7 @@ StringRef StaticDataProfileInfo::getConstantSectionPrefix(
// The accummulated counter shows the constant is hot. Return 'hot' whether
// this variable is seen by unprofiled functions or not.
if (PSI->isHotCount(*Count))
- return "hot";
+ return PreserveHotDataSectionPrefix ? "hot" : "";
// The constant is not hot, and seen by unprofiled functions. We don't want to
// assign it to unlikely sections, even if the counter says 'cold'. So return
// an empty prefix before checking whether the counter is cold.
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 739dcc7f4c868..756bb052294b5 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -76,6 +76,8 @@
using namespace llvm;
using namespace dwarf;
+extern cl::opt<bool> PreserveHotDataSectionPrefix;
+
static cl::opt<bool> JumpTableInFunctionSection(
"jumptable-in-function-section", cl::Hidden, cl::init(false),
cl::desc("Putting Jump Table in function section"));
@@ -655,26 +657,43 @@ getELFSectionNameForGlobal(const GlobalObject *GO, SectionKind Kind,
}
bool HasPrefix = false;
+ SmallString<32> SectionPrefix;
if (const auto *F = dyn_cast<Function>(GO)) {
// Jump table hotness takes precedence over its enclosing function's hotness
// if it's known. The function's section prefix is used if jump table entry
// hotness is unknown.
if (JTE && JTE->Hotness != MachineFunctionDataHotness::Unknown) {
- if (JTE->Hotness == MachineFunctionDataHotness::Hot) {
- raw_svector_ostream(Name) << ".hot";
- } else {
- assert(JTE->Hotness == MachineFunctionDataHotness::Cold &&
- "Hotness must be cold");
- raw_svector_ostream(Name) << ".unlikely";
+ switch (JTE->Hotness) {
+ case MachineFunctionDataHotness::Cold:
+ raw_svector_ostream(SectionPrefix) << ".unlikely";
+ break;
+ case MachineFunctionDataHotness::Hot: {
+ if (PreserveHotDataSectionPrefix)
+ raw_svector_ostream(SectionPrefix) << ".hot";
+ break;
}
- HasPrefix = true;
- } else if (std::optional<StringRef> Prefix = F->getSectionPrefix()) {
- raw_svector_ostream(Name) << '.' << *Prefix;
- HasPrefix = true;
- }
+ default:
+ // Note this is unreachable code.
+ break;
+ }
+ } else if (std::optional<StringRef> Prefix = F->getSectionPrefix())
+ raw_svector_ostream(SectionPrefix) << "." << *Prefix;
} else if (const auto *GV = dyn_cast<GlobalVariable>(GO)) {
if (std::optional<StringRef> Prefix = GV->getSectionPrefix()) {
- raw_svector_ostream(Name) << '.' << *Prefix;
+ raw_svector_ostream(SectionPrefix) << "." << *Prefix;
+ }
+ }
+
+ if (!SectionPrefix.empty()) {
+ bool AddSectionPrefix = true;
+ if (Kind.isReadOnly() || Kind.isReadOnlyWithRel() || Kind.isData() ||
+ Kind.isBSS()) {
+ AddSectionPrefix =
+ !SectionPrefix.starts_with(".hot") || PreserveHotDataSectionPrefix;
+ }
+
+ if (AddSectionPrefix) {
+ Name += SectionPrefix;
HasPrefix = true;
}
}
>From b55cd2ec087edabbd2bada45e1339e07ccfac838 Mon Sep 17 00:00:00 2001
From: mingmingl <mingmingl at google.com>
Date: Fri, 12 Sep 2025 12:47:20 -0700
Subject: [PATCH 2/2] unit test coverage
---
.../CodeGen/TargetLoweringObjectFileImpl.cpp | 2 +-
.../AArch64/constant-pool-partition.ll | 175 +++++++++++-------
.../CodeGen/AArch64/jump-table-partition.ll | 34 +++-
.../CodeGen/X86/global-variable-partition.ll | 38 ++++
4 files changed, 174 insertions(+), 75 deletions(-)
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 756bb052294b5..3c165d9e16796 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -673,7 +673,7 @@ getELFSectionNameForGlobal(const GlobalObject *GO, SectionKind Kind,
break;
}
default:
- // Note this is unreachable code.
+ llvm_unreachable("Unknown jump table hotness");
break;
}
} else if (std::optional<StringRef> Prefix = F->getSectionPrefix())
diff --git a/llvm/test/CodeGen/AArch64/constant-pool-partition.ll b/llvm/test/CodeGen/AArch64/constant-pool-partition.ll
index 9f4b3e21f22b5..61b3b60ba8983 100644
--- a/llvm/test/CodeGen/AArch64/constant-pool-partition.ll
+++ b/llvm/test/CodeGen/AArch64/constant-pool-partition.ll
@@ -1,11 +1,21 @@
; RUN: llc -mtriple=aarch64 -partition-static-data-sections \
; RUN: -function-sections -unique-section-names=false \
-; RUN: %s -o - 2>&1 | FileCheck %s --dump-input=always
+; RUN: %s -o - 2>&1 | FileCheck %s --check-prefixes=HOT,COMM --dump-input=always
+
+; RUN: llc -mtriple=aarch64 -partition-static-data-sections \
+; RUN: -function-sections -unique-section-names=false \
+; RUN: -preserve-hot-data-section-prefix=false \
+; RUN: %s -o - 2>&1 | FileCheck %s --check-prefixes=NOHOT,COMM --dump-input=always
+
+; Repeat the RUN commands above for big-endian systems.
+; RUN: llc -mtriple=aarch64_be -partition-static-data-sections \
+; RUN: -function-sections -unique-section-names=false \
+; RUN: %s -o - 2>&1 | FileCheck %s --check-prefixes=HOT,COMM --dump-input=always
-; Repeat the RUN command above for big-endian systems.
; RUN: llc -mtriple=aarch64_be -partition-static-data-sections \
; RUN: -function-sections -unique-section-names=false \
-; RUN: %s -o - 2>&1 | FileCheck %s --dump-input=always
+; RUN: -preserve-hot-data-section-prefix=false \
+; RUN: %s -o - 2>&1 | FileCheck %s --check-prefixes=NOHOT,COMM --dump-input=always
; Tests that constant pool hotness is aggregated across the module. The
; static-data-splitter processes data from cold_func first, unprofiled_func
@@ -19,77 +29,112 @@
; function, constant pools for this constant should not have `.unlikely` suffix.
;; Constant pools for function @cold_func.
-; CHECK: .section .rodata.cst8.hot.,"aM", at progbits,8
-; CHECK-NEXT: .p2align
-; CHECK-NEXT: .LCPI0_0:
-; CHECK-NEXT: .xword 0x3fe5c28f5c28f5c3 // double 0.68000000000000005
-; CHECK-NEXT: .section .rodata.cst8.unlikely.,"aM", at progbits,8
-; CHECK-NEXT: .p2align
-; CHECK-NEXT: .LCPI0_1:
-; CHECK-NEXT: .xword 0x3fe5eb851eb851ec // double 0.68500000000000005
-; CHECK-NEXT: .section .rodata.cst8,"aM", at progbits,8
-; CHECK-NEXT: .p2align
-; CHECK-NEXT: .LCPI0_2:
-; CHECK-NEXT: .byte 0 // 0x0
-; CHECK-NEXT: .byte 4 // 0x4
-; CHECK-NEXT: .byte 8 // 0x8
-; CHECK-NEXT: .byte 12 // 0xc
-; CHECK-NEXT: .byte 255 // 0xff
-; CHECK-NEXT: .byte 255 // 0xff
-; CHECK-NEXT: .byte 255 // 0xff
-; CHECK-NEXT: .byte 255 // 0xff
+; HOT: .section .rodata.cst8.hot.,"aM", at progbits,8
+; HOT-NEXT: .p2align
+; HOT-NEXT: .LCPI0_0:
+; HOT-NEXT: .xword 0x3fe5c28f5c28f5c3 // double 0.68000000000000005
+; HOT-NEXT: .section .rodata.cst8.unlikely.,"aM", at progbits,8
+; HOT-NEXT: .p2align
+; HOT-NEXT: .LCPI0_1:
+; HOT-NEXT: .xword 0x3fe5eb851eb851ec // double 0.68500000000000005
+; HOT-NEXT: .section .rodata.cst8,"aM", at progbits,8
+; HOT-NEXT: .p2align
+; HOT-NEXT: .LCPI0_2:
+; HOT-NEXT: .byte 0 // 0x0
+; HOT-NEXT: .byte 4 // 0x4
+; HOT-NEXT: .byte 8 // 0x8
+; HOT-NEXT: .byte 12 // 0xc
+; HOT-NEXT: .byte 255 // 0xff
+; HOT-NEXT: .byte 255 // 0xff
+; HOT-NEXT: .byte 255 // 0xff
+; HOT-NEXT: .byte 255 // 0xff
+
+;; Constant pools for function @cold_func.
+; NOHOT: .section .rodata.cst8,"aM", at progbits,8
+; NOHOT-NEXT: .p2align
+; NOHOT-NEXT: .LCPI0_0:
+; NOHOT-NEXT: .xword 0x3fe5c28f5c28f5c3 // double 0.68000000000000005
+; NOHOT-NEXT: .LCPI0_2:
+; NOHOT-NEXT: .byte 0 // 0x0
+; NOHOT-NEXT: .byte 4 // 0x4
+; NOHOT-NEXT: .byte 8 // 0x8
+; NOHOT-NEXT: .byte 12 // 0xc
+; NOHOT-NEXT: .byte 255 // 0xff
+; NOHOT-NEXT: .byte 255 // 0xff
+; NOHOT-NEXT: .byte 255 // 0xff
+; NOHOT-NEXT: .byte 255 // 0xff
+; NOHOT-NEXT: .section .rodata.cst8.unlikely.,"aM", at progbits,8
+; NOHOT-NEXT: .p2align
+; NOHOT-NEXT: .LCPI0_1:
+; NOHOT-NEXT: .xword 0x3fe5eb851eb851ec // double 0.68500000000000005
;; Constant pools for function @unprofiled_func
-; CHECK: .section .rodata.cst8,"aM", at progbits,8
-; CHECK-NEXT: .p2align
-; CHECK-NEXT: .LCPI1_0:
-; CHECK-NEXT: .byte 0 // 0x0
-; CHECK-NEXT: .byte 4 // 0x4
-; CHECK-NEXT: .byte 8 // 0x8
-; CHECK-NEXT: .byte 12 // 0xc
-; CHECK-NEXT: .byte 255 // 0xff
-; CHECK-NEXT: .byte 255 // 0xff
-; CHECK-NEXT: .byte 255 // 0xff
-; CHECK-NEXT: .byte 255 // 0xff
-; CHECK-NEXT: .section .rodata.cst16,"aM", at progbits,16
-; CHECK-NEXT: .p2align
-; CHECK-NEXT: .LCPI1_1:
-; CHECK-NEXT: .word 2 // 0x2
-; CHECK-NEXT: .word 3 // 0x3
-; CHECK-NEXT: .word 5 // 0x5
-; CHECK-NEXT: .word 7 // 0x7
-; CHECK-NEXT: .section .rodata.cst16.hot.,"aM", at progbits,16
-; CHECK-NEXT: .p2align
-; CHECK-NEXT: .LCPI1_2:
-; CHECK-NEXT: .word 442 // 0x1ba
-; CHECK-NEXT: .word 100 // 0x64
-; CHECK-NEXT: .word 0 // 0x0
-; CHECK-NEXT: .word 0 // 0x0
+; COMM: .section .rodata.cst8,"aM", at progbits,8
+; COMM-NEXT: .p2align
+; COMM-NEXT: .LCPI1_0:
+; COMM-NEXT: .byte 0 // 0x0
+; COMM-NEXT: .byte 4 // 0x4
+; COMM-NEXT: .byte 8 // 0x8
+; COMM-NEXT: .byte 12 // 0xc
+; COMM-NEXT: .byte 255 // 0xff
+; COMM-NEXT: .byte 255 // 0xff
+; COMM-NEXT: .byte 255 // 0xff
+; COMM-NEXT: .byte 255 // 0xff
+
+; HOT-NEXT: .section .rodata.cst16,"aM", at progbits,16
+; HOT-NEXT: .p2align
+; HOT-NEXT: .LCPI1_1:
+; HOT-NEXT: .word 2 // 0x2
+; HOT-NEXT: .word 3 // 0x3
+; HOT-NEXT: .word 5 // 0x5
+; HOT-NEXT: .word 7 // 0x7
+; HOT-NEXT: .section .rodata.cst16.hot.,"aM", at progbits,16
+; HOT-NEXT: .p2align
+; HOT-NEXT: .LCPI1_2:
+; HOT-NEXT: .word 442 // 0x1ba
+; HOT-NEXT: .word 100 // 0x64
+; HOT-NEXT: .word 0 // 0x0
+; HOT-NEXT: .word 0 // 0x0
+
+; NOHOT: .section .rodata.cst16,"aM", at progbits,16
+; NOHOT-NEXT: .p2align
+; NOHOT-NEXT: .LCPI1_1:
+; NOHOT-NEXT: .word 2 // 0x2
+; NOHOT-NEXT: .word 3 // 0x3
+; NOHOT-NEXT: .word 5 // 0x5
+; NOHOT-NEXT: .word 7 // 0x7
+; NOHOT-NEXT: .LCPI1_2:
+; NOHOT-NEXT: .word 442 // 0x1ba
+; NOHOT-NEXT: .word 100 // 0x64
+; NOHOT-NEXT: .word 0 // 0x0
+; NOHOT-NEXT: .word 0 // 0x0
;; Constant pools for function @hot_func
-; CHECK: .section .rodata.cst8.hot.,"aM", at progbits,8
-; CHECK-NEXT: .p2align
-; CHECK-NEXT: .LCPI2_0:
-; CHECK-NEXT: .xword 0x3fe5c28f5c28f5c3 // double 0.68000000000000005
-; CHECK-NEXT: .section .rodata.cst16.hot.,"aM", at progbits,16
-; CHECK-NEXT: .p2align
-; CHECK-NEXT: .LCPI2_1:
-; CHECK-NEXT: .word 0 // 0x0
-; CHECK-NEXT: .word 100 // 0x64
-; CHECK-NEXT: .word 0 // 0x0
-; CHECK-NEXT: .word 442 // 0x1ba
-; CHECK-NEXT: .LCPI2_2:
-; CHECK-NEXT: .word 442 // 0x1ba
-; CHECK-NEXT: .word 100 // 0x64
-; CHECK-NEXT: .word 0 // 0x0
-; CHECK-NEXT: .word 0 // 0x0
+; HOT: .section .rodata.cst8.hot.,"aM", at progbits,8
+; NOHOT: .section .rodata.cst8,"aM", at progbits,8
+; COMM: .p2align
+; COMM-NEXT: .LCPI2_0:
+; COMM-NEXT: .xword 0x3fe5c28f5c28f5c3 // double 0.68000000000000005
+; NOHOT: .section .rodata.cst16,"aM", at progbits,16
+; HOT-NEXT: .section .rodata.cst16.hot.,"aM", at progbits,16
+; COMM: .p2align
+; COMM-NEXT: .LCPI2_1:
+; COMM-NEXT: .word 0 // 0x0
+; COMM-NEXT: .word 100 // 0x64
+; COMM-NEXT: .word 0 // 0x0
+; COMM-NEXT: .word 442 // 0x1ba
+; COMM-NEXT: .LCPI2_2:
+; COMM-NEXT: .word 442 // 0x1ba
+; COMM-NEXT: .word 100 // 0x64
+; COMM-NEXT: .word 0 // 0x0
+; COMM-NEXT: .word 0 // 0x0
;; For global variable @val
;; The section name remains `.rodata.cst32` without hotness prefix because
;; the variable has external linkage and not analyzed. Compiler need symbolized
;; data access profiles to annotate such global variables' hotness.
-; CHECK: .section .rodata.cst32,"aM", at progbits,32
-; CHECK-NEXT: .globl val
+; COMM: .section .rodata.cst32,"aM", at progbits,32
+; COMM-NEXT: .globl val
define i32 @cold_func(double %x, <16 x i8> %a, <16 x i8> %b) !prof !16 {
%2 = tail call i32 (...) @func_taking_arbitrary_param(double 6.800000e-01)
diff --git a/llvm/test/CodeGen/AArch64/jump-table-partition.ll b/llvm/test/CodeGen/AArch64/jump-table-partition.ll
index 47a7aa5306f41..e6eea5d12825d 100644
--- a/llvm/test/CodeGen/AArch64/jump-table-partition.ll
+++ b/llvm/test/CodeGen/AArch64/jump-table-partition.ll
@@ -7,17 +7,24 @@
; The static-data-splitter pass doesn't run.
; RUN: llc -mtriple=aarch64-unknown-linux-gnu -function-sections=true \
; RUN: -aarch64-enable-atomic-cfg-tidy=false -aarch64-min-jump-table-entries=2 \
-; RUN: -unique-section-names=true %s -o - 2>&1 | FileCheck %s --check-prefixes=DEFAULT
+; RUN: -unique-section-names=true %s -o - 2>&1 | FileCheck %s --check-prefixes=DEFAULT,COMM
+
+; Repeat the command with -preserve-hot-data-section-prefix=false
+; RUN: llc -mtriple=aarch64-unknown-linux-gnu -function-sections=true \
+; RUN: -aarch64-enable-atomic-cfg-tidy=false -aarch64-min-jump-table-entries=2 \
+; RUN: -preserve-hot-data-section-prefix=false \
+; RUN: -unique-section-names=true %s -o - 2>&1 | FileCheck %s --check-prefixes=DEFNOHOT,COMM
; DEFAULT: .section .rodata.hot.foo,"a", at progbits
-; DEFAULT: .LJTI0_0:
-; DEFAULT: .LJTI0_1:
-; DEFAULT: .LJTI0_2:
-; DEFAULT: .LJTI0_3:
-; DEFAULT: .section .rodata.func_without_profile,"a", at progbits
-; DEFAULT: .LJTI1_0:
-; DEFAULT: .section .rodata.bar_prefix.bar,"a", at progbits
-; DEFAULT: .LJTI2_0
+; DEFNOHOT: .section .rodata.foo,"a", at progbits
+; COMM: .LJTI0_0:
+; COMM: .LJTI0_1:
+; COMM: .LJTI0_2:
+; COMM: .LJTI0_3:
+; COMM: .section .rodata.func_without_profile,"a", at progbits
+; COMM: .LJTI1_0:
+; COMM: .section .rodata.bar_prefix.bar,"a", at progbits
+; COMM: .LJTI2_0
; Test that section names are uniqufied by numbers but not function names with
; {-function-sections, -unique-section-names=false}. Specifically, @foo jump
@@ -40,6 +47,14 @@
; RUN: -aarch64-enable-atomic-cfg-tidy=false -aarch64-min-jump-table-entries=2 \
; RUN: %s -o - 2>&1 | FileCheck %s --check-prefixes=FUNCLESS,JT
+;; Repeat the commands above with -preserve-hot-data-section-prefix=false
+; RUN: llc -mtriple=aarch64-unknown-linux-gnu -partition-static-data-sections \
+; RUN: -function-sections -unique-section-names=false \
+; RUN: -preserve-hot-data-section-prefix=false \
+; RUN: -aarch64-enable-atomic-cfg-tidy=false -aarch64-min-jump-table-entries=2 \
+; RUN: %s -o - 2>&1 | FileCheck %s --check-prefixes=NOHOT,JT
+
+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "aarch64-unknown-linux-gnu"
@@ -58,6 +73,7 @@ target triple = "aarch64-unknown-linux-gnu"
; NUM: .section .rodata.hot.,"a", at progbits,unique,2
; FUNC: .section .rodata.hot.foo,"a", at progbits
; FUNCLESS: .section .rodata.hot.,"a", at progbits
+; NOHOT: .section .rodata,"a", at progbits
; JT: .LJTI0_0:
; JT: .LJTI0_2:
; NUM: .section .rodata.unlikely.,"a", at progbits,unique,3
diff --git a/llvm/test/CodeGen/X86/global-variable-partition.ll b/llvm/test/CodeGen/X86/global-variable-partition.ll
index ce06d1712f840..a60f56a0563eb 100644
--- a/llvm/test/CodeGen/X86/global-variable-partition.ll
+++ b/llvm/test/CodeGen/X86/global-variable-partition.ll
@@ -29,11 +29,33 @@ target triple = "x86_64-unknown-linux-gnu"
; RUN: -data-sections=false -unique-section-names=false \
; RUN: %s -o - 2>&1 | FileCheck %s --check-prefixes=AGG,COMMON --dump-input=always
+;; Repeat the commands above with '-preserve-hot-data-section-prefix=false'
+
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -relocation-model=pic \
+; RUN: -partition-static-data-sections=true \
+; RUN: -data-sections=true -unique-section-names=false \
+; RUN: -preserve-hot-data-section-prefix=false \
+; RUN: %s -o - 2>&1 | FileCheck %s --check-prefixes=COMMON,NOHOT,MUT --dump-input=always
+
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -relocation-model=pic \
+; RUN: -partition-static-data-sections=true \
+; RUN: -data-sections=true -unique-section-names=false \
+; RUN: -preserve-hot-data-section-prefix=false \
+; RUN: %s -o - 2>&1 | FileCheck %s --check-prefixes=COMMON,NOHOT,MUT --dump-input=always
+
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -relocation-model=pic \
+; RUN: -partition-static-data-sections=true \
+; RUN: -data-sections=false -unique-section-names=false \
+; RUN: -preserve-hot-data-section-prefix=false \
+; RUN: %s -o - 2>&1 | FileCheck %s --check-prefixes=COMMON,NOHOT --dump-input=always
+
+
; For @.str and @.str.1
; COMMON: .type .L.str, at object
; SYM-NEXT: .section .rodata.str1.1.hot.
; UNIQ-NEXT: .section .rodata.str1.1.hot.,"aMS", at progbits,1
; AGG-NEXT: .section .rodata.str1.1.hot
+; NOHOT: .section .rodata.str1.1,"aMS", at progbits,1
; COMMON-NEXT: .L.str:
; COMMON-NEXT: "hot\t"
; COMMON: .L.str.1:
@@ -44,24 +66,32 @@ target triple = "x86_64-unknown-linux-gnu"
; SYM-NEXT: .section .data.rel.ro.hot.hot_relro_array
; UNIQ-NEXT: .section .data.rel.ro.hot.,"aw", at progbits,unique,1
; AGG-NEXT: .section .data.rel.ro.hot.,"aw", at progbits
+; NOHOT: .section .data.rel.ro,"aw", at progbits
; For @hot_data, which is accessed by {cold_func, unprofiled_func, hot_func}.
; COMMON: .type hot_data, at object
; SYM-NEXT: .section .data.hot.hot_data,"aw", at progbits
; UNIQ-NEXT: .section .data.hot.,"aw", at progbits,unique,2
; AGG-NEXT: .section .data.hot.,"aw", at progbits
+; The `.section` directive is omitted for .data with -unique-section-names=false.
+; See MCSectionELF::shouldOmitSectionDirective for the implementation details.
+; MUT: .section .data,"aw"
; For @hot_bss, which is accessed by {unprofiled_func, hot_func}.
; COMMON: .type hot_bss, at object
; SYM-NEXT: .section .bss.hot.hot_bss,"aw", at nobits
; UNIQ-NEXT: .section .bss.hot.,"aw", at nobits,unique,3
; AGG-NEXT: .section .bss.hot.,"aw", at nobits
+; The `.section` directive is omitted for .bss with -unique-section-names=false.
+; See MCSectionELF::shouldOmitSectionDirective for the implementation details.
+; MUT: .section .bss,"aw"
; For @.str.2
; COMMON: .type .L.str.2, at object
; SYM-NEXT: .section .rodata.str1.1.unlikely.,"aMS", at progbits,1
; UNIQ-NEXT: .section .rodata.str1.1.unlikely.,"aMS", at progbits,1
; AGG-NEXT: .section .rodata.str1.1.unlikely.,"aMS", at progbits,1
+; NOHOT: .section .rodata.str1.1.unlikely.,"aMS", at progbits,1
; COMMON-NEXT: .L.str.2:
; COMMON-NEXT: "cold%d\t%d\t%d\n"
@@ -70,12 +100,14 @@ target triple = "x86_64-unknown-linux-gnu"
; SYM-NEXT: .section .bss.unlikely.cold_bss,"aw", at nobits
; UNIQ-NEXT: .section .bss.unlikely.,"aw", at nobits,unique,4
; AGG-NEXT: .section .bss.unlikely.,"aw", at nobits
+; NOHOT: .section .bss.unlikely.,"aw", at nobits
; For @cold_data
; COMMON: .type cold_data, at object
; SYM-NEXT: .section .data.unlikely.cold_data,"aw", at progbits
; UNIQ-NEXT: .section .data.unlikely.,"aw", at progbits,unique,5
; AGG-NEXT: .section .data.unlikely.,"aw", at progbits
+; NOHOT: .section .data.unlikely.,"aw", at progbits
; For @cold_data_custom_foo_section
; It has an explicit section 'foo' and shouldn't have hot or unlikely suffix.
@@ -83,12 +115,14 @@ target triple = "x86_64-unknown-linux-gnu"
; SYM-NEXT: .section foo,"aw", at progbits
; UNIQ-NEXT: .section foo,"aw", at progbits
; AGG-NEXT: .section foo,"aw", at progbits
+; NOHOT: .section foo,"aw", at progbits
; For @cold_relro_array
; COMMON: .type cold_relro_array, at object
; SYM-NEXT: .section .data.rel.ro.unlikely.cold_relro_array,"aw", at progbits
; UNIQ-NEXT: .section .data.rel.ro.unlikely.,"aw", at progbits,unique,6
; AGG-NEXT: .section .data.rel.ro.unlikely.,"aw", at progbits
+; NOHOT: .section .data.rel.ro.unlikely.,"aw", at progbits
; Currently static-data-splitter only analyzes access from code.
; @bss2 and @data3 are indirectly accessed by code through @hot_relro_array
@@ -99,12 +133,14 @@ target triple = "x86_64-unknown-linux-gnu"
; SYM-NEXT: .section .bss.unlikely.bss2,"aw", at nobits
; UNIQ-NEXT: .section .bss.unlikely.,"aw", at nobits,unique,7
; AGG-NEXT: .section .bss.unlikely.,"aw", at nobits
+; NOHOT: .section .bss.unlikely.,"aw", at nobits
; For @data3
; COMMON: .type data3, at object
; SYM-NEXT: .section .data.unlikely.data3,"aw", at progbits
; UNIQ-NEXT: .section .data.unlikely.,"aw", at progbits,unique,8
; AGG-NEXT: .section .data.unlikely.,"aw", at progbits
+; NOHOT: .section .data.unlikely.,"aw", at progbits
; For @data_with_unknown_hotness
; SYM: .type .Ldata_with_unknown_hotness, at object # @data_with_unknown_hotness
@@ -113,6 +149,7 @@ target triple = "x86_64-unknown-linux-gnu"
; The `.section` directive is omitted for .data with -unique-section-names=false.
; See MCSectionELF::shouldOmitSectionDirective for the implementation details.
; AGG: .data
+; NOHOT: .data
; COMMON: .Ldata_with_unknown_hotness:
; For @hot_data_custom_bar_section
@@ -122,6 +159,7 @@ target triple = "x86_64-unknown-linux-gnu"
; SYM: hot_data_custom_bar_section
; UNIQ: .section bar,"aw", at progbits
; AGG: .section bar,"aw", at progbits
+; NOHOT: .section bar,"aw", at progbits
@.str = private unnamed_addr constant [5 x i8] c"hot\09\00", align 1
@.str.1 = private unnamed_addr constant [10 x i8] c"%d\09%d\09%d\0A\00", align 1
More information about the llvm-commits
mailing list