Skip to content
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
8 changes: 4 additions & 4 deletions src/ir/module-splitting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -979,13 +979,13 @@ void ModuleSplitter::indirectReferencesToSecondaryFunctions() {
gatherer.walkModule(secondaryPtr.get());
}

// Ignore references to secondary functions that occur in the active segment
// Ignore references to secondary functions that occur in the active segments
// that will contain the imported placeholders. Indirect calls to table slots
// initialized by that segment will already go to the right place once the
// initialized by those segments will already go to the right place once the
// secondary module has been loaded and the table has been patched.
std::unordered_set<RefFunc*> ignore;
if (tableManager.activeSegment) {
for (auto* expr : tableManager.activeSegment->data) {
for (auto* segment : tableManager.activeTableSegments) {
for (auto* expr : segment->data) {
if (auto* ref = expr->dynCast<RefFunc>()) {
ignore.insert(ref);
}
Expand Down
34 changes: 34 additions & 0 deletions test/lit/wasm-split/trampoline-ignore-active-segments.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.
;; RUN: wasm-split %s --disable-reference-types --split-funcs=split -g -o1 %t.1.wasm -o2 %t.2.wasm
;; RUN: wasm-dis %t.1.wasm | filecheck %s --check-prefix PRIMARY

;; Regression test for a bug that we incorrectly created a trampoline for
;; (elem $e0 (i32.const 0) $split) segment, even though it was one of active
;; segments.

(module
;; PRIMARY: (type $0 (func))
(type $0 (func))
;; PRIMARY: (table $active_table 2 2 funcref)
(table $active_table 2 2 funcref)
;; PRIMARY: (elem $e0 (i32.const 0) $placeholder_0)

;; PRIMARY: (elem $e1 (i32.const 1) $keep)

;; PRIMARY: (export "active_table" (table $active_table))
(export "active_table" (table $active_table))

(elem $e0 (i32.const 0) $split)
(elem $e1 (i32.const 1) $keep)

;; PRIMARY: (func $keep
;; PRIMARY-NEXT: (nop)
;; PRIMARY-NEXT: )
(func $keep (type $0)
(nop)
)

(func $split (type $0)
(nop)
)
)
Loading