Skip to content

Commit 29456e9

Browse files
authored
[PowerPC] Fix assembler error with toc-data and data-sections (#91976)
We should not emit the label for the toc-data variable when data-sections=false.
1 parent c618ae1 commit 29456e9

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2831,8 +2831,10 @@ void PPCAIXAsmPrinter::emitGlobalVariableHelper(const GlobalVariable *GV) {
28312831

28322832
// When -fdata-sections is enabled, every GlobalVariable will
28332833
// be put into its own csect; therefore, label is not necessary here.
2834-
if (!TM.getDataSections() || GV->hasSection())
2835-
OutStreamer->emitLabel(EmittedInitSym);
2834+
if (!TM.getDataSections() || GV->hasSection()) {
2835+
if (Csect->getMappingClass() != XCOFF::XMC_TD)
2836+
OutStreamer->emitLabel(EmittedInitSym);
2837+
}
28362838

28372839
// No alias to emit.
28382840
if (!GOAliasMap[GV].size()) {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
; RUN: llc -mtriple powerpc64-ibm-aix-xcoff -data-sections=false -verify-machineinstrs < %s | FileCheck %s
2+
3+
@a1 = global i32 0, align 4 #0
4+
5+
define void @foo() {
6+
entry:
7+
store i32 1, ptr @a1, align 4
8+
ret void
9+
}
10+
11+
attributes #0 = { "toc-data" }
12+
13+
; CHECK: .toc
14+
; CHECK-NEXT: .csect a1[TD],2
15+
; CHECK-NEXT: .globl a1[TD]
16+
; CHECK-NEXT: .align 2
17+
; CHECK-NOT: a1[TD]:
18+
; CHECK-NEXT: .vbyte 4, 0

0 commit comments

Comments
 (0)