Skip to content

Commit 0cfd854

Browse files
mandlebuggithub-actions[bot]
authored andcommitted
Automerge: 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.
2 parents 089ceff + 43b69e7 commit 0cfd854

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2750,6 +2750,10 @@ void PPCAIXAsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
27502750
if (isSpecialLLVMGlobalArrayToSkip(GV) || isSpecialLLVMGlobalArrayForStaticInit(GV))
27512751
return;
27522752

2753+
// Ignore non-emitted data.
2754+
if (GV->getSection() == "llvm.metadata")
2755+
return;
2756+
27532757
// If the Global Variable has the toc-data attribute, it needs to be emitted
27542758
// when we emit the .toc section.
27552759
if (GV->hasAttribute("toc-data")) {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; RUN: llc -verify-machineinstrs -mcpu=pwr8 -mtriple powerpc-ibm-aix-xcoff < \
2+
; RUN: %s | FileCheck %s
3+
; RUN: llc -verify-machineinstrs -mcpu=pwr8 -mtriple powerpc64le-unknown-linux < \
4+
; RUN: %s | FileCheck %s
5+
6+
@.str = private unnamed_addr constant [12 x i8] c"MY_METADATA\00", section "llvm.metadata"
7+
@.str.1 = private unnamed_addr constant [10 x i8] c"my_file.c\00", section "llvm.metadata"
8+
@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"
9+
10+
@a = global i32 1
11+
@b = global i32 2
12+
@c = global i32 3
13+
14+
; CHECK-NOT: metadata
15+
; CHECK-NOT: annotations

0 commit comments

Comments
 (0)