[llvm-branch-commits] [llvm] 33e14ec - [CodeGen] Don't treat thread local globals as large data (#67764)

Tobias Hieta via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Oct 2 10:23:56 PDT 2023


Author: Arthur Eubanks
Date: 2023-10-02T19:23:20+02:00
New Revision: 33e14ecd6aac8c61c055921dd6e564d170fe34d6

URL: https://github.com/llvm/llvm-project/commit/33e14ecd6aac8c61c055921dd6e564d170fe34d6
DIFF: https://github.com/llvm/llvm-project/commit/33e14ecd6aac8c61c055921dd6e564d170fe34d6.diff

LOG: [CodeGen] Don't treat thread local globals as large data (#67764)

Otherwise they may mistakenly get the large section flag.

(cherry picked from commit b915f60678c3033c466611be1119a46ba4b0869c)
(fix was slightly different since cherry-pick didn't apply well)

Added: 
    

Modified: 
    llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
    llvm/test/CodeGen/X86/code-model-elf-sections.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 55fb522554fad25..4ffffd85ee53899 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -855,7 +855,7 @@ static MCSectionELF *selectELFSectionForGlobal(
     Group = C->getName();
     IsComdat = C->getSelectionKind() == Comdat::Any;
   }
-  if (isa<GlobalVariable>(GO)) {
+  if (isa<GlobalVariable>(GO) && !cast<GlobalVariable>(GO)->isThreadLocal()) {
     if (TM.isLargeData()) {
       assert(TM.getTargetTriple().getArch() == Triple::x86_64);
       Flags |= ELF::SHF_X86_64_LARGE;

diff  --git a/llvm/test/CodeGen/X86/code-model-elf-sections.ll b/llvm/test/CodeGen/X86/code-model-elf-sections.ll
index 24c672d10e95a45..4862f02f883f5f2 100644
--- a/llvm/test/CodeGen/X86/code-model-elf-sections.ll
+++ b/llvm/test/CodeGen/X86/code-model-elf-sections.ll
@@ -16,21 +16,29 @@
 ; SMALL: .bss {{.*}} WA {{.*}}
 ; SMALL: .rodata {{.*}} A {{.*}}
 ; SMALL: .data.rel.ro {{.*}} WA {{.*}}
+; SMALL: .tbss {{.*}} WAT {{.*}}
+; SMALL: .tdata {{.*}} WAT {{.*}}
 
 ; SMALL-DS: .data.data {{.*}} WA {{.*}}
 ; SMALL-DS: .bss.bss {{.*}} WA {{.*}}
 ; SMALL-DS: .rodata.rodata {{.*}} A {{.*}}
 ; SMALL-DS: .data.rel.ro.relro {{.*}} WA {{.*}}
+; SMALL-DS: .tbss.tbss {{.*}} WAT {{.*}}
+; SMALL-DS: .tdata.tdata {{.*}} WAT {{.*}}
 
 ; LARGE: .ldata {{.*}} WAl {{.*}}
 ; LARGE: .lbss {{.*}} WAl {{.*}}
 ; LARGE: .lrodata {{.*}} Al {{.*}}
 ; LARGE: .ldata.rel.ro {{.*}} WAl {{.*}}
+; LARGE: .tbss {{.*}} WAT {{.*}}
+; LARGE: .tdata {{.*}} WAT {{.*}}
 
 ; LARGE-DS: .ldata.data {{.*}} WAl {{.*}}
 ; LARGE-DS: .lbss.bss {{.*}} WAl {{.*}}
 ; LARGE-DS: .lrodata.rodata {{.*}} Al {{.*}}
 ; LARGE-DS: .ldata.rel.ro.relro {{.*}} WAl {{.*}}
+; LARGE-DS: .tbss.tbss {{.*}} WAT {{.*}}
+; LARGE-DS: .tdata.tdata {{.*}} WAT {{.*}}
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64--linux"
@@ -39,5 +47,7 @@ target triple = "x86_64--linux"
 @bss = internal global [10 x i64] zeroinitializer
 @rodata = internal constant [10 x i64] zeroinitializer
 @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]
+ at tbss = internal thread_local global [10 x i64] zeroinitializer
+ at 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]
 
 declare void @func()


        


More information about the llvm-branch-commits mailing list