From: jasonliu Date: Tue, 26 Nov 2019 16:05:26 +0000 (+0000) Subject: [XCOFF][AIX] Check linkage on the function, and two fixes for comments X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7707d8aa9db8aa3814593f9c40cc707f306e3ae2;p=platform%2Fupstream%2Fllvm.git [XCOFF][AIX] Check linkage on the function, and two fixes for comments This is a follow up commit to address post-commit comment in D70443 Differential revision: https://reviews.llvm.org/D70443 --- diff --git a/llvm/lib/MC/XCOFFObjectWriter.cpp b/llvm/lib/MC/XCOFFObjectWriter.cpp index ca96a0e..ab0d904 100644 --- a/llvm/lib/MC/XCOFFObjectWriter.cpp +++ b/llvm/lib/MC/XCOFFObjectWriter.cpp @@ -574,7 +574,7 @@ void XCOFFObjectWriter::assignAddressesAndIndices(const MCAsmLayout &Layout) { // yet, so start at index 0. uint32_t SymbolTableIndex = 0; - // Calculate undefined symbol's indices. + // Calculate indices for undefined symbols. for (auto &Csect : UndefinedCsects) { Csect.Size = 0; Csect.Address = 0; diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp index f95f8be..3c59cea 100644 --- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp @@ -52,6 +52,7 @@ #include "llvm/CodeGen/SelectionDAGNodes.h" #include "llvm/CodeGen/TargetInstrInfo.h" #include "llvm/CodeGen/TargetLowering.h" +#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" #include "llvm/CodeGen/TargetRegisterInfo.h" #include "llvm/CodeGen/ValueTypes.h" #include "llvm/IR/CallSite.h" @@ -5326,16 +5327,19 @@ SDValue PPCTargetLowering::FinishCall( GlobalAddressSDNode *G = cast(Callee); auto &Context = DAG.getMachineFunction().getMMI().getContext(); + const GlobalObject *GO = cast(G->getGlobal()); MCSymbolXCOFF *S = cast(Context.getOrCreateSymbol( - Twine(".") + Twine(G->getGlobal()->getName()))); - - const GlobalValue *GV = G->getGlobal(); - if (GV && GV->isDeclaration() && !S->hasContainingCsect()) { - // On AIX, undefined symbol need to associate with a MCSectionXCOFF to - // get the correct storage mapping class. In this case, XCOFF::XMC_PR. + Twine(".") + Twine(GO->getName()))); + + if (GO && GO->isDeclaration() && !S->hasContainingCsect()) { + // On AIX, an undefined symbol needs to be associated with a + // MCSectionXCOFF to get the correct storage mapping class. + // In this case, XCOFF::XMC_PR. + const XCOFF::StorageClass SC = + TargetLoweringObjectFileXCOFF::getStorageClassForGlobal(GO); MCSectionXCOFF *Sec = Context.getXCOFFSection(S->getName(), XCOFF::XMC_PR, XCOFF::XTY_ER, - XCOFF::C_EXT, SectionKind::getMetadata()); + SC, SectionKind::getMetadata()); S->setContainingCsect(Sec); } diff --git a/llvm/test/CodeGen/PowerPC/aix-weak-undef-func-call.ll b/llvm/test/CodeGen/PowerPC/aix-weak-undef-func-call.ll new file mode 100644 index 0000000..9fb3dec --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/aix-weak-undef-func-call.ll @@ -0,0 +1,30 @@ +; RUN: llc -mtriple powerpc-ibm-aix-xcoff -filetype=obj -o %t.o < %s +; RUN: llvm-readobj --symbols %t.o | FileCheck %s + +define void @bar() { +entry: + call void bitcast (void (...)* @foo to void ()*)() + ret void +} + +declare extern_weak void @foo(...) + +;CHECK: Symbol { +;CHECK: Name: .foo +;CHECK-NEXT: Value (RelocatableAddress): 0x0 +;CHECK-NEXT: Section: N_UNDEF +;CHECK-NEXT: Type: 0x0 +;CHECK-NEXT: StorageClass: C_WEAKEXT (0x6F) +;CHECK-NEXT: NumberOfAuxEntries: 1 +;CHECK-NEXT: CSECT Auxiliary Entry { +;CHECK: SectionLen: 0 +;CHECK-NEXT: ParameterHashIndex: 0x0 +;CHECK-NEXT: TypeChkSectNum: 0x0 +;CHECK-NEXT: SymbolAlignmentLog2: 0 +;CHECK-NEXT: SymbolType: XTY_ER (0x0) +;CHECK-NEXT: StorageMappingClass: XMC_PR (0x0) +;CHECK-NEXT: StabInfoIndex: 0x0 +;CHECK-NEXT: StabSectNum: 0x0 +;CHECK-NEXT: } +;CHECK-NEXT: } +