summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen/packed-structure.c
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-01-20 07:57:12 +0000
committerJohn McCall <rjmccall@apple.com>2011-01-20 07:57:12 +0000
commit4e81961a1e24aff155ef981f14ac84e2cd1f7de7 (patch)
treef51b6aaae4c8bf1d280227e695fcc9e93adb9b10 /clang/test/CodeGen/packed-structure.c
parent4dc72284b254925713e08f5cf8d992d28a4a6412 (diff)
downloadbcm5719-llvm-4e81961a1e24aff155ef981f14ac84e2cd1f7de7.tar.gz
bcm5719-llvm-4e81961a1e24aff155ef981f14ac84e2cd1f7de7.zip
Fix the computation of alignment for fields of packed+aligned structs.
Part of the fix for PR8413. llvm-svn: 123904
Diffstat (limited to 'clang/test/CodeGen/packed-structure.c')
-rw-r--r--clang/test/CodeGen/packed-structure.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/test/CodeGen/packed-structure.c b/clang/test/CodeGen/packed-structure.c
index 2934d01d649..731a50bb077 100644
--- a/clang/test/CodeGen/packed-structure.c
+++ b/clang/test/CodeGen/packed-structure.c
@@ -87,3 +87,16 @@ int s2_load_y(struct s2 *a) { return a->y; }
// CHECK-FUNCTIONS: define void @s2_copy
// CHECK-FUNCTIONS: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* {{.*}}, i64 8, i32 2, i1 false)
void s2_copy(struct s2 *a, struct s2 *b) { *b = *a; }
+
+struct __attribute__((packed, aligned)) s3 {
+ short aShort;
+ int anInt;
+};
+// CHECK-GLOBAL: @s3_1 = global i32 2
+int s3_1 = __alignof(((struct s3*) 0)->anInt);
+// CHECK-FUNCTIONS: define i32 @test3(
+int test3(struct s3 *ptr) {
+ // CHECK-FUNCTIONS: [[PTR:%.*]] = getelementptr inbounds {{%.*}}* {{%.*}}, i32 0, i32 1
+ // CHECK-FUNCTIONS-NEXT: load i32* [[PTR]], align 2
+ return ptr->anInt;
+}
OpenPOWER on IntegriCloud