blob: af34336a0ae29b47a76c0f1a417b2b5ecedde58f [file] [log] [blame]
John McCall5f8d6042011-08-27 01:09:30 +00001// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck %s
2
Eric Christopherb06cf892011-08-16 21:41:35 +00003// rdar://7309675
4// PR4678
John McCall5f8d6042011-08-27 01:09:30 +00005namespace test0 {
6 // test1 should be compmiled to be a varargs function in the IR even
7 // though there is no way to do a va_begin. Otherwise, the optimizer
8 // will warn about 'dropped arguments' at the call site.
Eric Christopherb06cf892011-08-16 21:41:35 +00009
John McCall5f8d6042011-08-27 01:09:30 +000010 // CHECK: define i32 @_ZN5test05test1Ez(...)
11 int test1(...) {
12 return -1;
13 }
Eric Christopherb06cf892011-08-16 21:41:35 +000014
John McCall5f8d6042011-08-27 01:09:30 +000015 // CHECK: call i32 (...)* @_ZN5test05test1Ez(i32 0)
16 void test() {
17 test1(0);
18 }
Eric Christopherb06cf892011-08-16 21:41:35 +000019}
20
John McCall5f8d6042011-08-27 01:09:30 +000021namespace test1 {
22 struct A {
23 int x;
24 int y;
25 };
26
27 void foo(...);
28
29 void test() {
30 A x;
31 foo(x);
32 }
33 // CHECK: define void @_ZN5test14testEv()
34 // CHECK: [[X:%.*]] = alloca [[A:%.*]], align 4
35 // CHECK-NEXT: [[TMP:%.*]] = alloca [[A]], align 4
36 // CHECK-NEXT: [[T0:%.*]] = bitcast [[A]]* [[TMP]] to i8*
37 // CHECK-NEXT: [[T1:%.*]] = bitcast [[A]]* [[X]] to i8*
38 // CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[T0]], i8* [[T1]], i64 8, i32 4, i1 false)
39 // CHECK-NEXT: [[T0:%.*]] = bitcast [[A]]* [[TMP]] to i64*
40 // CHECK-NEXT: [[T1:%.*]] = load i64* [[T0]], align 1
41 // CHECK-NEXT: call void (...)* @_ZN5test13fooEz(i64 [[T1]])
42 // CHECK-NEXT: ret void
Eric Christopherb06cf892011-08-16 21:41:35 +000043}