[llvm-dev] How can I get the opcode length of an IR instruction in LLVM?

Bruce Hoult via llvm-dev llvm-dev at lists.llvm.org
Mon Feb 27 07:50:02 PST 2017

Not possible, even in theory, because the size of some instructions -- such
as relative branches -- are not known until link time, and that affects the
offsets of instructions following them.

On Mon, Feb 27, 2017 at 6:24 PM, Mohsen Ahmadvand via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> I need to get the offset and the exact length of opcode corresponding to a
> particular LLVM IR instruction in x86 architecture. I believe for this I
> must hack in backends.
> I assume there is a way when the opcodes are being generated in x86
> backend to dump their offsets and sizes. However, considering optimizations
> and translation of one IR instruction to multiple operations, I'm not sure
> whether the relation between a single IR instruction and its corresponding
> opcode is maintainable or not.
> My questions are:
>    - Is this in general possible?
>    - How to hack the backend to dump the required informations? Is there
>    a generic way to do so, or do I need to hack all backends?
> Thanks a lot.
> Mohsen
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170227/101bf7e0/attachment.html>

More information about the llvm-dev mailing list