]> granicus.if.org Git - llvm/commitdiff
[WebAssembly] Revert r319186 "Support bitcasted function addresses with varargs."
authorDan Gohman <dan433584@gmail.com>
Thu, 30 Nov 2017 18:16:49 +0000 (18:16 +0000)
committerDan Gohman <dan433584@gmail.com>
Thu, 30 Nov 2017 18:16:49 +0000 (18:16 +0000)
The patch broke Emscripten's EM_ASM macros, which utiltize unprototyped
functions.

See https://bugs.llvm.org/show_bug.cgi?id=35385 for details.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319452 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
test/CodeGen/WebAssembly/call.ll
test/CodeGen/WebAssembly/function-bitcasts-varargs.ll [deleted file]
test/CodeGen/WebAssembly/function-bitcasts.ll

index 6473a2bfb5957951bc2328e42a96373d1d57e42d..f1d2c00d1635481716988dbcb28de5d218331ee7 100644 (file)
@@ -162,6 +162,11 @@ bool FixFunctionBitcasts::runOnModule(Module &M) {
     if (!Ty)
       continue;
 
+    // Bitcasted vararg functions occur in Emscripten's implementation of
+    // EM_ASM, so suppress wrappers for them for now.
+    if (Ty->isVarArg() || F->isVarArg())
+      continue;
+
     auto Pair = Wrappers.insert(std::make_pair(std::make_pair(F, Ty), nullptr));
     if (Pair.second)
       Pair.first->second = CreateWrapper(F, Ty);
index 74c9fb6c08f8fe0b1cfd642ce8e7b687ac587238..dfa0cf5efe0bdf1891a81656479ab62f59187804 100644 (file)
@@ -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 .Lbitcast@FUNCTION, $pop[[L0]], $pop[[L1]]{{$}}
+; CHECK-NEXT: call vararg_func@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
deleted file mode 100644 (file)
index c08fe8f..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-; RUN: llc < %s -asm-verbose=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]+$}}
index 17843a267ab37d6f17793710aade010d859d8c00..3e796e3ff31b0e444f01f8b1113e685599753953 100644 (file)
@@ -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.4@FUNCTION, $pop[[L0]]{{$}}
+; CHECK-NEXT: call        .Lbitcast.2@FUNCTION, $pop[[L0]]{{$}}
 ; CHECK-NEXT: i32.const   $push[[L1:[0-9]+]]=, 0
-; CHECK-NEXT: call        .Lbitcast.4@FUNCTION, $pop[[L1]]{{$}}
+; CHECK-NEXT: call        .Lbitcast.2@FUNCTION, $pop[[L1]]{{$}}
 ; CHECK-NEXT: i32.const   $push[[L2:[0-9]+]]=, 0
-; CHECK-NEXT: call        .Lbitcast.4@FUNCTION, $pop[[L2]]{{$}}
+; CHECK-NEXT: call        .Lbitcast.2@FUNCTION, $pop[[L2]]{{$}}
 ; CHECK-NEXT: call        foo0@FUNCTION
-; CHECK-NEXT: i32.call    $drop=, .Lbitcast.5@FUNCTION{{$}}
+; CHECK-NEXT: i32.call    $drop=, .Lbitcast.3@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        .Lbitcast.2@FUNCTION, $pop[[L3]]{{$}}
+; CHECK-NEXT: call        vararg@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        .Lbitcast.3@FUNCTION, $[[L5]]{{$}}
+; CHECK-NEXT: call        plain@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,19 +147,11 @@ 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.5:
+; CHECK-LABEL: .Lbitcast.3:
 ; CHECK-NEXT: .result     i32
 ; CHECK-NEXT: call        foo1@FUNCTION{{$}}
 ; CHECK-NEXT: copy_local  $push0=, $0