Skip to content

Commit a10bdb0

Browse files
tlivelyradekdoulik
authored andcommitted
Fix printing of types for imported functions (WebAssembly#5927)
Previously, the printer incorrectly reconstructed imported functions' types from their signatures instead of printing their types directly. This could cause the printer to print uses of types that were never defined and did not exist in the module. Fix the bug by printing imported functions' heap types directly.
1 parent 9729846 commit a10bdb0

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

src/passes/Print.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2846,7 +2846,7 @@ void PrintSExpression::visitImportedFunction(Function* curr) {
28462846
lastPrintedLocation = {0, 0, 0};
28472847
o << '(';
28482848
emitImportHeader(curr);
2849-
handleSignature(curr->getSig(), curr->name);
2849+
handleSignature(curr->type, curr->name);
28502850
o << ')';
28512851
o << maybeNewLine;
28522852
}

test/lit/passes/signature-pruning.wast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@
398398

399399
;; As above, but now an import also uses this signature, which prevents us
400400
;; from changing anything.
401-
;; CHECK: (import "out" "func" (func $import (type $func.0) (param i32)))
401+
;; CHECK: (import "out" "func" (func $import (type $sig) (param i32)))
402402
(import "out" "func" (func $import (type $sig) (param i32)))
403403

404404
(memory 1 1)

test/lit/passes/signature-refining.wast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@
918918

919919
;; CHECK: (type $8 (func (param funcref) (result (ref $C))))
920920

921-
;; CHECK: (import "binaryen-intrinsics" "call.without.effects" (func $no.side.effects (type $func.0) (param funcref) (result (ref null $A))))
921+
;; CHECK: (import "binaryen-intrinsics" "call.without.effects" (func $no.side.effects (type $6) (param funcref) (result (ref null $A))))
922922
(import "binaryen-intrinsics" "call.without.effects" (func $no.side.effects
923923
(param funcref)
924924
(result (ref null $A))

test/lit/wat-kitchen-sink.wast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@
168168

169169
;; CHECK: (import "mod" "" (global $gimport$1 (ref null $many)))
170170

171-
;; CHECK: (import "mod" "f5" (func $fimport$1 (type $func.0)))
171+
;; CHECK: (import "mod" "f5" (func $fimport$1 (type $void)))
172172

173173
;; CHECK: (global $2 (mut i32) (i32.const 0))
174174

0 commit comments

Comments
 (0)