[PATCH] D157802: [JITLink][EHFrameSupport] Accept multiple relocations

Job Noorman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 19 00:18:23 PDT 2023


jobnoorman added a comment.

In D157802#4647814 <https://reviews.llvm.org/D157802#4647814>, @Hahnfeld wrote:

> I had an alternative idea and it seems to work in some preliminary tests, but I don't have enough time to fully validate it right now: Instead of teaching `EHFrameEdgeFixer` how to deal with multiple relocations at one offset, we can also establish that precondition for RISC-V for the limited cases we need, concretely by fusing `ADD32` and a `SUB32` to the start of a block into a virtual `Offset32` edge: https://github.com/hahnjo/llvm-project/tree/riscv-eh-frame.offset

This sounds like an interesting approach because it would allow us to get rid of multiple relocations at the same offset without having to store multiple symbols per edge. However, I think this can only work if we somehow make sure that every symbol that is referred to by a `SUB*` relocation is at the start of a block. That is, we'd need a pass that splits blocks at those edges and in case of objects with `.eh_frame`s or debug info, we'd probably need to split //a lot// of blocks. Take the following example:

      .text
      .globl main
  main:
      nop
  1:  call f
  2:  ret
  
  f:
      ret
  
      .data
  diff:
      .word 2b - 1b

Since the symbol `1` is not at the start of a block, your approach will not work here without first splitting blocks. This may seem like a silly example but it is exactly how `DW_CFA_advance_loc` calculates its offset (so this test case <https://github.com/llvm/llvm-project/pull/66067/files#diff-297d9308360fbf461cc8dcd59fddb4c7ff60eedb59ef54f37631e2b970d30902> would fail).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157802/new/

https://reviews.llvm.org/D157802



More information about the llvm-commits mailing list