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

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 27 13:36:23 PDT 2023


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

>From 96ed091974d0c6bad5e86262c424b128459a8323 Mon Sep 17 00:00:00 2001
From: Arthur Eubanks <aeubanks at google.com>
Date: Thu, 26 Oct 2023 14:01:43 -0700
Subject: [PATCH 1/2] [X86] Print 'l' section flag for SHF_X86_64_LARGE

When directly compiling to an object file we properly set the section flag, but not when emitting assembly.
---
 llvm/lib/MC/MCSectionELF.cpp                     | 3 +++
 llvm/test/CodeGen/X86/code-model-elf-sections.ll | 4 ++++
 2 files changed, 7 insertions(+)

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"
 

>From cbd9a39a9ef08db1ac370036ae84eecd492b4b00 Mon Sep 17 00:00:00 2001
From: Arthur Eubanks <aeubanks at google.com>
Date: Fri, 27 Oct 2023 13:34:20 -0700
Subject: [PATCH 2/2] Use MC test instead

---
 llvm/test/CodeGen/X86/code-model-elf-sections.ll | 4 ----
 llvm/test/MC/ELF/section.s                       | 2 ++
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/llvm/test/CodeGen/X86/code-model-elf-sections.ll b/llvm/test/CodeGen/X86/code-model-elf-sections.ll
index e09e145b3f47b72..fe659fa9a46e727 100644
--- a/llvm/test/CodeGen/X86/code-model-elf-sections.ll
+++ b/llvm/test/CodeGen/X86/code-model-elf-sections.ll
@@ -16,8 +16,6 @@
 ; 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 {{.*}}
@@ -50,8 +48,6 @@
 ; 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"
 
diff --git a/llvm/test/MC/ELF/section.s b/llvm/test/MC/ELF/section.s
index 3a6d046821f4ae5..8c625256a2761d8 100644
--- a/llvm/test/MC/ELF/section.s
+++ b/llvm/test/MC/ELF/section.s
@@ -269,6 +269,8 @@ bar:
 // CHECK-NEXT:     ]
 
 .section .large,"l"
+// ASM: .section .large,"l"
+
 // CHECK:        Section {
 // CHECK:          Name: .large
 // CHECK-NEXT:     Type: SHT_PROGBITS



More information about the llvm-commits mailing list