xref: /aosp_15_r20/external/clang/test/CodeGen/mips-transparent-union.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -triple mips64-linux-gnu -S -o - -emit-llvm %s | FileCheck %s
2*67e74705SXin Li //
3*67e74705SXin Li // Transparent unions are passed according to the calling convention rules of
4*67e74705SXin Li // the first member. In this case, it is as if it were a void pointer so we
5*67e74705SXin Li // do not have the inreg attribute we would normally have for unions.
6*67e74705SXin Li //
7*67e74705SXin Li // This comes up in glibc's wait() function and matters for the big-endian N32
8*67e74705SXin Li // case where pointers are promoted to i64 and a non-transparent union would be
9*67e74705SXin Li // passed in the upper 32-bits of an i64.
10*67e74705SXin Li 
11*67e74705SXin Li union either_pointer {
12*67e74705SXin Li   void *void_ptr;
13*67e74705SXin Li   int *int_ptr;
14*67e74705SXin Li } __attribute__((transparent_union));
15*67e74705SXin Li 
16*67e74705SXin Li extern void foo(union either_pointer p);
17*67e74705SXin Li 
18*67e74705SXin Li int data;
19*67e74705SXin Li 
bar(void)20*67e74705SXin Li void bar(void) {
21*67e74705SXin Li   return foo(&data);
22*67e74705SXin Li }
23*67e74705SXin Li 
24*67e74705SXin Li // CHECK-LABEL: define void @bar()
25*67e74705SXin Li // CHECK:         call void @foo(i8* %{{[0-9]+}})
26*67e74705SXin Li 
27*67e74705SXin Li // CHECK: declare void @foo(i8*)
28