[AMDGPU][True16][CodeGen] true16 codegen pattern for v_med3_u/i16 (#121850)
[llvm-project.git] / clang / test / CodeGenCXX / microsoft-abi-byval-vararg.cpp
blob80ea63e2a1e107e6b0c4b1d89699ec6237baacf6
1 // RUN: %clang_cc1 -Wno-non-pod-varargs -emit-llvm %s -o - -triple=i686-pc-win32 -mconstructor-aliases -fno-rtti | FileCheck %s
3 #include <stdarg.h>
5 struct A {
6 A(int a) : a(a) {}
7 A(const A &o) : a(o.a) {}
8 ~A() {}
9 int a;
12 int foo(A a, ...) {
13 va_list ap;
14 va_start(ap, a);
15 int sum = 0;
16 for (int i = 0; i < a.a; ++i)
17 sum += va_arg(ap, int);
18 va_end(ap);
19 return sum;
22 // CHECK-LABEL: define dso_local noundef i32 @"?foo@@YAHUA@@ZZ"(ptr inalloca(<{ %struct.A }>) %0, ...)
24 int main() {
25 return foo(A(3), 1, 2, 3);
27 // CHECK-LABEL: define dso_local noundef i32 @main()
28 // CHECK: %[[argmem:[^ ]*]] = alloca inalloca <{ %struct.A, i32, i32, i32 }>
29 // CHECK: call noundef i32 (ptr, ...) @"?foo@@YAHUA@@ZZ"{{.*}}(ptr inalloca(<{ %struct.A, i32, i32, i32 }>) %[[argmem]])
31 void varargs_zero(...);
32 void varargs_one(int, ...);
33 void varargs_two(int, int, ...);
34 void varargs_three(int, int, int, ...);
35 void call_var_args() {
36 A x(3);
37 varargs_zero(x);
38 varargs_one(1, x);
39 varargs_two(1, 2, x);
40 varargs_three(1, 2, 3, x);
43 // CHECK-LABEL: define dso_local void @"?call_var_args@@YAXXZ"()
44 // CHECK: call void {{.*varargs_zero.*}}(ptr inalloca(<{ %struct.A }>) %{{.*}})
45 // CHECK: call void {{.*varargs_one.*}}(ptr inalloca(<{ i32, %struct.A }>) %{{.*}})
46 // CHECK: call void {{.*varargs_two.*}}(ptr inalloca(<{ i32, i32, %struct.A }>) %{{.*}})
47 // CHECK: call void {{.*varargs_three.*}}(ptr inalloca(<{ i32, i32, i32, %struct.A }>) %{{.*}})
49 // CHECK-LABEL: declare dso_local void @"?varargs_zero@@YAXZZ"(...)
50 // CHECK-LABEL: declare dso_local void @"?varargs_one@@YAXHZZ"(i32 noundef, ...)
51 // CHECK-LABEL: declare dso_local void @"?varargs_two@@YAXHHZZ"(i32 noundef, i32 noundef, ...)
52 // CHECK-LABEL: declare dso_local void @"?varargs_three@@YAXHHHZZ"(i32 noundef, i32 noundef, i32 noundef, ...)