Home | History | Annotate | Download | only in Verifier
      1 ; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
      2 
      3 ; Each musttail call should fail to validate.
      4 
      5 declare x86_stdcallcc void @cc_mismatch_callee()
      6 define void @cc_mismatch() {
      7 ; CHECK: mismatched calling conv
      8   musttail call x86_stdcallcc void @cc_mismatch_callee()
      9   ret void
     10 }
     11 
     12 declare void @more_parms_callee(i32)
     13 define void @more_parms() {
     14 ; CHECK: mismatched parameter counts
     15   musttail call void @more_parms_callee(i32 0)
     16   ret void
     17 }
     18 
     19 declare void @mismatched_intty_callee(i8)
     20 define void @mismatched_intty(i32) {
     21 ; CHECK: mismatched parameter types
     22   musttail call void @mismatched_intty_callee(i8 0)
     23   ret void
     24 }
     25 
     26 declare void @mismatched_vararg_callee(i8*, ...)
     27 define void @mismatched_vararg(i8*) {
     28 ; CHECK: mismatched varargs
     29   musttail call void (i8*, ...) @mismatched_vararg_callee(i8* null)
     30   ret void
     31 }
     32 
     33 ; We would make this an implicit sret parameter, which would disturb the
     34 ; tail call.
     35 declare { i32, i32, i32 } @mismatched_retty_callee(i32)
     36 define void @mismatched_retty(i32) {
     37 ; CHECK: mismatched return types
     38   musttail call { i32, i32, i32 } @mismatched_retty_callee(i32 0)
     39   ret void
     40 }
     41 
     42 declare void @mismatched_byval_callee({ i32 }*)
     43 define void @mismatched_byval({ i32 }* byval %a) {
     44 ; CHECK: mismatched ABI impacting function attributes
     45   musttail call void @mismatched_byval_callee({ i32 }* %a)
     46   ret void
     47 }
     48 
     49 declare void @mismatched_inreg_callee(i32 inreg)
     50 define void @mismatched_inreg(i32 %a) {
     51 ; CHECK: mismatched ABI impacting function attributes
     52   musttail call void @mismatched_inreg_callee(i32 inreg %a)
     53   ret void
     54 }
     55 
     56 declare void @mismatched_sret_callee(i32* sret)
     57 define void @mismatched_sret(i32* %a) {
     58 ; CHECK: mismatched ABI impacting function attributes
     59   musttail call void @mismatched_sret_callee(i32* sret %a)
     60   ret void
     61 }
     62 
     63 declare void @mismatched_alignment_callee(i32* byval align 8)
     64 define void @mismatched_alignment(i32* byval align 4 %a) {
     65 ; CHECK: mismatched ABI impacting function attributes
     66   musttail call void @mismatched_alignment_callee(i32* byval align 8 %a)
     67   ret void
     68 }
     69 
     70 declare i32 @not_tail_pos_callee()
     71 define i32 @not_tail_pos() {
     72 ; CHECK: musttail call must be precede a ret with an optional bitcast
     73   %v = musttail call i32 @not_tail_pos_callee()
     74   %w = add i32 %v, 1
     75   ret i32 %w
     76 }
     77 
     78 define void @inline_asm() {
     79 ; CHECK: cannot use musttail call with inline asm
     80   musttail call void asm "ret", ""()
     81   ret void
     82 }
     83