blob: de3147e488d84e5e26c224906fab75289e47c369 [file] [log] [blame]
Florian Hahn80788d82018-01-06 19:45:40 +00001; RUN: opt < %s -inline -S | FileCheck %s
2; RUN: opt < %s -passes='cgscc(inline,function(instcombine))' -S | FileCheck %s
3
4declare void @ext_method(i8*, i32)
5declare void @vararg_fn(i8*, ...)
6
7define linkonce_odr void @thunk(i8* %this, ...) {
8 %this_adj = getelementptr i8, i8* %this, i32 4
9 musttail call void (i8*, ...) bitcast (void (i8*, i32)* @ext_method to void (i8*, ...)*)(i8* %this_adj, ...)
10 ret void
11}
12
13define void @thunk_caller(i8* %p) {
14 call void (i8*, ...) @thunk(i8* %p, i32 42)
15 ret void
16}
17; CHECK-LABEL: define void @thunk_caller(i8* %p)
18; CHECK: call void (i8*, ...) bitcast (void (i8*, i32)* @ext_method to void (i8*, ...)*)(i8* %this_adj.i, i32 42)
19
20define void @test_callee_2(i8* %this, ...) {
21 %this_adj = getelementptr i8, i8* %this, i32 4
22 musttail call void (i8*, ...) @vararg_fn(i8* %this_adj, ...)
23 ret void
24}
25
26define void @test_caller_2(i8* %p) {
27 call void (i8*, ...) @test_callee_2(i8* %p)
28 ret void
29}
30; CHECK-LABEL: define void @test_caller_2(i8* %p)
31; CHECK: call void (i8*, ...) @vararg_fn(i8* %this_adj.i)
32
33
34define internal i32 @varg_accessed(...) {
35entry:
36 %vargs = alloca i8*, align 8
37 %vargs.ptr = bitcast i8** %vargs to i8*
38 call void @llvm.va_start(i8* %vargs.ptr)
39 %va1 = va_arg i8** %vargs, i32
40 call void @llvm.va_end(i8* %vargs.ptr)
41 ret i32 %va1
42}
43
44define i32 @call_vargs() {
45 %res = call i32 (...) @varg_accessed(i32 10)
46 ret i32 %res
47}
48; CHECK-LABEL: @call_vargs
49; CHECK: %res = call i32 (...) @varg_accessed(i32 10)
50
51declare void @llvm.va_start(i8*)
52declare void @llvm.va_end(i8*)