GlobalStructInference: Handle nested optimizable global.gets#8019
Conversation
|
(diff without whitespace is smaller) |
| ;; CHECK-NEXT: ) | ||
| (func $caller (result anyref) | ||
| (call_ref $func | ||
| ;; TODO: If we did two passes, we could optimize this one too. |
There was a problem hiding this comment.
Why doesn't this get optimized via un-nesting as well?
There was a problem hiding this comment.
It would just take another pass. Maybe worth it as the TODO says.
(We could do it in a single pass with more complexity, or if we traversed in the other direction, in theory...)
There was a problem hiding this comment.
Oh, we can only do one level of un-nesting per pass because we're function-parallel and therefore cannot actually install the un-nested globals before we move on to the parent? That seems worth fixing! There's no reason why the globals wouldn't have very deep initialization trees, and we don't want to have to run this pass many times to fully optimize them.
There was a problem hiding this comment.
Yeah, it does seem worth fixing. We could perhaps just take a lock around global creation.
There was a problem hiding this comment.
Or maintain a per-function set of un-nested globals (with deterministic names) to be de-duplicated at the module level afterward.
When we un-nest, temporarily there is a global.get of a global we have not
yet created. Mark those so we don't read them and get confused.