xref: /llvm-project/llvm/test/Verifier/byref.ll (revision b05c71814c3b9f91a2e00af891d67a83790a109c)
1; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
2
3%opaque.ty = type opaque
4
5; CHECK: Attribute 'byref' does not support unsized types!
6; CHECK-NEXT: ptr @byref_unsized
7define void @byref_unsized(ptr byref(%opaque.ty)) {
8  ret void
9}
10
11; CHECK: Attributes 'byval', 'inalloca', 'preallocated', 'inreg', 'nest', 'byref', and 'sret' are incompatible!
12; CHECK-NEXT: ptr @byref_byval
13define void @byref_byval(ptr byref(i32) byval(i32)) {
14  ret void
15}
16
17; CHECK: Attributes 'byval', 'inalloca', 'preallocated', 'inreg', 'nest', 'byref', and 'sret' are incompatible!
18; CHECK-NEXT: ptr @byref_inalloca
19define void @byref_inalloca(ptr byref(i32) inalloca(i32)) {
20  ret void
21}
22
23; CHECK: Attributes 'byval', 'inalloca', 'preallocated', 'inreg', 'nest', 'byref', and 'sret' are incompatible!
24; CHECK-NEXT: ptr @byref_preallocated
25define void @byref_preallocated(ptr byref(i32) preallocated(i32)) {
26  ret void
27}
28
29; CHECK: Attributes 'byval', 'inalloca', 'preallocated', 'inreg', 'nest', 'byref', and 'sret' are incompatible!
30; CHECK-NEXT: ptr @byref_sret
31define void @byref_sret(ptr byref(i32) sret(i32)) {
32  ret void
33}
34
35; CHECK: Attributes 'byval', 'inalloca', 'preallocated', 'inreg', 'nest', 'byref', and 'sret' are incompatible!
36; CHECK-NEXT: ptr @byref_inreg
37define void @byref_inreg(ptr byref(i32) inreg) {
38  ret void
39}
40
41; CHECK: Attributes 'byval', 'inalloca', 'preallocated', 'inreg', 'nest', 'byref', and 'sret' are incompatible!
42; CHECK-NEXT: ptr @byref_nest
43define void @byref_nest(ptr byref(i32) nest) {
44  ret void
45}
46
47; CHECK: Attribute 'byref(i32)' applied to incompatible type!
48; CHECK-NEXT: ptr @byref_non_pointer
49define void @byref_non_pointer(i32 byref(i32)) {
50  ret void
51}
52
53define void @byref_callee(ptr byref([64 x i8])) {
54  ret void
55}
56
57define void @no_byref_callee(ptr) {
58  ret void
59}
60
61; CHECK: cannot guarantee tail call due to mismatched ABI impacting function attributes
62; CHECK-NEXT: musttail call void @byref_callee(ptr byref([64 x i8]) %ptr)
63; CHECK-NEXT: ptr %ptr
64define void @musttail_byref_caller(ptr %ptr) {
65  musttail call void @byref_callee(ptr byref([64 x i8]) %ptr)
66  ret void
67}
68
69; CHECK: cannot guarantee tail call due to mismatched ABI impacting function attributes
70; CHECK-NEXT: musttail call void @byref_callee(ptr %ptr)
71; CHECK-NEXT: ptr %ptr
72define void @musttail_byref_callee(ptr byref([64 x i8]) %ptr) {
73  musttail call void @byref_callee(ptr %ptr)
74  ret void
75}
76
77define void @byref_callee_align32(ptr byref([64 x i8]) align 32) {
78  ret void
79}
80
81; CHECK: cannot guarantee tail call due to mismatched ABI impacting function attributes
82; CHECK-NEXT: musttail call void @byref_callee_align32(ptr byref([64 x i8]) align 32 %ptr)
83; CHECK-NEXT: ptr %ptr
84define void @musttail_byref_caller_mismatched_align(ptr byref([64 x i8]) align 16 %ptr) {
85  musttail call void @byref_callee_align32(ptr byref([64 x i8]) align 32 %ptr)
86  ret void
87}
88