Skip to content

Commit b915f60

Browse files
authored
[CodeGen] Don't treat thread local globals as large data (llvm#67764)
Otherwise they may mistakenly get the large section flag.
1 parent 7ebf3e0 commit b915f60

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

llvm/lib/Target/TargetMachine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ TargetMachine::TargetMachine(const Target &T, StringRef DataLayoutString,
4040
TargetMachine::~TargetMachine() = default;
4141

4242
bool TargetMachine::isLargeData(const GlobalVariable *GV) const {
43-
if (getTargetTriple().getArch() != Triple::x86_64)
43+
if (getTargetTriple().getArch() != Triple::x86_64 || GV->isThreadLocal())
4444
return false;
4545
// Large data under the large code model still needs to be thought about, so
4646
// restrict this to medium.

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,29 @@
2020
; SMALL: .bss {{.*}} WA {{.*}}
2121
; SMALL: .rodata {{.*}} A {{.*}}
2222
; SMALL: .data.rel.ro {{.*}} WA {{.*}}
23+
; SMALL: .tbss {{.*}} WAT {{.*}}
24+
; SMALL: .tdata {{.*}} WAT {{.*}}
2325

2426
; SMALL-DS: .data.data {{.*}} WA {{.*}}
2527
; SMALL-DS: .bss.bss {{.*}} WA {{.*}}
2628
; SMALL-DS: .rodata.rodata {{.*}} A {{.*}}
2729
; SMALL-DS: .data.rel.ro.relro {{.*}} WA {{.*}}
30+
; SMALL-DS: .tbss.tbss {{.*}} WAT {{.*}}
31+
; SMALL-DS: .tdata.tdata {{.*}} WAT {{.*}}
2832

2933
; LARGE: .ldata {{.*}} WAl {{.*}}
3034
; LARGE: .lbss {{.*}} WAl {{.*}}
3135
; LARGE: .lrodata {{.*}} Al {{.*}}
3236
; LARGE: .ldata.rel.ro {{.*}} WAl {{.*}}
37+
; LARGE: .tbss {{.*}} WAT {{.*}}
38+
; LARGE: .tdata {{.*}} WAT {{.*}}
3339

3440
; LARGE-DS: .ldata.data {{.*}} WAl {{.*}}
3541
; LARGE-DS: .lbss.bss {{.*}} WAl {{.*}}
3642
; LARGE-DS: .lrodata.rodata {{.*}} Al {{.*}}
3743
; LARGE-DS: .ldata.rel.ro.relro {{.*}} WAl {{.*}}
44+
; LARGE-DS: .tbss.tbss {{.*}} WAT {{.*}}
45+
; LARGE-DS: .tdata.tdata {{.*}} WAT {{.*}}
3846

3947
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4048
target triple = "x86_64--linux"
@@ -43,5 +51,7 @@ target triple = "x86_64--linux"
4351
@bss = internal global [10 x i64] zeroinitializer
4452
@rodata = internal constant [10 x i64] zeroinitializer
4553
@relro = internal constant [10 x ptr] [ptr @func, ptr @func, ptr @func, ptr @func, ptr @func, ptr @func, ptr @func, ptr @func, ptr @func, ptr @func]
54+
@tbss = internal thread_local global [10 x i64] zeroinitializer
55+
@tdata = internal thread_local global [10 x i64] [i64 1, i64 2, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0]
4656

4757
declare void @func()

0 commit comments

Comments
 (0)