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 3target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" 4target triple = "wasm32-unknown-emscripten" 5 6declare i32 @foo() 7declare i32 @bar() 8declare hidden i32 @hidden_function() 9 10@indirect_func = hidden global i32 ()* @foo 11@alias_func = hidden alias i32 (), i32 ()* @local_function 12 13define i32 @local_function() { 14 ret i32 1 15} 16 17define 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: call_indirect $push[[L4:[0-9]+]]=, $pop[[L3]]{{$}} 24 %1 = load i32 ()*, i32 ()** @indirect_func, align 4 25 %call = call i32 %1() 26 ret void 27} 28 29define void @call_direct() { 30; CHECK-LABEL: call_direct: 31; CHECK: .functype call_direct () -> () 32; CHECK-NEXT: call $push0=, foo{{$}} 33; CHECK-NEXT: drop $pop0{{$}} 34; CHECK-NEXT: return{{$}} 35 %call = call i32 @foo() 36 ret void 37} 38 39define void @call_alias_func() { 40; CHECK-LABEL: call_alias_func: 41; CHECK: .functype call_alias_func () -> () 42; CHECK-NEXT: call $push0=, alias_func 43; CHECK-NEXT: drop $pop0{{$}} 44; CHECK-NEXT: return{{$}} 45 %call = call i32 @alias_func() 46 ret void 47} 48 49define 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{{$}} 54 55 ret i8* bitcast (i32 ()* @bar to i8*) 56} 57 58define 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{{$}} 65 66 ret i8* bitcast (i32 ()* @hidden_function to i8*) 67} 68