1; RUN: llc < %s -asm-verbose=false | FileCheck %s
2
3; Test that function pointer casts are replaced with wrappers.
4
5target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
6target triple = "wasm32-unknown-unknown"
7
8; CHECK-LABEL: test:
9; CHECK-NEXT: call        .Lbitcast@FUNCTION{{$}}
10; CHECK-NEXT: call        .Lbitcast.1@FUNCTION{{$}}
11; CHECK-NEXT: i32.const   $push[[L0:[0-9]+]]=, 0
12; CHECK-NEXT: call        .Lbitcast.2@FUNCTION, $pop[[L0]]{{$}}
13; CHECK-NEXT: i32.call    $drop=, .Lbitcast.3@FUNCTION{{$}}
14; CHECK-NEXT: call        foo2@FUNCTION{{$}}
15; CHECK-NEXT: call        foo3@FUNCTION{{$}}
16; CHECK-NEXT: .endfunc
17
18; CHECK-LABEL: .Lbitcast:
19; CHECK-NEXT: .local      i32
20; CHECK-NEXT: call        has_i32_arg@FUNCTION, $0{{$}}
21; CHECK-NEXT: .endfunc
22
23; CHECK-LABEL: .Lbitcast.1:
24; CHECK-NEXT: call        $drop=, has_i32_ret@FUNCTION{{$}}
25; CHECK-NEXT: .endfunc
26
27; CHECK-LABEL: .Lbitcast.2:
28; CHECK-NEXT: .param      i32
29; CHECK-NEXT: call        foo0@FUNCTION{{$}}
30; CHECK-NEXT: .endfunc
31
32; CHECK-LABEL: .Lbitcast.3:
33; CHECK-NEXT: .result     i32
34; CHECK-NEXT: .local      i32
35; CHECK-NEXT: call        foo1@FUNCTION{{$}}
36; CHECK-NEXT: copy_local  $push0=, $0
37; CHECK-NEXT: .endfunc
38
39declare void @has_i32_arg(i32)
40declare i32 @has_i32_ret()
41
42declare void @foo0()
43declare void @foo1()
44declare void @foo2()
45declare void @foo3()
46
47define void @test() {
48entry:
49  call void bitcast (void (i32)* @has_i32_arg to void ()*)()
50  call void bitcast (i32 ()* @has_i32_ret to void ()*)()
51  call void bitcast (void ()* @foo0 to void (i32)*)(i32 0)
52  %t = call i32 bitcast (void ()* @foo1 to i32 ()*)()
53  call void bitcast (void ()* @foo2 to void ()*)()
54  call void @foo3()
55  ret void
56}
57