[llvm-dev] in an IR pass: access the instruction pointer/BB address

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Thu Aug 8 08:07:17 PDT 2019

Hi Marc,

On Thu, 8 Aug 2019 at 15:39, Marc via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> I want to access the current address of the basic block. It does not
> need to be the exact address of the BB, a few instructions down of that
> BB is fine as well.

I think you want BlockAddress:
https://llvm.org/doxygen/classllvm_1_1BlockAddress.html. It's an
instance of Constant and therefore also Value, and doesn't need to be
inserted as an instruction.

> basically the same that I could do with an "leaq (%rip), %rdx"
> instruction on intel x64.

That's slightly different, and I don't think there is an intrinsic for
the current PC. You could use inline assembly to get it though, since
you don't care about portability.



More information about the llvm-dev mailing list