Skip to content

Commit 5ceb717

Browse files
committed
Fix codegen for transparent_union function params
Update codegen for func param with transparent_union attr to be that of the first union member. This closes #76773.
1 parent c1a8283 commit 5ceb717

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// RUN: %clang_cc1 -triple powerpc64le-linux -O2 -target-cpu pwr7 -emit-llvm \
2+
// RUN: -fshort-enums %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-64
3+
// RUN: %clang_cc1 -triple powerpc64-linux -O2 -target-cpu pwr7 -emit-llvm \
4+
// RUN: -fshort-enums %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-64
5+
// RUN: %clang_cc1 -triple powerpc-linux -O2 -target-cpu pwr7 -emit-llvm \
6+
// RUN: -fshort-enums %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-32
7+
// RUN: %clang_cc1 -triple powerpc64-aix -O2 -target-cpu pwr7 -emit-llvm \
8+
// RUN: -fshort-enums %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-64
9+
// RUN: %clang_cc1 -triple powerpc-aix -O2 -target-cpu pwr7 -emit-llvm \
10+
// RUN: -fshort-enums %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-32
11+
// RUN: %clang_cc1 -triple riscv64-linux -O2 -emit-llvm -fshort-enums \
12+
// RUN: %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-64
13+
// RUN: %clang_cc1 -triple riscv32-linux -O2 -emit-llvm -fshort-enums \
14+
// RUN: %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-32
15+
// RUN: %clang_cc1 -triple i386-linux -O2 -emit-llvm -fshort-enums \
16+
// RUN: %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-32
17+
// RUN: %clang_cc1 -triple x86_64-linux -O2 -emit-llvm -fshort-enums \
18+
// RUN: %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-64
19+
// RUN: %clang_cc1 -triple armv7-linux -O2 -emit-llvm -fshort-enums \
20+
// RUN: %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-32
21+
// RUN: %clang_cc1 -triple arm64 -target-abi darwinpcs -O2 -emit-llvm \
22+
// RUN: -fshort-enums %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-64
23+
// RUN: %clang_cc1 -triple aarch64 -target-abi darwinpcs -O2 -emit-llvm \
24+
// RUN: -fshort-enums %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-64
25+
26+
typedef union tu_c {
27+
signed char a;
28+
signed char b;
29+
} tu_c_t __attribute__((transparent_union));
30+
31+
typedef union tu_s {
32+
short a;
33+
} tu_s_t __attribute__((transparent_union));
34+
35+
typedef union tu_us {
36+
unsigned short a;
37+
} tu_us_t __attribute__((transparent_union));
38+
39+
typedef union tu_l {
40+
long a;
41+
} tu_l_t __attribute__((transparent_union));
42+
43+
// CHECK-LABEL: define{{.*}} void @ftest0(
44+
// CHECK-SAME: i8 noundef signext [[UC_COERCE:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
45+
// CHECK-NEXT: [[ENTRY:.*:]]
46+
// CHECK-NEXT: ret void
47+
void ftest0(tu_c_t uc) { }
48+
49+
// CHECK-LABEL: define{{.*}} void @ftest1(
50+
// CHECK-SAME: i16 noundef signext [[UC_COERCE:%.*]]) local_unnamed_addr #[[ATTR0]] {
51+
// CHECK-NEXT: [[ENTRY:.*:]]
52+
// CHECK-NEXT: ret void
53+
void ftest1(tu_s_t uc) { }
54+
55+
// CHECK-LABEL: define{{.*}} void @ftest2(
56+
// CHECK-SAME: i16 noundef zeroext [[UC_COERCE:%.*]]) local_unnamed_addr #[[ATTR0]] {
57+
// CHECK-NEXT: [[ENTRY:.*:]]
58+
// CHECK-NEXT: ret void
59+
void ftest2(tu_us_t uc) { }
60+
61+
// CHECK-64-LABEL: define{{.*}} void @ftest3(
62+
// CHECK-64-SAME: i64 [[UC_COERCE:%.*]]) local_unnamed_addr #[[ATTR0]] {
63+
// CHECK-64-NEXT: [[ENTRY:.*:]]
64+
// CHECK-64-NEXT: ret void
65+
//
66+
// CHECK-32-LABEL: define{{.*}} void @ftest3(
67+
// CHECK-32-SAME: i32 [[UC_COERCE:%.*]]) local_unnamed_addr #[[ATTR0]] {
68+
// CHECK-32-NEXT: [[ENTRY:.*:]]
69+
// CHECK-32-NEXT: ret void
70+
void ftest3(tu_l_t uc) { }
71+
72+
typedef union etest {
73+
enum flag {red, yellow, blue} fl;
74+
enum weekend {sun, sat} b;
75+
} etest_t __attribute__((transparent_union));
76+
77+
// CHECK-LABEL: define{{.*}} void @ftest4(
78+
// CHECK-SAME: i8 noundef zeroext [[A_COERCE:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
79+
// CHECK-NEXT: [[ENTRY:.*:]]
80+
// CHECK-NEXT: ret void
81+
void ftest4(etest_t a) {}

0 commit comments

Comments
 (0)