[PATCH] D69528: [PowerPC][XCOFF] Add assembly support for zero initalized global values.

Sean Fertile via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 28 13:20:13 PDT 2019


sfertile created this revision.
sfertile added reviewers: xingxue, jasonliu, daltenty, DiggerLin.
Herald added subscribers: shchenz, jsji, kbarton, hiraditya, nemanjai.
Herald added a project: LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69528

Files:
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
  llvm/test/CodeGen/PowerPC/aix-xcoff-data.ll


Index: llvm/test/CodeGen/PowerPC/aix-xcoff-data.ll
===================================================================
--- llvm/test/CodeGen/PowerPC/aix-xcoff-data.ll
+++ llvm/test/CodeGen/PowerPC/aix-xcoff-data.ll
@@ -9,6 +9,9 @@
 @over_aligned = local_unnamed_addr global double 9.000000e+02, align 32
 @charr = local_unnamed_addr global [4 x i8] c"abcd", align 1
 @dblarr = local_unnamed_addr global [4 x double] [double 1.000000e+00, double 2.000000e+00, double 3.000000e+00, double 4.000000e+00], align 8
+ at d_0 = global double 0.000000e+00, align 8
+ at s_0 = global i16 0, align 2
+ at f_0 = global float 0.000000e+00, align 4
 
 ; CHECK:      .csect .data[RW]
 ; CHECK-NEXT: .globl  ivar
@@ -55,3 +58,18 @@
 ; CHECK-NEXT: .llong  4611686018427387904
 ; CHECK-NEXT: .llong  4613937818241073152
 ; CHECK-NEXT: .llong  4616189618054758400
+
+; CHECK:      .globl  d_0
+; CHECK-NEXT: .align 3
+; CHECK-NEXT: d_0:
+; CHECK-NEXT: .llong 0
+
+; CHECK:      .globl  s_0
+; CHECK-NEXT: .align  1
+; CHECK-NEXT: s_0:
+; CHECK-NEXT: .short 0
+
+; CHECK:      .globl f_0
+; CHECK-NEXT: .align 2
+; CHECK-NEXT: f_0:
+; CHECK-NEXT: .long 0
Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -1747,7 +1747,7 @@
     report_fatal_error("COMDAT not yet supported by AIX.");
 
   SectionKind GVKind = getObjFileLowering().getKindForGlobal(GV, TM);
-  if (!GVKind.isCommon() && !GVKind.isBSSLocal() && !GVKind.isData())
+  if (!GVKind.isCommon() && !GVKind.isBSS() && !GVKind.isData())
     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
@@ -1855,6 +1855,12 @@
   if (Kind.isData())
     return DataSection;
 
+  // Zero initialized data must be emitted to the .data section because external
+  // linkage control sections that get mapped to the .bss section will be linked
+  // as tentative defintions, which is only appropriate for SectionKind::Common.
+  if (Kind.isBSS())
+    return DataSection;
+
   report_fatal_error("XCOFF other section types not yet implemented.");
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69528.226739.patch
Type: text/x-patch
Size: 2425 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191028/7219bdf4/attachment.bin>


More information about the llvm-commits mailing list