1 ; RUN: not opt -S %s -passes=verify 2>&1 | FileCheck %s
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 ; Fake LLVM intrinsic to return a token
8 declare token @llvm.what()
11 declare void @foo1(ptr preallocated(i32))
12 declare void @foo2(ptr preallocated(i32), ptr, ptr preallocated(i32))
13 declare i32 @blackbox()
15 ; CHECK: llvm.call.preallocated.arg must be called with a "preallocated" call site attribute
16 define void @preallocated_arg_missing_preallocated_attribute() {
17 %cs = call token @llvm.call.preallocated.setup(i32 1)
18 %x = call ptr @llvm.call.preallocated.arg(token %cs, i32 0)
19 call void @foo1(ptr preallocated(i32) %x) ["preallocated"(token %cs)]
23 ; CHECK: preallocated as a call site attribute can only be on llvm.call.preallocated.arg
24 define void @preallocated_call_site_attribute_not_on_arg() {
25 call void @foo0() preallocated(i32)
29 ; CHECK: "preallocated" argument must be a token from llvm.call.preallocated.setup
30 define void @preallocated_bundle_token() {
31 %i = call i32 @blackbox()
32 call void @foo0() ["preallocated"(i32 %i)]
36 ; CHECK: "preallocated" argument must be a token from llvm.call.preallocated.setup
37 define void @preallocated_bundle_token_from_setup() {
38 %cs = call token @llvm.what()
39 call void @foo0() ["preallocated"(token %cs)]
43 ; CHECK: Expected exactly one preallocated bundle operand
44 define void @preallocated_bundle_one_token() {
45 %cs0 = call token @llvm.call.preallocated.setup(i32 0)
46 %cs1 = call token @llvm.call.preallocated.setup(i32 0)
47 call void @foo0() ["preallocated"(token %cs0, token %cs1)]
51 ; CHECK: Multiple preallocated operand bundles
52 define void @preallocated_multiple_bundles() {
53 %cs0 = call token @llvm.call.preallocated.setup(i32 0)
54 %cs1 = call token @llvm.call.preallocated.setup(i32 0)
55 call void @foo0() ["preallocated"(token %cs0), "preallocated"(token %cs1)]
59 ; CHECK: Can have at most one call
60 define void @preallocated_one_call() {
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 call void @foo1(ptr preallocated(i32) %x) ["preallocated"(token %cs)]
64 call void @foo1(ptr preallocated(i32) %x) ["preallocated"(token %cs)]
68 ; CHECK: must be a constant
69 define void @preallocated_setup_constant() {
70 %ac = call i32 @blackbox()
71 %cs = call token @llvm.call.preallocated.setup(i32 %ac)
75 ; CHECK: must be between 0 and corresponding
76 define void @preallocated_setup_arg_index_in_bounds() {
77 %cs = call token @llvm.call.preallocated.setup(i32 2)
78 %a0 = call ptr @llvm.call.preallocated.arg(token %cs, i32 2) preallocated(i32)
82 ; CHECK: preallocated operand either requires a preallocated bundle or the call to be musttail
83 define void @preallocated_require_bundle() {
84 %cs = call token @llvm.call.preallocated.setup(i32 1)
85 %x = call ptr @llvm.call.preallocated.arg(token %cs, i32 0) preallocated(i32)
86 call void @foo1(ptr preallocated(i32) %x)
90 ; CHECK: arg size must be equal to number of preallocated arguments
91 define void @preallocated_num_args() {
92 %cs = call token @llvm.call.preallocated.setup(i32 3)
93 %x = call ptr @llvm.call.preallocated.arg(token %cs, i32 0) preallocated(i32)
94 %y = call ptr @llvm.call.preallocated.arg(token %cs, i32 1) preallocated(i32)
95 %a = inttoptr i32 0 to ptr
96 call void @foo2(ptr preallocated(i32) %x, ptr %a, ptr preallocated(i32) %y) ["preallocated"(token %cs)]
100 ; CHECK: token argument must be a llvm.call.preallocated.setup
101 define void @preallocated_arg_token() {
102 %t = call token @llvm.what()
103 %x = call ptr @llvm.call.preallocated.arg(token %t, i32 1) preallocated(i32)
107 ; CHECK: cannot use preallocated intrinsics on a call without preallocated arguments
108 define void @preallocated_no_preallocated_args() {
109 %cs = call token @llvm.call.preallocated.setup(i32 0)
110 call void @foo0() ["preallocated"(token %cs)]
114 ; CHECK: preallocated operand either requires a preallocated bundle or the call to be musttail
115 define void @musttail_and_bundle(ptr preallocated(i32) %a) {
116 %cs = call token @llvm.call.preallocated.setup(i32 0)
117 musttail call void @musttail_and_bundle(ptr preallocated(i32) %a) ["preallocated"(token %cs)]
121 ; CHECK: cannot guarantee tail call due to mismatched ABI impacting function attributes
122 define void @musttail_attr_no_match(ptr preallocated(i32) %a) {
123 musttail call void @musttail_and_bundle(ptr %a)
127 ; CHECK: token argument must be a llvm.call.preallocated.setup
128 define void @teardown_token_not_from_setup() {
129 %cs = call token @llvm.what()
130 call void @llvm.call.preallocated.teardown(token %cs)
134 ; CHECK: Attribute 'preallocated(i32)' applied to incompatible type!
135 ; CHECK-NEXT: ptr @not_pointer
136 declare void @not_pointer(i32 preallocated(i32))