summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/struct-packed-align.c
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2015-04-21 17:29:35 +0000
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2015-04-21 17:29:35 +0000
commitca3cb7f35c3f88e50323eaa94103982765412403 (patch)
tree8a10a5cff86878a32965de904227088e44c549f5 /clang/test/Sema/struct-packed-align.c
parent46084383868b63daf87f1dabdc6e09a39e2ff077 (diff)
downloadbcm5719-llvm-ca3cb7f35c3f88e50323eaa94103982765412403.tar.gz
bcm5719-llvm-ca3cb7f35c3f88e50323eaa94103982765412403.zip
Implement target-specific __attribute__((aligned)) value
The GCC construct __attribute__((aligned)) is defined to set alignment to "the default alignment for the target architecture" according to the GCC documentation: The default alignment is sufficient for all scalar types, but may not be enough for all vector types on a target that supports vector operations. The default alignment is fixed for a particular target ABI. clang currently hard-coded an alignment of 16 bytes for that construct, which is correct on some platforms (including X86), but wrong on others (including SystemZ). Since this value is ABI-relevant, it is important to get correct for compatibility purposes. This patch adds a new TargetInfo member "DefaultAlignForAttributeAligned" that targets can set to the appropriate default __attribute__((aligned)) value. Note that I'm deliberately *not* using the existing "SuitableAlign" value, which is used to set the pre-defined macro __BIGGEST_ALIGNMENT__, since those two values may not be the same on all platforms. In fact, on X86, __attribute__((aligned)) always uses 16-byte alignment, while __BIGGEST_ALIGNMENT__ may be larger if AVX-2 or AVX-512 are supported. (This is actually not yet correctly implemented in clang either.) The patch provides a value for DefaultAlignForAttributeAligned only for SystemZ, and leaves the default for all other targets at 16, which means no visible change in behavior on all other targets. (The value is still wrong for some other targets, but I'd prefer to leave it to the target maintainers for those platforms to fix.) llvm-svn: 235397
Diffstat (limited to 'clang/test/Sema/struct-packed-align.c')
-rw-r--r--clang/test/Sema/struct-packed-align.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/test/Sema/struct-packed-align.c b/clang/test/Sema/struct-packed-align.c
index 291de6762cd..417c30308ca 100644
--- a/clang/test/Sema/struct-packed-align.c
+++ b/clang/test/Sema/struct-packed-align.c
@@ -55,13 +55,16 @@ struct __attribute__((aligned(8))) as1 {
extern int e1[sizeof(struct as1) == 8 ? 1 : -1];
extern int e2[__alignof(struct as1) == 8 ? 1 : -1];
-// FIXME: Will need to force arch once max usable alignment isn't hard
-// coded.
struct __attribute__((aligned)) as1_2 {
char c;
};
+#ifdef __s390x__
+extern int e1_2[sizeof(struct as1_2) == 8 ? 1 : -1];
+extern int e2_2[__alignof(struct as1_2) == 8 ? 1 : -1];
+#else
extern int e1_2[sizeof(struct as1_2) == 16 ? 1 : -1];
extern int e2_2[__alignof(struct as1_2) == 16 ? 1 : -1];
+#endif
struct as2 {
char c;
OpenPOWER on IntegriCloud