[PATCH] D75305: [AIX] Handle LinkOnceODRLinkage and llvm.global_ctors/dtors' AppendingLinkage
Xiangling Liao via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 27 14:15:30 PST 2020
Xiangling_L created this revision.
Xiangling_L added reviewers: jasonliu, sfertile, hubert.reinterpretcast, stevewan.
Xiangling_L added a project: LLVM.
Herald added subscribers: llvm-commits, jsji, kbarton, hiraditya, nemanjai.
(1)LinkOnceODRLinkage:
emit .weak for the symbol;
(2) AppendingLinkage of `llvm.global_ctors`, `llvm.global_dtors`:
omit emitting anything from these two global arrays until we support `-qtwolink` similar behavior on AIX.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D75305
Files:
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
llvm/test/CodeGen/PowerPC/aix-AppendingLinkage.ll
llvm/test/CodeGen/PowerPC/aix-LinkOnceODRLinkage.ll
Index: llvm/test/CodeGen/PowerPC/aix-LinkOnceODRLinkage.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-LinkOnceODRLinkage.ll
@@ -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_
Index: llvm/test/CodeGen/PowerPC/aix-AppendingLinkage.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-AppendingLinkage.ll
@@ -0,0 +1,22 @@
+; RUN: llc -mtriple powerpc-ibm-aix-xcoff < %s | \
+; RUN: FileCheck %s
+
+; RUN: llc -mtriple powerpc64-ibm-aix-xcoff < %s | \
+; RUN: FileCheck %s
+
+ at llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @foo, i8* null }]
+ at 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
+; CHECK-NOT: Should never emit it.
Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -1584,9 +1584,18 @@
return PPCAsmPrinter::lowerConstant(CV);
}
+static bool isSpecialLLVMGlobal(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);
+ if (isSpecialLLVMGlobal(GV))
+ return;
+
// Create the symbol, set its storage class.
MCSymbolXCOFF *GVSym = cast<MCSymbolXCOFF>(getSymbol(GV));
GVSym->setStorageClass(
Index: llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===================================================================
--- llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -1946,7 +1946,10 @@
case GlobalValue::CommonLinkage:
return XCOFF::C_EXT;
case GlobalValue::ExternalWeakLinkage:
+ case GlobalValue::LinkOnceODRLinkage:
return XCOFF::C_WEAKEXT;
+ case GlobalValue::AppendingLinkage:
+ llvm_unreachable("Should never emit it.");
default:
report_fatal_error(
"Unhandled linkage when mapping linkage to StorageClass.");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75305.247102.patch
Type: text/x-patch
Size: 2717 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200227/e08fbc2d/attachment-0001.bin>
More information about the llvm-commits
mailing list