1 ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -relocation-model=pic -fast-isel=1 | FileCheck %s
2 ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -relocation-model=pic -fast-isel=0 | FileCheck %s
3 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
4 target triple = "wasm32-unknown-emscripten"
8 declare hidden i32 @hidden_function()
10 @indirect_func = hidden global i32 ()* @foo
11 @alias_func = hidden alias i32 (), i32 ()* @local_function
13 define i32 @local_function() {
17 define void @call_indirect_func() {
18 ; CHECK-LABEL: call_indirect_func:
19 ; CHECK: global.get $push[[L0:[0-9]+]]=, __memory_base{{$}}
20 ; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, indirect_func@MBREL{{$}}
21 ; CHECK-NEXT: i32.add $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
22 ; CHECK-NEXT: i32.load $push[[L3:[0-9]+]]=, 0($pop[[L2]]){{$}}
23 ; CHECK-NEXT: i32.call_indirect $push[[L4:[0-9]+]]=, $pop[[L3]]{{$}}
24 %1 = load i32 ()*, i32 ()** @indirect_func, align 4
29 define void @call_direct() {
30 ; CHECK-LABEL: call_direct:
31 ; CHECK: .functype call_direct () -> ()
32 ; CHECK-NEXT: i32.call $push0=, foo{{$}}
33 ; CHECK-NEXT: drop $pop0{{$}}
34 ; CHECK-NEXT: return{{$}}
35 %call = call i32 @foo()
39 define void @call_alias_func() {
40 ; CHECK-LABEL: call_alias_func:
41 ; CHECK: .functype call_alias_func () -> ()
42 ; CHECK-NEXT: i32.call $push0=, alias_func
43 ; CHECK-NEXT: drop $pop0{{$}}
44 ; CHECK-NEXT: return{{$}}
45 %call = call i32 @alias_func()
49 define i8* @get_function_address() {
50 ; CHECK-LABEL: get_function_address:
51 ; CHECK: global.get $push[[L0:[0-9]+]]=, bar@GOT{{$}}
52 ; CHECK-NEXT: return $pop[[L0]]{{$}}
53 ; CHECK-NEXT: end_function{{$}}
55 ret i8* bitcast (i32 ()* @bar to i8*)
58 define i8* @get_function_address_hidden() {
59 ; CHECK-LABEL: get_function_address_hidden:
60 ; CHECK: global.get $push[[L0:[0-9]+]]=, __table_base{{$}}
61 ; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, hidden_function@TBREL{{$}}
62 ; CHECK-NEXT: i32.add $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
63 ; CHECK-NEXT: return $pop[[L2]]{{$}}
64 ; CHECK-NEXT: end_function{{$}}
66 ret i8* bitcast (i32 ()* @hidden_function to i8*)