Re-land [openmp] Fix warnings when building on Windows with latest MSVC or Clang...
[llvm-project.git] / llvm / test / CodeGen / WebAssembly / call-pic.ll
blobf6f24bdd0530c342887acfaca86e66c77dac2e0b
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 triple = "wasm32-unknown-emscripten"
5 declare i32 @foo()
6 declare i32 @bar()
7 declare hidden i32 @hidden_function()
9 @indirect_func = hidden global ptr @foo
10 @alias_func = hidden alias i32 (), ptr @local_function
12 define i32 @local_function() {
13   ret i32 1
16 define 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 4
24   %call = call i32 %1()
25   ret void
28 define 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 void
38 define void @call_alias_func() {
39 ; CHECK-LABEL: call_alias_func:
40 ; CHECK: .functype call_alias_func () -> ()
41 ; CHECK-NEXT: call $push0=, alias_func
42 ; CHECK-NEXT: drop $pop0{{$}}
43 ; CHECK-NEXT: return{{$}}
44   %call = call i32 @alias_func()
45   ret void
48 define 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{{$}}
54   ret ptr @bar
57 define 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{{$}}
65   ret ptr @hidden_function