1; RUN: opt -S %s -verify 2 3declare token @llvm.call.preallocated.setup(i32) 4declare i8* @llvm.call.preallocated.arg(token, i32) 5declare void @llvm.call.preallocated.teardown(token) 6 7declare i32 @__CxxFrameHandler3(...) 8 9declare void @foo1(i32* preallocated(i32)) 10declare i64 @foo1_i64(i32* preallocated(i32)) 11declare void @foo2(i32* preallocated(i32), i32*, i32* preallocated(i32)) 12 13declare void @constructor(i32*) 14 15define 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)] 20 ret void 21} 22 23define 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)] 28 ret void 29} 30 31define 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) 34 ret void 35} 36 37define 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)] 45 ret void 46} 47 48define void @preallocated_musttail(i32* preallocated(i32) %a) { 49 musttail call void @foo1(i32* preallocated(i32) %a) 50 ret void 51} 52 53define i64 @preallocated_musttail_i64(i32* preallocated(i32) %a) { 54 %r = musttail call i64 @foo1_i64(i32* preallocated(i32) %a) 55 ret i64 %r 56} 57 58define void @preallocated_teardown() { 59 %cs = call token @llvm.call.preallocated.setup(i32 1) 60 call void @llvm.call.preallocated.teardown(token %cs) 61 ret void 62} 63 64define 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 69conta: 70 call void @foo1(i32* preallocated(i32) %y) ["preallocated"(token %cs)] 71 ret void 72contb: 73 %s = catchswitch within none [label %catch] unwind to caller 74catch: 75 %p = catchpad within %s [] 76 call void @llvm.call.preallocated.teardown(token %cs) 77 ret void 78} 79