Debian Codegraph @

clang/test/CIR/CodeGen/empty-union.cpp

raw
1 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s --check-prefix=CIR
2 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o - | FileCheck %s --check-prefix=LLVM
3 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix=OGCG
4
5 // Empty union (should be padded to size 1)
6 union Empty {};
7 // CIR: !rec_Empty = !cir.record<union "Empty" padded {!u8i}>
8 // LLVM: %union.Empty = type { i8 }
9 // OGCG: %union.Empty = type { i8 }
10
11 // Aligned empty union (should have aligned integer member in CIR)
12 union alignas(16) EmptyAligned {};
13 // CIR: !rec_EmptyAligned = !cir.record<union "EmptyAligned" padded {!cir.array<!u8i x 16>}>
14 // LLVM: %union.EmptyAligned = type { [16 x i8] }
15 // OGCG: %union.EmptyAligned = type { [16 x i8] }
16
17 void useEmpty() {
18 Empty e;
19 }
20 // CIR: cir.func {{.*}}@_Z8useEmptyv()
21 // CIR: cir.alloca !rec_Empty, !cir.ptr<!rec_Empty>, ["e"] {alignment = 1 : i64}
22 // LLVM: define {{.*}} void @_Z8useEmptyv()
23 // LLVM: alloca %union.Empty, i64 1, align 1
24 // OGCG: define {{.*}} void @_Z8useEmptyv()
25 // OGCG: alloca %union.Empty, align 1
26
27 void useEmptyAligned() {
28 EmptyAligned e;
29 }
30 // CIR: cir.func {{.*}}@_Z15useEmptyAlignedv()
31 // CIR: cir.alloca !rec_EmptyAligned, !cir.ptr<!rec_EmptyAligned>, ["e"] {alignment = 16 : i64}
32 // LLVM: define {{.*}} void @_Z15useEmptyAlignedv()
33 // LLVM: alloca %union.EmptyAligned, i64 1, align 16
34 // OGCG: define {{.*}} void @_Z15useEmptyAlignedv()
35 // OGCG: alloca %union.EmptyAligned, align 16