Skip to content

RemoveUnusedBrs: Make branches to traps just trap themselves#8398

Merged
kripken merged 7 commits intoWebAssembly:mainfrom
kripken:rubrs.trap
Feb 27, 2026
Merged

RemoveUnusedBrs: Make branches to traps just trap themselves#8398
kripken merged 7 commits intoWebAssembly:mainfrom
kripken:rubrs.trap

Conversation

@kripken
Copy link
Member

@kripken kripken commented Feb 27, 2026

We already did jump threading, folding a br->br to a single br. This
does br->trap into a trap.

@kripken kripken requested a review from tlively February 27, 2026 00:15
Comment on lines 1230 to 1231
if (child->name.is() && child->name != curr->name &&
child->type == curr->type) {
Copy link
Member

Choose a reason for hiding this comment

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

Possible drive-by or follow-on improvement. The outer block cannot be unreachable unless its single child is also unreachable, so no need to check the outer type. The outer block may have a strict supertype of the inner block, but that would be ok.

Suggested change
if (child->name.is() && child->name != curr->name &&
child->type.isConcrete()) {

Copy link
Member Author

Choose a reason for hiding this comment

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

sg, I can look into that later.

Comment on lines 1244 to 1245
// Anything branching to the child will end up in that second
// instruction |after|.
Copy link
Member

Choose a reason for hiding this comment

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

Please add a mention of the cases of |after| we will optimize.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Comment on lines +50 to +51
(call $import)
(call $import)
Copy link
Member

Choose a reason for hiding this comment

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

What's the purpose of having two calls here?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's nice to help differentiate the if arms. could also have been a call param.

Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to port this to lit! Then I would be able to see what test input corresponds to the changed output.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can port this test after, or do you want it first?

Copy link
Member

Choose a reason for hiding this comment

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

After is fine.

@kripken kripken merged commit 9ee4a25 into WebAssembly:main Feb 27, 2026
17 checks passed
@kripken kripken deleted the rubrs.trap branch February 27, 2026 17:36
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