[llvm-dev] Inserting instructions when encountered a specific label

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Wed Oct 23 13:42:44 PDT 2019


On Wed, 23 Oct 2019 at 13:27, Kaarthik Alagapan
<kaarthik at knights.ucf.edu> wrote:
> I initially was printing out the result from getName() (I.getParent()->getName()) and it printed out nothing sadly.
>
> when parsing the instructions in SelectionDAGBuilder but it was only visiting instructions in the first/main BB and outputted %2.

The instruction's parent is the (unnamed) entry block to the function
(i.e. the block containing the instruction). By LLVM's automatic
numbering system that's %2 in a function with two arguments. So yes,
getName would return an empty string in that case.


> I'm not sure what's going on there, it would depend on which function
> you're modifying in SelectionDAG.
>
> I am calling it right after each instruction is visited in the visit(…) function. And it prints out the instruction’s number but it prints out only %2 when I call printAsOperand on the instruction’s parent, hence why I assumed that the visit function was going over only the main block.

I'm afraid I still don't have anything very helpful to tell you about that.

> That’s true. I’m now trying to detect the specific label in the LLParser and hopefully can insert my instruction there. Would creating a new pseudo instruction be a good way to emit “.byte …” assembly code?

An intrinsic would probably be simpler. You need to modify a lot of
places to invent a new instruction (LL parser, LL printer, Bitcode
parser, Bitcode printer, Codegen, ...)

Cheers.

Tim.


More information about the llvm-dev mailing list