Skip to content

Is it possible to mark function as pure to optimize it out ignoring any side effects? #7431

Answered by kripken
GulgDev asked this question in Q&A
Discussion options

You must be logged in to vote

We do have an intrinsic for that, call.without.effects, that can mark a call (not a function, but you can mark all calls to a target) as having no effects. This is experimental and may change. Here is the test that shows its usage:

(func $unused
;; The result is unused, so we can remove the call.
(drop
(call $call.without.effects (ref.func $i))
)
)

More docs:

https://github.com/WebAssembly/binaryen?tab=readme-ov-file#intrinsics

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@GulgDev
Comment options

@kripken
Comment options

Answer selected by GulgDev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants