Skip to content

Conversation

kripken
Copy link
Member

@kripken kripken commented Oct 2, 2025

An exported global can have extra uses, which prevent folding its value
into others.

@kripken kripken requested a review from tlively October 2, 2025 15:28
@kripken
Copy link
Member Author

kripken commented Oct 2, 2025

(found by fuzzing wasm-split: the globals were exported and read from a second module, that then noticed the bug)

(global $B (ref $struct) (global.get $A))

;; CHECK: (export "A" (global $A))
(export "A" (global $A))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could still optimize by exporting $B instead. Maybe worth considering as a follow-up?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a TODO, that might be possible, not sure offhand about corner cases though.

@kripken kripken merged commit ebe21ca into WebAssembly:main Oct 2, 2025
16 checks passed
@kripken kripken deleted the sg.exp.fold branch October 2, 2025 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants