[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 08:39:41 PST 2021
pmatos updated this revision to Diff 392798.
pmatos added a comment.
Make the fix slightly more generic. I have found while writing LLVM IR with lots of usage of store and loads on reference types and intrinsics, that there are several cases where the Idx to the table can be the result of a call or copy from reg, etc. These have 2 values, the main value and the chain so checking if the Idx has a single value is the wrong approach. This seems to work as by default we use the first value of the Node and we don't need to impose any restrictions on it. The only case this could possibly fail is if we get a Node whose value we want to use is not the first value but I cannot imagine a case where that could happen and I didn't come accross it.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D115327/new/
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_slot() 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_slot
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: table.set externref_table
+; CHECK-NEXT: end_function
+ %id = call i32 @get_table_slot()
+ %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,7 @@
if (GA) {
// We are in Case 2 above.
Idx = Base->getOperand(1);
- if (!Idx || GA->getNumValues() != 1 || Idx->getNumValues() != 1)
+ if (Idx.isUndef() || GA->getNumValues() != 1)
return false;
} else {
// This might be Case 1 above (or an error)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115327.392798.patch
Type: text/x-patch
Size: 1501 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211208/465602aa/attachment.bin>
More information about the llvm-commits
mailing list