[llvm] r319452 - [WebAssembly] Revert r319186 "Support bitcasted function addresses with varargs."

Dan Gohman via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 30 10:16:49 PST 2017


Author: djg
Date: Thu Nov 30 10:16:49 2017
New Revision: 319452

URL: http://llvm.org/viewvc/llvm-project?rev=319452&view=rev
Log:
[WebAssembly] Revert r319186 "Support bitcasted function addresses with varargs."

The patch broke Emscripten's EM_ASM macros, which utiltize unprototyped
functions.

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

Removed:
    llvm/trunk/test/CodeGen/WebAssembly/function-bitcasts-varargs.ll
Modified:
    llvm/trunk/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
    llvm/trunk/test/CodeGen/WebAssembly/call.ll
    llvm/trunk/test/CodeGen/WebAssembly/function-bitcasts.ll

Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp?rev=319452&r1=319451&r2=319452&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp Thu Nov 30 10:16:49 2017
@@ -162,6 +162,11 @@ bool FixFunctionBitcasts::runOnModule(Mo
     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);

Modified: llvm/trunk/test/CodeGen/WebAssembly/call.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/call.ll?rev=319452&r1=319451&r2=319452&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/call.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/call.ll Thu Nov 30 10:16:49 2017
@@ -153,7 +153,7 @@ define void @coldcc_tail_call_void_nulla
 ; 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 at FUNCTION, $pop[[L0]], $pop[[L1]]{{$}}
+; CHECK-NEXT: call vararg_func at FUNCTION, $pop[[L0]], $pop[[L1]]{{$}}
 ; CHECK-NEXT: call other_void_nullary at FUNCTION{{$}}
 ; CHECK-NEXT: call void_nullary at FUNCTION{{$}}
 ; CHECK-NEXT: return{{$}}

Removed: llvm/trunk/test/CodeGen/WebAssembly/function-bitcasts-varargs.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/function-bitcasts-varargs.ll?rev=319451&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/function-bitcasts-varargs.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/function-bitcasts-varargs.ll (removed)
@@ -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 at FUNCTION, $pop1, $pop0
-; CHECK: call    	.Lbitcast.1 at FUNCTION, $pop{{[0-9]+$}}
-
-; CHECK: .Lbitcast:
-; CHECK-NEXT: .param  	i32, i32{{$}}
-; CHECK: call    	underspecified at FUNCTION, $pop{{[0-9]+$}}
-
-; CHECK: .Lbitcast.1:
-; CHECK-NEXT: .param  	i32{{$}}
-; CHECK: call    	specified at FUNCTION, $pop{{[0-9]+}}, $pop{{[0-9]+$}}

Modified: llvm/trunk/test/CodeGen/WebAssembly/function-bitcasts.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/function-bitcasts.ll?rev=319452&r1=319451&r2=319452&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/function-bitcasts.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/function-bitcasts.ll Thu Nov 30 10:16:49 2017
@@ -20,13 +20,13 @@ declare void @foo3()
 ; CHECK-NEXT: call        .Lbitcast at FUNCTION{{$}}
 ; CHECK-NEXT: call        .Lbitcast.1 at FUNCTION{{$}}
 ; CHECK-NEXT: i32.const   $push[[L0:[0-9]+]]=, 0
-; CHECK-NEXT: call        .Lbitcast.4 at FUNCTION, $pop[[L0]]{{$}}
+; CHECK-NEXT: call        .Lbitcast.2 at FUNCTION, $pop[[L0]]{{$}}
 ; CHECK-NEXT: i32.const   $push[[L1:[0-9]+]]=, 0
-; CHECK-NEXT: call        .Lbitcast.4 at FUNCTION, $pop[[L1]]{{$}}
+; CHECK-NEXT: call        .Lbitcast.2 at FUNCTION, $pop[[L1]]{{$}}
 ; CHECK-NEXT: i32.const   $push[[L2:[0-9]+]]=, 0
-; CHECK-NEXT: call        .Lbitcast.4 at FUNCTION, $pop[[L2]]{{$}}
+; CHECK-NEXT: call        .Lbitcast.2 at FUNCTION, $pop[[L2]]{{$}}
 ; CHECK-NEXT: call        foo0 at FUNCTION
-; CHECK-NEXT: i32.call    $drop=, .Lbitcast.5 at FUNCTION{{$}}
+; CHECK-NEXT: i32.call    $drop=, .Lbitcast.3 at FUNCTION{{$}}
 ; CHECK-NEXT: call        foo2 at FUNCTION{{$}}
 ; CHECK-NEXT: call        foo1 at FUNCTION{{$}}
 ; CHECK-NEXT: call        foo3 at 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 at FUNCTION, $pop[[L3]]{{$}}
+; CHECK-NEXT: call        vararg at 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 at FUNCTION, $[[L5]]{{$}}
+; CHECK-NEXT: call        plain at 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 at FUNCTION, $1{{$}}
-; CHECK: end_function
-
-; CHECK-LABEL: .Lbitcast.3:
-; CHECK: call        plain at FUNCTION, $1{{$}}
-; CHECK: end_function
-
-; CHECK-LABEL: .Lbitcast.4:
 ; CHECK-NEXT: .param      i32
 ; CHECK-NEXT: call        foo0 at FUNCTION{{$}}
 ; CHECK-NEXT: end_function
 
-; CHECK-LABEL: .Lbitcast.5:
+; CHECK-LABEL: .Lbitcast.3:
 ; CHECK-NEXT: .result     i32
 ; CHECK-NEXT: call        foo1 at FUNCTION{{$}}
 ; CHECK-NEXT: copy_local  $push0=, $0




More information about the llvm-commits mailing list