[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:
> 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
> I can only find r208104 which introduces llvm.read_register:
> 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?
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev