[PATCH] D72461: [AIX][XCOFF] Supporting the ReadOnlyWithRel SectionKnd
Digger via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 9 08:49:41 PST 2020
DiggerLin created this revision.
DiggerLin added reviewers: hubert.reinterpretcast, jasonliu, daltenty, sfertile.
Herald added subscribers: llvm-commits, jsji, kbarton, hiraditya, nemanjai.
Herald added a project: LLVM.
in this patch we put the global variable in a Csect which's SectionKind is "ReadOnlyWithRel" into Data Section.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D72461
Files:
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
llvm/test/CodeGen/PowerPC/aix-readonly-relocation.ll
Index: llvm/test/CodeGen/PowerPC/aix-readonly-relocation.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-readonly-relocation.ll
@@ -0,0 +1,19 @@
+; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff --relocation-model=pic < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff --relocation-model=pic < %s | FileCheck --check-prefix=CHECK64 %s
+
+ at a = common global i32 0
+ at b = constant i32* @a
+
+;CHECK: .comm a[RW],4,2
+;CHECK-NEXT: .csect .data[RW]
+;CHECK-NEXT: .globl b
+;CHECK-NEXT: .align 2
+;CHECK-NEXT: b:
+;CHECK-NEXT: .long a
+
+;CHECK64: .comm a[RW],4,2
+;CHECK64-NEXT: .csect .data[RW]
+;CHECK64-NEXT: .globl b
+;CHECK64-NEXT: .align 3
+;CHECK64-NEXT: b:
+;CHECK64-NEXT: .llong a
Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -1799,7 +1799,7 @@
SectionKind GVKind = getObjFileLowering().getKindForGlobal(GV, TM);
if ((!GVKind.isCommon() && !GVKind.isBSS() && !GVKind.isData() &&
- !GVKind.isReadOnly()) ||
+ !GVKind.isReadOnly() && !GVKind.isReadOnlyWithRel()) ||
GVKind.isMergeable2ByteCString() || GVKind.isMergeable4ByteCString())
report_fatal_error("Encountered a global variable kind that is "
"not supported yet.");
Index: llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===================================================================
--- llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -1870,7 +1870,7 @@
if (Kind.isText())
return TextSection;
- if (Kind.isData())
+ if (Kind.isData() || Kind.isReadOnlyWithRel())
return DataSection;
// Zero initialized data must be emitted to the .data section because external
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72461.237100.patch
Type: text/x-patch
Size: 2019 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200109/20e35822/attachment.bin>
More information about the llvm-commits
mailing list