summaryrefslogtreecommitdiff
path: root/test/CodeGen/WebAssembly
diff options
context:
space:
mode:
authorDan Gohman <dan433584@gmail.com>2017-12-08 21:27:00 +0000
committerDan Gohman <dan433584@gmail.com>2017-12-08 21:27:00 +0000
commit87f92ec32dbf0593f0ec99e8e4e54ff295780d67 (patch)
tree067728f301f8f690b0ce457e04d14a3883dfba46 /test/CodeGen/WebAssembly
parent2e99c3afdad5b63a6a999e4de2e3ed2b8fa7a2a8 (diff)
[WebAssembly] Reapply r319186: "Support bitcasted function addresses with varargs."
This puts the functionality under control of a command-line option which is off by default to avoid breaking existing setups. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320197 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/WebAssembly')
-rw-r--r--test/CodeGen/WebAssembly/call.ll6
-rw-r--r--test/CodeGen/WebAssembly/function-bitcasts-varargs.ll31
-rw-r--r--test/CodeGen/WebAssembly/function-bitcasts.ll24
3 files changed, 50 insertions, 11 deletions
diff --git a/test/CodeGen/WebAssembly/call.ll b/test/CodeGen/WebAssembly/call.ll
index dfa0cf5efe0..8a5e8d8c480 100644
--- a/test/CodeGen/WebAssembly/call.ll
+++ b/test/CodeGen/WebAssembly/call.ll
@@ -1,5 +1,5 @@
-; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt | FileCheck %s
-; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -fast-isel -fast-isel-abort=1 | FileCheck %s
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-temporary-workarounds=false | FileCheck %s
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -fast-isel -fast-isel-abort=1 -wasm-temporary-workarounds=false | FileCheck %s
; Test that basic call operations assemble as expected.
@@ -153,7 +153,7 @@ define void @coldcc_tail_call_void_nullary() {
; CHECK-LABEL: call_constexpr:
; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 2{{$}}
; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, 3{{$}}
-; CHECK-NEXT: call vararg_func@FUNCTION, $pop[[L0]], $pop[[L1]]{{$}}
+; CHECK-NEXT: call .Lbitcast@FUNCTION, $pop[[L0]], $pop[[L1]]{{$}}
; CHECK-NEXT: call other_void_nullary@FUNCTION{{$}}
; CHECK-NEXT: call void_nullary@FUNCTION{{$}}
; CHECK-NEXT: return{{$}}
diff --git a/test/CodeGen/WebAssembly/function-bitcasts-varargs.ll b/test/CodeGen/WebAssembly/function-bitcasts-varargs.ll
new file mode 100644
index 00000000000..b5f3d2f64e9
--- /dev/null
+++ b/test/CodeGen/WebAssembly/function-bitcasts-varargs.ll
@@ -0,0 +1,31 @@
+; RUN: llc < %s -asm-verbose=false -wasm-temporary-workarounds=false | FileCheck %s
+
+; Test that function pointer casts casting away varargs are replaced with
+; wrappers.
+
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown-wasm"
+
+define void @callWithArgs() {
+entry:
+ call void bitcast (void (...)* @underspecified to void (i32, i32)*)(i32 0, i32 1)
+ call void(...) bitcast (void (i32, i32)* @specified to void (...)*)(i32 0, i32 1)
+ ret void
+}
+
+declare void @underspecified(...)
+declare void @specified(i32, i32)
+
+; CHECK: callWithArgs:
+; CHECK: i32.const $push1=, 0
+; CHECK-NEXT: i32.const $push0=, 1
+; CHECK-NEXT: call .Lbitcast@FUNCTION, $pop1, $pop0
+; CHECK: call .Lbitcast.1@FUNCTION, $pop{{[0-9]+$}}
+
+; CHECK: .Lbitcast:
+; CHECK-NEXT: .param i32, i32{{$}}
+; CHECK: call underspecified@FUNCTION, $pop{{[0-9]+$}}
+
+; CHECK: .Lbitcast.1:
+; CHECK-NEXT: .param i32{{$}}
+; CHECK: call specified@FUNCTION, $pop{{[0-9]+}}, $pop{{[0-9]+$}}
diff --git a/test/CodeGen/WebAssembly/function-bitcasts.ll b/test/CodeGen/WebAssembly/function-bitcasts.ll
index 3e796e3ff31..ab03716ef74 100644
--- a/test/CodeGen/WebAssembly/function-bitcasts.ll
+++ b/test/CodeGen/WebAssembly/function-bitcasts.ll
@@ -1,4 +1,4 @@
-; RUN: llc < %s -asm-verbose=false -disable-wasm-explicit-locals -enable-emscripten-cxx-exceptions | FileCheck %s
+; RUN: llc < %s -asm-verbose=false -disable-wasm-explicit-locals -enable-emscripten-cxx-exceptions -wasm-temporary-workarounds=false | FileCheck %s
; Test that function pointer casts are replaced with wrappers.
@@ -20,13 +20,13 @@ declare void @foo3()
; CHECK-NEXT: call .Lbitcast@FUNCTION{{$}}
; CHECK-NEXT: call .Lbitcast.1@FUNCTION{{$}}
; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 0
-; CHECK-NEXT: call .Lbitcast.2@FUNCTION, $pop[[L0]]{{$}}
+; CHECK-NEXT: call .Lbitcast.4@FUNCTION, $pop[[L0]]{{$}}
; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, 0
-; CHECK-NEXT: call .Lbitcast.2@FUNCTION, $pop[[L1]]{{$}}
+; CHECK-NEXT: call .Lbitcast.4@FUNCTION, $pop[[L1]]{{$}}
; CHECK-NEXT: i32.const $push[[L2:[0-9]+]]=, 0
-; CHECK-NEXT: call .Lbitcast.2@FUNCTION, $pop[[L2]]{{$}}
+; CHECK-NEXT: call .Lbitcast.4@FUNCTION, $pop[[L2]]{{$}}
; CHECK-NEXT: call foo0@FUNCTION
-; CHECK-NEXT: i32.call $drop=, .Lbitcast.3@FUNCTION{{$}}
+; CHECK-NEXT: i32.call $drop=, .Lbitcast.5@FUNCTION{{$}}
; CHECK-NEXT: call foo2@FUNCTION{{$}}
; CHECK-NEXT: call foo1@FUNCTION{{$}}
; CHECK-NEXT: call foo3@FUNCTION{{$}}
@@ -54,10 +54,10 @@ entry:
; CHECK-LABEL: test_varargs:
; CHECK: set_global
; CHECK: i32.const $push[[L3:[0-9]+]]=, 0{{$}}
-; CHECK-NEXT: call vararg@FUNCTION, $pop[[L3]]{{$}}
+; CHECK-NEXT: call .Lbitcast.2@FUNCTION, $pop[[L3]]{{$}}
; CHECK-NEXT: i32.const $push[[L4:[0-9]+]]=, 0{{$}}
; CHECK-NEXT: i32.store 0($[[L5:[0-9]+]]), $pop[[L4]]{{$}}
-; CHECK-NEXT: call plain@FUNCTION, $[[L5]]{{$}}
+; CHECK-NEXT: call .Lbitcast.3@FUNCTION, $[[L5]]{{$}}
define void @test_varargs() {
call void bitcast (void (...)* @vararg to void (i32)*)(i32 0)
call void (...) bitcast (void (i32)* @plain to void (...)*)(i32 0)
@@ -147,11 +147,19 @@ end:
; CHECK-NEXT: end_function
; CHECK-LABEL: .Lbitcast.2:
+; CHECK: call vararg@FUNCTION, $1{{$}}
+; CHECK: end_function
+
+; CHECK-LABEL: .Lbitcast.3:
+; CHECK: call plain@FUNCTION, $1{{$}}
+; CHECK: end_function
+
+; CHECK-LABEL: .Lbitcast.4:
; CHECK-NEXT: .param i32
; CHECK-NEXT: call foo0@FUNCTION{{$}}
; CHECK-NEXT: end_function
-; CHECK-LABEL: .Lbitcast.3:
+; CHECK-LABEL: .Lbitcast.5:
; CHECK-NEXT: .result i32
; CHECK-NEXT: call foo1@FUNCTION{{$}}
; CHECK-NEXT: copy_local $push0=, $0