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

Reid Kleckner via llvm-dev llvm-dev at lists.llvm.org
Wed Jan 25 16:14:13 PST 2017


I would do inline asm for now.

If you wanted to avoid the asm, I recommend adding a new intrinsic to get
the "current" PC. The intrinsic would probably have to be modeled as
reading and writing memory to establish control dependence and avoid being
CSE'd to the entry block.

On Wed, Jan 25, 2017 at 4:08 PM, Kostya Serebryany via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> 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
>
> _______________________________________________
> 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/20170125/e1c8daea/attachment.html>


More information about the llvm-dev mailing list