2019-03-27 03:46:15 +08:00
|
|
|
; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -relocation-model=pic -fast-isel=1 | FileCheck %s
|
|
|
|
; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -relocation-model=pic -fast-isel=0 | FileCheck %s
|
|
|
|
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
|
2019-06-06 04:01:01 +08:00
|
|
|
target triple = "wasm32-unknown-emscripten"
|
2019-03-27 03:46:15 +08:00
|
|
|
|
|
|
|
declare i32 @foo()
|
|
|
|
declare i32 @bar()
|
2019-04-05 01:43:50 +08:00
|
|
|
declare hidden i32 @hidden_function()
|
2019-03-27 03:46:15 +08:00
|
|
|
|
2019-05-10 09:52:08 +08:00
|
|
|
@indirect_func = hidden global i32 ()* @foo
|
2019-04-20 06:43:32 +08:00
|
|
|
@alias_func = hidden alias i32 (), i32 ()* @local_function
|
|
|
|
|
|
|
|
define i32 @local_function() {
|
|
|
|
ret i32 1
|
|
|
|
}
|
2019-03-27 03:46:15 +08:00
|
|
|
|
|
|
|
define void @call_indirect_func() {
|
|
|
|
; CHECK-LABEL: call_indirect_func:
|
|
|
|
; CHECK: global.get $push[[L0:[0-9]+]]=, __memory_base{{$}}
|
2019-04-05 01:43:50 +08:00
|
|
|
; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, indirect_func@MBREL{{$}}
|
2019-03-27 03:46:15 +08:00
|
|
|
; CHECK-NEXT: i32.add $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
|
|
|
|
; CHECK-NEXT: i32.load $push[[L3:[0-9]+]]=, 0($pop[[L2]]){{$}}
|
[WebAssembly] Replace all calls with generalized multivalue calls
Summary:
Extends the multivalue call infrastructure to tail calls, removes all
legacy calls specialized for particular result types, and removes the
CallIndirectFixup pass, since all indirect call arguments are now
fixed up directly in the post-insertion hook.
In order to keep supporting pretty-printed defs and uses in test
expectations, MCInstLower now inserts an immediate containing the
number of defs for each call and call_indirect. The InstPrinter is
updated to query this immediate if it is present and determine which
MCOperands are defs and uses accordingly.
Depends on D72902.
Reviewers: aheejin
Subscribers: dschuff, mgorny, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D74192
2020-02-07 08:29:59 +08:00
|
|
|
; CHECK-NEXT: call_indirect $push[[L4:[0-9]+]]=, $pop[[L3]]{{$}}
|
2019-03-27 03:46:15 +08:00
|
|
|
%1 = load i32 ()*, i32 ()** @indirect_func, align 4
|
|
|
|
%call = call i32 %1()
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @call_direct() {
|
|
|
|
; CHECK-LABEL: call_direct:
|
|
|
|
; CHECK: .functype call_direct () -> ()
|
[WebAssembly] Replace all calls with generalized multivalue calls
Summary:
Extends the multivalue call infrastructure to tail calls, removes all
legacy calls specialized for particular result types, and removes the
CallIndirectFixup pass, since all indirect call arguments are now
fixed up directly in the post-insertion hook.
In order to keep supporting pretty-printed defs and uses in test
expectations, MCInstLower now inserts an immediate containing the
number of defs for each call and call_indirect. The InstPrinter is
updated to query this immediate if it is present and determine which
MCOperands are defs and uses accordingly.
Depends on D72902.
Reviewers: aheejin
Subscribers: dschuff, mgorny, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D74192
2020-02-07 08:29:59 +08:00
|
|
|
; CHECK-NEXT: call $push0=, foo{{$}}
|
2019-03-27 03:46:15 +08:00
|
|
|
; CHECK-NEXT: drop $pop0{{$}}
|
|
|
|
; CHECK-NEXT: return{{$}}
|
|
|
|
%call = call i32 @foo()
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2019-04-20 06:43:32 +08:00
|
|
|
define void @call_alias_func() {
|
|
|
|
; CHECK-LABEL: call_alias_func:
|
|
|
|
; CHECK: .functype call_alias_func () -> ()
|
[WebAssembly] Replace all calls with generalized multivalue calls
Summary:
Extends the multivalue call infrastructure to tail calls, removes all
legacy calls specialized for particular result types, and removes the
CallIndirectFixup pass, since all indirect call arguments are now
fixed up directly in the post-insertion hook.
In order to keep supporting pretty-printed defs and uses in test
expectations, MCInstLower now inserts an immediate containing the
number of defs for each call and call_indirect. The InstPrinter is
updated to query this immediate if it is present and determine which
MCOperands are defs and uses accordingly.
Depends on D72902.
Reviewers: aheejin
Subscribers: dschuff, mgorny, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D74192
2020-02-07 08:29:59 +08:00
|
|
|
; CHECK-NEXT: call $push0=, alias_func
|
2019-04-20 06:43:32 +08:00
|
|
|
; CHECK-NEXT: drop $pop0{{$}}
|
|
|
|
; CHECK-NEXT: return{{$}}
|
|
|
|
%call = call i32 @alias_func()
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2019-03-27 03:46:15 +08:00
|
|
|
define i8* @get_function_address() {
|
|
|
|
; CHECK-LABEL: get_function_address:
|
|
|
|
; CHECK: global.get $push[[L0:[0-9]+]]=, bar@GOT{{$}}
|
|
|
|
; CHECK-NEXT: return $pop[[L0]]{{$}}
|
|
|
|
; CHECK-NEXT: end_function{{$}}
|
|
|
|
|
|
|
|
ret i8* bitcast (i32 ()* @bar to i8*)
|
|
|
|
}
|
|
|
|
|
|
|
|
define i8* @get_function_address_hidden() {
|
|
|
|
; CHECK-LABEL: get_function_address_hidden:
|
|
|
|
; CHECK: global.get $push[[L0:[0-9]+]]=, __table_base{{$}}
|
2019-04-05 01:43:50 +08:00
|
|
|
; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, hidden_function@TBREL{{$}}
|
2019-03-27 03:46:15 +08:00
|
|
|
; CHECK-NEXT: i32.add $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]]{{$}}
|
|
|
|
; CHECK-NEXT: return $pop[[L2]]{{$}}
|
|
|
|
; CHECK-NEXT: end_function{{$}}
|
|
|
|
|
|
|
|
ret i8* bitcast (i32 ()* @hidden_function to i8*)
|
|
|
|
}
|