xref: /aosp_15_r20/external/clang/test/CodeGenCXX/arm64-empty-struct.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -triple arm64-apple-ios -target-abi darwinpcs -emit-llvm -o - %s | FileCheck %s
2*67e74705SXin Li struct Empty {};
3*67e74705SXin Li 
4*67e74705SXin Li Empty emptyvar;
5*67e74705SXin Li 
take_args(int a,...)6*67e74705SXin Li int take_args(int a, ...) {
7*67e74705SXin Li   __builtin_va_list l;
8*67e74705SXin Li   __builtin_va_start(l, a);
9*67e74705SXin Li // CHECK: call void @llvm.va_start
10*67e74705SXin Li 
11*67e74705SXin Li   emptyvar = __builtin_va_arg(l, Empty);
12*67e74705SXin Li // CHECK: load i8*, i8**
13*67e74705SXin Li // CHECK-NOT: getelementptr
14*67e74705SXin Li // CHECK: [[EMPTY_PTR:%[a-zA-Z0-9._]+]] = bitcast i8* {{%[a-zA-Z0-9._]+}} to %struct.Empty*
15*67e74705SXin Li 
16*67e74705SXin Li   // It's conceivable that EMPTY_PTR may not actually be a valid pointer
17*67e74705SXin Li   // (e.g. it's at the very bottom of the stack and the next page is
18*67e74705SXin Li   // invalid). This doesn't matter provided it's never loaded (there's no
19*67e74705SXin Li   // well-defined way to tell), but it becomes a problem if we do try to use it.
20*67e74705SXin Li // CHECK-NOT: load %struct.Empty, %struct.Empty* [[EMPTY_PTR]]
21*67e74705SXin Li 
22*67e74705SXin Li   int i = __builtin_va_arg(l, int);
23*67e74705SXin Li // CHECK: va_arg i8** {{%[a-zA-Z0-9._]+}}, i32
24*67e74705SXin Li 
25*67e74705SXin Li   __builtin_va_end(l);
26*67e74705SXin Li   return i;
27*67e74705SXin Li }
28