Skip to content

Comments

Preserve CallMeta results during inference#640

Merged
serenity4 merged 5 commits intomasterfrom
serenity4/callmeta
May 13, 2025
Merged

Preserve CallMeta results during inference#640
serenity4 merged 5 commits intomasterfrom
serenity4/callmeta

Conversation

@serenity4
Copy link
Collaborator

Store CallMeta information emitted as a result of call inference, so that we may use it during analysis once inference is done. It should theoretically provide more refined rt/exct/effects values, and it additionally contains refinements information should we ever want to support introspecting into that (which could prove helpful e.g. for JuliaLang/julia#57651).

This is performed by defining CthulhuCallInfo <: CC.CallInfo which is used as a wrapper for (almost) all CC.CallInfo structures, applied right after inference and propagated throughout optimization (notably, through inlining). Special handling had to be done for CC.UnionSplitApplyCallInfo, but as far I as am aware this should not be limiting in any way.

We might be able to refactor and trim a few of our CallInfo structures with this change, I plan to tackle that next. In the current state, I think this can be merged safely to keep changes incremental and small, if we are willing to commit to this design.
I'd be happy to have any pointers on which example may bring to light the theoretical improvements of keeping CallMeta information for rt/exct/effects, so we can add a test and have this PR be a clear and net improvement overall.

Many thanks to @aviatesk for suggesting this approach and paving the way with explanations on how to integrate custom CC.CallInfo into the compilation pipeline.

@serenity4
Copy link
Collaborator Author

@aviatesk would you have some time to take a look?

@aviatesk aviatesk self-requested a review May 5, 2025 10:24
Keno added a commit to JuliaLang/julia that referenced this pull request May 6, 2025
This makes invoke inlining work for CallInfo wrappers, e.g.
- JuliaComputing/DAECompiler.jl#23
- JuliaDebug/Cthulhu.jl#640

I think this is probably the cleanest way to do it. Other ways
might be to refactor InvokeCallInfo to wrap around a generic
call info, but we already have this interface for callinfos, so
might as well try to use it.
Keno added a commit to JuliaLang/julia that referenced this pull request May 8, 2025
This makes invoke inlining work for CallInfo wrappers, e.g.
- JuliaComputing/DAECompiler.jl#23
- JuliaDebug/Cthulhu.jl#640

I think this is probably the cleanest way to do it. Other ways
might be to refactor InvokeCallInfo to wrap around a generic
call info, but we already have this interface for callinfos, so
might as well try to use it.
Keno added a commit to JuliaLang/julia that referenced this pull request May 9, 2025
This makes invoke inlining work for CallInfo wrappers, e.g.
- JuliaComputing/DAECompiler.jl#23
- JuliaDebug/Cthulhu.jl#640

I think this is probably the cleanest way to do it. Other ways might be
to refactor InvokeCallInfo to wrap around a generic call info, but we
already have this interface for callinfos, so might as well try to use
it.
charleskawczynski pushed a commit to charleskawczynski/julia that referenced this pull request May 12, 2025
This makes invoke inlining work for CallInfo wrappers, e.g.
- JuliaComputing/DAECompiler.jl#23
- JuliaDebug/Cthulhu.jl#640

I think this is probably the cleanest way to do it. Other ways might be
to refactor InvokeCallInfo to wrap around a generic call info, but we
already have this interface for callinfos, so might as well try to use
it.
Copy link
Member

@aviatesk aviatesk left a comment

Choose a reason for hiding this comment

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

Sorry for the significant delay in reviewing this.
I think the overall approach and implementation look good. Thanks.
The necessary special case for UnionSplitApplyCallInfo is a bit of a pain, but I think it's okay to hold off on a fundamental fix (like preparing an interface on the inlining algorithm side) until we actually run into an issue.
LGTM.

@serenity4
Copy link
Collaborator Author

serenity4 commented May 13, 2025

No worries, I understand you've been quite busy these days :) thanks for the review!
I 100% agree with your comment on UnionSplitApplyCallInfo.

@serenity4 serenity4 merged commit 52bf170 into master May 13, 2025
6 of 7 checks passed
@timholy timholy deleted the serenity4/callmeta branch August 31, 2025 08:01
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