summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen/arm-bitfield-alignment.c
diff options
context:
space:
mode:
authorBradley Smith <bradley.smith@arm.com>2015-04-28 11:24:54 +0000
committerBradley Smith <bradley.smith@arm.com>2015-04-28 11:24:54 +0000
commitba945626b094899c7a4cae587398a69097da560c (patch)
tree8999ff7481a090b491d669dc6bbcaeee21b32aeb /clang/test/CodeGen/arm-bitfield-alignment.c
parent86e0249235f15fae19709e21b1ae250fd1f20ca0 (diff)
downloadbcm5719-llvm-ba945626b094899c7a4cae587398a69097da560c.tar.gz
bcm5719-llvm-ba945626b094899c7a4cae587398a69097da560c.zip
[ARM/AArch64] Enforce alignment for bitfielded structs
When creating a global variable with a type of a struct with bitfields, we must forcibly set the alignment of the global from the RecordDecl. We must do this so that the proper bitfield alignment makes its way down to LLVM, since clang will mangle the bitfields into one large type. llvm-svn: 235976
Diffstat (limited to 'clang/test/CodeGen/arm-bitfield-alignment.c')
-rw-r--r--clang/test/CodeGen/arm-bitfield-alignment.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/test/CodeGen/arm-bitfield-alignment.c b/clang/test/CodeGen/arm-bitfield-alignment.c
new file mode 100644
index 00000000000..66bbdae57bb
--- /dev/null
+++ b/clang/test/CodeGen/arm-bitfield-alignment.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple arm-none-eabi -ffreestanding -emit-llvm -o - -O3 %s | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64 -ffreestanding -emit-llvm -o - -O3 %s | FileCheck %s
+
+extern struct T {
+ int b0 : 8;
+ int b1 : 24;
+ int b2 : 1;
+} g;
+
+int func() {
+ return g.b1;
+}
+
+// CHECK: @g = external global %struct.T, align 4
+// CHECK: %{{.*}} = load i64, i64* bitcast (%struct.T* @g to i64*), align 4
OpenPOWER on IntegriCloud