| 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 (no padding, size 0 in CIR) |
| 6 |
union Empty {}; |
| 7 |
// CIR: !rec_Empty = !cir.record<union "Empty" {}> |
| 8 |
// LLVM: %union.Empty = type {} |
| 9 |
// OGCG: %union.Empty = type {} |
| 10 |
|
| 11 |
// Aligned empty union (size 0, alignment 16) |
| 12 |
union EmptyAligned {} __attribute__((aligned(16))); |
| 13 |
// CIR: !rec_EmptyAligned = !cir.record<union "EmptyAligned" {}> |
| 14 |
// LLVM: %union.EmptyAligned = type {} |
| 15 |
// OGCG: %union.EmptyAligned = type {} |
| 16 |
|
| 17 |
void useEmpty() { |
| 18 |
union Empty e; |
| 19 |
} |
| 20 |
// CIR: cir.func {{.*}}@useEmpty() |
| 21 |
// CIR: cir.alloca !rec_Empty, !cir.ptr<!rec_Empty>, ["e"] {alignment = 1 : i64} |
| 22 |
// LLVM: define {{.*}} void @useEmpty() |
| 23 |
// LLVM: alloca %union.Empty, i64 1, align 1 |
| 24 |
// OGCG: define {{.*}} void @useEmpty() |
| 25 |
// OGCG: alloca %union.Empty, align 1 |
| 26 |
|
| 27 |
void useEmptyAligned() { |
| 28 |
union EmptyAligned e; |
| 29 |
} |
| 30 |
// CIR: cir.func {{.*}}@useEmptyAligned() |
| 31 |
// CIR: cir.alloca !rec_EmptyAligned, !cir.ptr<!rec_EmptyAligned>, ["e"] {alignment = 16 : i64} |
| 32 |
// LLVM: define {{.*}} void @useEmptyAligned() |
| 33 |
// LLVM: alloca %union.EmptyAligned, i64 1, align 16 |
| 34 |
// OGCG: define {{.*}} void @useEmptyAligned() |
| 35 |
// OGCG: alloca %union.EmptyAligned, align 16 |