Skip to content

Commit

Permalink
Fix FlatTable for table64 (#6598)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 committed May 16, 2024
1 parent e5f2edf commit 85f677a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/ir/table-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct FlatTable {
valid = false;
return;
}
Index start = offset->cast<Const>()->value.geti32();
Index start = offset->cast<Const>()->value.getInteger();
Index size = segment->data.size();
Index end;
if (std::ckd_add(&end, start, size) || end > table.initial) {
Expand Down
16 changes: 12 additions & 4 deletions test/lit/passes/directize_all-features.wast
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,23 @@
;; CHECK: (table $0 5 5 funcref)
;; IMMUT: (table $0 5 5 funcref)
(table $0 5 5 funcref)
(elem (i32.const 1) $foo)
;; CHECK: (table $t64 i64 5 5 funcref)

;; CHECK: (elem $0 (i32.const 1) $foo)
;; CHECK: (elem $elem (table $0) (i32.const 1) func $foo)
;; IMMUT: (table $t64 i64 5 5 funcref)

;; IMMUT: (elem $elem (table $0) (i32.const 1) func $foo)
(elem $elem (i32.const 1) $foo)

(table $t64 i64 5 5 funcref)

;; CHECK: (elem $elem64 (table $t64) (i64.const 1) func $foo)
;; IMMUT: (elem $elem64 (table $t64) (i64.const 1) func $foo)
(elem $elem64 (table $t64) (i64.const 1) funcref (ref.func $foo))

;; CHECK: (func $foo (type $ii) (param $0 i32) (param $1 i32)
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
;; IMMUT: (elem $0 (i32.const 1) $foo)

;; IMMUT: (func $foo (type $ii) (param $0 i32) (param $1 i32)
;; IMMUT-NEXT: (unreachable)
;; IMMUT-NEXT: )
Expand Down

0 comments on commit 85f677a

Please sign in to comment.