[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:41:33 PST 2023
yamt updated this revision to Diff 493486.
yamt added a comment.
i added a 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,24 @@
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
+ at table = external local_unnamed_addr global [0 x ptr], align 4
+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.493486.patch
Type: text/x-patch
Size: 1554 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230131/3075a16e/attachment.bin>
More information about the llvm-commits
mailing list