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

Optimize jl_tls_world_age ccall #54537

Merged
merged 1 commit into from
Jun 12, 2024
Merged

Optimize jl_tls_world_age ccall #54537

merged 1 commit into from
Jun 12, 2024

Conversation

gbaraldi
Copy link
Member

This makes it so we avoid a ccall boundary and potentially optimize away repeated world age checks

@gbaraldi gbaraldi requested a review from vtjnash May 21, 2024 17:36
src/ccall.cpp Outdated Show resolved Hide resolved
@gbaraldi
Copy link
Member Author

With the latest change we avoid any of the wird invariant.load stuff but it still lifts the check to a preheader in a function like

function foo(oc, arr)
       sum = 0.0
           for i in eachindex(arr)
               if (oc.world) == Base.tls_world_age()
                  sum += oc(arr[i])
               else
                   sum += arr[i]
               end
           end
       sum
       end

src/ccall.cpp Outdated Show resolved Hide resolved
src/codegen.cpp Outdated Show resolved Hide resolved
src/codegen.cpp Outdated Show resolved Hide resolved
src/ccall.cpp Outdated Show resolved Hide resolved
src/codegen.cpp Outdated Show resolved Hide resolved
src/ccall.cpp Outdated Show resolved Hide resolved
src/codegen.cpp Show resolved Hide resolved
src/codegen.cpp Outdated Show resolved Hide resolved
Copy link
Member

@topolarity topolarity left a comment

Choose a reason for hiding this comment

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

Nice! Thanks for iterating on this until all the details were right 👍

@gbaraldi gbaraldi added the merge me PR is reviewed. Merge when all tests are passing label Jun 7, 2024
@topolarity topolarity force-pushed the gb/optimize_world_age branch from 255ef33 to 70e96fe Compare June 12, 2024 02:14
@topolarity topolarity merged commit dfb2fd9 into master Jun 12, 2024
7 checks passed
@topolarity topolarity deleted the gb/optimize_world_age branch June 12, 2024 12:36
@oscardssmith oscardssmith added compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) and removed merge me PR is reviewed. Merge when all tests are passing labels Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:optimizer Optimization passes (mostly in base/compiler/ssair/)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants