67 lines · plain
1; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -relocation-model=pic -fast-isel=1 | FileCheck %s2; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -relocation-model=pic -fast-isel=0 | FileCheck %s3target triple = "wasm32-unknown-emscripten"4 5declare i32 @foo()6declare i32 @bar()7declare hidden i32 @hidden_function()8 9@indirect_func = hidden global ptr @foo10@alias_func = hidden alias i32 (), ptr @local_function11 12define i32 @local_function() {13 ret i32 114}15 16define void @call_indirect_func() {17; CHECK-LABEL: call_indirect_func:18; CHECK: global.get $push[[L0:[0-9]+]]=, __memory_base{{$}}19; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, indirect_func@MBREL{{$}}20; CHECK-NEXT: i32.add $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}21; CHECK-NEXT: i32.load $push[[L3:[0-9]+]]=, 0($pop[[L2]]){{$}}22; CHECK-NEXT: call_indirect $push[[L4:[0-9]+]]=, $pop[[L3]]{{$}}23 %1 = load ptr, ptr @indirect_func, align 424 %call = call i32 %1()25 ret void26}27 28define void @call_direct() {29; CHECK-LABEL: call_direct:30; CHECK: .functype call_direct () -> ()31; CHECK-NEXT: call $push0=, foo{{$}}32; CHECK-NEXT: drop $pop0{{$}}33; CHECK-NEXT: return{{$}}34 %call = call i32 @foo()35 ret void36}37 38define void @call_alias_func() {39; CHECK-LABEL: call_alias_func:40; CHECK: .functype call_alias_func () -> ()41; CHECK-NEXT: call $push0=, alias_func42; CHECK-NEXT: drop $pop0{{$}}43; CHECK-NEXT: return{{$}}44 %call = call i32 @alias_func()45 ret void46}47 48define ptr @get_function_address() {49; CHECK-LABEL: get_function_address:50; CHECK: global.get $push[[L0:[0-9]+]]=, bar@GOT{{$}}51; CHECK-NEXT: return $pop[[L0]]{{$}}52; CHECK-NEXT: end_function{{$}}53 54 ret ptr @bar55}56 57define ptr @get_function_address_hidden() {58; CHECK-LABEL: get_function_address_hidden:59; CHECK: global.get $push[[L0:[0-9]+]]=, __table_base{{$}}60; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, hidden_function@TBREL{{$}}61; CHECK-NEXT: i32.add $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}62; CHECK-NEXT: return $pop[[L2]]{{$}}63; CHECK-NEXT: end_function{{$}}64 65 ret ptr @hidden_function66}67