[llvm-dev] Quick question: How to BuildMI mov64mi32 arbitrary MMB address to memory

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Sun Sep 23 02:36:46 PDT 2018


Hi,

On Sat, 22 Sep 2018 at 22:21, K Jelesnianski <kjski at vt.edu> wrote:
> I am looking for a work around to accommodate this feature. I have never attempted to make my own section/symbols using LLVM, but I assume this is the route I should take? Pairing each trampoline BB to a symbol should make it visible and this MOVQ instruction I want possible?

You've still got to access that symbol, and it's not obvious how a
block that's moving around in memory could do that. The same arguments
that it can't use %rip relative addressing for a local BB would seem
to apply to any other entity.

If you have a solution for that problem, an alternative to creating
entirely new symbols would be to reference the stationary BB relative
to the function's entry-point. In assembly something like:

    movq func at GOTPCREL(%rip), %rax
    addq (.LBB0_0-func), %rax

> Do I need to make these symbols for the trampoline BBs as an IR opt pass, can I get away with it using a MachineModule Pass to add the trampolines per module (file) (so far I have only created BasicBlock, MachineBasicBlock, and MachineFunction passes)??

If you go that route you can probably add entries to the
MachineConstantPool with a MachineModule pass. The same addressing
concerns seem to apply though.

Cheers.

Tim.


More information about the llvm-dev mailing list