1 ; RUN: opt -S %s -verify
3 declare token @llvm.call.preallocated.setup(i32)
4 declare i8* @llvm.call.preallocated.arg(token, i32)
5 declare void @llvm.call.preallocated.teardown(token)
7 declare i32 @__CxxFrameHandler3(...)
9 declare void @foo1(i32* preallocated(i32))
10 declare i64 @foo1_i64(i32* preallocated(i32))
11 declare void @foo2(i32* preallocated(i32), i32*, i32* preallocated(i32))
13 declare void @constructor(i32*)
15 define void @preallocated() {
16 %cs = call token @llvm.call.preallocated.setup(i32 1)
17 %x = call i8* @llvm.call.preallocated.arg(token %cs, i32 0) preallocated(i32)
18 %y = bitcast i8* %x to i32*
19 call void @foo1(i32* preallocated(i32) %y) ["preallocated"(token %cs)]
23 define void @preallocated_indirect(void (i32*)* %f) {
24 %cs = call token @llvm.call.preallocated.setup(i32 1)
25 %x = call i8* @llvm.call.preallocated.arg(token %cs, i32 0) preallocated(i32)
26 %y = bitcast i8* %x to i32*
27 call void %f(i32* preallocated(i32) %y) ["preallocated"(token %cs)]
31 define void @preallocated_setup_without_call() {
32 %cs = call token @llvm.call.preallocated.setup(i32 1)
33 %a0 = call i8* @llvm.call.preallocated.arg(token %cs, i32 0) preallocated(i32)
37 define void @preallocated_num_args() {
38 %cs = call token @llvm.call.preallocated.setup(i32 2)
39 %x = call i8* @llvm.call.preallocated.arg(token %cs, i32 0) preallocated(i32)
40 %x1 = bitcast i8* %x to i32*
41 %y = call i8* @llvm.call.preallocated.arg(token %cs, i32 1) preallocated(i32)
42 %y1 = bitcast i8* %y to i32*
43 %a = inttoptr i32 0 to i32*
44 call void @foo2(i32* preallocated(i32) %x1, i32* %a, i32* preallocated(i32) %y1) ["preallocated"(token %cs)]
48 define void @preallocated_musttail(i32* preallocated(i32) %a) {
49 musttail call void @foo1(i32* preallocated(i32) %a)
53 define i64 @preallocated_musttail_i64(i32* preallocated(i32) %a) {
54 %r = musttail call i64 @foo1_i64(i32* preallocated(i32) %a)
58 define void @preallocated_teardown() {
59 %cs = call token @llvm.call.preallocated.setup(i32 1)
60 call void @llvm.call.preallocated.teardown(token %cs)
64 define void @preallocated_teardown_invoke() personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
65 %cs = call token @llvm.call.preallocated.setup(i32 1)
66 %x = call i8* @llvm.call.preallocated.arg(token %cs, i32 0) preallocated(i32)
67 %y = bitcast i8* %x to i32*
68 invoke void @constructor(i32* %y) to label %conta unwind label %contb
70 call void @foo1(i32* preallocated(i32) %y) ["preallocated"(token %cs)]
73 %s = catchswitch within none [label %catch] unwind to caller
75 %p = catchpad within %s []
76 call void @llvm.call.preallocated.teardown(token %cs)