-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
compiler_rt: aarch64 outline atomics #11828
Conversation
ae4d00f
to
4a4cd4d
Compare
@PiotrSikora could you try this to see if it fixes #10777 ? |
31fc53d
to
4fee891
Compare
0a660f1
to
d111ab7
Compare
2300bba
to
d6823f9
Compare
* Rely on libSystem when targeting macOS. * Make tools/gen_outline_atomics.zig more idiomatic. * Remove the CPU detection / auxval checking from compiler_rt. This functionality belongs in a different component. Zig's compiler_rt must not rely on constructors. Instead it will export a symbol for setting the value, and start code can detect and activate it. * Remove the separate logic for inline assembly when the target does or does not have lse support. `.inst` works in both cases.
After this, the machine code generated by zig matches identically to gcc's after the differences in loading the have_lse flag.
d6823f9
to
545c311
Compare
@devins2518 thank you for implementing this. It took me a long time to get around to merging it but it finally landed in 271cc52. I made some edits to what you have here:
|
Thanks so much! It's so awesome to have my first meaningful contribution to zig merged 🎉! I've been planning to rewrite this a bit since #12756 was merged which would remove the need for the generation script and simplify |
Follow-up: #13622 @devins2518 let's chat with @MasterQ32 about inline assembly - right now zig is at a fork in the road about whether to proceed with string concatenation or a more sophisticated inline assembly syntax built into the language. |
compiler_rt: aarch64 outline atomics
zig aarch64 outline atomics was resolved in ziglang/zig#11828 [ci skip]
Ported from llvm's port of libgcc's outline atomics.
Includes #11667 though, I can remove if this pr is merged before hazes.RemovedFixes #10086 and
zig c++
as noted here.Issues
The code is admittedly pretty ugly. There's a lot of inline assembly created through a mixture of multiline strings and regular string concatenation which is not ideal. Not sure if the level of comptime variable parsing is possible through just using inputs for inline assembly.__aarch64_ldadd4_acq_rel
is tested as it was the test case, but I'm not too sure about all of the other functions.__aarch64_have_lse_atomics
is constructed through a function in the.ctors
section which is definitely hidden control flow. Would be interesting to see any more ziggy solutions to fixing this.__init_aarch64_have_lse_atomics
needs to be linked into either__DATA,__mod_init_func
or.init_array
depending on platform, but@export
section handling isn't implemented. Right now, it is just called at the beginning of each outlined function.initHaveLseAtomics
also callsstd.os.linux.getauxval
even on macOS, which doesn't seem right. This seems beyond the scope of this PR though.