Index: clang/test/CodeGen/arm-bitfield-alignment.c =================================================================== --- clang/test/CodeGen/arm-bitfield-alignment.c +++ clang/test/CodeGen/arm-bitfield-alignment.c @@ -1,5 +1,7 @@ -// RUN: %clang_cc1 -triple arm-none-eabi -ffreestanding -emit-llvm -o - %s | FileCheck %s -// RUN: %clang_cc1 -triple aarch64 -ffreestanding -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple arm-none-eabi -fdump-record-layouts-simple -ffreestanding -emit-llvm -o %t %s | FileCheck %s -check-prefixes=LAYOUT +// RUN: <%t FileCheck %s -check-prefixes=IR +// RUN: %clang_cc1 -triple aarch64 -fdump-record-layouts-simple -ffreestanding -emit-llvm -o %t %s | FileCheck %s -check-prefixes=LAYOUT +// RUN: <%t FileCheck %s -check-prefixes=IR extern struct T { int b0 : 8; @@ -11,5 +13,14 @@ return g.b1; } -// CHECK: @g = external global %struct.T, align 4 -// CHECK: %{{.*}} = load i64, ptr @g, align 4 +// IR: @g = external global %struct.T, align 4 +// IR: %{{.*}} = load i64, ptr @g, align 4 + +// LAYOUT-LABEL: Record: RecordDecl {{.*}} struct T definition +// LAYOUT: Layout: Index: clang/test/CodeGen/arm64-be-bitfield.c =================================================================== --- clang/test/CodeGen/arm64-be-bitfield.c +++ clang/test/CodeGen/arm64-be-bitfield.c @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -triple aarch64_be-linux-gnu -ffreestanding -emit-llvm -O0 -o - %s | FileCheck --check-prefix IR %s +// RUN: %clang_cc1 -triple aarch64_be-linux-gnu -ffreestanding -emit-llvm -O0 -o %t -fdump-record-layouts-simple %s | FileCheck %s +// RUN: <%t FileCheck %s --check-prefix=IR struct bt3 { signed b2:10; signed b3:10; } b16; @@ -9,3 +10,11 @@ // IR: call void @llvm.memcpy.p0.p0.i64(ptr {{.*}}, ptr align 8 [[PTR]], i64 4 return bp11.b2; } + +// CHECK-LABEL: Record: RecordDecl {{.*}} struct bt3 definition +// CHECK: Layout: Index: clang/test/CodeGen/struct-x86-darwin.c =================================================================== --- clang/test/CodeGen/struct-x86-darwin.c +++ clang/test/CodeGen/struct-x86-darwin.c @@ -1,13 +1,5 @@ -// RUN: %clang_cc1 %s -emit-llvm -triple=i686-apple-darwin9 -o - | FileCheck %s -// CHECK: STest1 = type { i32, [4 x i16], double } -// CHECK: STest2 = type { i16, i16, i32, i32 } -// CHECK: STest3 = type { i8, i16, i32 } -// CHECK: STestB1 = type { i8, i8 } -// CHECK: STestB2 = type { i8, i8, i8 } -// CHECK: STestB3 = type { i8, i8 } -// CHECK: STestB4 = type { i8, i8, i8, i8 } -// CHECK: STestB5 = type { i8, i16, i8 } -// CHECK: STestB6 = type { i8, i8, i16 } +// RUN: %clang_cc1 %s -emit-llvm -o %t -triple=i686-apple-darwin9 -fdump-record-layouts-simple | FileCheck %s + // Test struct layout for x86-darwin target struct STest1 {int x; short y[4]; double z; } st1; @@ -20,6 +12,68 @@ struct STestB3 {char a; char b:2; } stb3; struct STestB4 {char a; short b:2; char c; } stb4; struct STestB5 {char a; short b:10; char c; } stb5; -struct STestB6 {int a:1; char b; int c:13 } stb6; +struct STestB6 {int a:1; char b; int c:13; } stb6; // Packed struct STestP1 {char a; short b; int c; } __attribute__((__packed__)) stp1; + +// CHECK-LABEL: Record: RecordDecl {{.*}} struct STest1 definition +// CHECK: Layout: + +// CHECK-LABEL: Record: RecordDecl {{.*}} struct STest2 definition +// CHECK: Layout: + +// CHECK-LABEL: Record: RecordDecl {{.*}} struct STest3 definition +// CHECK: Layout: + +// CHECK-LABEL: Record: RecordDecl {{.*}} struct STestB1 definition +// CHECK: Layout: + +// CHECK-LABEL: Record: RecordDecl {{.*}} struct STestB2 definition +// CHECK: Layout: + +// CHECK-LABEL: Record: RecordDecl {{.*}} struct STestB3 definition +// CHECK: Layout: + +// CHECK-LABEL: Record: RecordDecl {{.*}} struct STestB4 definition +// CHECK: Layout: + +// CHECK-LABEL: Record: RecordDecl {{.*}} struct STestB5 definition +// CHECK: Layout: + +// CHECK-LABEL: Record: RecordDecl {{.*}} struct STestB6 definition +// CHECK: Layout: Index: clang/test/Layout/aapcs-bitfield-placement.c =================================================================== --- /dev/null +++ clang/test/Layout/aapcs-bitfield-placement.c @@ -0,0 +1,287 @@ +// RUN: %clang_cc1 -triple armv8-none-linux-eabi -fno-aapcs-bitfield-width -emit-llvm -o %t %s -fdump-record-layouts-simple | FileCheck %s -check-prefixes=LAYOUT,LAYOUT_LE +// RUN: %clang_cc1 -triple armebv8-none-linux-eabi -fno-aapcs-bitfield-width -emit-llvm -o %t %s -fdump-record-layouts-simple | FileCheck %s -check-prefixes=LAYOUT,LAYOUT_BE + +// RUN: %clang_cc1 -triple armv8-none-linux-eabi -faapcs-bitfield-width -emit-llvm -o %t %s -fdump-record-layouts-simple | FileCheck %s -check-prefixes=LAYOUT,LAYOUT_LE +// RUN: %clang_cc1 -triple armebv8-none-linux-eabi -faapcs-bitfield-width -emit-llvm -o %t %s -fdump-record-layouts-simple | FileCheck %s -check-prefixes=LAYOUT,LAYOUT_BE + +struct st0 { + short c : 7; +} st0; +// LAYOUT-LABEL: Record: {{.*}} struct st0 definition +// LAYOUT: Layout: + +struct st1 { + int a : 10; + short c : 6; +} st1; +// LAYOUT-LABEL: Record: {{.*}} struct st1 definition +// LAYOUT: Layout: + +struct st2 { + int a : 10; + short c : 7; +} st2; +// LAYOUT-LABEL: Record: {{.*}} struct st2 definition +// LAYOUT: Layout: + +struct st3 { + volatile short c : 7; +} st3; +// LAYOUT-LABEL: Record: {{.*}} struct st3 definition +// LAYOUT: Layout: + +struct st4 { + int b : 9; + volatile char c : 5; +} st4; +// LAYOUT-LABEL: Record: {{.*}} struct st4 definition +// LAYOUT: Layout: + +struct st5 { + int a : 12; + volatile char c : 5; +} st5; +// LAYOUT-LABEL: Record: {{.*}} struct st5 definition +// LAYOUT: Layout: + +struct st6 { + int a : 12; + char b; + int c : 5; +} st6; +// LAYOUT-LABEL: Record: {{.*}} struct st6 definition +// LAYOUT: Layout: + +struct st7a { + char a; + int b : 5; +} st7a; +// LAYOUT-LABEL: Record: {{.*}} struct st7a definition +// LAYOUT: Layout: + +struct st7b { + char x; + volatile struct st7a y; +} st7b; +// LAYOUT-LABEL: Record: {{.*}} struct st7b definition +// LAYOUT: Layout: + +struct st8 { + unsigned f : 16; +} st8; +// LAYOUT-LABEL: Record: {{.*}} struct st8 definition +// LAYOUT: Layout: + +struct st9{ + int f : 8; +} st9; +// LAYOUT-LABEL: Record: {{.*}} struct st9 definition +// LAYOUT: Layout: + +struct st10{ + int e : 1; + int f : 8; +} st10; +// LAYOUT-LABEL: Record: {{.*}} struct st10 definition +// LAYOUT: Layout: + +struct st11{ + char e; + int f : 16; +} st11; +// LAYOUT-LABEL: Record: {{.*}} struct st11 definition +// LAYOUT: Layout: +// LAYOUT: BitFields:[ +// LAYOUT_LE-NEXT: + +struct st12{ + int e : 8; + int f : 16; +} st12; +// LAYOUT-LABEL: Record: {{.*}} struct st12 definition +// LAYOUT: Layout: + +struct st13 { + char a : 8; + int b : 32; +} __attribute__((packed)) st13; +// LAYOUT-LABEL: Record: {{.*}} struct st13 definition +// LAYOUT: Layout: + +struct st14 { + char a : 8; +} __attribute__((packed)) st14; +// LAYOUT-LABEL: Record: {{.*}} struct st14 definition +// LAYOUT: Layout: + +struct st15 { + short a : 8; +} __attribute__((packed)) st15; +// LAYOUT-LABEL: Record: {{.*}} struct st15 definition +// LAYOUT: Layout: + +struct st16 { + int a : 32; + int b : 16; + int c : 32; + int d : 16; +} st16; +// LAYOUT-LABEL: Record: {{.*}} struct st16 definition +// LAYOUT: Layout: + +struct st17 { +int b : 32; +char c : 8; +} __attribute__((packed)) st17; +// LAYOUT-LABEL: Record: {{.*}} struct st17 definition +// LAYOUT: Layout: + +struct zero_bitfield { + int a : 8; + char : 0; + int b : 8; +} st18; +// LAYOUT-LABEL: Record: {{.*}} struct zero_bitfield definition +// LAYOUT: Layout: + +struct zero_bitfield_ok { + short a : 8; + char a1 : 8; + long : 0; + int b : 24; +} st19; +// LAYOUT-LABEL: Record: {{.*}} struct zero_bitfield_ok definition +// LAYOUT: Layout: + +