[PATCH] D71144: [AIX] Use csect reference for function address constants
Digger via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 23 08:57:26 PST 2019
DiggerLin updated this revision to Diff 235149.
DiggerLin added a comment.
change C_HIDDEN to C_HIDEXT
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71144/new/
https://reviews.llvm.org/D71144
Files:
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
llvm/test/CodeGen/PowerPC/aix-reference-func-addr-const.ll
Index: llvm/test/CodeGen/PowerPC/aix-reference-func-addr-const.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-reference-func-addr-const.ll
@@ -0,0 +1,32 @@
+; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff < %s | FileCheck --check-prefix=CHECK64 %s
+
+ at foo_ptr = global void (...)* @foo
+declare void @foo(...)
+
+ at bar_ptr1 = global void (...)* bitcast (void ()* @bar to void (...)*)
+define void @bar() {
+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]
+
+;CHECK64: .csect .data[RW]
+;CHECK64-NEXT: .globl foo_ptr
+;CHECK64-NEXT: .align 3
+;CHECK64-NEXT: foo_ptr:
+;CHECK64-NEXT: .llong foo[DS]
+;CHECK64-NEXT: .globl bar_ptr1
+;CHECK64-NEXT: .align 3
+;CHECK64-NEXT: bar_ptr1:
+;CHECK64-NEXT: .llong bar[DS]
Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ 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 Function *F = dyn_cast<Function>(CV)) {
+ MCSymbolXCOFF *FSym = cast<MCSymbolXCOFF>(getSymbol(F));
+ if (!FSym->hasContainingCsect()) {
+ const XCOFF::StorageClass SC =
+ F->isDeclaration()
+ ? TargetLoweringObjectFileXCOFF::getStorageClassForGlobal(F)
+ : XCOFF::C_HIDEXT;
+ MCSectionXCOFF *Csect = OutStreamer->getContext().getXCOFFSection(
+ FSym->getName(), XCOFF::XMC_DS,
+ F->isDeclaration() ? XCOFF::XTY_ER : XCOFF::XTY_SD, SC,
+ SectionKind::getMetadata());
+ FSym->setContainingCsect(Csect);
+ }
+ return MCSymbolRefExpr::create(
+ FSym->getContainingCsect()->getQualNameSymbol(), OutContext);
+ }
+ return PPCAsmPrinter::lowerConstant(CV);
+}
+
void PPCAIXAsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
ValidateGV(GV);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71144.235149.patch
Type: text/x-patch
Size: 2717 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191223/1e9cac21/attachment.bin>
More information about the llvm-commits
mailing list