Is any way to get deference pointer value's raw type(i.e. pointer type)

Maybe the title is somehow confused. but let me show you a example.


void foo(int val)
{
// do something
}

int i = 27;
int* pi = &i;

foo(*pi);

Here, if we compile it using clang, the type of *pi will be i32, but we know pi is pointer type.

my question is we use Function::getgetFunctionParamType method, the result will be i32. but how do I use some wayst to get ’ pi ’ type, not ’ *pi ’ type? This problem has confused me some days.

Thanks

Best Regards

Wu Zhao

Maybe the title is somehow confused. but let me show you a example.

[code]

void foo(int val)
{
    // do something
}

int i = 27;
int* pi = &i;

foo(*pi);

[/code]

Here, if we compile it using clang, the type of *pi will be i32, but we
know pi is pointer type.

my question is we use Function::getgetFunctionParamType method, the result
will be i32. but how do I use some wayst to get ' pi ' type, not ' *pi '
type? This problem has confused me some days.

I'm not clear on exactly what you want, sorry - if you're examining the
'foo' function in LLVM IR, then there's no remnant of the type of 'pi' -
that's an artefact of the call site, but the actual function takes an i32.

If you look at the call site to foo, then you can walk the operands of the
call instruction and look through the subexpressions - there should be a
load instruction you can look through to find the raw pointer that was
loaded from.

- David