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 @@ -17,6 +17,9 @@ @over_aligned = local_unnamed_addr global double 9.000000e+02, align 32 @chrarray = 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 @a = common global i32 0, align 4 @b = common global i64 0, align 8 @@ -68,6 +71,21 @@ ; 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 + ; CHECK: .comm a,4,2 ; CHECK-NEXT: .comm b,8,3 ; CHECK-NEXT: .comm c,2,1 @@ -97,7 +115,7 @@ ; OBJ-NEXT: Name: .data ; OBJ-NEXT: PhysicalAddress: 0x0 ; OBJ-NEXT: VirtualAddress: 0x0 -; OBJ-NEXT: Size: 0x50 +; OBJ-NEXT: Size: 0x60 ; OBJ-NEXT: RawDataOffset: 0x8C ; OBJ-NEXT: RelocationPointer: 0x0 ; OBJ-NEXT: LineNumberPointer: 0x0 @@ -109,8 +127,8 @@ ; OBJ: Section { ; OBJ-NEXT: Index: 3 ; OBJ-NEXT: Name: .bss -; OBJ-NEXT: PhysicalAddress: 0x50 -; OBJ-NEXT: VirtualAddress: 0x50 +; OBJ-NEXT: PhysicalAddress: 0x60 +; OBJ-NEXT: VirtualAddress: 0x60 ; OBJ-NEXT: Size: 0x14 ; OBJ-NEXT: RawDataOffset: 0x0 ; OBJ-NEXT: RelocationPointer: 0x0 @@ -153,7 +171,7 @@ ; OBJ-NEXT: NumberOfAuxEntries: 1 ; OBJ-NEXT: CSECT Auxiliary Entry { ; OBJ-NEXT: Index: [[#INDX+3]] -; OBJ-NEXT: SectionLen: 80 +; OBJ-NEXT: SectionLen: 96 ; OBJ-NEXT: ParameterHashIndex: 0x0 ; OBJ-NEXT: TypeChkSectNum: 0x0 ; OBJ-NEXT: SymbolAlignmentLog2: 5 @@ -331,4 +349,68 @@ ; OBJ-NEXT: StabSectNum: 0x0 ; OBJ-NEXT: } ; OBJ-NEXT: } + +; OBJ: Symbol { +; OBJ-NEXT: Index: [[#INDX+20]] +; OBJ-NEXT: Name: d_0 +; OBJ-NEXT: Value (RelocatableAddress): 0x50 +; OBJ-NEXT: Section: .data +; OBJ-NEXT: Type: 0x0 +; OBJ-NEXT: StorageClass: C_EXT (0x2) +; OBJ-NEXT: NumberOfAuxEntries: 1 +; OBJ-NEXT: CSECT Auxiliary Entry { +; OBJ-NEXT: Index: [[#INDX+21]] +; OBJ-NEXT: ContainingCsectSymbolIndex: [[#INDX+2]] +; OBJ-NEXT: ParameterHashIndex: 0x0 +; OBJ-NEXT: TypeChkSectNum: 0x0 +; OBJ-NEXT: SymbolAlignmentLog2: 0 +; OBJ-NEXT: SymbolType: XTY_LD (0x2) +; OBJ-NEXT: StorageMappingClass: XMC_RW (0x5) +; OBJ-NEXT: StabInfoIndex: 0x0 +; OBJ-NEXT: StabSectNum: 0x0 +; OBJ-NEXT: } +; OBJ-NEXT: } + +; OBJ: Symbol { +; OBJ-NEXT: Index: [[#INDX+22]] +; OBJ-NEXT: Name: s_0 +; OBJ-NEXT: Value (RelocatableAddress): 0x58 +; OBJ-NEXT: Section: .data +; OBJ-NEXT: Type: 0x0 +; OBJ-NEXT: StorageClass: C_EXT (0x2) +; OBJ-NEXT: NumberOfAuxEntries: 1 +; OBJ-NEXT: CSECT Auxiliary Entry { +; OBJ-NEXT: Index: [[#INDX+23]] +; OBJ-NEXT: ContainingCsectSymbolIndex: [[#INDX+2]] +; OBJ-NEXT: ParameterHashIndex: 0x0 +; OBJ-NEXT: TypeChkSectNum: 0x0 +; OBJ-NEXT: SymbolAlignmentLog2: 0 +; OBJ-NEXT: SymbolType: XTY_LD (0x2) +; OBJ-NEXT: StorageMappingClass: XMC_RW (0x5) +; OBJ-NEXT: StabInfoIndex: 0x0 +; OBJ-NEXT: StabSectNum: 0x0 +; OBJ-NEXT: } +; OBJ-NEXT: } + +; OBJ: Symbol { +; OBJ-NEXT: Index: [[#INDX+24]] +; OBJ-NEXT: Name: f_0 +; OBJ-NEXT: Value (RelocatableAddress): 0x5C +; OBJ-NEXT: Section: .data +; OBJ-NEXT: Type: 0x0 +; OBJ-NEXT: StorageClass: C_EXT (0x2) +; OBJ-NEXT: NumberOfAuxEntries: 1 +; OBJ-NEXT: CSECT Auxiliary Entry { +; OBJ-NEXT: Index: [[#INDX+25]] +; OBJ-NEXT: ContainingCsectSymbolIndex: [[#INDX+2]] +; OBJ-NEXT: ParameterHashIndex: 0x0 +; OBJ-NEXT: TypeChkSectNum: 0x0 +; OBJ-NEXT: SymbolAlignmentLog2: 0 +; OBJ-NEXT: SymbolType: XTY_LD (0x2) +; OBJ-NEXT: StorageMappingClass: XMC_RW (0x5) +; OBJ-NEXT: StabInfoIndex: 0x0 +; OBJ-NEXT: StabSectNum: 0x0 +; OBJ-NEXT: } +; OBJ-NEXT: } + ; OBJ: ]