[LowerClasses] Stop cloning operations one at a time, NFCI. #7822
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The previous implementation would clone operations from the original module-like body to the new OM class body one at a time, maintaining an IRMapping as it went. This becomes a pretty bad performance bottleneck as the IR size increases, and the DenseMap within IRMapping starts to dominate.
Instead, this clones the entire region wholesale, and splices the body into the new OM class op. It then traverses both the original module-like and the OM class op to clean up each side: removing property ops from the module-like, and removing non-property ops from the OM class op.
This should be a non-functional change, but should dramatically help with scalability of this pass.