[llvm-dev] Using a MachineInstruction Address

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Wed Dec 2 13:51:21 PST 2020


On Wed, 2 Dec 2020 at 17:32, Diogo Sampaio via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> Is there a straight-forward way to obtain an arbitrary MachineInstruction address and maintain it updated along the backend optimizations, even if it is in the middle of a MachineBasicBlock?
> I have an instruction that takes a relative address. E.g

I added a similar feature to AArch64 recently to handle jump-tables. I
think tracking both BB-start and offset is probably a non-starter, so
to take vocabulary from your example I implemented something like:

        myInstruction Ltmp0
        [...]
    BBN:
        ... x instructions ...
    Ltmp0:
        target_instruction

In this situation target_instruction is a Pseudo-instructrion that
gets expanded at the AsmPrinter stage into a label followed by the
real instruction. Both myInstruction and target_instruction would
share some kind of immediate operand saying which instance they are,
and the symbol generated would be coordinated by XYZFunctionInfo
(first user asks for a temporary symbol and records it there).

If target_instruction could actually be lots and lots of different
alternatives that you don't want to create pseudos for then you may be
able to arrange a bundle with a label-pseudo and the real instruction.
I just mention this so you don't abandon the idea entirely, I can give
more details if needed.

Cheers.

Tim.


More information about the llvm-dev mailing list