Skip to content

Commit a9829f9

Browse files
authored
LegalizeJSInterface: Fix up RefFuncs in global code too (#8061)
Without this, after we turn an import into an internal function, a `ref.func` in a global init might not get updated to inexact, and error in the fuzzer.
1 parent 06b1579 commit a9829f9

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/passes/LegalizeJSInterface.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ struct LegalizeAndPruneJSInterface : public LegalizeJSInterface {
412412

413413
// RefFunc types etc. need updating.
414414
ReFinalize().run(getPassRunner(), module);
415+
ReFinalize().runOnModuleCode(getPassRunner(), module);
415416

416417
// TODO: globals etc.
417418
}

test/lit/passes/legalize-and-prune-js-interface.wast

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@
4545

4646
;; CHECK: (import "env" "imported-64" (func $legalimport$imported-64 (type $9) (param i32 f64) (result i32)))
4747

48+
;; CHECK: (global $global funcref (ref.func $imported-v128))
49+
(global $global funcref
50+
;; The ref target will turn from an import into an internal function. We'd
51+
;; error if we do not update this ref.func while doing so, to make its type
52+
;; exact.
53+
(ref.func $imported-v128)
54+
)
55+
4856
;; CHECK: (func $imported-v128 (type $0) (result v128)
4957
;; CHECK-NEXT: (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000)
5058
;; CHECK-NEXT: )

0 commit comments

Comments
 (0)