[llvm] [X86] Print 'l' section flag for SHF_X86_64_LARGE (PR #70380)

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 26 14:05:48 PDT 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-x86

Author: Arthur Eubanks (aeubanks)

<details>
<summary>Changes</summary>

When directly compiling to an object file we properly set the section flag, but not when emitting assembly.


---
Full diff: https://github.com/llvm/llvm-project/pull/70380.diff


2 Files Affected:

- (modified) llvm/lib/MC/MCSectionELF.cpp (+3) 
- (modified) llvm/test/CodeGen/X86/code-model-elf-sections.ll (+4) 


``````````diff
diff --git a/llvm/lib/MC/MCSectionELF.cpp b/llvm/lib/MC/MCSectionELF.cpp
index 666252ffcb74eb3..95fdf33522076e4 100644
--- a/llvm/lib/MC/MCSectionELF.cpp
+++ b/llvm/lib/MC/MCSectionELF.cpp
@@ -123,6 +123,9 @@ void MCSectionELF::printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
   } else if (Arch == Triple::hexagon) {
     if (Flags & ELF::SHF_HEX_GPREL)
       OS << 's';
+  } else if (Arch == Triple::x86_64) {
+    if (Flags & ELF::SHF_X86_64_LARGE)
+      OS << 'l';
   }
 
   OS << '"';
diff --git a/llvm/test/CodeGen/X86/code-model-elf-sections.ll b/llvm/test/CodeGen/X86/code-model-elf-sections.ll
index fe659fa9a46e727..e09e145b3f47b72 100644
--- a/llvm/test/CodeGen/X86/code-model-elf-sections.ll
+++ b/llvm/test/CodeGen/X86/code-model-elf-sections.ll
@@ -16,6 +16,8 @@
 ; RUN: llc < %s -relocation-model=pic -filetype=obj -code-model=large -data-sections -o %t
 ; RUN: llvm-readelf -S %t | FileCheck %s --check-prefix=SMALL-DS
 
+; RUN: llc < %s -relocation-model=pic -filetype=asm -code-model=medium -large-data-threshold=79 -o - | FileCheck %s --check-prefix=LARGE-ASM
+
 ; SMALL: .data {{.*}} WA {{.*}}
 ; SMALL: foo {{.*}} WA {{.*}}
 ; SMALL: .bss {{.*}} WA {{.*}}
@@ -48,6 +50,8 @@
 ; LARGE-DS: .tbss.tbss {{.*}} WAT {{.*}}
 ; LARGE-DS: .tdata.tdata {{.*}} WAT {{.*}}
 
+; LARGE-ASM: .lrodata,"al"
+
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64--linux"
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/70380


More information about the llvm-commits mailing list