<div dir="ltr"><div>Hi, </div><div><br></div><div>I want implement an instrumentation that gets the current PC. </div><div>On x86_64 I can do it using inline asm (something like "lea (%%rip),%0"), </div><div>but I wonder if there is some more LLVM-ish way to do it, e.g. an intrinsic? </div><div><br></div>I can only find r208104 which introduces llvm.read_register:<br><a href="http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20140505/215840.html">http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20140505/215840.html</a><div><br></div>The LangRef says: <br>> Warning: So far it only works with the stack pointer on selected architectures (ARM, AArch64,<br>> PowerPC and x86_64). Significant amount of work is needed to support other registers and even<br>>  more so, allocatable registers.<div><div class="gmail-section" id="gmail-llvm-stacksave-intrinsic"><span id="gmail-int-stacksave" style="color:rgb(0,0,0);font-family:"lucida grande","lucida sans unicode",geneva,verdana,sans-serif;font-size:14px"></span></div></div><div><br></div><div>Is it reasonable to extend <span style="color:rgb(0,0,0);white-space:pre-wrap">llvm.read_register to handle the program counter register </span><span style="color:rgb(0,0,0);white-space:pre-wrap">(on x86_64)? </span></div><div><span style="color:rgb(0,0,0);white-space:pre-wrap">Or </span><font color="#000000"><span style="white-space:pre-wrap">InlineAsm is a better way? </span></font></div><div><font color="#000000"><span style="white-space:pre-wrap"><br></span></font></div>Thanks,<br><br>--kcc</div>