Skip to content

OptimizeInstructions: Check mayNotReturn when refining ref.cast under TNH - #9256

Merged
tlively merged 1 commit into
WebAssembly:mainfrom
tamaroning:optimize-instructions-tnh-cast-maynotreturn
Oct 16, 2026
Merged

tlively merged 1 commit into
WebAssembly:mainfrom
tamaroning:optimize-instructions-tnh-cast-maynotreturn

Conversation

@tamaroning

Copy link
Copy Markdown
Contributor

fix #9246

Comment thread src/passes/OptimizeInstructions.cpp Outdated
// trap in the child either, unless control flow transfers and we
// might not reach the parent.
// trap in the child either.
// TODO: handle more cases.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It might be even simpler to create an EffectAnalyzer with just the trap effect set, then check whether it is orderedBefore the effects of all the later children. Then we wouldn't have to list the particular effects we care about here or manually check trapsNeverHappen. That would also resolve this TODO. What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Totally agreed. That would be much simpler 👍

@tamaroning
tamaroning force-pushed the optimize-instructions-tnh-cast-maynotreturn branch from 38cc29c to 1ff244a Compare October 16, 2026 05:53

@tlively tlively left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@tlively
tlively merged commit c8a002d into WebAssembly:main Oct 16, 2026
16 checks passed
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.

OptimizeInstructions: --tnh makes ref.cast non-nullable before a possibly infinite loop

2 participants