-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[NativeAOT] Inline TLS access for linux/arm64 #97910
[NativeAOT] Inline TLS access for linux/arm64 #97910
Conversation
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsWe now generate the inlined TLS access during compilation : 90000000 adrp x0, 0 <System_Console_System_ConsoleKeyInfo____GetFieldHelper>
5a2f0: R_AARCH64_TLSDESC_ADR_PAGE21 tls_InlinedThreadStatics
5a2f4: 91000000 add x0, x0, #0x0
5a2f4: R_AARCH64_TLSDESC_ADD_LO12 tls_InlinedThreadStatics
5a2f8: d53bd041 mrs x1, tpidr_el0
5a2fc: f9400002 ldr x2, [x0]
5a2fc: R_AARCH64_TLSDESC_LD64_LO12 tls_InlinedThreadStatics
5a300: d63f0040 blr x2
5a300: R_AARCH64_TLSDESC_CALL tls_InlinedThreadStatics
5a304: 8b000020 add x0, x1, x0
5a308: f9400013 ldr x19, [x0] which gets converted by the linker in following: ![]() TODOSharedlibrary scenario fails for some reason. The ![]()
|
Can you dump the object file relocations for a given offset with |
Here are the files. Look for
|
@filipnavara - did you get a chance to check this? |
Sorry, I was out for the weekend and now I have an emergency to attend to... will hopefully get to look at it in the evening. |
Nevermind, I accidentally built a Debug build. Trying again. |
Are we generating the exact instruction sequence clang/gcc would generate? Various breadcrumbs online seem to suggest linkers want to see exact instruction sequences: https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20150302/263562.html |
It works for executable, so yes, we generate exact sequence. It is failing only from sharedlibrary. When @VSadov added initial support of hand assembly, he didn't add anything special for sharedlibrary, so not sure what is wrong. |
I can reproduce it locally. It helped to check out the correct branch 😅 Notably, the sequence is different from what clang:
The Shared libraries get a different rewrite than executables due to the way they are relocated at runtime. |
src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs
Outdated
Show resolved
Hide resolved
Ah, that could be it. I thought adrp/add is a pair and shouldn't matter. Let me fix it and see. |
/azp run runtime-nativeaot-outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
@dotnet/jit-contrib |
src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs
Outdated
Show resolved
Hide resolved
// that we will attach to this node to guarantee that they are available | ||
// during generating this node. | ||
assert(call->gtFlags & GTF_TLS_GET_ADDR); | ||
newRefPosition(REG_R0, currentLoc, RefTypeFixedReg, nullptr, genRegMask(REG_R0)); |
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.
Do these have to be R0/R1/R2 for the linker, or is this just a choice you've made to make things simpler?
Or is it the case that since the ultimate expansion has a call these choices don't add new constraints?
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.
@VSadov PTAL |
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.
LGTM! Thanks!!
We now generate the inlined TLS access during compilation
which gets converted by the linker in following:
TODO
Sharedlibrary scenario fails for some reason. Theobjdump
on the object file looks identical between before and after, however when I doobjdump
on the shared library i.e..so
file, I see a difference in bits foradrp
which tells me that I am missing some relocation update, but cannot find out what. @MichalStrehovsky - any idea?superpmi changesIMAGE_REL_ARM64_TLSDESC*
inntimage.h
?