Skip to content

Commit 0d19efa

Browse files
[NFC]In codegen pipeline, turn static-data-splitter pass on/off with its own option (#134752)
Per discussion in #129781 (comment), we'd like to refactor out the requirement of MFS.
1 parent 642481a commit 0d19efa

File tree

5 files changed

+55
-54
lines changed

5 files changed

+55
-54
lines changed

llvm/lib/CodeGen/TargetPassConfig.cpp

+18-13
Original file line numberDiff line numberDiff line change
@@ -1235,13 +1235,9 @@ void TargetPassConfig::addMachinePasses() {
12351235
addPass(createMIRAddFSDiscriminatorsPass(
12361236
sampleprof::FSDiscriminatorPass::PassLast));
12371237

1238-
// Machine function splitter uses the basic block sections feature.
1239-
// When used along with `-basic-block-sections=`, the basic-block-sections
1240-
// feature takes precedence. This means functions eligible for
1241-
// basic-block-sections optimizations (`=all`, or `=list=` with function
1242-
// included in the list profile) will get that optimization instead.
12431238
if (TM->Options.EnableMachineFunctionSplitter ||
1244-
EnableMachineFunctionSplitter) {
1239+
EnableMachineFunctionSplitter || SplitStaticData ||
1240+
TM->Options.EnableStaticDataPartitioning) {
12451241
const std::string ProfileFile = getFSProfileFile(TM);
12461242
if (!ProfileFile.empty()) {
12471243
if (EnableFSDiscriminator) {
@@ -1256,14 +1252,23 @@ void TargetPassConfig::addMachinePasses() {
12561252
"performance.\n";
12571253
}
12581254
}
1255+
}
1256+
1257+
// Machine function splitter uses the basic block sections feature.
1258+
// When used along with `-basic-block-sections=`, the basic-block-sections
1259+
// feature takes precedence. This means functions eligible for
1260+
// basic-block-sections optimizations (`=all`, or `=list=` with function
1261+
// included in the list profile) will get that optimization instead.
1262+
if (TM->Options.EnableMachineFunctionSplitter ||
1263+
EnableMachineFunctionSplitter)
12591264
addPass(createMachineFunctionSplitterPass());
1260-
if (SplitStaticData || TM->Options.EnableStaticDataPartitioning) {
1261-
// The static data splitter pass is a machine function pass. and
1262-
// static data annotator pass is a module-wide pass. See the file comment
1263-
// in StaticDataAnnotator.cpp for the motivation.
1264-
addPass(createStaticDataSplitterPass());
1265-
addPass(createStaticDataAnnotatorPass());
1266-
}
1265+
1266+
if (SplitStaticData || TM->Options.EnableStaticDataPartitioning) {
1267+
// The static data splitter pass is a machine function pass. and
1268+
// static data annotator pass is a module-wide pass. See the file comment
1269+
// in StaticDataAnnotator.cpp for the motivation.
1270+
addPass(createStaticDataSplitterPass());
1271+
addPass(createStaticDataAnnotatorPass());
12671272
}
12681273
// We run the BasicBlockSections pass if either we need BB sections or BB
12691274
// address map (or both).

llvm/test/CodeGen/AArch64/constant-pool-partition.ll

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
; RUN: llc -mtriple=aarch64 -enable-split-machine-functions \
2-
; RUN: -partition-static-data-sections=true -function-sections=true \
3-
; RUN: -unique-section-names=false \
1+
; RUN: llc -mtriple=aarch64 -partition-static-data-sections \
2+
; RUN: -function-sections -unique-section-names=false \
43
; RUN: %s -o - 2>&1 | FileCheck %s --dump-input=always
54

65
; Repeat the RUN command above for big-endian systems.
7-
; RUN: llc -mtriple=aarch64_be -enable-split-machine-functions \
8-
; RUN: -partition-static-data-sections=true -function-sections=true \
9-
; RUN: -unique-section-names=false \
6+
; RUN: llc -mtriple=aarch64_be -partition-static-data-sections \
7+
; RUN: -function-sections -unique-section-names=false \
108
; RUN: %s -o - 2>&1 | FileCheck %s --dump-input=always
119

1210
; Tests that constant pool hotness is aggregated across the module. The

llvm/test/CodeGen/X86/constant-pool-partition.ll

+6-8
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,16 @@ target triple = "x86_64-grtev4-linux-gnu"
1010
; 2. Similarly if a constant is accessed by both cold function and un-profiled
1111
; function, constant pools for this constant should not have .unlikely suffix.
1212

13-
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -enable-split-machine-functions \
14-
; RUN: -partition-static-data-sections=true -function-sections=true -data-sections=true \
15-
; RUN: -unique-section-names=false \
13+
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -partition-static-data-sections \
14+
; RUN: -function-sections -data-sections -unique-section-names=false \
1615
; RUN: %s -o - 2>&1 | FileCheck %s --dump-input=always
1716

18-
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -enable-split-machine-functions \
19-
; RUN: -partition-static-data-sections=true -function-sections=true -data-sections=true \
20-
; RUN: -unique-section-names=true \
17+
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -partition-static-data-sections \
18+
; RUN: -function-sections -data-sections -unique-section-names \
2119
; RUN: %s -o - 2>&1 | FileCheck %s --dump-input=always
2220

23-
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -enable-split-machine-functions \
24-
; RUN: -partition-static-data-sections=true -function-sections=false -data-sections=false \
21+
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -partition-static-data-sections \
22+
; RUN: -function-sections=false -data-sections=false \
2523
; RUN: -unique-section-names=false \
2624
; RUN: %s -o - 2>&1 | FileCheck %s --dump-input=always
2725

llvm/test/CodeGen/X86/global-variable-partition.ll

+18-18
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ target triple = "x86_64-unknown-linux-gnu"
1111

1212
; This RUN command sets `-data-sections=true -unique-section-names=true` so data
1313
; sections are uniqufied by numbers.
14-
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -enable-split-machine-functions \
15-
; RUN: -partition-static-data-sections=true -data-sections=true \
16-
; RUN: -unique-section-names=true -relocation-model=pic \
14+
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -relocation-model=pic \
15+
; RUN: -partition-static-data-sections=true \
16+
; RUN: -data-sections=true -unique-section-names=true \
1717
; RUN: %s -o - 2>&1 | FileCheck %s --check-prefixes=SYM,COMMON --dump-input=always
1818

1919
; This RUN command sets `-data-sections=true -unique-section-names=false` so
2020
; data sections are uniqufied by variable names.
21-
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -enable-split-machine-functions \
22-
; RUN: -partition-static-data-sections=true -data-sections=true \
23-
; RUN: -unique-section-names=false -relocation-model=pic \
21+
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -relocation-model=pic \
22+
; RUN: -partition-static-data-sections=true \
23+
; RUN: -data-sections=true -unique-section-names=false \
2424
; RUN: %s -o - 2>&1 | FileCheck %s --check-prefixes=UNIQ,COMMON --dump-input=always
2525

2626
; This RUN command sets `-data-sections=false -unique-section-names=false`.
27-
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -enable-split-machine-functions \
28-
; RUN: -partition-static-data-sections=true -data-sections=false \
29-
; RUN: -unique-section-names=false -relocation-model=pic \
27+
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -relocation-model=pic \
28+
; RUN: -partition-static-data-sections=true \
29+
; RUN: -data-sections=false -unique-section-names=false \
3030
; RUN: %s -o - 2>&1 | FileCheck %s --check-prefixes=AGG,COMMON --dump-input=always
3131

3232
; For @.str and @.str.1
@@ -42,19 +42,19 @@ target triple = "x86_64-unknown-linux-gnu"
4242
; For @hot_relro_array
4343
; COMMON: .type hot_relro_array,@object
4444
; SYM-NEXT: .section .data.rel.ro.hot.hot_relro_array
45-
; UNIQ-NEXT: .section .data.rel.ro.hot.,"aw",@progbits,unique,3
45+
; UNIQ-NEXT: .section .data.rel.ro.hot.,"aw",@progbits,unique,1
4646
; AGG-NEXT: .section .data.rel.ro.hot.,"aw",@progbits
4747

4848
; For @hot_data, which is accessed by {cold_func, unprofiled_func, hot_func}.
4949
; COMMON: .type hot_data,@object
5050
; SYM-NEXT: .section .data.hot.hot_data,"aw",@progbits
51-
; UNIQ-NEXT: .section .data.hot.,"aw",@progbits,unique,4
51+
; UNIQ-NEXT: .section .data.hot.,"aw",@progbits,unique,2
5252
; AGG-NEXT: .section .data.hot.,"aw",@progbits
5353

5454
; For @hot_bss, which is accessed by {unprofiled_func, hot_func}.
5555
; COMMON: .type hot_bss,@object
5656
; SYM-NEXT: .section .bss.hot.hot_bss,"aw",@nobits
57-
; UNIQ-NEXT: .section .bss.hot.,"aw",@nobits,unique,5
57+
; UNIQ-NEXT: .section .bss.hot.,"aw",@nobits,unique,3
5858
; AGG-NEXT: .section .bss.hot.,"aw",@nobits
5959

6060
; For @.str.2
@@ -68,13 +68,13 @@ target triple = "x86_64-unknown-linux-gnu"
6868
; For @cold_bss
6969
; COMMON: .type cold_bss,@object
7070
; SYM-NEXT: .section .bss.unlikely.cold_bss,"aw",@nobits
71-
; UNIQ-NEXT: .section .bss.unlikely.,"aw",@nobits,unique,6
71+
; UNIQ-NEXT: .section .bss.unlikely.,"aw",@nobits,unique,4
7272
; AGG-NEXT: .section .bss.unlikely.,"aw",@nobits
7373

7474
; For @cold_data
7575
; COMMON: .type cold_data,@object
7676
; SYM-NEXT: .section .data.unlikely.cold_data,"aw",@progbits
77-
; UNIQ-NEXT: .section .data.unlikely.,"aw",@progbits,unique,7
77+
; UNIQ-NEXT: .section .data.unlikely.,"aw",@progbits,unique,5
7878
; AGG-NEXT: .section .data.unlikely.,"aw",@progbits
7979

8080
; For @cold_data_custom_foo_section
@@ -87,7 +87,7 @@ target triple = "x86_64-unknown-linux-gnu"
8787
; For @cold_relro_array
8888
; COMMON: .type cold_relro_array,@object
8989
; SYM-NEXT: .section .data.rel.ro.unlikely.cold_relro_array,"aw",@progbits
90-
; UNIQ-NEXT: .section .data.rel.ro.unlikely.,"aw",@progbits,unique,8
90+
; UNIQ-NEXT: .section .data.rel.ro.unlikely.,"aw",@progbits,unique,6
9191
; AGG-NEXT: .section .data.rel.ro.unlikely.,"aw",@progbits
9292

9393
; Currently static-data-splitter only analyzes access from code.
@@ -97,19 +97,19 @@ target triple = "x86_64-unknown-linux-gnu"
9797
; For @bss2
9898
; COMMON: .type bss2,@object
9999
; SYM-NEXT: .section .bss.unlikely.bss2,"aw",@nobits
100-
; UNIQ-NEXT: .section .bss.unlikely.,"aw",@nobits,unique,9
100+
; UNIQ-NEXT: .section .bss.unlikely.,"aw",@nobits,unique,7
101101
; AGG-NEXT: .section .bss.unlikely.,"aw",@nobits
102102

103103
; For @data3
104104
; COMMON: .type data3,@object
105105
; SYM-NEXT: .section .data.unlikely.data3,"aw",@progbits
106-
; UNIQ-NEXT: .section .data.unlikely.,"aw",@progbits,unique,10
106+
; UNIQ-NEXT: .section .data.unlikely.,"aw",@progbits,unique,8
107107
; AGG-NEXT: .section .data.unlikely.,"aw",@progbits
108108

109109
; For @data_with_unknown_hotness
110110
; SYM: .type .Ldata_with_unknown_hotness,@object # @data_with_unknown_hotness
111111
; SYM: .section .data..Ldata_with_unknown_hotness,"aw",@progbits
112-
; UNIQ: .section .data,"aw",@progbits,unique,11
112+
; UNIQ: .section .data,"aw",@progbits,unique,9
113113
; The `.section` directive is omitted for .data with -unique-section-names=false.
114114
; See MCSectionELF::shouldOmitSectionDirective for the implementation details.
115115
; AGG: .data

llvm/test/CodeGen/X86/jump-table-partition.ll

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@
1313
; STAT: 2 static-data-splitter - Number of hot jump tables seen
1414
; STAT: 2 static-data-splitter - Number of jump tables with unknown hotness
1515

16-
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -enable-split-machine-functions \
17-
; RUN: -partition-static-data-sections=true -function-sections=true \
18-
; RUN: -min-jump-table-entries=2 -unique-section-names=false \
16+
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -partition-static-data-sections \
17+
; RUN: -function-sections -unique-section-names=false \
18+
; RUN: -min-jump-table-entries=2 \
1919
; RUN: %s -o - 2>&1 | FileCheck %s --check-prefixes=NUM,JT
2020

2121
; Section names will optionally have `.<func>` if -function-sections is enabled.
22-
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -enable-split-machine-functions \
23-
; RUN: -partition-static-data-sections=true -function-sections=true \
24-
; RUN: -min-jump-table-entries=2 %s -o - 2>&1 | FileCheck %s --check-prefixes=FUNC,JT
22+
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -partition-static-data-sections \
23+
; RUN: -function-sections -min-jump-table-entries=2 \
24+
; RUN: %s -o - 2>&1 | FileCheck %s --check-prefixes=FUNC,JT
2525

26-
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -enable-split-machine-functions \
27-
; RUN: -partition-static-data-sections=true -function-sections=false \
28-
; RUN: -min-jump-table-entries=2 %s -o - 2>&1 | FileCheck %s --check-prefixes=FUNCLESS,JT
26+
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -partition-static-data-sections \
27+
; RUN: -function-sections=false -min-jump-table-entries=2 \
28+
; RUN: %s -o - 2>&1 | FileCheck %s --check-prefixes=FUNCLESS,JT
2929

3030
; In function @foo, the 2 switch instructions to jt0.* and jt1.* are placed in
3131
; hot-prefixed sections, and the 2 switch instructions to jt2.* and jt3.* are

0 commit comments

Comments
 (0)