llvm.org GIT mirror llvm / 5155d51
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319452 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 2 years ago
4 changed file(s) with 13 addition(s) and 47 deletion(s). Raw diff Collapse all Expand all
161161 if (!Ty)
162162 continue;
163163
164 // Bitcasted vararg functions occur in Emscripten's implementation of
165 // EM_ASM, so suppress wrappers for them for now.
166 if (Ty->isVarArg() || F->isVarArg())
167 continue;
168
164169 auto Pair = Wrappers.insert(std::make_pair(std::make_pair(F, Ty), nullptr));
165170 if (Pair.second)
166171 Pair.first->second = CreateWrapper(F, Ty);
152152 ; CHECK-LABEL: call_constexpr:
153153 ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 2{{$}}
154154 ; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, 3{{$}}
155 ; CHECK-NEXT: call .Lbitcast@FUNCTION, $pop[[L0]], $pop[[L1]]{{$}}
155 ; CHECK-NEXT: call vararg_func@FUNCTION, $pop[[L0]], $pop[[L1]]{{$}}
156156 ; CHECK-NEXT: call other_void_nullary@FUNCTION{{$}}
157157 ; CHECK-NEXT: call void_nullary@FUNCTION{{$}}
158158 ; CHECK-NEXT: return{{$}}
+0
-31
test/CodeGen/WebAssembly/function-bitcasts-varargs.ll less more
None ; RUN: llc < %s -asm-verbose=false | FileCheck %s
1
2 ; Test that function pointer casts casting away varargs are replaced with
3 ; wrappers.
4
5 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
6 target triple = "wasm32-unknown-unknown-wasm"
7
8 define void @callWithArgs() {
9 entry:
10 call void bitcast (void (...)* @underspecified to void (i32, i32)*)(i32 0, i32 1)
11 call void(...) bitcast (void (i32, i32)* @specified to void (...)*)(i32 0, i32 1)
12 ret void
13 }
14
15 declare void @underspecified(...)
16 declare void @specified(i32, i32)
17
18 ; CHECK: callWithArgs:
19 ; CHECK: i32.const $push1=, 0
20 ; CHECK-NEXT: i32.const $push0=, 1
21 ; CHECK-NEXT: call .Lbitcast@FUNCTION, $pop1, $pop0
22 ; CHECK: call .Lbitcast.1@FUNCTION, $pop{{[0-9]+$}}
23
24 ; CHECK: .Lbitcast:
25 ; CHECK-NEXT: .param i32, i32{{$}}
26 ; CHECK: call underspecified@FUNCTION, $pop{{[0-9]+$}}
27
28 ; CHECK: .Lbitcast.1:
29 ; CHECK-NEXT: .param i32{{$}}
30 ; CHECK: call specified@FUNCTION, $pop{{[0-9]+}}, $pop{{[0-9]+$}}
1919 ; CHECK-NEXT: call .Lbitcast@FUNCTION{{$}}
2020 ; CHECK-NEXT: call .Lbitcast.1@FUNCTION{{$}}
2121 ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 0
22 ; CHECK-NEXT: call .Lbitcast.4@FUNCTION, $pop[[L0]]{{$}}
22 ; CHECK-NEXT: call .Lbitcast.2@FUNCTION, $pop[[L0]]{{$}}
2323 ; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, 0
24 ; CHECK-NEXT: call .Lbitcast.4@FUNCTION, $pop[[L1]]{{$}}
24 ; CHECK-NEXT: call .Lbitcast.2@FUNCTION, $pop[[L1]]{{$}}
2525 ; CHECK-NEXT: i32.const $push[[L2:[0-9]+]]=, 0
26 ; CHECK-NEXT: call .Lbitcast.4@FUNCTION, $pop[[L2]]{{$}}
26 ; CHECK-NEXT: call .Lbitcast.2@FUNCTION, $pop[[L2]]{{$}}
2727 ; CHECK-NEXT: call foo0@FUNCTION
28 ; CHECK-NEXT: i32.call $drop=, .Lbitcast.5@FUNCTION{{$}}
28 ; CHECK-NEXT: i32.call $drop=, .Lbitcast.3@FUNCTION{{$}}
2929 ; CHECK-NEXT: call foo2@FUNCTION{{$}}
3030 ; CHECK-NEXT: call foo1@FUNCTION{{$}}
3131 ; CHECK-NEXT: call foo3@FUNCTION{{$}}
5353 ; CHECK-LABEL: test_varargs:
5454 ; CHECK: set_global
5555 ; CHECK: i32.const $push[[L3:[0-9]+]]=, 0{{$}}
56 ; CHECK-NEXT: call .Lbitcast.2@FUNCTION, $pop[[L3]]{{$}}
56 ; CHECK-NEXT: call vararg@FUNCTION, $pop[[L3]]{{$}}
5757 ; CHECK-NEXT: i32.const $push[[L4:[0-9]+]]=, 0{{$}}
5858 ; CHECK-NEXT: i32.store 0($[[L5:[0-9]+]]), $pop[[L4]]{{$}}
59 ; CHECK-NEXT: call .Lbitcast.3@FUNCTION, $[[L5]]{{$}}
59 ; CHECK-NEXT: call plain@FUNCTION, $[[L5]]{{$}}
6060 define void @test_varargs() {
6161 call void bitcast (void (...)* @vararg to void (i32)*)(i32 0)
6262 call void (...) bitcast (void (i32)* @plain to void (...)*)(i32 0)
146146 ; CHECK-NEXT: end_function
147147
148148 ; CHECK-LABEL: .Lbitcast.2:
149 ; CHECK: call vararg@FUNCTION, $1{{$}}
150 ; CHECK: end_function
151
152 ; CHECK-LABEL: .Lbitcast.3:
153 ; CHECK: call plain@FUNCTION, $1{{$}}
154 ; CHECK: end_function
155
156 ; CHECK-LABEL: .Lbitcast.4:
157149 ; CHECK-NEXT: .param i32
158150 ; CHECK-NEXT: call foo0@FUNCTION{{$}}
159151 ; CHECK-NEXT: end_function
160152
161 ; CHECK-LABEL: .Lbitcast.5:
153 ; CHECK-LABEL: .Lbitcast.3:
162154 ; CHECK-NEXT: .result i32
163155 ; CHECK-NEXT: call foo1@FUNCTION{{$}}
164156 ; CHECK-NEXT: copy_local $push0=, $0