diff --git a/llvm/lib/MC/MCXCOFFStreamer.cpp b/llvm/lib/MC/MCXCOFFStreamer.cpp --- a/llvm/lib/MC/MCXCOFFStreamer.cpp +++ b/llvm/lib/MC/MCXCOFFStreamer.cpp @@ -10,12 +10,13 @@ // //===----------------------------------------------------------------------===// +#include "llvm/MC/MCXCOFFStreamer.h" #include "llvm/BinaryFormat/XCOFF.h" #include "llvm/MC/MCAsmBackend.h" #include "llvm/MC/MCCodeEmitter.h" +#include "llvm/MC/MCDirectives.h" #include "llvm/MC/MCObjectWriter.h" #include "llvm/MC/MCSymbolXCOFF.h" -#include "llvm/MC/MCXCOFFStreamer.h" #include "llvm/Support/TargetRegistry.h" using namespace llvm; @@ -37,6 +38,10 @@ Symbol->setStorageClass(XCOFF::C_EXT); Symbol->setExternal(true); break; + case MCSA_LGlobal: + Symbol->setStorageClass(XCOFF::C_HIDEXT); + Symbol->setExternal(true); + break; default: report_fatal_error("Not implemented yet."); } diff --git a/llvm/lib/MC/XCOFFObjectWriter.cpp b/llvm/lib/MC/XCOFFObjectWriter.cpp --- a/llvm/lib/MC/XCOFFObjectWriter.cpp +++ b/llvm/lib/MC/XCOFFObjectWriter.cpp @@ -353,6 +353,10 @@ if (XSym == ContainingCsect->getQualNameSymbol()) continue; + // Only put a label into the symbol table when it is an external label. + if (!XSym->isExternal()) + continue; + assert(SectionMap.find(ContainingCsect) != SectionMap.end() && "Expected containing csect to exist in map"); // Lookup the containing csect and add the symbol to it. diff --git a/llvm/test/CodeGen/PowerPC/aix-internal.ll b/llvm/test/CodeGen/PowerPC/aix-internal.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/aix-internal.ll @@ -0,0 +1,38 @@ +; RUN: llc -mtriple powerpc-ibm-aix -verify-machineinstrs -mcpu=pwr4 \ +; RUN: -filetype=obj -o %t.o < %s +; RUN: llvm-readobj --syms %t.o | FileCheck %s +; RUN: not --crash llc -mtriple powerpc64-ibm-aix -verify-machineinstrs -mcpu=pwr4 \ +; RUN: -filetype=obj -o %t.o < %s 2>&1 | FileCheck --check-prefix=64-CHECK %s + +define internal i32 @foo() { + ret i32 1 +} + +; CHECK: Symbol { +; CHECK: Name: .foo +; CHECK-NEXT: Value (RelocatableAddress): +; CHECK-NEXT: Section: .text +; CHECK-NEXT: Type: 0x0 +; CHECK-NEXT: StorageClass: C_HIDEXT (0x6B) + +; CHECK: Symbol { +; CHECK-NEXT: Index: [[#INDX:]] +; CHECK-NEXT: Name: foo +; CHECK-NEXT: Value (RelocatableAddress): +; CHECK-NEXT: Section: .data +; CHECK-NEXT: Type: 0x0 +; CHECK-NEXT: StorageClass: C_HIDEXT (0x6B) +; CHECK-NEXT: NumberOfAuxEntries: 1 +; CHECK-NEXT: CSECT Auxiliary Entry { +; CHECK-NEXT: Index: [[#INDX+1]] +; CHECK-NEXT: SectionLen: 12 +; CHECK-NEXT: ParameterHashIndex: +; CHECK-NEXT: TypeChkSectNum: +; CHECK-NEXT: SymbolAlignmentLog2: +; CHECK-NEXT: SymbolType: XTY_SD (0x1) +; CHECK-NEXT: StorageMappingClass: XMC_DS (0xA) + +; Make sure no label is emitted. +; CHECK-NOT: Name: foo + +;64-CHECK: LLVM ERROR: 64-bit XCOFF object files are not supported yet. diff --git a/llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll b/llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll --- a/llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll +++ b/llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll @@ -52,18 +52,15 @@ ;CHECKOBJ-NEXT: 4: 4e 80 00 20 blr ;CHECKOBJ-NEXT: ...{{[[:space:]] *}} ;CHECKOBJ-NEXT: 00000010 .rodata: -;CHECKOBJ-NEXT: 10: 40 00 00 00 bdnzf 0, .+0 -;CHECKOBJ-NEXT: 14: 00 00 00 32 +;CHECKOBJ-NEXT: 10: 40 00 00 00 +;CHECKOBJ-NEXT: 14: 00 00 00 32 ;CHECKOBJ-NEXT: ...{{[[:space:]] *}} -;CHECKOBJ-NEXT: 00000030 .L__const.main.cnst16: -;CHECKOBJ-NEXT: 30: 40 00 00 00 bdnzf 0, .+0 -;CHECKOBJ-NEXT: 34: 00 00 00 16 +;CHECKOBJ-SAME: 30: 40 00 00 00 +;CHECKOBJ-NEXT: 34: 00 00 00 16 ;CHECKOBJ-NEXT: ...{{[[:space:]] *}} -;CHECKOBJ-NEXT: 00000040 .L__const.main.cnst8: -;CHECKOBJ-NEXT: 40: 40 00 00 08 bdnzf 0, .+8 -;CHECKOBJ-NEXT: 44: 00 00 00 00 {{[[:space:]] *}} -;CHECKOBJ-NEXT: 00000048 .L__const.main.cnst4: -;CHECKOBJ-NEXT: 48: 40 08 00 00 bdnzf 8, .+0 +;CHECKOBJ-SAME: 40: 40 00 00 08 +;CHECKOBJ-NEXT: 44: 00 00 00 00 +;CHECKOBJ-NEXT: 48: 40 08 00 00 ;CHECKSYM: Symbol {{[{][[:space:]] *}}Index: [[#Index:]]{{[[:space:]] *}}Name: .rodata @@ -84,83 +81,3 @@ ;CHECKSYM-NEXT: StabSectNum: 0x0 ;CHECKSYM-NEXT: } ;CHECKSYM-NEXT: } -;CHECKSYM-NEXT: Symbol { -;CHECKSYM-NEXT: Index: [[#Index+2]] -;CHECKSYM-NEXT: Name: .L__const.main.cnst32 -;CHECKSYM-NEXT: Value (RelocatableAddress): 0x10 -;CHECKSYM-NEXT: Section: .text -;CHECKSYM-NEXT: Type: 0x0 -;CHECKSYM-NEXT: StorageClass: C_HIDEXT (0x6B) -;CHECKSYM-NEXT: NumberOfAuxEntries: 1 -;CHECKSYM-NEXT: CSECT Auxiliary Entry { -;CHECKSYM-NEXT: Index: [[#Index+3]] -;CHECKSYM-NEXT: ContainingCsectSymbolIndex: [[#Index]] -;CHECKSYM-NEXT: ParameterHashIndex: 0x0 -;CHECKSYM-NEXT: TypeChkSectNum: 0x0 -;CHECKSYM-NEXT: SymbolAlignmentLog2: 0 -;CHECKSYM-NEXT: SymbolType: XTY_LD (0x2) -;CHECKSYM-NEXT: StorageMappingClass: XMC_RO (0x1) -;CHECKSYM-NEXT: StabInfoIndex: 0x0 -;CHECKSYM-NEXT: StabSectNum: 0x0 -;CHECKSYM-NEXT: } -;CHECKSYM-NEXT: } -;CHECKSYM-NEXT: Symbol { -;CHECKSYM-NEXT: Index: [[#Index+4]] -;CHECKSYM-NEXT: Name: .L__const.main.cnst16 -;CHECKSYM-NEXT: Value (RelocatableAddress): 0x30 -;CHECKSYM-NEXT: Section: .text -;CHECKSYM-NEXT: Type: 0x0 -;CHECKSYM-NEXT: StorageClass: C_HIDEXT (0x6B) -;CHECKSYM-NEXT: NumberOfAuxEntries: 1 -;CHECKSYM-NEXT: CSECT Auxiliary Entry { -;CHECKSYM-NEXT: Index: [[#Index+5]] -;CHECKSYM-NEXT: ContainingCsectSymbolIndex: [[#Index]] -;CHECKSYM-NEXT: ParameterHashIndex: 0x0 -;CHECKSYM-NEXT: TypeChkSectNum: 0x0 -;CHECKSYM-NEXT: SymbolAlignmentLog2: 0 -;CHECKSYM-NEXT: SymbolType: XTY_LD (0x2) -;CHECKSYM-NEXT: StorageMappingClass: XMC_RO (0x1) -;CHECKSYM-NEXT: StabInfoIndex: 0x0 -;CHECKSYM-NEXT: StabSectNum: 0x0 -;CHECKSYM-NEXT: } -;CHECKSYM-NEXT: } -;CHECKSYM-NEXT: Symbol { -;CHECKSYM-NEXT: Index: [[#Index+6]] -;CHECKSYM-NEXT: Name: .L__const.main.cnst8 -;CHECKSYM-NEXT: Value (RelocatableAddress): 0x40 -;CHECKSYM-NEXT: Section: .text -;CHECKSYM-NEXT: Type: 0x0 -;CHECKSYM-NEXT: StorageClass: C_HIDEXT (0x6B) -;CHECKSYM-NEXT: NumberOfAuxEntries: 1 -;CHECKSYM-NEXT: CSECT Auxiliary Entry { -;CHECKSYM-NEXT: Index: [[#Index+7]] -;CHECKSYM-NEXT: ContainingCsectSymbolIndex: [[#Index]] -;CHECKSYM-NEXT: ParameterHashIndex: 0x0 -;CHECKSYM-NEXT: TypeChkSectNum: 0x0 -;CHECKSYM-NEXT: SymbolAlignmentLog2: 0 -;CHECKSYM-NEXT: SymbolType: XTY_LD (0x2) -;CHECKSYM-NEXT: StorageMappingClass: XMC_RO (0x1) -;CHECKSYM-NEXT: StabInfoIndex: 0x0 -;CHECKSYM-NEXT: StabSectNum: 0x0 -;CHECKSYM-NEXT: } -;CHECKSYM-NEXT: } -;CHECKSYM-NEXT: Symbol { -;CHECKSYM-NEXT: Index: [[#Index+8]] -;CHECKSYM-NEXT: Name: .L__const.main.cnst4 -;CHECKSYM-NEXT: Value (RelocatableAddress): 0x48 -;CHECKSYM-NEXT: Section: .text -;CHECKSYM-NEXT: Type: 0x0 -;CHECKSYM-NEXT: StorageClass: C_HIDEXT (0x6B) -;CHECKSYM-NEXT: NumberOfAuxEntries: 1 -;CHECKSYM-NEXT: CSECT Auxiliary Entry { -;CHECKSYM-NEXT: Index: [[#Index+9]] -;CHECKSYM-NEXT: ContainingCsectSymbolIndex: [[#Index]] -;CHECKSYM-NEXT: ParameterHashIndex: 0x0 -;CHECKSYM-NEXT: TypeChkSectNum: 0x0 -;CHECKSYM-NEXT: SymbolAlignmentLog2: 0 -;CHECKSYM-NEXT: SymbolType: XTY_LD (0x2) -;CHECKSYM-NEXT: StorageMappingClass: XMC_RO (0x1) -;CHECKSYM-NEXT: StabInfoIndex: 0x0 -;CHECKSYM-NEXT: StabSectNum: 0x0 -;CHECKSYM-NEXT: } -;CHECKSYM-NEXT: } diff --git a/llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll b/llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll --- a/llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll +++ b/llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll @@ -78,9 +78,6 @@ ; CHECKOBJ-NEXT: 28: 68 65 6c 6c ; CHECKOBJ-NEXT: 2c: 6f 20 77 6f ; CHECKOBJ-NEXT: 30: 72 6c 64 21 -; CHECKOBJ-NEXT: 34: 0a 00 61 62 {{.*}}{{[[:space:]] *}} -; CHECKOBJ-NEXT: 00000036 .L.str: -; CHECKOBJ-NEXT: 36: 61 62 63 64 -; CHECKOBJ-NEXT: 3a: 65 66 67 68 -; CHECKOBJ-NEXT: 3e: 00 -; CHECKOBJ-NEXT: 3f: 00 +; CHECKOBJ-NEXT: 34: 0a 00 61 62 +; CHECKOBJ-NEXT: 38: 63 64 65 66 +; CHECKOBJ-NEXT: 3c: 67 68 00 00