Skip to content

Commit 05bef88

Browse files
committed
[AIX] Let alloca return 16 bytes alignment
On AIX, to support vector types, which should always be 16 bytes aligned, we set alloca to return 16 bytes aligned memory space. Differential Revision: https://reviews.llvm.org/D89910
1 parent 2e64ad9 commit 05bef88

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

clang/lib/Basic/Targets/PPC.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,6 @@ class LLVM_LIBRARY_VISIBILITY PPC32TargetInfo : public PPCTargetInfo {
370370
SizeType = UnsignedLong;
371371
PtrDiffType = SignedLong;
372372
IntPtrType = SignedLong;
373-
SuitableAlign = 64;
374373
LongDoubleWidth = 64;
375374
LongDoubleAlign = DoubleAlign = 32;
376375
LongDoubleFormat = &llvm::APFloat::IEEEdouble();
@@ -409,7 +408,6 @@ class LLVM_LIBRARY_VISIBILITY PPC64TargetInfo : public PPCTargetInfo {
409408
if (Triple.isOSAIX()) {
410409
// TODO: Set appropriate ABI for AIX platform.
411410
DataLayout = "E-m:a-i64:64-n32:64";
412-
SuitableAlign = 64;
413411
LongDoubleWidth = 64;
414412
LongDoubleAlign = DoubleAlign = 32;
415413
LongDoubleFormat = &llvm::APFloat::IEEEdouble();

clang/test/CodeGen/aix_alloca_align.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %clang_cc1 -triple=powerpc-ibm-aix-xcoff -S -emit-llvm < %s | \
2+
// RUN: FileCheck --check-prefix=32BIT %s
3+
4+
// RUN: %clang_cc1 -triple=powerpc64-ibm-aix-xcoff -S -emit-llvm < %s | \
5+
// RUN: FileCheck --check-prefix=64BIT %s
6+
7+
typedef __SIZE_TYPE__ size_t;
8+
extern void *alloca(size_t __size) __attribute__((__nothrow__));
9+
10+
void foo() {
11+
char *ptr1 = (char *)alloca(sizeof(char) * 9);
12+
char *ptr2 = (char *)alloca(sizeof(char) * 32);
13+
}
14+
15+
// 32BIT: %0 = alloca i8, i32 9, align 16
16+
// 32BIT: %1 = alloca i8, i32 32, align 16
17+
18+
// 64BIT: %0 = alloca i8, i64 9, align 16
19+
// 64BIT: %1 = alloca i8, i64 32, align 16

clang/test/Preprocessor/init-ppc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@
398398
// PPC-AIX:#define _LONG_LONG 1
399399
// PPC-AIX-NOT:#define _LP64 1
400400
// PPC-AIX:#define _POWER 1
401-
// PPC-AIX:#define __BIGGEST_ALIGNMENT__ 8
401+
// PPC-AIX:#define __BIGGEST_ALIGNMENT__ 16
402402
// PPC-AIX:#define __BIG_ENDIAN__ 1
403403
// PPC-AIX:#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__
404404
// PPC-AIX:#define __CHAR16_TYPE__ unsigned short

clang/test/Preprocessor/init-ppc64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@
666666
// PPC64-AIX:#define _LP64 1
667667
// PPC64-AIX:#define _POWER 1
668668
// PPC64-AIX:#define __64BIT__ 1
669-
// PPC64-AIX:#define __BIGGEST_ALIGNMENT__ 8
669+
// PPC64-AIX:#define __BIGGEST_ALIGNMENT__ 16
670670
// PPC64-AIX:#define __BIG_ENDIAN__ 1
671671
// PPC64-AIX:#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__
672672
// PPC64-AIX:#define __CHAR16_TYPE__ unsigned short

0 commit comments

Comments
 (0)