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