[PATCH] D66508: [WebAssembly] Handle aliases in WebAssemblyFixFunctionBitcasts

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 21 12:59:00 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL369566: [WebAssembly] Handle aliases in WebAssemblyFixFunctionBitcasts (authored by sbc, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D66508?vs=216296&id=216450#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66508/new/

https://reviews.llvm.org/D66508

Files:
  llvm/trunk/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
  llvm/trunk/test/CodeGen/WebAssembly/function-bitcasts.ll


Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
===================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
+++ llvm/trunk/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)
Index: llvm/trunk/test/CodeGen/WebAssembly/function-bitcasts.ll
===================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/function-bitcasts.ll
+++ llvm/trunk/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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66508.216450.patch
Type: text/x-patch
Size: 1707 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190821/f651f3aa/attachment.bin>


More information about the llvm-commits mailing list