-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Darwin/ARM64: Linker corrupts generated code #39820
Comments
For posterity, the linker in question here is |
Actually, the linker is fine here. The issue is the intervening assignment to |
Looks like the fix in https://reviews.llvm.org/D80834 needs to be extended to the adrp/add/ldr case also. |
Do you have an IR reproducer? I tried to re-construct the issue by using this MIR:
but linking this I get a binary that has the last load becoming a literal load, which seems correct:
|
Can you try making the address of |
@aemerson Here's a full end-to-end example for you: https://gist.github.com/Keno/97c670bb659866ed1925081624fa1fb6. The .s is generated from the .ll in the gist using the command at the top (this is on LLVM11, but the issue reproduced on trunk also, though I didn't check this particular test case). You can see the problematic sequence here: https://gist.github.com/Keno/97c670bb659866ed1925081624fa1fb6#file-extract-loh-s-L476-L488 |
(Note this is only extracting the one function. If that turns out to not be big enough to reproduce this fully, I can send you the whole .bc file. It's about 100MB though. |
Ok, adding some very large padding in the assembly seems to have reproduced it. I now see:
|
Yep, that's the issue. The |
Includes patches for JuliaLang/julia#39823 JuliaLang/julia#39820 JuliaLang/julia#39818 as well as an issue causing an assertion in debug mode due to address spaces.
…bber of the def of the adrp before the ldr. Apparently this pass used to have liveness analysis but it was removed for scompile time reasons. This workaround prevents the LOH from being emitted unless the ADD and LDR are adjacent. Fixes JuliaLang/julia#39820 Differential Revision: https://reviews.llvm.org/D97571
Includes patches for JuliaLang/julia#39823 JuliaLang/julia#39820 JuliaLang/julia#39818 as well as an issue causing an assertion in debug mode due to address spaces.
Includes patches for JuliaLang/julia#39823 JuliaLang/julia#39820 JuliaLang/julia#39818 as well as an issue causing an assertion in debug mode due to address spaces.
…bber of the def of the adrp before the ldr. Apparently this pass used to have liveness analysis but it was removed for scompile time reasons. This workaround prevents the LOH from being emitted unless the ADD and LDR are adjacent. Fixes JuliaLang/julia#39820 Differential Revision: https://reviews.llvm.org/D97571
…e def of the adrp before the ldr. Apparently this pass used to have liveness analysis but it was removed for scompile time reasons. This workaround prevents the LOH from being emitted unless the ADD and LDR are adjacent. Fixes JuliaLang/julia#39820 Reviewed By: loladiro, qcolombet Differential Revision: https://reviews.llvm.org/D97571
…bber of the def of the adrp before the ldr. Apparently this pass used to have liveness analysis but it was removed for scompile time reasons. This workaround prevents the LOH from being emitted unless the ADD and LDR are adjacent. Fixes JuliaLang/julia#39820 Differential Revision: https://reviews.llvm.org/D97571
LLVM emits the following:
LOH is what's called
Linker-optimization-hint
which is an aarch64-specific thing where the linker patches out some instructions (an explanation of how that works is here: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AArch64/AArch64CollectLOH.cpp). However, after linking the instruction sequence is:looks to me like what happened here is that the relocation offset overflowed the size of the available immediate operand of the subsequent load, causing it to overflow into the source register field, causing crashes.The text was updated successfully, but these errors were encountered: