[PATCH] D130206: CodeGen: use address form for DW_AT_high_pc on RISCV
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 21 10:36:17 PDT 2022
MaskRay added a comment.
In D130206#3669301 <https://reviews.llvm.org/D130206#3669301>, @compnerd wrote:
> In D130206#3666984 <https://reviews.llvm.org/D130206#3666984>, @MaskRay wrote:
>
>> This does not fix the incompatibility with RISC-V linker relaxation. This changes DW_AT_high_pc from a length to (pre-DWARF-v4) an address.
>
> Correct, this is not to fix the incompatibility with relaxation, it is to fix the compatibility with no relaxation and fission.
For -mno-relax code, using the length instead of the end address for DW_AT_high_pc leads to fewer relocations in the output.
MC should be able to resolve R_RISCV_ADD32/R_RISCV_SUB32 .
With this patch, there will be a relocation which cannot be resolved at assembler time.
>> The address needs to be relocated as well. The correct approach is to use .debug_addr indirection via DW_FORM_addrx.
>
> Interesting, do we have any target currently using that form?
No. As you can see, for -mno-relax, DW_AT_high_pc is a constant which saves more space than using the end address (one relocation) or using a .debug_addr indirection to represent the end address (more expensive),
so it is unimplemented. I think GCC doesn't implement it as well, hence the silent broken output :)
>> This is useful with linker relaxation, though, as it can decrease the number of relocations.
>>
>> https://maskray.me/blog/2021-03-14-the-dark-side-of-riscv-linker-relaxation#code-addresses I am going to revise some paragraphs about DWARF.
>
> Yes, this should be able to reduce the number of relocations at the cost of debug info size. However, given that we currently fail to emit the object file this seems like a good tradeoff.
See above.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130206/new/
https://reviews.llvm.org/D130206
More information about the llvm-commits
mailing list