[llvm] Jump table annotations for Linux (PR #112606)

Ard Biesheuvel via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 17 09:16:08 PDT 2024


ardbiesheuvel wrote:

> You either need to teach the code that is adding the `mov` to place it before the pseudo instruction (which will still be fragile to other changes), or make the code looking for the pseudo instruction walk backwards from the jump to see if there are any in the current block (which is the approach I took).

So in this particular case, there is the `.reloc` that gets emitted along with the `jmp` - there may be more than one of those sharing the same jump table so it belongs with the JUMP_TABLE_DEBUG_INFO op. However, the label used in the `.reloc` could be emitted separately, as long as the name can be constructed unambiguously.

Would that make it feasible to tweak the BR_JT to BRIND lowering (and further) to remember its BR_JT origin, and always emit a local label unconditionally? Then, whether or not that label is ever referenced is based on whether the annotations are emitted when printing the ASM, and where the `.reloc` ends up with respect to the jump is no longer important.

Just throwing this out as an idea - I am a total noob when it comes to LLVM hacking so I will gratefully take all the help and advice I can get.


https://github.com/llvm/llvm-project/pull/112606


More information about the llvm-commits mailing list