Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Wasm64] Fix PostEmscripten::optimizeExceptions on invokes with an i64 argument #6074

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/passes/PostEmscripten.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ struct PostEmscripten : public Pass {
// The first operand is the function pointer index, which must be
// constant if we are to optimize it statically.
if (auto* index = curr->operands[0]->dynCast<Const>()) {
size_t indexValue = index->value.geti32();
size_t indexValue = index->value.getInteger();
if (indexValue >= flatTable.names.size()) {
// UB can lead to indirect calls to invalid pointers.
return;
Expand Down
31 changes: 31 additions & 0 deletions test/lit/passes/post-emscripten-64.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; RUN: wasm-opt %s --post-emscripten -all -S -o - | filecheck %s

;; Test we do not error on invoke calls that take an i64 index (which is the
;; case in wasm64). Nothing should change here.

(module
;; CHECK: (type $0 (func (param i64)))

;; CHECK: (type $1 (func))

;; CHECK: (import "env" "invoke_v" (func $invoke (type $0) (param i64)))
(import "env" "invoke_v" (func $invoke (param i64)))

;; CHECK: (table $0 269 269 funcref)
(table $0 269 269 funcref)
;; CHECK: (elem $0 (i32.const 1))
(elem $0 (i32.const 1))

;; CHECK: (func $0 (type $1)
;; CHECK-NEXT: (call $invoke
;; CHECK-NEXT: (i64.const 42)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $0
(call $invoke
(i64.const 42)
)
)
)

Loading