LLVM IR instumentation. how to get the element value the pointer arg is pointing to?

arguments, function, instrumentation, llvm

Solution

You want to

get the element/variable that pointer is pointing to

This is also called "dereferencing a pointer". This is not something you can do at compile time, but what you can do is insert an instruction which does the dereferencing - in other words, a `load` instruction.

Problem

I am trying to instrument LLVM IR call instruction. What I want to achieve is to get the arguments of a function call. If the argument is pointer type, then I want to get the element/variable that pointer is pointing to. I know that if I have the argument, I can use ``` getPointerElementType to get the type of element the pointer is pointing to. ``` But how to access the value of element?

Original source