File: musttail-invalid.ll

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,634,792 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (83 lines) | stat: -rw-r--r-- 2,467 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
; RUN: not llvm-as %s -opaque-pointers -o /dev/null 2>&1 | FileCheck %s

; Each musttail call should fail to validate.

declare x86_stdcallcc void @cc_mismatch_callee()
define void @cc_mismatch() {
; CHECK: mismatched calling conv
  musttail call x86_stdcallcc void @cc_mismatch_callee()
  ret void
}

declare void @more_parms_callee(i32)
define void @more_parms() {
; CHECK: mismatched parameter counts
  musttail call void @more_parms_callee(i32 0)
  ret void
}

declare void @mismatched_intty_callee(i8)
define void @mismatched_intty(i32) {
; CHECK: mismatched parameter types
  musttail call void @mismatched_intty_callee(i8 0)
  ret void
}

declare void @mismatched_vararg_callee(ptr, ...)
define void @mismatched_vararg(ptr) {
; CHECK: mismatched varargs
  musttail call void (ptr, ...) @mismatched_vararg_callee(ptr null)
  ret void
}

; We would make this an implicit sret parameter, which would disturb the
; tail call.
declare { i32, i32, i32 } @mismatched_retty_callee(i32)
define void @mismatched_retty(i32) {
; CHECK: mismatched return types
  musttail call { i32, i32, i32 } @mismatched_retty_callee(i32 0)
  ret void
}

declare void @mismatched_byval_callee(ptr)
define void @mismatched_byval(ptr byval({ i32 }) %a) {
; CHECK: mismatched ABI impacting function attributes
  musttail call void @mismatched_byval_callee(ptr %a)
  ret void
}

declare void @mismatched_inreg_callee(i32 inreg)
define void @mismatched_inreg(i32 %a) {
; CHECK: mismatched ABI impacting function attributes
  musttail call void @mismatched_inreg_callee(i32 inreg %a)
  ret void
}

declare void @mismatched_sret_callee(ptr sret(i32))
define void @mismatched_sret(ptr %a) {
; CHECK: mismatched ABI impacting function attributes
  musttail call void @mismatched_sret_callee(ptr sret(i32) %a)
  ret void
}

declare void @mismatched_alignment_callee(ptr byval(i32) align 8)
define void @mismatched_alignment(ptr byval(i32) align 4 %a) {
; CHECK: mismatched ABI impacting function attributes
  musttail call void @mismatched_alignment_callee(ptr byval(i32) align 8 %a)
  ret void
}

declare i32 @not_tail_pos_callee()
define i32 @not_tail_pos() {
; CHECK: musttail call must precede a ret with an optional bitcast
  %v = musttail call i32 @not_tail_pos_callee()
  %w = add i32 %v, 1
  ret i32 %w
}

define void @inline_asm() {
; CHECK: cannot use musttail call with inline asm
  musttail call void asm "ret", ""()
  ret void
}