-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
codegen: add a pass for late conversion of known modify ops to call atomicrmw #57010
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
base: master
Are you sure you want to change the base?
Conversation
Why is there such a large aotcompile.cpp diff? Looks unrelated |
It is mostly support code for this, since if you don't have the IR emitted for the target, then it has to use a loop&call, which isn't want people want to see, so we need to make sure to emit the target code too into all of the correct compile units. We could land some of it separately, but it wouldn't do anything (be mostly untested) until this landed |
666985c
to
c98b43f
Compare
Is this ready to merge? Edit: no. CI seems pretty unhappy with this currently. |
Also there's a merge conflict. |
Please review, but hold off on merging. I think there might be one other PR I try to merge first |
CI failures look real: Specifically the following seems to be a multithreading test that breaks with this PR:
|
67ad4b6
to
dbecbe8
Compare
@@ -9476,7 +9552,7 @@ static jl_llvm_functions_t | |||
Instruction &prologue_end = ctx.builder.GetInsertBlock()->back(); | |||
|
|||
// step 11a. Emit the entry safepoint | |||
if (JL_FEAT_TEST(ctx, safepoint_on_entry)) | |||
if (params.safepoint_on_entry && JL_FEAT_TEST(ctx, safepoint_on_entry)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks weird, shouldn't ctx be derived from params?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ctx derives from params.params not params (I agree the naming choice here was a choice)
dbecbe8
to
7eb8691
Compare
…tomicrmw The ExpandAtomicModify can recognize our pseudo-intrinsic julia.atomicmodify and convert it into some of known atomicrmw expressions, or simplify it with more inlining, as applicable. This ensures that now our `@atomic` modify is as fast as `Threads.Atomic` for the cases we implement now.
7eb8691
to
5cfdf66
Compare
This is now ready for someone to review, particularly any correctness implications of optimizing atomics that I didn't already address |
The ExpandAtomicModify can recognize our pseudo-intrinsic julia.atomicmodify and convert it into some of known atomicrmw expressions, or simplify it with more inlining, as applicable. Ideally we could get this pass upstreamed, since there's nothing specific to julia about this pass, and LLVM's IR cannot express this quite correctly without making it a new intrinsic.
This ensures that now our
@atomic
modify is as fast asThreads.Atomic
!