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

Marc via llvm-dev llvm-dev at lists.llvm.org
Thu Aug 8 07:40:48 PDT 2019


I looked through the documentation and source and am unable to find a way:

in an IR pass on basic blocks

  for (auto &F : M)
    for (auto &BB : F) {

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.

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

I want to then use this address as a "Value *" type and continue using
it in IRB.CreateStore() etc.

The sanatizer seems to call a function which then uses GET_CALLER_PC,
but that costs speed and complicates my IR code...

Is that possible? Even if its not portable on anything else than intel
x64 that would be enough.
Thanks a lot!


Marc Heuse

PGP: AF3D 1D4C D810 F0BB 977D  3807 C7EE D0A0 6BE9 F573

More information about the llvm-dev mailing list