[llvm] r369566 - [WebAssembly] Handle aliases in WebAssemblyFixFunctionBitcasts
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 21 12:52:33 PDT 2019
Author: sbc
Date: Wed Aug 21 12:52:33 2019
New Revision: 369566
URL: http://llvm.org/viewvc/llvm-project?rev=369566&view=rev
Log:
[WebAssembly] Handle aliases in WebAssemblyFixFunctionBitcasts
Fixes: https://github.com/emscripten-core/emscripten/issues/8770
Differential Revision: https://reviews.llvm.org/D66508
Modified:
llvm/trunk/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
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=369566&r1=369565&r2=369566&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp Wed Aug 21 12:52:33 2019
@@ -70,6 +70,8 @@ static void findUses(Value *V, Function
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)
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=369566&r1=369565&r2=369566&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/function-bitcasts.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/function-bitcasts.ll Wed Aug 21 12:52:33 2019
@@ -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 @@ entry:
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
More information about the llvm-commits
mailing list