1 ; RUN: opt -S %s -passes=verify
3 declare token @llvm.call.preallocated.setup(i32)
4 declare ptr @llvm.call.preallocated.arg(token, i32)
5 declare void @llvm.call.preallocated.teardown(token)
7 declare i32 @__CxxFrameHandler3(...)
9 declare void @foo1(ptr preallocated(i32))
10 declare i64 @foo1_i64(ptr preallocated(i32))
11 declare void @foo2(ptr preallocated(i32), ptr, ptr preallocated(i32))
13 declare void @constructor(ptr)
15 define void @preallocated() {
16 %cs = call token @llvm.call.preallocated.setup(i32 1)
17 %x = call ptr @llvm.call.preallocated.arg(token %cs, i32 0) preallocated(i32)
18 call void @foo1(ptr preallocated(i32) %x) ["preallocated"(token %cs)]
22 define void @preallocated_indirect(ptr %f) {
23 %cs = call token @llvm.call.preallocated.setup(i32 1)
24 %x = call ptr @llvm.call.preallocated.arg(token %cs, i32 0) preallocated(i32)
25 call void %f(ptr preallocated(i32) %x) ["preallocated"(token %cs)]
29 define void @preallocated_setup_without_call() {
30 %cs = call token @llvm.call.preallocated.setup(i32 1)
31 %a0 = call ptr @llvm.call.preallocated.arg(token %cs, i32 0) preallocated(i32)
35 define void @preallocated_num_args() {
36 %cs = call token @llvm.call.preallocated.setup(i32 2)
37 %x = call ptr @llvm.call.preallocated.arg(token %cs, i32 0) preallocated(i32)
38 %y = call ptr @llvm.call.preallocated.arg(token %cs, i32 1) preallocated(i32)
39 %a = inttoptr i32 0 to ptr
40 call void @foo2(ptr preallocated(i32) %x, ptr %a, ptr preallocated(i32) %y) ["preallocated"(token %cs)]
44 define void @preallocated_musttail(ptr preallocated(i32) %a) {
45 musttail call void @foo1(ptr preallocated(i32) %a)
49 define i64 @preallocated_musttail_i64(ptr preallocated(i32) %a) {
50 %r = musttail call i64 @foo1_i64(ptr preallocated(i32) %a)
54 define void @preallocated_teardown() {
55 %cs = call token @llvm.call.preallocated.setup(i32 1)
56 call void @llvm.call.preallocated.teardown(token %cs)
60 define void @preallocated_teardown_invoke() personality ptr @__CxxFrameHandler3 {
61 %cs = call token @llvm.call.preallocated.setup(i32 1)
62 %x = call ptr @llvm.call.preallocated.arg(token %cs, i32 0) preallocated(i32)
63 invoke void @constructor(ptr %x) to label %conta unwind label %contb
65 call void @foo1(ptr preallocated(i32) %x) ["preallocated"(token %cs)]
68 %s = catchswitch within none [label %catch] unwind to caller
70 %p = catchpad within %s []
71 call void @llvm.call.preallocated.teardown(token %cs)