summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/passes/Directize.cpp2
-rw-r--r--test/lit/passes/directize-wasm64.wast14
2 files changed, 15 insertions, 1 deletions
diff --git a/src/passes/Directize.cpp b/src/passes/Directize.cpp
index 7faf2e23a..93b3d04e7 100644
--- a/src/passes/Directize.cpp
+++ b/src/passes/Directize.cpp
@@ -130,7 +130,7 @@ private:
return CallUtils::Unknown{};
}
- Index index = c->value.getInteger();
+ Address index = c->value.getUnsigned();
// Check if index is invalid, or the type is wrong.
auto& flatTable = *table.flatTable;
diff --git a/test/lit/passes/directize-wasm64.wast b/test/lit/passes/directize-wasm64.wast
index 8c3a0623f..5a6b1f311 100644
--- a/test/lit/passes/directize-wasm64.wast
+++ b/test/lit/passes/directize-wasm64.wast
@@ -34,4 +34,18 @@
(i64.const 1)
)
)
+
+ ;; CHECK: (func $bar-32 (param $x i32) (param $y i32)
+ ;; CHECK-NEXT: (unreachable)
+ ;; CHECK-NEXT: )
+ (func $bar-32 (param $x i32) (param $y i32)
+ ;; As above, but the constant has 2**32 added to it. If we operate on a 32-bit
+ ;; index, we might think we can optimize to a call to $foo. Instead, we should
+ ;; see that this traps, and optimize to that.
+ (call_indirect (type $ii)
+ (local.get $x)
+ (local.get $y)
+ (i64.const 4294967297)
+ )
+ )
)