[PATCH] D72461: [AIX][XCOFF] Supporting the ReadOnlyWithRel SectionKnd

Digger via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 13 13:15:16 PST 2020


DiggerLin updated this revision to Diff 237761.
DiggerLin marked 5 inline comments as done.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72461/new/

https://reviews.llvm.org/D72461

Files:
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
  llvm/test/CodeGen/PowerPC/aix-readonly-with-relocation.ll


Index: llvm/test/CodeGen/PowerPC/aix-readonly-with-relocation.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-readonly-with-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
@@ -1798,8 +1798,7 @@
       TargetLoweringObjectFileXCOFF::getStorageClassForGlobal(GV));
 
   SectionKind GVKind = getObjFileLowering().getKindForGlobal(GV, TM);
-  if ((!GVKind.isCommon() && !GVKind.isBSS() && !GVKind.isData() &&
-       !GVKind.isReadOnly()) ||
+  if ((!GVKind.isGlobalWriteableData() && !GVKind.isReadOnly()) ||
       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,10 @@
   if (Kind.isText())
     return TextSection;
 
-  if (Kind.isData())
+  if (Kind.isData() || Kind.isReadOnlyWithRel())
+    // TODO: We maybe put this under option control, because user maybe want to
+    // have read-only data with relocations placed into a read-only section by
+    // the compiler.
     return DataSection;
 
   // Zero initialized data must be emitted to the .data section because external


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72461.237761.patch
Type: text/x-patch
Size: 2286 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200113/1082dd2f/attachment-0001.bin>


More information about the llvm-commits mailing list