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

Inlining/Finalizer-elimination cleanup refactor #46700

Merged
merged 1 commit into from
Sep 11, 2022
Merged

Conversation

Keno
Copy link
Member

@Keno Keno commented Sep 11, 2022

This started as an attempt to fix the broken test at [1], but I don't actually think that test ever worked. I still intend to fix that, but this PR is prepratory, merging code paths that basically did identical things, but were incomplete in some cases. Also some general quality improvements. The test case in question is better now (everything gets inlined and it's down to needing to prove that the finalizer itself is inlineable and the mutable :new is eliminable), but not quite fixed.

[1] https://github.com/JuliaLang/julia/blob/master/test/compiler/inline.jl#L1306

This started as an attempt to fix the broken test at [1], but I don't actually
think that test ever worked. I still intend to fix that, but this PR is prepratory,
merging code paths that basically did identical things, but were incomplete in some
cases. Also some general quality improvements. The test case in question is better
now (everything gets inlined and it's down to needing to prove that the finalizer
itself is inlineable and the mutable :new is eliminable), but not quite fixed.

[1] https://github.com/JuliaLang/julia/blob/master/test/compiler/inline.jl#L1306
@Keno Keno merged commit 83f10ac into master Sep 11, 2022
@Keno Keno deleted the kf/inlinecleanup branch September 11, 2022 02:38
if inline::Bool && try_inline_finalizer!(ir, argexprs, maxval, mi, inlining)
# the finalizer body has been inlined
flags = info === nothing ? UInt8(0) : flags_for_effects(info.effects)
if length(finalizer_stmt.args) >= 4
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be length(finalizer_stmt.args) >= 5?

end
else
insert_node!(ir, maxval, with_flags(NewInstruction(Expr(:call, argexprs...), Nothing), flags), true)
Copy link
Member

@aviatesk aviatesk Sep 12, 2022

Choose a reason for hiding this comment

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

So is my understanding right that this branch is for generating Core.finalizer call expression that may be handled by the second run of this optimization pass?

EDIT: or maybe for external consumers who may run the inlining pass and SROA pass in a different order?

Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

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

LGTM

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.

3 participants