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

Xiangling Liao via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 22 07:53:06 PDT 2020


Xiangling_L updated this revision to Diff 299975.
Xiangling_L marked 3 inline comments as done.
Xiangling_L added a comment.

Fixed the testcase formatting issues;
Fixed the `BIGGEST_ALIGNMENT` value in testcases;


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

https://reviews.llvm.org/D89910

Files:
  clang/lib/Basic/Targets/PPC.h
  clang/test/CodeGen/aix_alloca_align.c
  clang/test/Preprocessor/init-ppc.c
  clang/test/Preprocessor/init-ppc64.c


Index: clang/test/Preprocessor/init-ppc64.c
===================================================================
--- clang/test/Preprocessor/init-ppc64.c
+++ clang/test/Preprocessor/init-ppc64.c
@@ -666,7 +666,7 @@
 // PPC64-AIX:#define _LP64 1
 // PPC64-AIX:#define _POWER 1
 // PPC64-AIX:#define __64BIT__ 1
-// PPC64-AIX:#define __BIGGEST_ALIGNMENT__ 8
+// PPC64-AIX:#define __BIGGEST_ALIGNMENT__ 16
 // PPC64-AIX:#define __BIG_ENDIAN__ 1
 // PPC64-AIX:#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__
 // PPC64-AIX:#define __CHAR16_TYPE__ unsigned short
Index: clang/test/Preprocessor/init-ppc.c
===================================================================
--- clang/test/Preprocessor/init-ppc.c
+++ clang/test/Preprocessor/init-ppc.c
@@ -398,7 +398,7 @@
 // PPC-AIX:#define _LONG_LONG 1
 // PPC-AIX-NOT:#define _LP64 1
 // PPC-AIX:#define _POWER 1
-// PPC-AIX:#define __BIGGEST_ALIGNMENT__ 8
+// PPC-AIX:#define __BIGGEST_ALIGNMENT__ 16
 // PPC-AIX:#define __BIG_ENDIAN__ 1
 // PPC-AIX:#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__
 // PPC-AIX:#define __CHAR16_TYPE__ unsigned short
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 __SIZE_TYPE__ 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.299975.patch
Type: text/x-patch
Size: 2515 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201022/95538462/attachment.bin>


More information about the cfe-commits mailing list