71 lines · plain
1; RUN: llc < %s -asm-verbose=false -wasm-keep-registers | FileCheck %s2 3; Test that function pointer casts that require conversions of arguments or4; return types are converted to unreachable.5 6target triple = "wasm32-unknown-unknown"7 8declare i32 @has_i64_arg(i64)9declare i32 @has_ptr_arg(ptr)10 11; CHECK-LABEL: test_invalid_rtn:12; CHECK: i32.const $push[[L0:[0-9]+]]=, 0{{$}}13; CHECK-NEXT: call $push[[L1:[0-9]+]]=, .Lhas_i64_arg_bitcast_invalid.1, $pop[[L0]]{{$}}14; CHECK-NEXT: drop $pop[[L1]]{{$}}15; CHECK-NEXT: i64.const $push[[L0:[0-9]+]]=, 0{{$}}16; CHECK-NEXT: call $push[[L1:[0-9]+]]=, .Lhas_i64_arg_bitcast_invalid, $pop[[L0]]{{$}}17; CHECK-NEXT: drop $pop[[L1]]{{$}}18; CHECK-NEXT: end_function19define void @test_invalid_rtn() {20entry:21 call i32 @has_i64_arg(i32 0)22 call [1 x i64] @has_i64_arg(i64 0)23 ret void24}25 26; CHECK-LABEL: test_struct_rtn:27; CHECK: call has_i64_arg, $pop6, $pop028define void @test_struct_rtn() {29 call {i32, i32} @has_i64_arg(i64 0)30 ret void31}32 33; CHECK-LABEL: test_invalid_arg:34; CHECK: i32.const $push[[L0:[0-9]+]]=, 2{{$}}35; CHECK-NEXT: call $push[[L1:[0-9]+]]=, .Lhas_ptr_arg_bitcast_invalid.2, $pop[[L0]]{{$}}36; CHECK-NEXT: drop $pop[[L1]]{{$}}37; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 2{{$}}38; CHECK-NEXT: call $push[[L1:[0-9]+]]=, has_ptr_arg, $pop[[L0]]{{$}}39; CHECK-NEXT: drop $pop[[L1]]{{$}}40; CHECK-NEXT: i64.const $push[[L0:[0-9]+]]=, 3{{$}}41; CHECK-NEXT: call $push[[L1:[0-9]+]]=, .Lhas_ptr_arg_bitcast_invalid, $pop[[L0]]{{$}}42; CHECK-NEXT: drop $pop[[L1]]{{$}}43; CHECK-NEXT: end_function44define void @test_invalid_arg() {45entry:46 call i32 @has_ptr_arg(i8 2)47 call i32 @has_ptr_arg(i32 2)48 call i32 @has_ptr_arg(i64 3)49 ret void50}51 52; CHECK-LABEL: .Lhas_i64_arg_bitcast_invalid:53; CHECK-NEXT: .functype .Lhas_i64_arg_bitcast_invalid (i64) -> (i64)54; CHECK-NEXT: unreachable55; CHECK-NEXT: end_function56 57; CHECK-LABEL: .Lhas_i64_arg_bitcast_invalid.1:58; CHECK-NEXT: .functype .Lhas_i64_arg_bitcast_invalid.1 (i32) -> (i32)59; CHECK-NEXT: unreachable60; CHECK-NEXT: end_function61 62; CHECK-LABEL: .Lhas_ptr_arg_bitcast_invalid:63; CHECK-NEXT: .functype .Lhas_ptr_arg_bitcast_invalid (i64) -> (i32)64; CHECK-NEXT: unreachable65; CHECK-NEXT: end_function66 67; CHECK-LABEL: .Lhas_ptr_arg_bitcast_invalid.2:68; CHECK-NEXT: .functype .Lhas_ptr_arg_bitcast_invalid.2 (i32) -> (i32)69; CHECK-NEXT: unreachable70; CHECK-NEXT: end_function71