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 @@ -177,6 +177,8 @@ void SetupMachineFunction(MachineFunction &MF) override; + const MCExpr *lowerConstant(const Constant *CV) override; + void EmitGlobalVariable(const GlobalVariable *GV) override; void EmitFunctionDescriptor() override; @@ -1755,6 +1757,26 @@ report_fatal_error("COMDAT not yet supported by AIX."); } +const MCExpr *PPCAIXAsmPrinter::lowerConstant(const Constant *CV) { + if (const GlobalObject *GO = dyn_cast(CV)) { + if (isa(GO)) { + MCSymbolXCOFF *GOSym = cast(getSymbol(GO)); + if (!GOSym->hasContainingCsect()) { + const XCOFF::StorageClass SC = + TargetLoweringObjectFileXCOFF::getStorageClassForGlobal(GO); + GOSym->setStorageClass(SC); + MCSectionXCOFF *Csect = OutStreamer->getContext().getXCOFFSection( + GOSym->getName(), XCOFF::XMC_DS, + GO->isDeclaration() ? XCOFF::XTY_ER : XCOFF::XTY_SD, SC, + SectionKind::getMetadata()); + GOSym->setContainingCsect(Csect); + } + return MCSymbolRefExpr::create( + GOSym->getContainingCsect()->getQualNameSymbol(), OutContext); + } + } + return AsmPrinter::lowerConstant(CV); +} void PPCAIXAsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) { ValidateGV(GV); diff --git a/llvm/test/CodeGen/PowerPC/aix-xcoff-FuntionDS.ll b/llvm/test/CodeGen/PowerPC/aix-xcoff-FuntionDS.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/aix-xcoff-FuntionDS.ll @@ -0,0 +1,22 @@ +; RUN: llc -mtriple powerpc-ibm-aix-xcoff < %s | FileCheck %s + +@foo_ptr = global void (...)* @foo, align 4 +declare void @foo(...) #0 + +@bar_ptr1 = global void (...)* bitcast (void ()* @bar to void (...)*), align 4 +; Function Attrs: noinline nounwind optnone +define void @bar() #0 { +entry: + ret void +} + + +;CHECK: .csect .data[RW] +;CHECK-NEXT: .globl foo_ptr +;CHECK-NEXT: .align 2 +;CHECK-NEXT: foo_ptr: +;CHECK-NEXT: .long foo[DS] +;CHECK-NEXT: .globl bar_ptr1 +;CHECK-NEXT: .align 2 +;CHECK-NEXT: bar_ptr1: +;CHECK-NEXT: .long bar[DS]