1a8ca4abfSNathan Sidwell // Check if we can merge bitfields across empty members 2a8ca4abfSNathan Sidwell 3a8ca4abfSNathan Sidwell // Configs that have cheap unaligned access 4a8ca4abfSNathan Sidwell // Little Endian 5a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=aarch64-apple-darwin %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 6a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=aarch64-linux-gnu %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 7a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=arm-apple-darwin %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT-DWN32 %s 8a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=arm-none-eabi %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 9a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=i686-linux-gnu %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 10a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=loongarch64-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 11a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=powerpcle-linux-gnu %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 12a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=ve-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 13a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=wasm32 %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 14a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=wasm64 %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 15a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=x86_64-linux-gnu %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 16a8ca4abfSNathan Sidwell 17a8ca4abfSNathan Sidwell // Big Endian 18a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=powerpc-linux-gnu %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 19a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=powerpc64-linux-gnu %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 20a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=systemz %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 21a8ca4abfSNathan Sidwell 22a8ca4abfSNathan Sidwell // Configs that have expensive unaligned access 23a8ca4abfSNathan Sidwell // Little Endian 24a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=amdgcn-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 25a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=arc-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 26a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=bpf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 27a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=csky %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 28a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=hexagon-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 29a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=loongarch32-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 30a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=nvptx-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 31a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=riscv32 %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 32a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=riscv64 %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 33a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=spir-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 34a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=xcore-none-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 35a8ca4abfSNathan Sidwell 36a8ca4abfSNathan Sidwell // Big endian 37a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=lanai-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 38a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=m68k-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 39a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=mips-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 40a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=mips64-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 41a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=sparc-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 42a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=tce-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT %s 43a8ca4abfSNathan Sidwell 44a8ca4abfSNathan Sidwell struct Empty {}; 45a8ca4abfSNathan Sidwell 46a8ca4abfSNathan Sidwell struct P1 { 47a8ca4abfSNathan Sidwell unsigned a : 16; 48a8ca4abfSNathan Sidwell [[no_unique_address]] Empty e; 49a8ca4abfSNathan Sidwell unsigned b : 16; 50a8ca4abfSNathan Sidwell } p1; 51a8ca4abfSNathan Sidwell // CHECK-LABEL: LLVMType:%struct.P1 = 52a8ca4abfSNathan Sidwell // LAYOUT-SAME: type { i16, i16 } 53a8ca4abfSNathan Sidwell // LAYOUT-DWN32-SAME: type { i16, i16 } 54a8ca4abfSNathan Sidwell // CHECK-NEXT: NonVirtualBaseLLVMType:%struct.P1 = 55a8ca4abfSNathan Sidwell // CHECK: BitFields:[ 56a8ca4abfSNathan Sidwell // LAYOUT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:0 StorageSize:16 StorageOffset:0 57a8ca4abfSNathan Sidwell // LAYOUT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:0 StorageSize:16 StorageOffset:2 58a8ca4abfSNathan Sidwell 59a8ca4abfSNathan Sidwell // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:0 StorageSize:16 StorageOffset:0 60a8ca4abfSNathan Sidwell // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:0 StorageSize:16 StorageOffset:2 61a8ca4abfSNathan Sidwell // CHECK-NEXT: ]> 62a8ca4abfSNathan Sidwell 63a8ca4abfSNathan Sidwell struct P2 { 64a8ca4abfSNathan Sidwell unsigned a : 15; 65a8ca4abfSNathan Sidwell [[no_unique_address]] Empty e; 66a8ca4abfSNathan Sidwell unsigned b : 15; 67a8ca4abfSNathan Sidwell } p2; 68a8ca4abfSNathan Sidwell // CHECK-LABEL: LLVMType:%struct.P2 = 69a8ca4abfSNathan Sidwell // LAYOUT-SAME: type { i16, i16 } 70a8ca4abfSNathan Sidwell // LAYOUT-DWN32-SAME: type { i16, i16 } 71a8ca4abfSNathan Sidwell // CHECK-NEXT: NonVirtualBaseLLVMType:%struct.P2 = 72a8ca4abfSNathan Sidwell // CHECK: BitFields:[ 73a8ca4abfSNathan Sidwell // LAYOUT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:15 IsSigned:0 StorageSize:16 StorageOffset:0 74a8ca4abfSNathan Sidwell // LAYOUT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:15 IsSigned:0 StorageSize:16 StorageOffset:2 75a8ca4abfSNathan Sidwell 76a8ca4abfSNathan Sidwell // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:15 IsSigned:0 StorageSize:16 StorageOffset:0 77a8ca4abfSNathan Sidwell // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:15 IsSigned:0 StorageSize:16 StorageOffset:2 78a8ca4abfSNathan Sidwell // CHECK-NEXT: ]> 79a8ca4abfSNathan Sidwell 80a8ca4abfSNathan Sidwell struct P3 { 81a8ca4abfSNathan Sidwell unsigned a : 16; 82a8ca4abfSNathan Sidwell Empty e; 83a8ca4abfSNathan Sidwell unsigned b : 16; 84a8ca4abfSNathan Sidwell } p3; 85a8ca4abfSNathan Sidwell // CHECK-LABEL: LLVMType:%struct.P3 = 86*4497ec29SMichael Buch // LAYOUT-SAME: type { i16, [2 x i8], i16, [2 x i8] } 87*4497ec29SMichael Buch // LAYOUT-DWN32-SAME: type <{ i16, i8, i16 }> 88a8ca4abfSNathan Sidwell // CHECK-NEXT: NonVirtualBaseLLVMType:%struct.P3 = 89a8ca4abfSNathan Sidwell // CHECK: BitFields:[ 90a8ca4abfSNathan Sidwell // LAYOUT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:0 StorageSize:16 StorageOffset:0 91a8ca4abfSNathan Sidwell // LAYOUT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:0 StorageSize:16 StorageOffset:4 92a8ca4abfSNathan Sidwell 93a8ca4abfSNathan Sidwell // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:0 StorageSize:16 StorageOffset:0 94a8ca4abfSNathan Sidwell // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:0 StorageSize:16 StorageOffset:3 95a8ca4abfSNathan Sidwell // CHECK-NEXT: ]> 96a8ca4abfSNathan Sidwell 97a8ca4abfSNathan Sidwell struct P4 { 98a8ca4abfSNathan Sidwell unsigned : 0; 99a8ca4abfSNathan Sidwell } p4; 100a8ca4abfSNathan Sidwell // CHECK-LABEL: LLVMType:%struct.P4 = 101a8ca4abfSNathan Sidwell // LAYOUT-SAME: type { {{.+}} } 102a8ca4abfSNathan Sidwell // CHECK-NEXT: NonVirtualBaseLLVMType:%struct.P4 = 103a8ca4abfSNathan Sidwell // CHECK: BitFields:[ 104a8ca4abfSNathan Sidwell // CHECK-NEXT: ]> 105a8ca4abfSNathan Sidwell 106a8ca4abfSNathan Sidwell struct P5 { 107a8ca4abfSNathan Sidwell ~P5(); 108a8ca4abfSNathan Sidwell unsigned : 0; 109a8ca4abfSNathan Sidwell } p5; 110a8ca4abfSNathan Sidwell // CHECK-LABEL: LLVMType:%struct.P5 = 111a8ca4abfSNathan Sidwell // CHECK-NEXT: NonVirtualBaseLLVMType:%struct.P5.base = type {} 112a8ca4abfSNathan Sidwell // CHECK: BitFields:[ 113a8ca4abfSNathan Sidwell // CHECK-NEXT: ]> 114a8ca4abfSNathan Sidwell 115a8ca4abfSNathan Sidwell struct P6 { 116a8ca4abfSNathan Sidwell unsigned a : 16; 117a8ca4abfSNathan Sidwell unsigned b : 8; 118a8ca4abfSNathan Sidwell [[no_unique_address]] Empty e; 119a8ca4abfSNathan Sidwell unsigned c; 120a8ca4abfSNathan Sidwell } p6; 121a8ca4abfSNathan Sidwell // CHECK-LABEL: LLVMType:%struct.P6 = 12249839f97SNathan Sidwell // LAYOUT-SAME: type { i32, i32 } 12349839f97SNathan Sidwell // LAYOUT-DWN32-SAME: type { i32, i32 } 124a8ca4abfSNathan Sidwell // CHECK-NEXT: NonVirtualBaseLLVMType:%struct.P6 = 125a8ca4abfSNathan Sidwell // CHECK: BitFields:[ 126a8ca4abfSNathan Sidwell // LAYOUT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:0 StorageSize:32 StorageOffset:0 127a8ca4abfSNathan Sidwell // LAYOUT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:8 IsSigned:0 StorageSize:32 StorageOffset:0 128a8ca4abfSNathan Sidwell 129a8ca4abfSNathan Sidwell // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:0 StorageSize:32 StorageOffset:0 130a8ca4abfSNathan Sidwell // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:8 IsSigned:0 StorageSize:32 StorageOffset:0 131a8ca4abfSNathan Sidwell // CHECK-NEXT: ]> 132a8ca4abfSNathan Sidwell 133a8ca4abfSNathan Sidwell struct P7 { 134a8ca4abfSNathan Sidwell unsigned a : 16; 135a8ca4abfSNathan Sidwell unsigned b : 8; 136a8ca4abfSNathan Sidwell Empty e; 137a8ca4abfSNathan Sidwell unsigned c; 138a8ca4abfSNathan Sidwell } p7; 139a8ca4abfSNathan Sidwell // CHECK-LABEL: LLVMType:%struct.P7 = 140*4497ec29SMichael Buch // LAYOUT-SAME: type { i32, i32 } 141*4497ec29SMichael Buch // LAYOUT-DWN32-SAME: type { i32, i32 } 142a8ca4abfSNathan Sidwell // CHECK-NEXT: NonVirtualBaseLLVMType:%struct.P7 = 143a8ca4abfSNathan Sidwell // CHECK: BitFields:[ 144*4497ec29SMichael Buch // LAYOUT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:0 StorageSize:32 StorageOffset:0 145*4497ec29SMichael Buch // LAYOUT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:8 IsSigned:0 StorageSize:32 StorageOffset:0 146a8ca4abfSNathan Sidwell 147*4497ec29SMichael Buch // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:0 StorageSize:32 StorageOffset:0 148*4497ec29SMichael Buch // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:8 IsSigned:0 StorageSize:32 StorageOffset:0 149a8ca4abfSNathan Sidwell // CHECK-NEXT: ]> 150