[llvm] Expand testing for global merge symbol table info on AIX. (PR #224099)

Sean Fertile via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 10:46:52 PDT 2026


https://github.com/mandlebug updated https://github.com/llvm/llvm-project/pull/224099

>From 0132ddfeff878f459ba04ea40415f3c660387390 Mon Sep 17 00:00:00 2001
From: Sean Fertile <sd.fertile at gmail.com>
Date: Wed, 16 Sep 2026 13:39:15 -0400
Subject: [PATCH 1/2] Expand testing for global merge symbol table info on AIX.

Add a test that checks the symbol table info for merged global symbols
when they do not have an explicit section attribute. Uses the option
nozero-initialized-in-bss so we get symbol table entiries for the
zero initialized globals as well.
---
 .../PowerPC/global-merge-aix-nosections.ll    | 82 +++++++++++++++++++
 1 file changed, 82 insertions(+)
 create mode 100644 llvm/test/CodeGen/PowerPC/global-merge-aix-nosections.ll

diff --git a/llvm/test/CodeGen/PowerPC/global-merge-aix-nosections.ll b/llvm/test/CodeGen/PowerPC/global-merge-aix-nosections.ll
new file mode 100644
index 0000000000000..5e1bc8dbbd223
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/global-merge-aix-nosections.ll
@@ -0,0 +1,82 @@
+; RUN: rm -rf %t
+; RUN: mkdir -p %t
+
+; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr8 -nozero-initialized-in-bss < %s | FileCheck %s
+
+; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr8 \
+; RUN:    -nozero-initialized-in-bss --filetype=obj -o %t/global-merge-aix-nosections.o < %s
+; RUN: llvm-objdump --syms %t/global-merge-aix-nosections.o | FileCheck %s --check-prefix=OBJ
+
+%struct.Example = type { i32, i8 }
+
+ at a = internal global i32 1, align 4
+ at b = internal global i32 2, align 4
+ at c = internal global i32 3, align 4
+ at S1 = internal global %struct.Example { i32 4, i8 5 }, align 4
+
+ at y = internal global i32 0, align 4
+ at z = internal global i32 0, align 4
+ at l = internal global i32 0, align 4
+ at u = internal global i16 0, align 2
+ at S2 = internal global %struct.Example zeroinitializer, align 4
+
+define void @g() {
+entry:
+  call void @escape(ptr noundef nonnull @a)
+  call void @escape(ptr noundef nonnull @b)
+  call void @escape(ptr noundef nonnull @c)
+  call void @escape(ptr noundef nonnull @S1)
+  call void @escape(ptr noundef nonnull @y)
+  call void @escape(ptr noundef nonnull @z)
+  call void @escape(ptr noundef nonnull @l)
+  call void @escape(ptr noundef nonnull @u)
+  call void @escape(ptr noundef nonnull @S2)
+  ret void
+}
+
+declare void @escape(ptr noundef)
+
+; CHECK:        .csect L.._MergedGlobals[RW],2
+; CHECK-NEXT:   .lglobl u
+; CHECK-NEXT:   .lglobl a
+; CHECK-NEXT:   .lglobl b
+; CHECK-NEXT:   .lglobl c
+; CHECK-NEXT:   .lglobl y
+; CHECK-NEXT:   .lglobl z
+; CHECK-NEXT:   .lglobl l
+; CHECK-NEXT:   .lglobl S1
+; CHECK-NEXT:   .lglobl S2
+; CHECK-NEXT:   .align  2
+; CHECK-NEXT: u:
+; CHECK-NEXT:   .vbyte  2, 0
+; CHECK-NEXT:   .space  2
+; CHECK-NEXT: a:
+; CHECK-NEXT:   .vbyte  4, 1
+; CHECK-NEXT: b:
+; CHECK-NEXT:   .vbyte  4, 2
+; CHECK-NEXT: c:
+; CHECK-NEXT:   .vbyte  4, 3
+; CHECK-NEXT: y:
+; CHECK-NEXT:   .vbyte  4, 0
+; CHECK-NEXT: z:
+; CHECK-NEXT:   .vbyte  4, 0
+; CHECK-NEXT: l:
+; CHECK-NEXT:   .vbyte  4, 0
+; CHECK-NEXT: S1:
+; CHECK-NEXT:   .vbyte  4, 4
+; CHECK-NEXT:   .byte   5
+; CHECK-NEXT:   .space  3
+; CHECK-NEXT: S2:
+; CHECK-NEXT:   .space  4
+; CHECK-NEXT:   .space  4
+
+; OBJ:      00000000000000ac l     O .data  000000000000002c L.._MergedGlobals
+; OBJ-NEXT: 00000000000000ac l     O .data (csect: L.._MergedGlobals)       0000000000000000 u
+; OBJ-NEXT: 00000000000000b0 l     O .data (csect: L.._MergedGlobals)       0000000000000000 a
+; OBJ-NEXT: 00000000000000b4 l     O .data (csect: L.._MergedGlobals)       0000000000000000 b
+; OBJ-NEXT: 00000000000000b8 l     O .data (csect: L.._MergedGlobals)       0000000000000000 c
+; OBJ-NEXT: 00000000000000bc l     O .data (csect: L.._MergedGlobals)       0000000000000000 y
+; OBJ-NEXT: 00000000000000c0 l     O .data (csect: L.._MergedGlobals)       0000000000000000 z
+; OBJ-NEXT: 00000000000000c4 l     O .data (csect: L.._MergedGlobals)       0000000000000000 l
+; OBJ-NEXT: 00000000000000c8 l     O .data (csect: L.._MergedGlobals)       0000000000000000 S1
+; OBJ-NEXT: 00000000000000d0 l     O .data (csect: L.._MergedGlobals)       0000000000000000 S2

>From 292946e2e30e23d28504857dd2f4ff16706d79b2 Mon Sep 17 00:00:00 2001
From: Sean Fertile <sd.fertile at gmail.com>
Date: Wed, 23 Sep 2026 13:45:37 -0400
Subject: [PATCH 2/2] Add comment to explain why nozero-initialized-in-bss is
 used in test.

---
 llvm/test/CodeGen/PowerPC/global-merge-aix-nosections.ll | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/llvm/test/CodeGen/PowerPC/global-merge-aix-nosections.ll b/llvm/test/CodeGen/PowerPC/global-merge-aix-nosections.ll
index 5e1bc8dbbd223..eb9de452a255e 100644
--- a/llvm/test/CodeGen/PowerPC/global-merge-aix-nosections.ll
+++ b/llvm/test/CodeGen/PowerPC/global-merge-aix-nosections.ll
@@ -7,7 +7,10 @@
 ; RUN:    -nozero-initialized-in-bss --filetype=obj -o %t/global-merge-aix-nosections.o < %s
 ; RUN: llvm-objdump --syms %t/global-merge-aix-nosections.o | FileCheck %s --check-prefix=OBJ
 
-%struct.Example = type { i32, i8 }
+;; Tests that we emit the symbol table information for symbols that
+;; are merged by the GlobalMerge pass. Use the option
+;; `nozero-initialized-in-bss` as bss symbols drop the extra information
+;; as there are no label defs in CSECTs mapped into the bss section.
 
 @a = internal global i32 1, align 4
 @b = internal global i32 2, align 4



More information about the llvm-commits mailing list