[llvm] 8bff8fb - [StaticDataLayout] Enable string literal partitioning by default (#225928)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 24 14:49:27 PDT 2026


Author: Aiden Grossman
Date: 2026-09-24T14:49:21-07:00
New Revision: 8bff8fbc71f43a1f721aa6403e0e66e913c05395

URL: https://github.com/llvm/llvm-project/commit/8bff8fbc71f43a1f721aa6403e0e66e913c05395
DIFF: https://github.com/llvm/llvm-project/commit/8bff8fbc71f43a1f721aa6403e0e66e913c05395.diff

LOG: [StaticDataLayout] Enable string literal partitioning by default (#225928)

We have started to roll this out internally, so enable it by default
upstream as well. This will enable seamless removal of the flag
internally with respect to our release process.

Added: 
    

Modified: 
    llvm/lib/Analysis/StaticDataProfileInfo.cpp
    llvm/test/CodeGen/X86/global-variable-partition-with-dap.ll
    llvm/test/Transforms/PGOProfile/data-access-profile.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/StaticDataProfileInfo.cpp b/llvm/lib/Analysis/StaticDataProfileInfo.cpp
index 40780ddf9bbf3..b685692a2a9cc 100644
--- a/llvm/lib/Analysis/StaticDataProfileInfo.cpp
+++ b/llvm/lib/Analysis/StaticDataProfileInfo.cpp
@@ -22,7 +22,7 @@ namespace llvm {
 // AnnotateStaticDataSectionPrefix in MemProfUse.cpp and this option should be
 // cleaned up.
 cl::opt<bool> AnnotateStringLiteralSectionPrefix(
-    "memprof-annotate-string-literal-section-prefix", cl::init(false),
+    "memprof-annotate-string-literal-section-prefix", cl::init(true),
     cl::Hidden,
     cl::desc("If true, annotate the string literal data section prefix"));
 namespace memprof {

diff  --git a/llvm/test/CodeGen/X86/global-variable-partition-with-dap.ll b/llvm/test/CodeGen/X86/global-variable-partition-with-dap.ll
index 05b3a639a30e5..57745fe7b0af6 100644
--- a/llvm/test/CodeGen/X86/global-variable-partition-with-dap.ll
+++ b/llvm/test/CodeGen/X86/global-variable-partition-with-dap.ll
@@ -10,16 +10,7 @@ target triple = "x86_64-unknown-linux-gnu"
 ; RUN:     -partition-static-data-sections=true \
 ; RUN:     -debug-only=static-data-profile-info \
 ; RUN:     -data-sections=true  -unique-section-names=false \
-; RUN:     input-with-data-access-prof-on.ll -o - 2>&1 | FileCheck %s --check-prefixes=LOGCOMMON,IRCOMMON,IR
-
-;; Repeat command above, but with string literals handled in the codegen pass,
-;; with -memprof-annotate-string-literal-section-prefix=true.
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -relocation-model=pic \
-; RUN:     -partition-static-data-sections=true \
-; RUN:     -debug-only=static-data-profile-info \
-; RUN:     -data-sections=true  -unique-section-names=false \
-; RUN:     -memprof-annotate-string-literal-section-prefix=true \
-; RUN:     input-with-data-access-prof-on.ll -o - 2>&1 | FileCheck %s --check-prefixes=LOGCOMMON,LOGSTR,IRCOMMON,IRSTR
+; RUN:     input-with-data-access-prof-on.ll -o - 2>&1 | FileCheck %s --check-prefixes=LOGCOMMON,IR
 
 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -relocation-model=pic \
 ; RUN:     -partition-static-data-sections=true \
@@ -38,33 +29,31 @@ target triple = "x86_64-unknown-linux-gnu"
 ; LOGSTR: .str.llvm.98765 has section prefix <empty>, solely from data access profiles
 ; LOGSTR: .str.2 has section prefix hot, solely from data access profiles
 
-; IRCOMMON:          .type   hot_bss, at object
-; IRCOMMON-NEXT:     .section .bss.hot.,"aw"
-; IRCOMMON:          .type   data_unknown_hotness, at object
-; IRCOMMON-NEXT:    .section .data,"aw"
-
-; IRSTR:         .section        .rodata,"a", at progbits
-; IR:            .section        .rodata.unlikely.,"a", at progbits
-; IRCOMMON-NEXT:    .L.str:
-; IRCOMMON-NEXT:    .ascii  "abcde"
-
-; IRCOMMON:         .section        .rodata.hot.,"a"
-; IRCOMMON-NEXT:    .str.1:
-; IRCOMMON-NEXT:    .ascii  "obj.a"
-
-; IRCOMMON:          .type   external_relro_array, at object
-; IRCOMMON-NEXT:     .section        .data.rel.ro.unlikely.,"aw"
-
-; IRCOMMON:         .section        .rodata,"a", at progbits
-; IRCOMMON-NEXT:    .globl  .str.llvm.98765
-; IRCOMMON-NEXT:    .str.llvm.98765:
-; IRCOMMON-NEXT:    .ascii  "Joins"
-
-; IRSTR:         .section        .rodata.hot.,"a", at progbits
-; IR:            .section        .rodata,"a", at progbits
-; IRSTR-NEXT:    .globl  .str.2
-; IRSTR-NEXT:    .str.2:
-; IRSTR-NEXT:    .ascii  "*ptr != nullptr"
+; IR:          .type   hot_bss, at object
+; IR-NEXT:     .section .bss.hot.,"aw"
+; IR:          .type   data_unknown_hotness, at object
+; IR-NEXT:    .section .data,"aw"
+
+; IR:         .section        .rodata,"a", at progbits
+; IR-NEXT:    .L.str:
+; IR-NEXT:    .ascii  "abcde"
+
+; IR:         .section        .rodata.hot.,"a"
+; IR-NEXT:    .str.1:
+; IR-NEXT:    .ascii  "obj.a"
+
+; IR:          .type   external_relro_array, at object
+; IR-NEXT:     .section        .data.rel.ro.unlikely.,"aw"
+
+; IR:         .section        .rodata,"a", at progbits
+; IR-NEXT:    .globl  .str.llvm.98765
+; IR-NEXT:    .str.llvm.98765:
+; IR-NEXT:    .ascii  "Joins"
+
+; IR:         .section        .rodata.hot.,"a", at progbits
+; IR-NEXT:    .globl  .str.2
+; IR-NEXT:    .str.2:
+; IR-NEXT:    .ascii  "*ptr != nullptr"
 
 ; OFF:        .type   hot_bss, at object
 ; OFF-NEXT:   .section        .bss.hot.,"aw"

diff  --git a/llvm/test/Transforms/PGOProfile/data-access-profile.ll b/llvm/test/Transforms/PGOProfile/data-access-profile.ll
index 7c062a90024ae..0f0aea9da5600 100644
--- a/llvm/test/Transforms/PGOProfile/data-access-profile.ll
+++ b/llvm/test/Transforms/PGOProfile/data-access-profile.ll
@@ -10,22 +10,12 @@
 ;; Run optimizer pass on an IR module without IR functions, and test that global
 ;; variables in the module could be annotated (i.e., no early return),
 ; RUN: opt -passes='memprof-use<profile-filename=memprof.profdata>' -memprof-annotate-static-data-prefix \
-; RUN: -debug-only=memprof -stats -S funcless-module.ll -o - 2>&1 | FileCheck %s --check-prefixes=LOGCOMMON,IRCOMMON,IR,STAT
-
-;; Add '-memprof-annotate-string-literal-section-prefix' to RUN command above.
-; RUN: opt -passes='memprof-use<profile-filename=memprof.profdata>' -memprof-annotate-static-data-prefix \
-; RUN: -memprof-annotate-string-literal-section-prefix \
-; RUN: -debug-only=memprof -stats -S funcless-module.ll -o - 2>&1 | FileCheck %s --check-prefixes=LOGCOMMON,LOGSTR,IRCOMMON,IRSTR,STRSTAT
+; RUN: -debug-only=memprof -stats -S funcless-module.ll -o - 2>&1 | FileCheck %s --check-prefixes=LOGCOMMON,IR,STAT
 
 ;; Run optimizer pass on the IR, and check the section prefix.
 ; RUN: opt -passes='memprof-use<profile-filename=memprof.profdata>' -memprof-annotate-static-data-prefix \
 ; RUN: -debug-only=memprof -stats -S input.ll -o - 2>&1 | FileCheck %s --check-prefixes=LOGCOMMON,IR,STAT
 
-;; Add '-memprof-annotate-string-literal-section-prefix' to RUN command above.
-; RUN: opt -passes='memprof-use<profile-filename=memprof.profdata>' -memprof-annotate-static-data-prefix \
-; RUN: -memprof-annotate-string-literal-section-prefix \
-; RUN: -debug-only=memprof -stats -S input.ll -o - 2>&1 | FileCheck %s --check-prefixes=LOGCOMMON,LOGSTR,IRSTR,STRSTAT
-
 ;; Run memprof without providing memprof data. Test that IR has module flag
 ;; `EnableDataAccessProf` as 0.
 ; RUN: opt -passes='memprof-use<profile-filename=memprof-no-dap.profdata>' -memprof-annotate-static-data-prefix \
@@ -51,44 +41,39 @@
 ; LOGSTR: Global variable .str.llvm.98765 is annotated as unlikely
 ; LOGSTR: Global variable .str.2 is not annotated
 
-;; String literals are not annotated.
-; IR: @.str = unnamed_addr constant [5 x i8] c"abcde"
-; IR-NOT: section_prefix
-; IR-SAME: {{$}}
-
 ;; .str is hot
-; IRSTR: @.str = unnamed_addr constant [5 x i8] c"abcde", !section_prefix !0
+; IR: @.str = unnamed_addr constant [5 x i8] c"abcde", !section_prefix !0
 
-; IRCOMMON: @var1 = global i32 123, !section_prefix !0
+; IR: @var1 = global i32 123, !section_prefix !0
 
 ;; @var.llvm.125 will be canonicalized to @var2 for profile look-up.
-; IRCOMMON-NEXT: @var2.llvm.125 = global i64 0, !section_prefix !0
+; IR-NEXT: @var2.llvm.125 = global i64 0, !section_prefix !0
 
 ;; @bar is not seen in hot symbol or known symbol set, so it won't get a section
 ;; prefix. Test this by testing that there is no section_prefix between @bar and
 ;; @foo.
-; IRCOMMON-NEXT: @bar = global i16 3
-; IRCOMMON-NOT: !section_prefix
-; IRCOMMON-SAME: {{$}}
+; IR-NEXT: @bar = global i16 3
+; IR-NOT: !section_prefix
+; IR-SAME: {{$}}
 
 ;; @foo is unlikely.
-; IRCOMMON-NEXT: @foo = global i8 2, !section_prefix !1
+; IR-NEXT: @foo = global i8 2, !section_prefix !1
 
-; IRCOMMON-NEXT: @var3 = constant [2 x i32] [i32 12345, i32 6789], section "sec1"
-; IRCOMMON-NEXT: @var4 = constant [1 x i64] [i64 98765] #0
+; IR-NEXT: @var3 = constant [2 x i32] [i32 12345, i32 6789], section "sec1"
+; IR-NEXT: @var4 = constant [1 x i64] [i64 98765] #0
 
-; IRCOMMON: @llvm.fake_var = global i32 123
-; IRCOMMON-NOT: !section_prefix
-; IRCOMMON-SAME: {{$}}
-; IRCOMMON: @qux = external global i64
-; IRCOMMON-NOT: !section_prefix
-; IRCOMMON-SAME: {{$}}
+; IR: @llvm.fake_var = global i32 123
+; IR-NOT: !section_prefix
+; IR-SAME: {{$}}
+; IR: @qux = external global i64
+; IR-NOT: !section_prefix
+; IR-SAME: {{$}}
 
 ;; @.str.llvm.98765 is unlikely and @.str.2 has no section prefix.
-; IRSTR: @.str.llvm.98765 = constant [5 x i8] c"Joins", align 1, !section_prefix !1
-; IRSTR: @.str.2 = constant [15 x i8] c"*ptr == nullptr", align 1
-; IRSTR-NOT: section_prefix
-; IRSTR-SAME: {{$}}
+; IR: @.str.llvm.98765 = constant [5 x i8] c"Joins", align 1, !section_prefix !1
+; IR: @.str.2 = constant [15 x i8] c"*ptr == nullptr", align 1
+; IR-NOT: section_prefix
+; IR-SAME: {{$}}
 
 ; IR: attributes #0 = { "rodata-section"="sec2" }
 
@@ -99,15 +84,10 @@
 ; FLAG: !{i32 2, !"EnableDataAccessProf", i32 0}
 ; FLAGLESS-NOT: EnableDataAccessProf
 
-; STAT: 1 memprof - Number of global vars annotated with 'unlikely' section prefix.
+; STAT: 2 memprof - Number of global vars annotated with 'unlikely' section prefix.
 ; STAT: 2 memprof - Number of global vars with user-specified section (not annotated).
-; STAT: 2 memprof - Number of global vars annotated with 'hot' section prefix.
-; STAT: 1 memprof - Number of global vars with unknown hotness (no section prefix).
-
-; STRSTAT: 2 memprof - Number of global vars annotated with 'unlikely' section prefix.
-; STRSTAT: 2 memprof - Number of global vars with user-specified section (not annotated).
-; STRSTAT: 3 memprof - Number of global vars annotated with 'hot' section prefix.
-; STRSTAT: 2 memprof - Number of global vars with unknown hotness (no section prefix).
+; STAT: 3 memprof - Number of global vars annotated with 'hot' section prefix.
+; STAT: 2 memprof - Number of global vars with unknown hotness (no section prefix).
 
 ;--- memprof.yaml
 ---


        


More information about the llvm-commits mailing list