0

Pointer type can be deduced through:

Value* v= i->getOperand(0);
.......    
if(PointerType* pt=dyn_cast<PointerType>(v->getType())){
      pt->getElementType()->getTypeID();

How can I read the value that this pointer points to?

I is a CallInst.

ConsistentProgrammer
  • 1,294
  • 10
  • 14
  • You read the content of memory with a `load` instruction, but I have a feeling that's not the answer you're looking for. Could you clarify what exactly are you trying to achieve? – Oak May 12 '14 at 06:59
  • @Oak: I have a function that takes two input paramerters. I want to read the values that I pass to this function: e.g. Foo(int i, int j). Void main(){foo(6,7)}... I want to read 6 and 7.... Thanks!! – ConsistentProgrammer May 12 '14 at 08:40

1 Answers1

1

Given a CallInst, you can get an argument via getArgOperand() or iterate over all of them with arg_operands(). The arguments you get this way are just Values, and you can do anything you can do with other Values on them.

In particular, if those Values are constants, you can get the actual values used in the compiler - see this related stackoverflow question: LLVM get constant integer back from Value*

Community
  • 1
  • 1
Oak
  • 26,231
  • 8
  • 93
  • 152