-
Notifications
You must be signed in to change notification settings - Fork 838
Intrinsic: binaryen.removable.if.unused #8268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Regarding the name: do the semantics match any of the existing GCC attributes of |
|
@dschuff Sadly I don't think they match those. gcc's Concretely, this is valid in gcc: x = pure();
foo();
bar(x);
=>
foo();
bar(pure()); // pure function pushed past foo(), which it cannot interact withBut that is not valid if |
|
Maybe |
|
@tlively I think more than removability is possible, though. The full meaning is "has no effects if the value is not used". Perhaps To clarify what I mean by more than removability being possible: imagine some code cannot be removed for technical, type-system or IR structure reasons. It might still be useful to know it has no effects. Not a great example, but: (drop
(block $block (result (ref $A))
(br_if $block
(local.get $value)
(local.get $condition)
)
(call $dead.if.unused)
)
)
(call $foo)The |
|
IIUC, we cannot move it past the |
|
Ah, do you mean because the call might trap or throw? Fair enough. So amend my example to replace |
|
No, we couldn't move a call with this annotation past a |
|
Ok, after discussion offline I agree @tlively 's approach is better here. So I think renaming to This also means that the optimization in this PR is the only thing the intrinsic allows: literally removing it from its current position, in Vacuum, and nothing else. |
|
Updated to the final name |
Co-authored-by: Thomas Lively <[email protected]>
Co-authored-by: Thomas Lively <[email protected]>
Based on discussion in
#7574 (comment)
the
@binaryen.removable.if.unusedcode annotation has the meaning thatif the result is unused (dropped), then the code can be considered
dead (no side effects, removable).
This can be used on a function to affect all calls to it, or on specific
call instructions. The optimizer then finds relevant dropped calls and
can remove them (in Vacuum).
Bikeshedding welcome on the name.
edit: updated, original name was
dead.if.unused