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

\n

More docs:

\n

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

","upvoteCount":1,"url":"https://github.com/WebAssembly/binaryen/discussions/7431#discussioncomment-12706558"}}}

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