Skip to content

Commit 9438ce1

Browse files
authored
Print tables for call_indirects for nonzero table index (#7843)
Rather than always printing the table like in #7839, this prints the table only when either reference types is enabled or the table index is not 0 (even if the features section or `--enable-reference-types` is not provided) This addresses the concern in #7802, while not printing table when it is not necessary. There is no test changes because - At the moment wasm-dis enables all features so wasm-dis always prints tables in `call_indirect`s. This will change in #7840. - wasm-opt results didn't print table so far when reference-types is not enabled, and all `call_indirect`s in those tests have table index 0.
1 parent 11d3aef commit 9438ce1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/passes/Print.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,13 @@ struct PrintExpressionContents
503503
printMedium(o, "call_indirect ");
504504
}
505505

506-
if (features.hasReferenceTypes()) {
506+
// Even if reference-types is not enabled because the features section or
507+
// the matching command-line flags are not present, if the table index is
508+
// greater than 0, we print the table because otherwise the results will be
509+
// incorrect.
510+
if (features.hasReferenceTypes() ||
511+
(wasm && !wasm->tables.empty() &&
512+
wasm->tables[0]->name != curr->table)) {
507513
curr->table.print(o);
508514
o << ' ';
509515
}

0 commit comments

Comments
 (0)