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

IncrementalCompact: Don't corrupt CFG when finishing early #54298

Merged
merged 1 commit into from Apr 30, 2024

Conversation

Keno
Copy link
Member

@Keno Keno commented Apr 29, 2024

Finishing an IncrementalComapact before iterating the whole underlying IRCode is not something that we really do in base, or at least not in places other than a basic block boundary. However, it can be useful for downstream consumers, so make it work anyway. Also create a separate test file for IncrementalCompact tests (of which we really should have more) and move one existing test.

@Keno Keno requested a review from aviatesk April 29, 2024 06:53
compact = IncrementalCompact(ir)

insert_node_here!(compact, NewInstruction(ReturnNode(1), Union{}, ir[SSAValue(1)][:line]))
new_ir = complete(compact)
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Suggested change
new_ir = complete(compact)
new_ir = Core.Compiler.finish(compact)

Shouldn't we use finish, or complete + Core.Compiler.non_dce_finish!?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, probably, I got confused by the other test using complete. Although this does make me suspicious whether this whole thing shouldn't be in non_dce_finish! in the first place. It's already trying to finish the basic block there, it's just doing the wrong one. Let me make the adjustment.

Finishing an IncrementalComapact before iterating the whole underlying
IRCode is not something that we really do in base, or at least not in
places other than a basic block boundary. However, it can be useful
for downstream consumers, so make it work anyway. Also create a
separate test file for IncrementalCompact tests (of which we really
should have more) and move one existing test.
@Keno Keno merged commit 3c985f1 into master Apr 30, 2024
5 of 7 checks passed
@Keno Keno deleted the kf/compactearlyfinish branch April 30, 2024 00:39
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.

None yet

2 participants