Skip to content

Commit 7433b1c

Browse files
committed
Reapply "[X86] Set SHF_X86_64_LARGE for globals with explicit well-known large section name (#74381)"
This reverts commit 19fff85. Now that explicit large globals are handled properly in the small code model.
1 parent e6f5762 commit 7433b1c

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

llvm/lib/Target/TargetMachine.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ bool TargetMachine::isLargeGlobalValue(const GlobalValue *GVal) const {
6161
// We should properly mark well-known section name prefixes as small/large,
6262
// because otherwise the output section may have the wrong section flags and
6363
// the linker will lay it out in an unexpected way.
64-
// TODO: bring back lbss/ldata/lrodata checks after fixing accesses to large
65-
// globals in the small code model.
6664
StringRef Name = GV->getSection();
6765
if (!Name.empty()) {
6866
auto IsPrefix = [&](StringRef Prefix) {
@@ -71,6 +69,8 @@ bool TargetMachine::isLargeGlobalValue(const GlobalValue *GVal) const {
7169
};
7270
if (IsPrefix(".bss") || IsPrefix(".data") || IsPrefix(".rodata"))
7371
return false;
72+
if (IsPrefix(".lbss") || IsPrefix(".ldata") || IsPrefix(".lrodata"))
73+
return true;
7474
}
7575

7676
// For x86-64, we treat an explicit GlobalVariable small code model to mean

llvm/test/CodeGen/X86/code-model-elf-sections.ll

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,33 @@
2121
; SMALL: .data {{.*}} WA {{.*}}
2222
; SMALL: .data.x {{.*}} WA {{.*}}
2323
; SMALL: .data0 {{.*}} WA {{.*}}
24-
; SMALL: .ldata {{.*}} WA {{.*}}
25-
; SMALL: .ldata.x {{.*}} WA {{.*}}
24+
; SMALL: .ldata {{.*}} WAl {{.*}}
25+
; SMALL: .ldata.x {{.*}} WAl {{.*}}
2626
; SMALL: .ldata0 {{.*}} WA {{.*}}
2727
; SMALL: force_small {{.*}} WA {{.*}}
2828
; SMALL: force_large {{.*}} WAl {{.*}}
2929
; SMALL: foo {{.*}} WA {{.*}}
3030
; SMALL: .bss {{.*}} WA {{.*}}
31-
; SMALL: .lbss {{.*}} WA {{.*}}
31+
; SMALL: .lbss {{.*}} WAl {{.*}}
3232
; SMALL: .rodata {{.*}} A {{.*}}
33-
; SMALL: .lrodata {{.*}} A {{.*}}
33+
; SMALL: .lrodata {{.*}} Al {{.*}}
3434
; SMALL: .data.rel.ro {{.*}} WA {{.*}}
3535
; SMALL: .tbss {{.*}} WAT {{.*}}
3636
; SMALL: .tdata {{.*}} WAT {{.*}}
3737

3838
; SMALL-DS: .data {{.*}} WA {{.*}}
3939
; SMALL-DS: .data.x {{.*}} WA {{.*}}
4040
; SMALL-DS: .data0 {{.*}} WA {{.*}}
41-
; SMALL-DS: .ldata {{.*}} WA {{.*}}
42-
; SMALL-DS: .ldata.x {{.*}} WA {{.*}}
41+
; SMALL-DS: .ldata {{.*}} WAl {{.*}}
42+
; SMALL-DS: .ldata.x {{.*}} WAl {{.*}}
4343
; SMALL-DS: .ldata0 {{.*}} WA {{.*}}
4444
; SMALL-DS: .data.data {{.*}} WA {{.*}}
4545
; SMALL-DS: force_small {{.*}} WA {{.*}}
4646
; SMALL-DS: force_large {{.*}} WAl {{.*}}
4747
; SMALL-DS: foo {{.*}} WA {{.*}}
48-
; SMALL-DS: .lbss {{.*}} WA {{.*}}
48+
; SMALL-DS: .lbss {{.*}} WAl {{.*}}
4949
; SMALL-DS: .bss.bss {{.*}} WA {{.*}}
50-
; SMALL-DS: .lrodata {{.*}} A {{.*}}
50+
; SMALL-DS: .lrodata {{.*}} Al {{.*}}
5151
; SMALL-DS: .rodata.rodata {{.*}} A {{.*}}
5252
; SMALL-DS: .data.rel.ro.relro {{.*}} WA {{.*}}
5353
; SMALL-DS: .tbss.tbss {{.*}} WAT {{.*}}

0 commit comments

Comments
 (0)