-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
LLD does not support the relax CPU feature of RISC-V (R_RISCV_ALIGN) #3451
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
Comments
If you do an |
It seems that
|
|
What does the relax feature do? Maybe we could disable it for the default target settings. |
That's certainly possible. The idea of code relaxations is that you replace longer instruction sequences with shorter, more optimized ones depending on information that is only available at link time. For instance, in RISC-V you can add a 12-bit immediate to a register in a single instruction, but it takes two instructions to add a 32-bit immediate. If the immediate comes from a symbol for which the final value is only known by the linker you must emit the two-instruction sequence. Yet, you can annotate the sequence with a |
The reason for the weird nops is that when you have compressed instructions enabled the linker might generate 16-bit instructions when doing the code relaxations, affecting the alignment. |
Ok, given that this is an optimization, I think it is reasonable to disable it until we have linker support for it, whether by improvements to LLD or #1535. |
FWIW, LLD has long since gained support for various kinds of relaxations. |
@Rexicon226 you're working on zld support for RISC-V relaxations, right? |
Yes, I would like to implement this in self-hosted before closing the issue. |
It seems that the RISC-V assembler is somehow emitting the wrong amount of
nop
s when therelax
feature is active.Here's a minimal test case:
When compiled with
Produces the following
This should be reported to the LLVM developers.
CC @luismarques
The text was updated successfully, but these errors were encountered: