[PATCH] D115327: [WebAssembly] Fix reftype load/store match with idx from call
Paulo Matos via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 8 03:28:40 PST 2021
pmatos created this revision.
pmatos added a reviewer: tlively.
Herald added subscribers: ecnelises, sunfish, hiraditya, jgravelle-google, sbc100, dschuff.
pmatos requested review of this revision.
Herald added subscribers: llvm-commits, aheejin.
Herald added a project: LLVM.
Implement support for matching an index from a WebAssembly CALL
instruction. Add test.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D115327
Files:
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/test/CodeGen/WebAssembly/externref-tableset.ll
Index: llvm/test/CodeGen/WebAssembly/externref-tableset.ll
===================================================================
--- llvm/test/CodeGen/WebAssembly/externref-tableset.ll
+++ llvm/test/CodeGen/WebAssembly/externref-tableset.ll
@@ -79,4 +79,19 @@
ret void
}
+declare i32 @get_table_id() local_unnamed_addr
+
+define void @set_externref_table_with_id_from_call(%externref %g) {
+; CHECK-LABEL: set_externref_table_with_id_from_call:
+; CHECK-NEXT: .functype set_externref_table_with_id_from_call (externref) -> ()
+; CHECK-NEXT: call get_table_id
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: table.set externref_table
+; CHECK-NEXT: end_function
+ %id = call i32 @get_table_id()
+ %p = getelementptr [0 x %externref], [0 x %externref] addrspace (1)* @externref_table, i32 0, i32 %id
+ store %externref %g, %externref addrspace(1)* %p
+ ret void
+}
+
; CHECK: .globl externref_table
Index: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
===================================================================
--- llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -1489,7 +1489,9 @@
if (GA) {
// We are in Case 2 above.
Idx = Base->getOperand(1);
- if (!Idx || GA->getNumValues() != 1 || Idx->getNumValues() != 1)
+ if (!Idx || GA->getNumValues() != 1 ||
+ (Idx->getOpcode() != WebAssemblyISD::CALL &&
+ Idx->getNumValues() != 1))
return false;
} else {
// This might be Case 1 above (or an error)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115327.392702.patch
Type: text/x-patch
Size: 1583 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211208/144d3d5a/attachment.bin>
More information about the llvm-commits
mailing list