diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -1855,6 +1855,12 @@ if (Kind.isData()) return DataSection; + // Zero initialized data must be emitted to the .data section because external + // linkage control sections that get mapped to the .bss section will be linked + // as tentative defintions, which is only appropriate for SectionKind::Common. + if (Kind.isBSS()) + return DataSection; + report_fatal_error("XCOFF other section types not yet implemented."); } diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp --- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -1747,7 +1747,7 @@ report_fatal_error("COMDAT not yet supported by AIX."); SectionKind GVKind = getObjFileLowering().getKindForGlobal(GV, TM); - if (!GVKind.isCommon() && !GVKind.isBSSLocal() && !GVKind.isData()) + if (!GVKind.isCommon() && !GVKind.isBSS() && !GVKind.isData()) report_fatal_error("Encountered a global variable kind that is " "not supported yet."); diff --git a/llvm/test/CodeGen/PowerPC/aix-xcoff-data.ll b/llvm/test/CodeGen/PowerPC/aix-xcoff-data.ll --- a/llvm/test/CodeGen/PowerPC/aix-xcoff-data.ll +++ b/llvm/test/CodeGen/PowerPC/aix-xcoff-data.ll @@ -9,6 +9,9 @@ @over_aligned = local_unnamed_addr global double 9.000000e+02, align 32 @charr = local_unnamed_addr global [4 x i8] c"abcd", align 1 @dblarr = local_unnamed_addr global [4 x double] [double 1.000000e+00, double 2.000000e+00, double 3.000000e+00, double 4.000000e+00], align 8 +@d_0 = global double 0.000000e+00, align 8 +@s_0 = global i16 0, align 2 +@f_0 = global float 0.000000e+00, align 4 ; CHECK: .csect .data[RW] ; CHECK-NEXT: .globl ivar @@ -55,3 +58,18 @@ ; CHECK-NEXT: .llong 4611686018427387904 ; CHECK-NEXT: .llong 4613937818241073152 ; CHECK-NEXT: .llong 4616189618054758400 + +; CHECK: .globl d_0 +; CHECK-NEXT: .align 3 +; CHECK-NEXT: d_0: +; CHECK-NEXT: .llong 0 + +; CHECK: .globl s_0 +; CHECK-NEXT: .align 1 +; CHECK-NEXT: s_0: +; CHECK-NEXT: .short 0 + +; CHECK: .globl f_0 +; CHECK-NEXT: .align 2 +; CHECK-NEXT: f_0: +; CHECK-NEXT: .long 0