[PATCH] D66508: [WebAssembly] Handle aliases in WebAssemblyFixFunctionBitcasts
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 20 17:25:29 PDT 2019
sbc100 created this revision.
Herald added subscribers: llvm-commits, sunfish, aheejin, hiraditya, jgravelle-google, dschuff.
Herald added a project: LLVM.
sbc100 edited the summary of this revision.
sbc100 added reviewers: jgravelle-google, kripken.
Fixes: https://github.com/emscripten-core/emscripten/issues/8770
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D66508
Files:
llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
llvm/test/CodeGen/WebAssembly/function-bitcasts.ll
Index: llvm/test/CodeGen/WebAssembly/function-bitcasts.ll
===================================================================
--- llvm/test/CodeGen/WebAssembly/function-bitcasts.ll
+++ llvm/test/CodeGen/WebAssembly/function-bitcasts.ll
@@ -5,7 +5,11 @@
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown"
-declare void @has_i32_arg(i32)
+define void @has_i32_arg(i32) {
+entry:
+ ret void
+}
+
declare void @has_struct_arg({i32})
declare i32 @has_i32_ret()
declare void @vararg(...)
@@ -54,6 +58,19 @@
ret void
}
+; Calling aliases should also generate a wrapper
+
+ at alias_i32_arg = weak hidden alias void (i32), void (i32)* @has_i32_arg
+
+; CHECK-LABEL: test_alias:
+; CHECK: call .Lhas_i32_arg_bitcast.2
+define void @test_alias() {
+entry:
+ call void bitcast (void (i32)* @alias_i32_arg to void ()*)()
+ ret void
+}
+
+
; CHECK-LABEL: test_structs:
; CHECK: call .Lhas_i32_arg_bitcast.1, $pop{{[0-9]+}}, $pop{{[0-9]+$}}
; CHECK: call .Lhas_i32_arg_bitcast, $0, $pop2
Index: llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
===================================================================
--- llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
@@ -70,6 +70,8 @@
for (Use &U : V->uses()) {
if (auto *BC = dyn_cast<BitCastOperator>(U.getUser()))
findUses(BC, F, Uses, ConstantBCs);
+ else if (auto *A = dyn_cast<GlobalAlias>(U.getUser()))
+ findUses(A, F, Uses, ConstantBCs);
else if (U.get()->getType() != F.getType()) {
CallSite CS(U.getUser());
if (!CS)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66508.216296.patch
Type: text/x-patch
Size: 1671 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190821/7a726117/attachment-0001.bin>
More information about the llvm-commits
mailing list