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

Kaarthik Alagapan via llvm-dev llvm-dev at lists.llvm.org
Wed Oct 23 13:47:11 PDT 2019


Got it, thank you Tim!


Kaarthik A.
On Oct 23, 2019, 4:43 PM -0400, Tim Northover <t.p.northover at gmail.com>, wrote:
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20191023/f1857a82/attachment.html>


More information about the llvm-dev mailing list