Skip to content
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

SimplifyGlobals: Propagate constant globals into nested gets in other globals #6285

Merged
merged 2 commits into from
Feb 8, 2024

Conversation

kripken
Copy link
Member

@kripken kripken commented Feb 7, 2024

Before we propagated to the top level, but not to anything interior.

@kripken kripken requested a review from tlively February 7, 2024 23:05
@@ -659,10 +660,11 @@ struct SimplifyGlobals : public Pass {
// This is the init of a passive segment, which is null.
return;
}
if (auto* get = init->dynCast<GlobalGet>()) {
for (auto** getp : FindAllPointers<GlobalGet>(init).list) {
Copy link
Member

Choose a reason for hiding this comment

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

As a separate cleanup it might be nice to use the template parameter on FindAllPointers in the type of its list to avoid the need for a cast below.

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'll try, though I have a vague memory of that not working for a sad C++ey reason...

Comment on lines +22 to +25
(global $struct (ref $struct) (struct.new $struct
(global.get $a)
(global.get $b)
))
Copy link
Member

Choose a reason for hiding this comment

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

I'm sure this is already tested elsewhere, but it might be nice to see that a global.get where the value cannot be propagated (because it is a GC data allocation, for instance) does not interfere with propagation of the other global.gets.

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you mean by "does not interfere"? Like if it is in the middle between them?

Copy link
Member

Choose a reason for hiding this comment

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

Not in the middle, necessarily, but yeah, if this struct had another field initialized with another global.get, but that one couldn't be propagated.

@kripken kripken merged commit 4e0796d into WebAssembly:main Feb 8, 2024
14 checks passed
@kripken kripken deleted the prop.nested.glob branch February 8, 2024 01:20
radekdoulik pushed a commit to dotnet/binaryen that referenced this pull request Jul 12, 2024
… globals (WebAssembly#6285)

Before we propagated to the top level, but not to anything interior.
@gkdn gkdn mentioned this pull request Aug 31, 2024
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