[PATCH] D142615: [WebAssembly] Fix tail call with return_call_indirect instruction

YAMAMOTO Takashi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 30 22:44:21 PST 2023


yamt updated this revision to Diff 493487.
yamt added a comment.

remove an unnecessary line in the test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142615

Files:
  llvm/lib/Target/WebAssembly/WebAssemblyInstrCall.td
  llvm/test/CodeGen/WebAssembly/tailcall.ll


Index: llvm/test/CodeGen/WebAssembly/tailcall.ll
===================================================================
--- llvm/test/CodeGen/WebAssembly/tailcall.ll
+++ llvm/test/CodeGen/WebAssembly/tailcall.ll
@@ -257,6 +257,23 @@
   ret i32 %v
 }
 
+; Note: the second global.set is to restore the SP.
+; CHECK-LABEL: alloca_and_indirect_tail_call
+; CHECK: global.get $push{{[0-9]+}}=, __stack_pointer
+; CHECK: global.set __stack_pointer, $pop{{[0-9]+}}
+; CHECK: global.set __stack_pointer, $pop{{[0-9]+}}
+; CHECK: return_call_indirect , $0, $1
+declare void @do_something(ptr)
+define i32 @alloca_and_indirect_tail_call(ptr %p) {
+  ; consume stack
+  %a = alloca i8
+  call void @do_something(ptr %a)
+
+  %f = load ptr, ptr %p
+  %v = musttail call i32 %f(ptr %p)
+  ret i32 %v
+}
+
 ; CHECK-LABEL: .section .custom_section.target_features
 ; CHECK-NEXT: .int8 1
 ; CHECK-NEXT: .int8 43
Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrCall.td
===================================================================
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrCall.td
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrCall.td
@@ -73,7 +73,7 @@
     "return_call    \t$callee", "return_call\t$callee", 0x12>,
   Requires<[HasTailCall]>;
 
-let isReturn = 1 in
+let isReturn = 1, isTerminator = 1, hasCtrlDep = 1, isBarrier = 1 in
 defm RET_CALL_INDIRECT :
   I<(outs), (ins TypeIndex:$type, table32_op:$table, variable_ops),
     (outs), (ins TypeIndex:$type, table32_op:$table), [],


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142615.493487.patch
Type: text/x-patch
Size: 1490 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230131/ab9db4e7/attachment.bin>


More information about the llvm-commits mailing list