llvm.org GIT mirror llvm / 0d4e33d
[WebAssembly] Don't create bitcast-wrappers for varargs. WebAssembly varargs functions use a significantly different ABI than non-varargs functions, and the current code in WebAssemblyFixFunctionBitcasts doesn't handle that difference. For now, just avoid creating wrapper functions in the presence of varargs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292645 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 3 years ago
2 changed file(s) with 22 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
147147 if (!Ty)
148148 continue;
149149
150 // Wasm varargs are not ABI-compatible with non-varargs. Just ignore
151 // such casts for now.
152 if (Ty->isVarArg() || F->isVarArg())
153 continue;
154
150155 auto Pair = Wrappers.insert(std::make_pair(std::make_pair(F, Ty), nullptr));
151156 if (Pair.second)
152157 Pair.first->second = CreateWrapper(F, Ty);
2121 ; CHECK-NEXT: call foo3@FUNCTION{{$}}
2222 ; CHECK-NEXT: .endfunc
2323
24 ; CHECK-LABEL: test_varargs:
25 ; CHECK-NEXT: .local i32
26 ; CHECK: store
27 ; CHECK: i32.const $push[[L3:[0-9]+]]=, 0{{$}}
28 ; CHECK-NEXT: call vararg@FUNCTION, $pop[[L3]]{{$}}
29 ; CHECK-NEXT: i32.const $push[[L4:[0-9]+]]=, 0{{$}}
30 ; CHECK-NEXT: i32.store 0($[[L5:[0-9]+]]), $pop[[L4]]{{$}}
31 ; CHECK-NEXT: call plain@FUNCTION, $[[L5]]{{$}}
32
2433 ; CHECK-LABEL: .Lbitcast:
2534 ; CHECK-NEXT: .local i32
2635 ; CHECK-NEXT: call has_i32_arg@FUNCTION, $0{{$}}
4453
4554 declare void @has_i32_arg(i32)
4655 declare i32 @has_i32_ret()
56 declare void @vararg(...)
57 declare void @plain(i32)
4758
4859 declare void @foo0()
4960 declare void @foo1()
6980
7081 ret void
7182 }
83
84 define void @test_varargs() {
85 call void bitcast (void (...)* @vararg to void (i32)*)(i32 0)
86 call void (...) bitcast (void (i32)* @plain to void (...)*)(i32 0)
87 ret void
88 }