[llvm] 43b69e7 - Filter out unemitted metadata before assertion in AIXAsmPrinter. (#165620)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 6 07:07:27 PST 2025
Author: Sean Fertile
Date: 2025-11-06T10:07:22-05:00
New Revision: 43b69e760eb489f2fa741e973a8cc36ff80ea9db
URL: https://github.com/llvm/llvm-project/commit/43b69e760eb489f2fa741e973a8cc36ff80ea9db
DIFF: https://github.com/llvm/llvm-project/commit/43b69e760eb489f2fa741e973a8cc36ff80ea9db.diff
LOG: Filter out unemitted metadata before assertion in AIXAsmPrinter. (#165620)
Global annotations metadata would trigger an assertion during code
emission on AIX. Filter out globals that are in the "llvm.metadata"
section before reaching the assert. Adds a test to verify the metadata
is not emitted on either ELF or XCOFF targets.
Added:
llvm/test/CodeGen/PowerPC/annotate-metadata.ll
Modified:
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
index 780e124bd2c14..122738caa6827 100644
--- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -2750,6 +2750,10 @@ void PPCAIXAsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
if (isSpecialLLVMGlobalArrayToSkip(GV) || isSpecialLLVMGlobalArrayForStaticInit(GV))
return;
+ // Ignore non-emitted data.
+ if (GV->getSection() == "llvm.metadata")
+ return;
+
// If the Global Variable has the toc-data attribute, it needs to be emitted
// when we emit the .toc section.
if (GV->hasAttribute("toc-data")) {
diff --git a/llvm/test/CodeGen/PowerPC/annotate-metadata.ll b/llvm/test/CodeGen/PowerPC/annotate-metadata.ll
new file mode 100644
index 0000000000000..4149b56e0ea95
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/annotate-metadata.ll
@@ -0,0 +1,15 @@
+; RUN: llc -verify-machineinstrs -mcpu=pwr8 -mtriple powerpc-ibm-aix-xcoff < \
+; RUN: %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mcpu=pwr8 -mtriple powerpc64le-unknown-linux < \
+; RUN: %s | FileCheck %s
+
+ at .str = private unnamed_addr constant [12 x i8] c"MY_METADATA\00", section "llvm.metadata"
+ at .str.1 = private unnamed_addr constant [10 x i8] c"my_file.c\00", section "llvm.metadata"
+ at global.annotations = appending global [3 x { ptr, ptr, ptr, i32, ptr }] [{ ptr, ptr, ptr, i32, ptr } { ptr @a, ptr @.str, ptr @.str.1, i32 100, ptr null }, { ptr, ptr, ptr, i32, ptr } { ptr @b, ptr @.str, ptr @.str.1, i32 200, ptr null }, { ptr, ptr, ptr, i32, ptr } { ptr @c, ptr @.str, ptr @.str.1, i32 300, ptr null }], section "llvm.metadata"
+
+ at a = global i32 1
+ at b = global i32 2
+ at c = global i32 3
+
+; CHECK-NOT: metadata
+; CHECK-NOT: annotations
More information about the llvm-commits
mailing list