[llvm] 97ef15a - [WebAssembly] Fix reftype load/store match with idx from call
Paulo Matos via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 13 02:05:05 PST 2022
Author: Paulo Matos
Date: 2022-01-13T11:04:22+01:00
New Revision: 97ef15ad769715b673fa5791776de34ec92692ac
URL: https://github.com/llvm/llvm-project/commit/97ef15ad769715b673fa5791776de34ec92692ac
DIFF: https://github.com/llvm/llvm-project/commit/97ef15ad769715b673fa5791776de34ec92692ac.diff
LOG: [WebAssembly] Fix reftype load/store match with idx from call
Implement support for matching an index from a WebAssembly CALL
instruction. Add test.
Reviewed By: tlively
Differential Revision: https://reviews.llvm.org/D115327
Added:
Modified:
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/test/CodeGen/WebAssembly/externref-tableset.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
index 38ed4c73fb935..5a505ddfc1122 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -1491,8 +1491,7 @@ bool WebAssemblyTargetLowering::MatchTableForLowering(SelectionDAG &DAG,
if (GA) {
// We are in Case 2 above.
Idx = Base->getOperand(1);
- if (!Idx || GA->getNumValues() != 1 || Idx->getNumValues() != 1)
- return false;
+ assert(GA->getNumValues() == 1);
} else {
// This might be Case 1 above (or an error)
SDValue V = Base->getOperand(0);
diff --git a/llvm/test/CodeGen/WebAssembly/externref-tableset.ll b/llvm/test/CodeGen/WebAssembly/externref-tableset.ll
index 025fb037328e1..bd5ad6942fcda 100644
--- a/llvm/test/CodeGen/WebAssembly/externref-tableset.ll
+++ b/llvm/test/CodeGen/WebAssembly/externref-tableset.ll
@@ -79,4 +79,19 @@ define void @set_externref_table_with_var_offset2(%externref %g, i32 %i) {
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: .tabletype externref_table, externref
More information about the llvm-commits
mailing list