diff --git a/llvm/include/llvm/MC/MCAsmInfo.h b/llvm/include/llvm/MC/MCAsmInfo.h --- a/llvm/include/llvm/MC/MCAsmInfo.h +++ b/llvm/include/llvm/MC/MCAsmInfo.h @@ -307,6 +307,10 @@ /// false. bool HasAltEntry = false; + /// True if this target supports the XCOFF .extern directive. Defaults to + /// false. + bool HasDotExternDirective = false; + /// Used to declare a global as being a weak symbol. Defaults to ".weak". const char *WeakDirective; @@ -583,6 +587,7 @@ bool hasIdentDirective() const { return HasIdentDirective; } bool hasNoDeadStrip() const { return HasNoDeadStrip; } bool hasAltEntry() const { return HasAltEntry; } + bool hasDotExternDirective() const { return HasDotExternDirective; } const char *getWeakDirective() const { return WeakDirective; } const char *getWeakRefDirective() const { return WeakRefDirective; } bool hasWeakDefDirective() const { return HasWeakDefDirective; } diff --git a/llvm/include/llvm/MC/MCDirectives.h b/llvm/include/llvm/MC/MCDirectives.h --- a/llvm/include/llvm/MC/MCDirectives.h +++ b/llvm/include/llvm/MC/MCDirectives.h @@ -29,6 +29,7 @@ MCSA_ELF_TypeGnuUniqueObject, /// .type _foo, @gnu_unique_object MCSA_Global, ///< .globl MCSA_LGlobal, ///< .lglobl (XCOFF) + MCSA_Extern, ///< .extern (XCOFF) MCSA_Hidden, ///< .hidden (ELF) MCSA_IndirectSymbol, ///< .indirect_symbol (MachO) MCSA_Internal, ///< .internal (ELF) diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -395,6 +395,8 @@ GlobalValue::LinkageTypes Linkage = GV->getLinkage(); switch (Linkage) { case GlobalValue::CommonLinkage: + assert(!TM.getTargetTriple().isOSBinFormatXCOFF() && + "CommonLinkage of XCOFF should not come to this path."); case GlobalValue::LinkOnceAnyLinkage: case GlobalValue::LinkOnceODRLinkage: case GlobalValue::WeakAnyLinkage: @@ -418,8 +420,10 @@ } return; case GlobalValue::ExternalLinkage: - // If external, declare as a global symbol: .globl _foo - OutStreamer->emitSymbolAttribute(GVSym, MCSA_Global); + if (MAI->hasDotExternDirective() && GV->isDeclaration()) + OutStreamer->emitSymbolAttribute(GVSym, MCSA_Extern); + else + OutStreamer->emitSymbolAttribute(GVSym, MCSA_Global); return; case GlobalValue::PrivateLinkage: return; @@ -427,9 +431,14 @@ if (MAI->hasDotLGloblDirective()) OutStreamer->emitSymbolAttribute(GVSym, MCSA_LGlobal); return; + case GlobalValue::ExternalWeakLinkage: + if (TM.getTargetTriple().isOSBinFormatXCOFF()) { + OutStreamer->emitSymbolAttribute(GVSym, MCSA_Weak); + return; + } + LLVM_FALLTHROUGH; case GlobalValue::AppendingLinkage: case GlobalValue::AvailableExternallyLinkage: - case GlobalValue::ExternalWeakLinkage: llvm_unreachable("Should never emit this"); } llvm_unreachable("Unknown linkage type!"); @@ -1489,15 +1498,30 @@ // Emit remaining GOT equivalent globals. emitGlobalGOTEquivs(); - // Emit visibility info for declarations + // Emit linkage(XCOFF) and visibility info for declarations for (const Function &F : M) { if (!F.isDeclarationForLinker()) continue; + + MCSymbol *Name = getSymbol(&F); + // Function getSymbol gives us the function descriptor symbol for XCOFF. + if (TM.getTargetTriple().isOSBinFormatXCOFF() && !F.isIntrinsic()) { + + // Get the function entry point symbol. + MCSymbol *FnEntryPointSym = OutContext.getOrCreateSymbol( + "." + cast(Name)->getUnqualifiedName()); + if (cast(FnEntryPointSym)->hasRepresentedCsectSet()) + // Emit linkage for the function entry point. + emitLinkage(&F, FnEntryPointSym); + + // Emit linkage for the function descriptor. + emitLinkage(&F, Name); + } + GlobalValue::VisibilityTypes V = F.getVisibility(); if (V == GlobalValue::DefaultVisibility) continue; - MCSymbol *Name = getSymbol(&F); emitVisibility(Name, V, false); } 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 @@ -2131,15 +2131,19 @@ case GlobalValue::CommonLinkage: return XCOFF::C_EXT; case GlobalValue::ExternalWeakLinkage: + case GlobalValue::LinkOnceAnyLinkage: case GlobalValue::LinkOnceODRLinkage: + case GlobalValue::WeakAnyLinkage: + case GlobalValue::WeakODRLinkage: return XCOFF::C_WEAKEXT; case GlobalValue::AppendingLinkage: report_fatal_error( "There is no mapping that implements AppendingLinkage for XCOFF."); - default: - report_fatal_error( - "Unhandled linkage when mapping linkage to StorageClass."); + case GlobalValue::AvailableExternallyLinkage: + report_fatal_error("unhandled AvailableExternallyLinkage when mapping " + "linkage to StorageClass"); } + llvm_unreachable("Unknown linkage type!"); } MCSection *TargetLoweringObjectFileXCOFF::getSectionForFunctionDescriptor( diff --git a/llvm/lib/MC/MCAsmInfoXCOFF.cpp b/llvm/lib/MC/MCAsmInfoXCOFF.cpp --- a/llvm/lib/MC/MCAsmInfoXCOFF.cpp +++ b/llvm/lib/MC/MCAsmInfoXCOFF.cpp @@ -15,6 +15,7 @@ MCAsmInfoXCOFF::MCAsmInfoXCOFF() { IsLittleEndian = false; HasDotTypeDotSizeDirective = false; + HasDotExternDirective = true; COMMDirectiveAlignmentIsInBytes = false; LCOMMDirectiveAlignmentType = LCOMM::Log2Alignment; UseDotAlignForAlignment = true; diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp --- a/llvm/lib/MC/MCAsmStreamer.cpp +++ b/llvm/lib/MC/MCAsmStreamer.cpp @@ -675,6 +675,9 @@ break; case MCSA_Protected: OS << "\t.protected\t"; break; case MCSA_Reference: OS << "\t.reference\t"; break; + case MCSA_Extern: + OS << "\t.extern\t"; + break; case MCSA_Weak: OS << MAI->getWeakDirective(); break; case MCSA_WeakDefinition: OS << "\t.weak_definition\t"; 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 @@ -35,6 +35,7 @@ switch (Attribute) { case MCSA_Global: + case MCSA_Extern: Symbol->setStorageClass(XCOFF::C_EXT); Symbol->setExternal(true); break; @@ -42,6 +43,10 @@ Symbol->setStorageClass(XCOFF::C_HIDEXT); Symbol->setExternal(true); break; + case llvm::MCSA_Weak: + Symbol->setStorageClass(XCOFF::C_WEAKEXT); + 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 @@ -354,21 +354,24 @@ // Handle undefined symbol. UndefinedCsects.emplace_back(ContainingCsect); SectionMap[ContainingCsect] = &UndefinedCsects.back(); - } else { - // If the symbol is the csect itself, we don't need to put the symbol - // into csect's Syms. - if (XSym == ContainingCsect->getQualNameSymbol()) - continue; + if (nameShouldBeInStringTable(ContainingCsect->getName())) + Strings.add(ContainingCsect->getName()); + continue; + } - // Only put a label into the symbol table when it is an external label. - if (!XSym->isExternal()) - continue; + // If the symbol is the csect itself, we don't need to put the symbol + // into csect's Syms. + if (XSym == ContainingCsect->getQualNameSymbol()) + continue; - assert(SectionMap.find(ContainingCsect) != SectionMap.end() && - "Expected containing csect to exist in map"); - // Lookup the containing csect and add the symbol to it. - SectionMap[ContainingCsect]->Syms.emplace_back(XSym); - } + // 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. + SectionMap[ContainingCsect]->Syms.emplace_back(XSym); // If the name does not fit in the storage provided in the symbol table // entry, add it to the string table. 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 @@ -1616,9 +1616,10 @@ GVSym->setStorageClass( TargetLoweringObjectFileXCOFF::getStorageClassForGlobal(GV)); - // External global variables are already handled. - if (GV->isDeclaration()) + if (GV->isDeclarationForLinker()) { + emitLinkage(GV, GVSym); return; + } SectionKind GVKind = getObjFileLowering().getKindForGlobal(GV, TM); if (!GVKind.isGlobalWriteableData() && !GVKind.isReadOnly()) diff --git a/llvm/test/CodeGen/PowerPC/aix-LinkOnceODRLinkage.ll b/llvm/test/CodeGen/PowerPC/aix-LinkOnceAnyLinkage.ll copy from llvm/test/CodeGen/PowerPC/aix-LinkOnceODRLinkage.ll copy to llvm/test/CodeGen/PowerPC/aix-LinkOnceAnyLinkage.ll --- a/llvm/test/CodeGen/PowerPC/aix-LinkOnceODRLinkage.ll +++ b/llvm/test/CodeGen/PowerPC/aix-LinkOnceAnyLinkage.ll @@ -4,10 +4,10 @@ ; RUN: llc -mtriple powerpc64-ibm-aix-xcoff < %s | \ ; RUN: FileCheck %s -define linkonce_odr void @_Z3fooIiEvT_() { +define linkonce void @_Z3fooIiEvT_() { entry: ret void } -; CHECK: .weak _Z3fooIiEvT_ +; CHECK: .weak _Z3fooIiEvT_[DS] ; CHECK: .weak ._Z3fooIiEvT_ diff --git a/llvm/test/CodeGen/PowerPC/aix-LinkOnceODRLinkage.ll b/llvm/test/CodeGen/PowerPC/aix-LinkOnceODRLinkage.ll --- a/llvm/test/CodeGen/PowerPC/aix-LinkOnceODRLinkage.ll +++ b/llvm/test/CodeGen/PowerPC/aix-LinkOnceODRLinkage.ll @@ -9,5 +9,5 @@ ret void } -; CHECK: .weak _Z3fooIiEvT_ +; CHECK: .weak _Z3fooIiEvT_[DS] ; CHECK: .weak ._Z3fooIiEvT_ diff --git a/llvm/test/CodeGen/PowerPC/aix-LinkOnceODRLinkage.ll b/llvm/test/CodeGen/PowerPC/aix-WeakODRLinkage.ll copy from llvm/test/CodeGen/PowerPC/aix-LinkOnceODRLinkage.ll copy to llvm/test/CodeGen/PowerPC/aix-WeakODRLinkage.ll --- a/llvm/test/CodeGen/PowerPC/aix-LinkOnceODRLinkage.ll +++ b/llvm/test/CodeGen/PowerPC/aix-WeakODRLinkage.ll @@ -4,10 +4,10 @@ ; RUN: llc -mtriple powerpc64-ibm-aix-xcoff < %s | \ ; RUN: FileCheck %s -define linkonce_odr void @_Z3fooIiEvT_() { +define weak_odr void @_Z3fooIiEvT_() { entry: ret void } -; CHECK: .weak _Z3fooIiEvT_ +; CHECK: .weak _Z3fooIiEvT_[DS] ; CHECK: .weak ._Z3fooIiEvT_ diff --git a/llvm/test/CodeGen/PowerPC/aix-extern-weak.ll b/llvm/test/CodeGen/PowerPC/aix-extern-weak.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/aix-extern-weak.ll @@ -0,0 +1,308 @@ +; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \ +; RUN: -mattr=-altivec < %s | FileCheck --check-prefixes=COMMON,BIT32 %s + +; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 \ +; RUN: -mattr=-altivec < %s | FileCheck --check-prefixes=COMMON,BIT64 %s + +; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \ +; RUN: -mattr=-altivec < %s | FileCheck %s + +; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \ +; RUN: -mattr=-altivec -filetype=obj -o %t.o < %s +; RUN: llvm-readobj --symbols %t.o | FileCheck --check-prefix=CHECKSYM %s + +; RUN: not --crash llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff \ +; RUN: -mattr=-altivec -filetype=obj -o %t.o 2>&1 < %s | FileCheck --check-prefix=XCOFF64 %s +; XCOFF64: LLVM ERROR: 64-bit XCOFF object files are not supported yet. + + +@foo_ext_weak_p = global void (...)* bitcast (void ()* @foo_ext_weak_ref to void (...)*) +@b_w = extern_weak global i32 + +declare extern_weak void @foo_ext_weak_ref() + +define i32 @main() { +entry: + %0 = load void (...)*, void (...)** @foo_ext_weak_p + %callee.knr.cast = bitcast void (...)* %0 to void ()* + call void %callee.knr.cast() + call void @foo_ext_weak(i32* @b_w) + ret i32 0 +} + +declare extern_weak void @foo_ext_weak(i32*) + +; COMMON: .globl main[DS] # -- Begin function main +; COMMON-NEXT: .globl .main +; COMMON-NEXT: .align 4 +; COMMON-NEXT: .csect main[DS] +; BIT32-NEXT: .long .main # @main +; BIT32-NEXT: .long TOC[TC0] +; BIT32-NEXT: .long 0 +; BIT64-NEXT: .llong .main # @main +; BIT64-NEXT: .llong TOC[TC0] +; BIT64-NEXT: .llong 0 +; COMMON-NEXT: .csect .text[PR] +; COMMON-NEXT: .main: + +; COMMON: .csect .data[RW] +; COMMON: .globl foo_ext_weak_p +; BIT32-NEXT: .align 2 +; BIT64-NEXT: .align 3 +; COMMON-NEXT: foo_ext_weak_p: +; BIT32-NEXT: .long foo_ext_weak_ref[DS] +; BIT64-NEXT: .llong foo_ext_weak_ref[DS] +; COMMON-NEXT: .weak b_w[UA] +; COMMON-NEXT: .weak foo_ext_weak_ref[DS] +; COMMON-NEXT: .weak .foo_ext_weak +; COMMON-NEXT: .weak foo_ext_weak[DS] +; COMMON-NEXT: .toc +; COMMON-NEXT: LC0: +; COMMON-NEXT: .tc foo_ext_weak_p[TC],foo_ext_weak_p +; COMMON-NEXT: LC1: +; COMMON-NEXT: .tc b_w[TC],b_w[UA] + +; CHECK-NOT: .weak .foo_ext_weak_ref + +; CHECKSYM: Symbols [ +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index:]] +; CHECKSYM-NEXT: Name: .foo_ext_weak +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x0 +; CHECKSYM-NEXT: Section: N_UNDEF +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_WEAKEXT (0x6F) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+1]] +; CHECKSYM-NEXT: SectionLen: 0 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 0 +; CHECKSYM-NEXT: SymbolType: XTY_ER (0x0) +; CHECKSYM-NEXT: StorageMappingClass: XMC_PR (0x0) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+2]] +; CHECKSYM-NEXT: Name: foo_ext_weak_ref +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x0 +; CHECKSYM-NEXT: Section: N_UNDEF +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_WEAKEXT (0x6F) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+3]] +; CHECKSYM-NEXT: SectionLen: 0 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 0 +; CHECKSYM-NEXT: SymbolType: XTY_ER (0x0) +; CHECKSYM-NEXT: StorageMappingClass: XMC_DS (0xA) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+4]] +; CHECKSYM-NEXT: Name: b_w +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x0 +; CHECKSYM-NEXT: Section: N_UNDEF +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_WEAKEXT (0x6F) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+5]] +; CHECKSYM-NEXT: SectionLen: 0 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 0 +; CHECKSYM-NEXT: SymbolType: XTY_ER (0x0) +; CHECKSYM-NEXT: StorageMappingClass: XMC_UA (0x4) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+6]] +; CHECKSYM-NEXT: Name: foo_ext_weak +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x0 +; CHECKSYM-NEXT: Section: N_UNDEF +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_WEAKEXT (0x6F) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+7]] +; CHECKSYM-NEXT: SectionLen: 0 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 0 +; CHECKSYM-NEXT: SymbolType: XTY_ER (0x0) +; CHECKSYM-NEXT: StorageMappingClass: XMC_DS (0xA) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+8]] +; CHECKSYM-NEXT: Name: .text +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x0 +; 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: SectionLen: 80 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 4 +; CHECKSYM-NEXT: SymbolType: XTY_SD (0x1) +; CHECKSYM-NEXT: StorageMappingClass: XMC_PR (0x0) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+10]] +; CHECKSYM-NEXT: Name: .main +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x0 +; CHECKSYM-NEXT: Section: .text +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_EXT (0x2) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+11]] +; CHECKSYM-NEXT: ContainingCsectSymbolIndex: [[#Index+8]] +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 0 +; CHECKSYM-NEXT: SymbolType: XTY_LD (0x2) +; CHECKSYM-NEXT: StorageMappingClass: XMC_PR (0x0) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+12]] +; CHECKSYM-NEXT: Name: .data +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x50 +; CHECKSYM-NEXT: Section: .data +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_HIDEXT (0x6B) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+13]] +; CHECKSYM-NEXT: SectionLen: 4 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 2 +; CHECKSYM-NEXT: SymbolType: XTY_SD (0x1) +; CHECKSYM-NEXT: StorageMappingClass: XMC_RW (0x5) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+14]] +; CHECKSYM-NEXT: Name: foo_ext_weak_p +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x50 +; CHECKSYM-NEXT: Section: .data +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_EXT (0x2) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+15]] +; CHECKSYM-NEXT: ContainingCsectSymbolIndex: [[#Index+12]] +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 0 +; CHECKSYM-NEXT: SymbolType: XTY_LD (0x2) +; CHECKSYM-NEXT: StorageMappingClass: XMC_RW (0x5) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+16]] +; CHECKSYM-NEXT: Name: main +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x54 +; CHECKSYM-NEXT: Section: .data +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_EXT (0x2) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+17]] +; CHECKSYM-NEXT: SectionLen: 12 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 2 +; CHECKSYM-NEXT: SymbolType: XTY_SD (0x1) +; CHECKSYM-NEXT: StorageMappingClass: XMC_DS (0xA) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+18]] +; CHECKSYM-NEXT: Name: TOC +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x60 +; CHECKSYM-NEXT: Section: .data +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_HIDEXT (0x6B) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+19]] +; CHECKSYM-NEXT: SectionLen: 0 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 2 +; CHECKSYM-NEXT: SymbolType: XTY_SD (0x1) +; CHECKSYM-NEXT: StorageMappingClass: XMC_TC0 (0xF) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+20]] +; CHECKSYM-NEXT: Name: foo_ext_weak_p +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x60 +; CHECKSYM-NEXT: Section: .data +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_HIDEXT (0x6B) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+21]] +; CHECKSYM-NEXT: SectionLen: 4 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 2 +; CHECKSYM-NEXT: SymbolType: XTY_SD (0x1) +; CHECKSYM-NEXT: StorageMappingClass: XMC_TC (0x3) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+22]] +; CHECKSYM-NEXT: Name: b_w +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x64 +; CHECKSYM-NEXT: Section: .data +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_HIDEXT (0x6B) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+23]] +; CHECKSYM-NEXT: SectionLen: 4 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 2 +; CHECKSYM-NEXT: SymbolType: XTY_SD (0x1) +; CHECKSYM-NEXT: StorageMappingClass: XMC_TC (0x3) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: ] diff --git a/llvm/test/CodeGen/PowerPC/aix-extern.ll b/llvm/test/CodeGen/PowerPC/aix-extern.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/aix-extern.ll @@ -0,0 +1,386 @@ +; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \ +; RUN: -mattr=-altivec < %s | FileCheck --check-prefixes=COMMON,BIT32 %s + +; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 \ +; RUN: -mattr=-altivec < %s | FileCheck --check-prefixes=COMMON,BIT64 %s + +; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \ +; RUN: -mattr=-altivec -filetype=obj -o %t.o < %s +; RUN: llvm-readobj --symbols %t.o | FileCheck --check-prefix=CHECKSYM %s + +; RUN: not --crash llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff \ +; RUN: -mattr=-altivec -filetype=obj -o %t.o 2>&1 < %s | FileCheck --check-prefix=XCOFF64 %s +; XCOFF64: LLVM ERROR: 64-bit XCOFF object files are not supported yet. + +@bar_p = global i32 (...)* @bar_ref, align 4 +@b_e = external global i32, align 4 + +; Function Attrs: noinline nounwind optnone +define void @foo() { +entry: + ret void +} + +declare i32 @bar_ref(...) + +; Function Attrs: noinline nounwind optnone +define i32 @main() { +entry: + %call = call i32 @bar_extern(i32* @b_e) + call void @foo() + %0 = load i32 (...)*, i32 (...)** @bar_p, align 4 + %callee.knr.cast = bitcast i32 (...)* %0 to i32 ()* + %call1 = call i32 %callee.knr.cast() + %call2 = call i32 bitcast (i32 (...)* @bar_ref to i32 ()*)() + ret i32 0 +} + +declare i32 @bar_extern(i32*) + + +; COMMON: .globl foo[DS] # -- Begin function foo +; COMMON-NEXT: .globl .foo +; COMMON-NEXT: .align 4 +; COMMON-NEXT: .csect foo[DS] +; BIT32-NEXT: .long .foo # @foo +; BIT32-NEXT: .long TOC[TC0] +; BIT32-NEXT: .long 0 +; BIT64-NEXT: .llong .foo # @foo +; BIT64-NEXT: .llong TOC[TC0] +; BIT64-NEXT: .llong 0 +; COMMON-NEXT: .csect .text[PR] +; COMMON-NEXT: .foo: + +; COMMON: .globl main[DS] # -- Begin function main +; COMMON-NEXT: .globl .main +; COMMON-NEXT: .align 4 +; COMMON-NEXT: .csect main[DS] +; BIT32-NEXT: .long .main # @main +; BIT32-NEXT: .long TOC[TC0] +; BIT32-NEXT: .long 0 +; BIT64-NEXT: .llong .main # @main +; BIT64-NEXT: .llong TOC[TC0] +; BIT64-NEXT: .llong 0 +; COMMON-NEXT: .csect .text[PR] +; COMMON-NEXT: .main: + +; COMMON: .csect .data[RW] +; COMMON-NEXT: .globl bar_p +; BIT32-NEXT: .align 2 +; BIT64-NEXT: .align 3 +; COMMON-NEXT: bar_p: +; BIT32-NEXT: .long bar_ref[DS] +; BIT64-NEXT: .llong bar_ref[DS] +; COMMON-NEXT: .extern b_e[UA] +; COMMON-NEXT: .extern .bar_ref +; COMMON-NEXT: .extern bar_ref[DS] +; COMMON-NEXT: .extern .bar_extern +; COMMON-NEXT: .extern bar_extern[DS] +; COMMON-NEXT: .toc +; COMMON-NEXT: LC0: +; COMMON-NEXT: .tc b_e[TC],b_e[UA] +; COMMON-NEXT: LC1: +; COMMON-NEXT: .tc bar_p[TC],bar_p + +; CHECKSYM: Symbols [ +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index:]] +; CHECKSYM-NEXT: Name: .bar_extern +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x0 +; CHECKSYM-NEXT: Section: N_UNDEF +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_EXT (0x2) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+1]] +; CHECKSYM-NEXT: SectionLen: 0 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 0 +; CHECKSYM-NEXT: SymbolType: XTY_ER (0x0) +; CHECKSYM-NEXT: StorageMappingClass: XMC_PR (0x0) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+2]] +; CHECKSYM-NEXT: Name: .bar_ref +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x0 +; CHECKSYM-NEXT: Section: N_UNDEF +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_EXT (0x2) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+3]] +; CHECKSYM-NEXT: SectionLen: 0 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 0 +; CHECKSYM-NEXT: SymbolType: XTY_ER (0x0) +; CHECKSYM-NEXT: StorageMappingClass: XMC_PR (0x0) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+4]] +; CHECKSYM-NEXT: Name: bar_ref +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x0 +; CHECKSYM-NEXT: Section: N_UNDEF +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_EXT (0x2) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+5]] +; CHECKSYM-NEXT: SectionLen: 0 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 0 +; CHECKSYM-NEXT: SymbolType: XTY_ER (0x0) +; CHECKSYM-NEXT: StorageMappingClass: XMC_DS (0xA) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+6]] +; CHECKSYM-NEXT: Name: b_e +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x0 +; CHECKSYM-NEXT: Section: N_UNDEF +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_EXT (0x2) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+7]] +; CHECKSYM-NEXT: SectionLen: 0 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 0 +; CHECKSYM-NEXT: SymbolType: XTY_ER (0x0) +; CHECKSYM-NEXT: StorageMappingClass: XMC_UA (0x4) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+8]] +; CHECKSYM-NEXT: Name: bar_extern +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x0 +; CHECKSYM-NEXT: Section: N_UNDEF +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_EXT (0x2) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+9]] +; CHECKSYM-NEXT: SectionLen: 0 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 0 +; CHECKSYM-NEXT: SymbolType: XTY_ER (0x0) +; CHECKSYM-NEXT: StorageMappingClass: XMC_DS (0xA) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+10]] +; CHECKSYM-NEXT: Name: .text +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x0 +; 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+11]] +; CHECKSYM-NEXT: SectionLen: 112 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 4 +; CHECKSYM-NEXT: SymbolType: XTY_SD (0x1) +; CHECKSYM-NEXT: StorageMappingClass: XMC_PR (0x0) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+12]] +; CHECKSYM-NEXT: Name: .foo +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x0 +; CHECKSYM-NEXT: Section: .text +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_EXT (0x2) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+13]] +; CHECKSYM-NEXT: ContainingCsectSymbolIndex: [[#Index+10]] +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 0 +; CHECKSYM-NEXT: SymbolType: XTY_LD (0x2) +; CHECKSYM-NEXT: StorageMappingClass: XMC_PR (0x0) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+14]] +; CHECKSYM-NEXT: Name: .main +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x10 +; CHECKSYM-NEXT: Section: .text +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_EXT (0x2) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+15]] +; CHECKSYM-NEXT: ContainingCsectSymbolIndex: [[#Index+10]] +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 0 +; CHECKSYM-NEXT: SymbolType: XTY_LD (0x2) +; CHECKSYM-NEXT: StorageMappingClass: XMC_PR (0x0) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+16]] +; CHECKSYM-NEXT: Name: .data +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x70 +; CHECKSYM-NEXT: Section: .data +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_HIDEXT (0x6B) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+17]] +; CHECKSYM-NEXT: SectionLen: 4 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 2 +; CHECKSYM-NEXT: SymbolType: XTY_SD (0x1) +; CHECKSYM-NEXT: StorageMappingClass: XMC_RW (0x5) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+18]] +; CHECKSYM-NEXT: Name: bar_p +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x70 +; CHECKSYM-NEXT: Section: .data +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_EXT (0x2) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+19]] +; CHECKSYM-NEXT: ContainingCsectSymbolIndex: [[#Index+16]] +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 0 +; CHECKSYM-NEXT: SymbolType: XTY_LD (0x2) +; CHECKSYM-NEXT: StorageMappingClass: XMC_RW (0x5) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+20]] +; CHECKSYM-NEXT: Name: foo +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x74 +; CHECKSYM-NEXT: Section: .data +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_EXT (0x2) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+21]] +; CHECKSYM-NEXT: SectionLen: 12 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 2 +; CHECKSYM-NEXT: SymbolType: XTY_SD (0x1) +; CHECKSYM-NEXT: StorageMappingClass: XMC_DS (0xA) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+22]] +; CHECKSYM-NEXT: Name: main +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x80 +; CHECKSYM-NEXT: Section: .data +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_EXT (0x2) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+23]] +; CHECKSYM-NEXT: SectionLen: 12 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 2 +; CHECKSYM-NEXT: SymbolType: XTY_SD (0x1) +; CHECKSYM-NEXT: StorageMappingClass: XMC_DS (0xA) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+24]] +; CHECKSYM-NEXT: Name: TOC +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x8C +; CHECKSYM-NEXT: Section: .data +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_HIDEXT (0x6B) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+25]] +; CHECKSYM-NEXT: SectionLen: 0 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 2 +; CHECKSYM-NEXT: SymbolType: XTY_SD (0x1) +; CHECKSYM-NEXT: StorageMappingClass: XMC_TC0 (0xF) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+26]] +; CHECKSYM-NEXT: Name: b_e +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x8C +; CHECKSYM-NEXT: Section: .data +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_HIDEXT (0x6B) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+27]] +; CHECKSYM-NEXT: SectionLen: 4 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 2 +; CHECKSYM-NEXT: SymbolType: XTY_SD (0x1) +; CHECKSYM-NEXT: StorageMappingClass: XMC_TC (0x3) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+28]] +; CHECKSYM-NEXT: Name: bar_p +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x90 +; CHECKSYM-NEXT: Section: .data +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_HIDEXT (0x6B) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+29]] +; CHECKSYM-NEXT: SectionLen: 4 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 2 +; CHECKSYM-NEXT: SymbolType: XTY_SD (0x1) +; CHECKSYM-NEXT: StorageMappingClass: XMC_TC (0x3) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: ] diff --git a/llvm/test/CodeGen/PowerPC/aix-reference-func-addr-const.ll b/llvm/test/CodeGen/PowerPC/aix-reference-func-addr-const.ll --- a/llvm/test/CodeGen/PowerPC/aix-reference-func-addr-const.ll +++ b/llvm/test/CodeGen/PowerPC/aix-reference-func-addr-const.ll @@ -20,6 +20,7 @@ ;CHECK-NEXT: .align 2 ;CHECK-NEXT: bar_ptr1: ;CHECK-NEXT: .long bar[DS] +;CHECK-NEXT: .extern foo[DS] ;CHECK64: .csect .data[RW] ;CHECK64-NEXT: .globl foo_ptr @@ -30,3 +31,4 @@ ;CHECK64-NEXT: .align 3 ;CHECK64-NEXT: bar_ptr1: ;CHECK64-NEXT: .llong bar[DS] +;CHECK64-NEXT: .extern foo[DS] diff --git a/llvm/test/CodeGen/PowerPC/aix-weak.ll b/llvm/test/CodeGen/PowerPC/aix-weak.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/aix-weak.ll @@ -0,0 +1,362 @@ +; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \ +; RUN: -mattr=-altivec < %s | FileCheck --check-prefixes=COMMON,BIT32 %s + +; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 \ +; RUN: -mattr=-altivec < %s | FileCheck --check-prefixes=COMMON,BIT64 %s + +; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \ +; RUN: -mattr=-altivec -filetype=obj -o %t.o < %s +; RUN: llvm-readobj --symbols %t.o | FileCheck --check-prefix=CHECKSYM %s + +; RUN: not --crash llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff \ +; RUN: -mattr=-altivec -filetype=obj -o %t.o 2>&1 < %s | FileCheck --check-prefix=XCOFF64 %s +; XCOFF64: LLVM ERROR: 64-bit XCOFF object files are not supported yet. + +@foo_weak_p = global void (...)* bitcast (void ()* @foo_ref_weak to void (...)*), align 4 +@b = weak global i32 0, align 4 + +define weak void @foo_weak(i32* %p) { +entry: + %p.addr = alloca i32*, align 4 + store i32* %p, i32** %p.addr, align 4 + %0 = load i32*, i32** %p.addr, align 4 + %1 = load i32, i32* %0, align 4 + %inc = add nsw i32 %1, 1 + store i32 %inc, i32* %0, align 4 + ret void +} + +define weak void @foo_ref_weak() { +entry: + ret void +} + +define i32 @main() { +entry: + %0 = load void (...)*, void (...)** @foo_weak_p, align 4 + %callee.knr.cast = bitcast void (...)* %0 to void ()* + call void %callee.knr.cast() + call void @foo_weak(i32* @b) + call void @foo_ref_weak() + ret i32 0 +} + +; COMMON: .weak foo_weak[DS] # -- Begin function foo_weak +; COMMON-NEXT: .weak .foo_weak +; COMMON-NEXT: .align 4 +; COMMON-NEXT: .csect foo_weak[DS] +; BIT32-NEXT: .long .foo_weak # @foo_weak +; BIT32-NEXT: .long TOC[TC0] +; BIT32-NEXT: .long 0 +; BIT64-NEXT: .llong .foo_weak # @foo_weak +; BIT64-NEXT: .llong TOC[TC0] +; BIT64-NEXT: .llong 0 +; COMMON-NEXT: .csect .text[PR] +; COMMON-NEXT: .foo_weak: + +; COMMON: .weak foo_ref_weak[DS] # -- Begin function foo_ref_weak +; COMMON-NEXT: .weak .foo_ref_weak +; COMMON-NEXT: .align 4 +; COMMON-NEXT: .csect foo_ref_weak[DS] +; BIT32-NEXT: .long .foo_ref_weak # @foo_ref_weak +; BIT32-NEXT: .long TOC[TC0] +; BIT32-NEXT: .long 0 +; BIT64-NEXT: .llong .foo_ref_weak # @foo_ref_weak +; BIT64-NEXT: .llong TOC[TC0] +; BIT64-NEXT: .llong 0 +; COMMON-NEXT: .csect .text[PR] +; COMMON-NEXT: .foo_ref_weak: + +; COMMON: .globl main[DS] # -- Begin function main +; COMMON-NEXT: .globl .main +; COMMON-NEXT: .align 4 +; COMMON-NEXT: .csect main[DS] +; BIT32-NEXT: .long .main # @main +; BIT32-NEXT: .long TOC[TC0] +; BIT32-NEXT: .long 0 +; BIT64-NEXT: .llong .main # @main +; BIT64-NEXT: .llong TOC[TC0] +; BIT64-NEXT: .llong 0 +; COMMON-NEXT: .csect .text[PR] +; COMMON-NEXT: .main: + +; COMMON: .csect .data[RW] +; COMMON-NEXT: .globl foo_weak_p +; BIT32-NEXT: .align 2 +; BIT64-NEXT: .align 3 +; COMMON-NEXT: foo_weak_p: +; BIT32-NEXT: .long foo_ref_weak[DS] +; BIT64-NEXT: .llong foo_ref_weak[DS] +; COMMON-NEXT: .weak b +; COMMON-NEXT: .align 2 +; COMMON-NEXT: b: +; COMMON-NEXT: .long 0 # 0x0 +; COMMON-NEXT: .toc +; COMMON-NEXT: LC0: +; COMMON-NEXT: .tc foo_weak_p[TC],foo_weak_p +; COMMON-NEXT: LC1: +; COMMON-NEXT: .tc b[TC],b + + +; CHECKSYM: Symbols [ +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index:]] +; CHECKSYM-NEXT: Name: .text +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x0 +; 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+1]] +; CHECKSYM-NEXT: SectionLen: 136 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 4 +; CHECKSYM-NEXT: SymbolType: XTY_SD (0x1) +; CHECKSYM-NEXT: StorageMappingClass: XMC_PR (0x0) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+2]] +; CHECKSYM-NEXT: Name: .foo_weak +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x0 +; CHECKSYM-NEXT: Section: .text +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_WEAKEXT (0x6F) +; 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_PR (0x0) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+4]] +; CHECKSYM-NEXT: Name: .foo_ref_weak +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x20 +; CHECKSYM-NEXT: Section: .text +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_WEAKEXT (0x6F) +; 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_PR (0x0) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+6]] +; CHECKSYM-NEXT: Name: .main +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x30 +; CHECKSYM-NEXT: Section: .text +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_EXT (0x2) +; 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_PR (0x0) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+8]] +; CHECKSYM-NEXT: Name: .data +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x88 +; CHECKSYM-NEXT: Section: .data +; 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: SectionLen: 8 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 2 +; CHECKSYM-NEXT: SymbolType: XTY_SD (0x1) +; CHECKSYM-NEXT: StorageMappingClass: XMC_RW (0x5) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+10]] +; CHECKSYM-NEXT: Name: foo_weak_p +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x88 +; CHECKSYM-NEXT: Section: .data +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_EXT (0x2) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+11]] +; CHECKSYM-NEXT: ContainingCsectSymbolIndex: [[#Index+8]] +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 0 +; CHECKSYM-NEXT: SymbolType: XTY_LD (0x2) +; CHECKSYM-NEXT: StorageMappingClass: XMC_RW (0x5) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+12]] +; CHECKSYM-NEXT: Name: b +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x8C +; CHECKSYM-NEXT: Section: .data +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_WEAKEXT (0x6F) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+13]] +; CHECKSYM-NEXT: ContainingCsectSymbolIndex: [[#Index+8]] +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 0 +; CHECKSYM-NEXT: SymbolType: XTY_LD (0x2) +; CHECKSYM-NEXT: StorageMappingClass: XMC_RW (0x5) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+14]] +; CHECKSYM-NEXT: Name: foo_weak +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x90 +; CHECKSYM-NEXT: Section: .data +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_WEAKEXT (0x6F) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+15]] +; CHECKSYM-NEXT: SectionLen: 12 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 2 +; CHECKSYM-NEXT: SymbolType: XTY_SD (0x1) +; CHECKSYM-NEXT: StorageMappingClass: XMC_DS (0xA) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+16]] +; CHECKSYM-NEXT: Name: foo_ref_weak +; CHECKSYM-NEXT: Value (RelocatableAddress): 0x9C +; CHECKSYM-NEXT: Section: .data +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_WEAKEXT (0x6F) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+17]] +; CHECKSYM-NEXT: SectionLen: 12 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 2 +; CHECKSYM-NEXT: SymbolType: XTY_SD (0x1) +; CHECKSYM-NEXT: StorageMappingClass: XMC_DS (0xA) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+18]] +; CHECKSYM-NEXT: Name: main +; CHECKSYM-NEXT: Value (RelocatableAddress): 0xA8 +; CHECKSYM-NEXT: Section: .data +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_EXT (0x2) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+19]] +; CHECKSYM-NEXT: SectionLen: 12 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 2 +; CHECKSYM-NEXT: SymbolType: XTY_SD (0x1) +; CHECKSYM-NEXT: StorageMappingClass: XMC_DS (0xA) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+20]] +; CHECKSYM-NEXT: Name: TOC +; CHECKSYM-NEXT: Value (RelocatableAddress): 0xB4 +; CHECKSYM-NEXT: Section: .data +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_HIDEXT (0x6B) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+21]] +; CHECKSYM-NEXT: SectionLen: 0 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 2 +; CHECKSYM-NEXT: SymbolType: XTY_SD (0x1) +; CHECKSYM-NEXT: StorageMappingClass: XMC_TC0 (0xF) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+22]] +; CHECKSYM-NEXT: Name: foo_weak_p +; CHECKSYM-NEXT: Value (RelocatableAddress): 0xB4 +; CHECKSYM-NEXT: Section: .data +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_HIDEXT (0x6B) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+23]] +; CHECKSYM-NEXT: SectionLen: 4 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 2 +; CHECKSYM-NEXT: SymbolType: XTY_SD (0x1) +; CHECKSYM-NEXT: StorageMappingClass: XMC_TC (0x3) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: Symbol { +; CHECKSYM-NEXT: Index: [[#Index+24]] +; CHECKSYM-NEXT: Name: b +; CHECKSYM-NEXT: Value (RelocatableAddress): 0xB8 +; CHECKSYM-NEXT: Section: .data +; CHECKSYM-NEXT: Type: 0x0 +; CHECKSYM-NEXT: StorageClass: C_HIDEXT (0x6B) +; CHECKSYM-NEXT: NumberOfAuxEntries: 1 +; CHECKSYM-NEXT: CSECT Auxiliary Entry { +; CHECKSYM-NEXT: Index: [[#Index+25]] +; CHECKSYM-NEXT: SectionLen: 4 +; CHECKSYM-NEXT: ParameterHashIndex: 0x0 +; CHECKSYM-NEXT: TypeChkSectNum: 0x0 +; CHECKSYM-NEXT: SymbolAlignmentLog2: 2 +; CHECKSYM-NEXT: SymbolType: XTY_SD (0x1) +; CHECKSYM-NEXT: StorageMappingClass: XMC_TC (0x3) +; CHECKSYM-NEXT: StabInfoIndex: 0x0 +; CHECKSYM-NEXT: StabSectNum: 0x0 +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: } +; CHECKSYM-NEXT: ] diff --git a/llvm/test/CodeGen/PowerPC/aix-xcoff-reloc.ll b/llvm/test/CodeGen/PowerPC/aix-xcoff-reloc.ll --- a/llvm/test/CodeGen/PowerPC/aix-xcoff-reloc.ll +++ b/llvm/test/CodeGen/PowerPC/aix-xcoff-reloc.ll @@ -36,7 +36,7 @@ ; OBJ-NEXT: NumberOfSections: 2 ; OBJ-NEXT: TimeStamp: None (0x0) ; OBJ-NEXT: SymbolTableOffset: 0x13C -; OBJ-NEXT: SymbolTableEntries: 24 +; OBJ-NEXT: SymbolTableEntries: 26 ; OBJ-NEXT: OptionalHeaderSize: 0x0 ; OBJ-NEXT: Flags: 0x0 ; OBJ-NEXT: } @@ -86,7 +86,7 @@ ; RELOC-NEXT: } ; RELOC-NEXT: Relocation { ; RELOC-NEXT: Virtual Address: 0x1A -; RELOC-NEXT: Symbol: globalA (20) +; RELOC-NEXT: Symbol: globalA (22) ; RELOC-NEXT: IsSigned: No ; RELOC-NEXT: FixupBitValue: 0 ; RELOC-NEXT: Length: 16 @@ -94,7 +94,7 @@ ; RELOC-NEXT: } ; RELOC-NEXT: Relocation { ; RELOC-NEXT: Virtual Address: 0x1E -; RELOC-NEXT: Symbol: globalB (22) +; RELOC-NEXT: Symbol: globalB (24) ; RELOC-NEXT: IsSigned: No ; RELOC-NEXT: FixupBitValue: 0 ; RELOC-NEXT: Length: 16 @@ -104,7 +104,7 @@ ; RELOC-NEXT: Section (index: 2) .data { ; RELOC-NEXT: Relocation { ; RELOC-NEXT: Virtual Address: 0x70 -; RELOC-NEXT: Symbol: arr (12) +; RELOC-NEXT: Symbol: arr (14) ; RELOC-NEXT: IsSigned: No ; RELOC-NEXT: FixupBitValue: 0 ; RELOC-NEXT: Length: 32 @@ -112,7 +112,7 @@ ; RELOC-NEXT: } ; RELOC-NEXT: Relocation { ; RELOC-NEXT: Virtual Address: 0x74 -; RELOC-NEXT: Symbol: .foo (4) +; RELOC-NEXT: Symbol: .foo (6) ; RELOC-NEXT: IsSigned: No ; RELOC-NEXT: FixupBitValue: 0 ; RELOC-NEXT: Length: 32 @@ -120,7 +120,7 @@ ; RELOC-NEXT: } ; RELOC-NEXT: Relocation { ; RELOC-NEXT: Virtual Address: 0x78 -; RELOC-NEXT: Symbol: TOC (18) +; RELOC-NEXT: Symbol: TOC (20) ; RELOC-NEXT: IsSigned: No ; RELOC-NEXT: FixupBitValue: 0 ; RELOC-NEXT: Length: 32 @@ -128,7 +128,7 @@ ; RELOC-NEXT: } ; RELOC-NEXT: Relocation { ; RELOC-NEXT: Virtual Address: 0x80 -; RELOC-NEXT: Symbol: globalA (8) +; RELOC-NEXT: Symbol: globalA (10) ; RELOC-NEXT: IsSigned: No ; RELOC-NEXT: FixupBitValue: 0 ; RELOC-NEXT: Length: 32 @@ -136,7 +136,7 @@ ; RELOC-NEXT: } ; RELOC-NEXT: Relocation { ; RELOC-NEXT: Virtual Address: 0x84 -; RELOC-NEXT: Symbol: globalB (10) +; RELOC-NEXT: Symbol: globalB (12) ; RELOC-NEXT: IsSigned: No ; RELOC-NEXT: FixupBitValue: 0 ; RELOC-NEXT: Length: 32 @@ -168,6 +168,26 @@ ; SYM-NEXT: } ; SYM-NEXT: Symbol { ; SYM-NEXT: Index: 2 +; SYM-NEXT: Name: bar +; SYM-NEXT: Value (RelocatableAddress): 0x0 +; SYM-NEXT: Section: N_UNDEF +; SYM-NEXT: Type: 0x0 +; SYM-NEXT: StorageClass: C_EXT (0x2) +; SYM-NEXT: NumberOfAuxEntries: 1 +; SYM-NEXT: CSECT Auxiliary Entry { +; SYM-NEXT: Index: 3 +; SYM-NEXT: SectionLen: 0 +; SYM-NEXT: ParameterHashIndex: 0x0 +; SYM-NEXT: TypeChkSectNum: 0x0 +; SYM-NEXT: SymbolAlignmentLog2: 0 +; SYM-NEXT: SymbolType: XTY_ER (0x0) +; SYM-NEXT: StorageMappingClass: XMC_DS (0xA) +; SYM-NEXT: StabInfoIndex: 0x0 +; SYM-NEXT: StabSectNum: 0x0 +; SYM-NEXT: } +; SYM-NEXT: } +; SYM-NEXT: Symbol { +; SYM-NEXT: Index: 4 ; SYM-NEXT: Name: .text ; SYM-NEXT: Value (RelocatableAddress): 0x0 ; SYM-NEXT: Section: .text @@ -175,7 +195,7 @@ ; SYM-NEXT: StorageClass: C_HIDEXT (0x6B) ; SYM-NEXT: NumberOfAuxEntries: 1 ; SYM-NEXT: CSECT Auxiliary Entry { -; SYM-NEXT: Index: 3 +; SYM-NEXT: Index: 5 ; SYM-NEXT: SectionLen: 64 ; SYM-NEXT: ParameterHashIndex: 0x0 ; SYM-NEXT: TypeChkSectNum: 0x0 @@ -187,7 +207,7 @@ ; SYM-NEXT: } ; SYM-NEXT: } ; SYM-NEXT: Symbol { -; SYM-NEXT: Index: 4 +; SYM-NEXT: Index: 6 ; SYM-NEXT: Name: .foo ; SYM-NEXT: Value (RelocatableAddress): 0x0 ; SYM-NEXT: Section: .text @@ -195,8 +215,8 @@ ; SYM-NEXT: StorageClass: C_EXT (0x2) ; SYM-NEXT: NumberOfAuxEntries: 1 ; SYM-NEXT: CSECT Auxiliary Entry { -; SYM-NEXT: Index: 5 -; SYM-NEXT: ContainingCsectSymbolIndex: 2 +; SYM-NEXT: Index: 7 +; SYM-NEXT: ContainingCsectSymbolIndex: 4 ; SYM-NEXT: ParameterHashIndex: 0x0 ; SYM-NEXT: TypeChkSectNum: 0x0 ; SYM-NEXT: SymbolAlignmentLog2: 0 @@ -207,7 +227,7 @@ ; SYM-NEXT: } ; SYM-NEXT: } ; SYM-NEXT: Symbol { -; SYM-NEXT: Index: 6 +; SYM-NEXT: Index: 8 ; SYM-NEXT: Name: .data ; SYM-NEXT: Value (RelocatableAddress): 0x40 ; SYM-NEXT: Section: .data @@ -215,7 +235,7 @@ ; SYM-NEXT: StorageClass: C_HIDEXT (0x6B) ; SYM-NEXT: NumberOfAuxEntries: 1 ; SYM-NEXT: CSECT Auxiliary Entry { -; SYM-NEXT: Index: 7 +; SYM-NEXT: Index: 9 ; SYM-NEXT: SectionLen: 52 ; SYM-NEXT: ParameterHashIndex: 0x0 ; SYM-NEXT: TypeChkSectNum: 0x0 @@ -227,7 +247,7 @@ ; SYM-NEXT: } ; SYM-NEXT: } ; SYM-NEXT: Symbol { -; SYM-NEXT: Index: 8 +; SYM-NEXT: Index: 10 ; SYM-NEXT: Name: globalA ; SYM-NEXT: Value (RelocatableAddress): 0x40 ; SYM-NEXT: Section: .data @@ -235,8 +255,8 @@ ; SYM-NEXT: StorageClass: C_EXT (0x2) ; SYM-NEXT: NumberOfAuxEntries: 1 ; SYM-NEXT: CSECT Auxiliary Entry { -; SYM-NEXT: Index: 9 -; SYM-NEXT: ContainingCsectSymbolIndex: 6 +; SYM-NEXT: Index: 11 +; SYM-NEXT: ContainingCsectSymbolIndex: 8 ; SYM-NEXT: ParameterHashIndex: 0x0 ; SYM-NEXT: TypeChkSectNum: 0x0 ; SYM-NEXT: SymbolAlignmentLog2: 0 @@ -247,7 +267,7 @@ ; SYM-NEXT: } ; SYM-NEXT: } ; SYM-NEXT: Symbol { -; SYM-NEXT: Index: 10 +; SYM-NEXT: Index: 12 ; SYM-NEXT: Name: globalB ; SYM-NEXT: Value (RelocatableAddress): 0x44 ; SYM-NEXT: Section: .data @@ -255,8 +275,8 @@ ; SYM-NEXT: StorageClass: C_EXT (0x2) ; SYM-NEXT: NumberOfAuxEntries: 1 ; SYM-NEXT: CSECT Auxiliary Entry { -; SYM-NEXT: Index: 11 -; SYM-NEXT: ContainingCsectSymbolIndex: 6 +; SYM-NEXT: Index: 13 +; SYM-NEXT: ContainingCsectSymbolIndex: 8 ; SYM-NEXT: ParameterHashIndex: 0x0 ; SYM-NEXT: TypeChkSectNum: 0x0 ; SYM-NEXT: SymbolAlignmentLog2: 0 @@ -267,7 +287,7 @@ ; SYM-NEXT: } ; SYM-NEXT: } ; SYM-NEXT: Symbol { -; SYM-NEXT: Index: 12 +; SYM-NEXT: Index: 14 ; SYM-NEXT: Name: arr ; SYM-NEXT: Value (RelocatableAddress): 0x48 ; SYM-NEXT: Section: .data @@ -275,8 +295,8 @@ ; SYM-NEXT: StorageClass: C_EXT (0x2) ; SYM-NEXT: NumberOfAuxEntries: 1 ; SYM-NEXT: CSECT Auxiliary Entry { -; SYM-NEXT: Index: 13 -; SYM-NEXT: ContainingCsectSymbolIndex: 6 +; SYM-NEXT: Index: 15 +; SYM-NEXT: ContainingCsectSymbolIndex: 8 ; SYM-NEXT: ParameterHashIndex: 0x0 ; SYM-NEXT: TypeChkSectNum: 0x0 ; SYM-NEXT: SymbolAlignmentLog2: 0 @@ -287,7 +307,7 @@ ; SYM-NEXT: } ; SYM-NEXT: } ; SYM-NEXT: Symbol { -; SYM-NEXT: Index: 14 +; SYM-NEXT: Index: 16 ; SYM-NEXT: Name: p ; SYM-NEXT: Value (RelocatableAddress): 0x70 ; SYM-NEXT: Section: .data @@ -295,8 +315,8 @@ ; SYM-NEXT: StorageClass: C_EXT (0x2) ; SYM-NEXT: NumberOfAuxEntries: 1 ; SYM-NEXT: CSECT Auxiliary Entry { -; SYM-NEXT: Index: 15 -; SYM-NEXT: ContainingCsectSymbolIndex: 6 +; SYM-NEXT: Index: 17 +; SYM-NEXT: ContainingCsectSymbolIndex: 8 ; SYM-NEXT: ParameterHashIndex: 0x0 ; SYM-NEXT: TypeChkSectNum: 0x0 ; SYM-NEXT: SymbolAlignmentLog2: 0 @@ -307,7 +327,7 @@ ; SYM-NEXT: } ; SYM-NEXT: } ; SYM-NEXT: Symbol { -; SYM-NEXT: Index: 16 +; SYM-NEXT: Index: 18 ; SYM-NEXT: Name: foo ; SYM-NEXT: Value (RelocatableAddress): 0x74 ; SYM-NEXT: Section: .data @@ -315,7 +335,7 @@ ; SYM-NEXT: StorageClass: C_EXT (0x2) ; SYM-NEXT: NumberOfAuxEntries: 1 ; SYM-NEXT: CSECT Auxiliary Entry { -; SYM-NEXT: Index: 17 +; SYM-NEXT: Index: 19 ; SYM-NEXT: SectionLen: 12 ; SYM-NEXT: ParameterHashIndex: 0x0 ; SYM-NEXT: TypeChkSectNum: 0x0 @@ -327,7 +347,7 @@ ; SYM-NEXT: } ; SYM-NEXT: } ; SYM-NEXT: Symbol { -; SYM-NEXT: Index: 18 +; SYM-NEXT: Index: 20 ; SYM-NEXT: Name: TOC ; SYM-NEXT: Value (RelocatableAddress): 0x80 ; SYM-NEXT: Section: .data @@ -335,7 +355,7 @@ ; SYM-NEXT: StorageClass: C_HIDEXT (0x6B) ; SYM-NEXT: NumberOfAuxEntries: 1 ; SYM-NEXT: CSECT Auxiliary Entry { -; SYM-NEXT: Index: 19 +; SYM-NEXT: Index: 21 ; SYM-NEXT: SectionLen: 0 ; SYM-NEXT: ParameterHashIndex: 0x0 ; SYM-NEXT: TypeChkSectNum: 0x0 @@ -347,7 +367,7 @@ ; SYM-NEXT: } ; SYM-NEXT: } ; SYM-NEXT: Symbol { -; SYM-NEXT: Index: 20 +; SYM-NEXT: Index: 22 ; SYM-NEXT: Name: globalA ; SYM-NEXT: Value (RelocatableAddress): 0x80 ; SYM-NEXT: Section: .data @@ -355,7 +375,7 @@ ; SYM-NEXT: StorageClass: C_HIDEXT (0x6B) ; SYM-NEXT: NumberOfAuxEntries: 1 ; SYM-NEXT: CSECT Auxiliary Entry { -; SYM-NEXT: Index: 21 +; SYM-NEXT: Index: 23 ; SYM-NEXT: SectionLen: 4 ; SYM-NEXT: ParameterHashIndex: 0x0 ; SYM-NEXT: TypeChkSectNum: 0x0 @@ -367,7 +387,7 @@ ; SYM-NEXT: } ; SYM-NEXT: } ; SYM-NEXT: Symbol { -; SYM-NEXT: Index: 22 +; SYM-NEXT: Index: 24 ; SYM-NEXT: Name: globalB ; SYM-NEXT: Value (RelocatableAddress): 0x84 ; SYM-NEXT: Section: .data @@ -375,7 +395,7 @@ ; SYM-NEXT: StorageClass: C_HIDEXT (0x6B) ; SYM-NEXT: NumberOfAuxEntries: 1 ; SYM-NEXT: CSECT Auxiliary Entry { -; SYM-NEXT: Index: 23 +; SYM-NEXT: Index: 25 ; SYM-NEXT: SectionLen: 4 ; SYM-NEXT: ParameterHashIndex: 0x0 ; SYM-NEXT: TypeChkSectNum: 0x0