[llvm-dev] llvm.read_register for %RIP on x86_64

Kostya Serebryany via llvm-dev llvm-dev at lists.llvm.org
Wed Jan 25 16:08:30 PST 2017


Hi,

I want implement an instrumentation that gets the current PC.
On x86_64 I can do it using inline asm (something like "lea (%%rip),%0"),
but I wonder if there is some more LLVM-ish way to do it, e.g. an
intrinsic?

I can only find r208104 which introduces llvm.read_register:
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20140505/215840.html

The LangRef says:
> Warning: So far it only works with the stack pointer on selected
architectures (ARM, AArch64,
> PowerPC and x86_64). Significant amount of work is needed to support
other registers and even
>  more so, allocatable registers.

Is it reasonable to extend llvm.read_register to handle the program counter
register (on x86_64)?
Or InlineAsm is a better way?

Thanks,

--kcc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170125/193c0cc0/attachment.html>


More information about the llvm-dev mailing list