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

David Blaikie dblaikie at gmail.com
Mon Mar 23 10:53:07 PDT 2015


On Mon, Mar 23, 2015 at 6:38 AM, Wu Zhao <bluechristlove at 163.com> wrote:

> 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


>
> Thanks
>
> Best Regards
>
> Wu Zhao
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150323/ac57ddb2/attachment.html>


More information about the llvm-dev mailing list