[PATCH] D89910: [AIX] Let alloca return 16 bytes alignment

Xiangling Liao via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 21 13:45:09 PDT 2020


Xiangling_L created this revision.
Xiangling_L added reviewers: hubert.reinterpretcast, jasonliu, ZarkoCA.
Herald added subscribers: cfe-commits, dexonsmith, kbarton, nemanjai.
Herald added a project: clang.
Xiangling_L requested review of this revision.

On AIX, to support vector types, which should always be 16bytes aligned, we set `alloca` to return 16 bytes aligned memory space.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89910

Files:
  clang/lib/Basic/Targets/PPC.h
  clang/test/CodeGen/aix_alloca_align.c


Index: clang/test/CodeGen/aix_alloca_align.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/aix_alloca_align.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple=powerpc-ibm-aix-xcoff -S -emit-llvm < %s | \
+// RUN:   FileCheck -check-prefix 32BIT %s
+
+// RUN: %clang_cc1 -triple=powerpc64-ibm-aix-xcoff -S -emit-llvm < %s | \
+// RUN:   FileCheck -check-prefix 64BIT %s
+
+typedef long unsigned int size_t;
+extern void *alloca(size_t __size) __attribute__((__nothrow__));
+
+void foo() {
+  char *ptr1 = (char *)alloca(sizeof(char) * 9);
+}
+
+// 32BIT: %0 = alloca i8, i32 9, align 16
+// 64BIT: %0 = alloca i8, i64 9, align 16
Index: clang/lib/Basic/Targets/PPC.h
===================================================================
--- clang/lib/Basic/Targets/PPC.h
+++ clang/lib/Basic/Targets/PPC.h
@@ -370,7 +370,6 @@
       SizeType = UnsignedLong;
       PtrDiffType = SignedLong;
       IntPtrType = SignedLong;
-      SuitableAlign = 64;
       LongDoubleWidth = 64;
       LongDoubleAlign = DoubleAlign = 32;
       LongDoubleFormat = &llvm::APFloat::IEEEdouble();
@@ -409,7 +408,6 @@
     if (Triple.isOSAIX()) {
       // TODO: Set appropriate ABI for AIX platform.
       DataLayout = "E-m:a-i64:64-n32:64";
-      SuitableAlign = 64;
       LongDoubleWidth = 64;
       LongDoubleAlign = DoubleAlign = 32;
       LongDoubleFormat = &llvm::APFloat::IEEEdouble();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89910.299796.patch
Type: text/x-patch
Size: 1430 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201021/0b6cdd62/attachment.bin>


More information about the cfe-commits mailing list