[PATCH] D147544: [BOLT] Move from RuntimeDyld to JITLink

Rafael Auler via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 31 17:32:52 PDT 2023


rafauler added a comment.

In D147544#4497505 <https://reviews.llvm.org/D147544#4497505>, @treapster wrote:

> In D147544#4477299 <https://reviews.llvm.org/D147544#4477299>, @jobnoorman wrote:
>
>> I'm not familiar with `LongJmpPass` but I did notice the following comment:
>>
>>> We pull this pass inside BOLT because here we can do a better job at stub inserting by manipulating the CFG, something linkers can't do.
>>
>> So wouldn't you lose something if this was moved to JITLink?
>
> You're right, losing CFG will make branches impossible to relax. We'll need MC layer to emit relocs for every branch which is apparently default behavior for RISC-V but not AArch64. 
> AFAIK currently JITLink doesn't relax branches for RISC-V, but if you intend to implement it, we can see how it works out and consider doing it for AArch64(starting with some MC option to emit R_AARCH64_JUMP26 and R_AARCH64_CONDBR19). As for updating the output values, it seems you mostly solved it in D154604 <https://reviews.llvm.org/D154604>.
> @rafauler, do you think it's feasible to move LongJMP to JITLink if we force MC to generate branch relocs, and are there some other reasons to manipulate the actual CFG?

In theory, if we feed the linker with as many relocations as it needs, it should be able to do any job. There is no specific reason to do that with a CFG other than "it's nicer to write a pass that goes over a real IR instead of just going over a stream of bytes + relocations", IMO. However, maintaining LongJmp pass in BOLT has its own complications too, such as the need to manually reproduce how the binary is going to be written before it is actually written. One could change something in BOLT and make LongJmp out of sync. In this case, LongJmp could not longer be accurately predicting how far apart instructions are from each other and which ones need trampoline stubs to extend their range.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147544



More information about the llvm-commits mailing list