[1.13] backport optimizer support for invoke(f, ::CodeInstance, args...)#60813
Closed
MasonProtter wants to merge 2 commits intoJuliaLang:backports-release-1.13from
Closed
Conversation
…Lang#60442) ~~(I wrote this with assistance from Gemini since I'm not very used to writing LLVM IR)~~ No longer using that code This is an attempt to fix JuliaLang#60441. After bumbling around a bit, it seems that the problem is that `invoke(f, ::CodeInstance, args...)` calls are not turned into `Expr(:invoke` statements in the IR, but remains as `:call`s to the `invoke` builtin which ends up going through the runtime. ~~There's probably a better way to do this, but the way I found was to just detect these builtin calls in the LLVM IR, and send them to `emit_invoke`.~~ I'm now detecting `InvokeCICallInfo`s in the inlining step of the optimizer and turning those into `Expr(:invoke`s. It appears to resolve the issue: ```julia using BenchmarkTools mysin(x::Float64) = sin(x) @Assert mysin(1.0) == sin(1.0) const mysin_ci = Base.specialize_method(Base._which(Tuple{typeof(mysin), Float64})).cache ``` Before this PR: ```julia julia> @Btime invoke(mysin, mysin_ci, x) setup=(x=rand()) 24.952 ns (2 allocations: 32 bytes) 0.7024964043721993 ``` After this PR: ```julia julia> @Btime invoke(mysin, mysin_ci, x) setup=(x=rand()) 4.748 ns (0 allocations: 0 bytes) 0.32283046823183426 ```
Contributor
Author
|
Already backported in 00737ca |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Backport of PR #60442