1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

[AIX] Handle LinkOnceODRLinkage and AppendingLinkage for static init gloabl arrays

Handle LinkOnceODRLinkage;
Handle AppendingLinkage type for llvm.global_ctors/dtors static init global arrays;

Differential Revision: https://reviews.llvm.org/D75305
This commit is contained in:
Xiangling Liao 2020-02-26 16:48:23 -05:00
parent d6ff1e3c2d
commit 827e353418
4 changed files with 51 additions and 0 deletions

View File

@ -1948,7 +1948,11 @@ XCOFF::StorageClass TargetLoweringObjectFileXCOFF::getStorageClassForGlobal(
case GlobalValue::CommonLinkage:
return XCOFF::C_EXT;
case GlobalValue::ExternalWeakLinkage:
case GlobalValue::LinkOnceODRLinkage:
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.");

View File

@ -1579,9 +1579,22 @@ const MCExpr *PPCAIXAsmPrinter::lowerConstant(const Constant *CV) {
return PPCAsmPrinter::lowerConstant(CV);
}
static bool isSpecialLLVMGlobalArrayForStaticInit(const GlobalVariable *GV) {
return StringSwitch<bool>(GV->getName())
.Cases("llvm.global_ctors", "llvm.global_dtors", true)
.Default(false);
}
void PPCAIXAsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
ValidateGV(GV);
// TODO: Update the handling of global arrays for static init when we support
// the ".ref" directive.
// Otherwise, we can skip these arrays, because the AIX linker collects
// static init functions simply based on their name.
if (isSpecialLLVMGlobalArrayForStaticInit(GV))
return;
// Create the symbol, set its storage class.
MCSymbolXCOFF *GVSym = cast<MCSymbolXCOFF>(getSymbol(GV));
GVSym->setStorageClass(

View File

@ -0,0 +1,21 @@
; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff < \
; RUN: %s | FileCheck %s
; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff < \
; RUN: %s | FileCheck %s
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @foo, i8* null }]
@llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @bar, i8* null }]
define dso_local void @foo() {
entry:
ret void
}
define dso_local void @bar() {
entry:
ret void
}
; CHECK-NOT: llvm.global_ctors
; CHECK-NOT: llvm.global_dtors

View File

@ -0,0 +1,13 @@
; RUN: llc -mtriple powerpc-ibm-aix-xcoff < %s | \
; RUN: FileCheck %s
; RUN: llc -mtriple powerpc64-ibm-aix-xcoff < %s | \
; RUN: FileCheck %s
define linkonce_odr void @_Z3fooIiEvT_() {
entry:
ret void
}
; CHECK: .weak _Z3fooIiEvT_
; CHECK: .weak ._Z3fooIiEvT_