[llvm-dev] struct size

David Blaikie via llvm-dev llvm-dev at lists.llvm.org
Thu Aug 31 09:22:28 PDT 2017


On Thu, Aug 31, 2017 at 7:55 AM Krzysztof Parzyszek via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> On 8/31/2017 8:11 AM, Anastasiya Ruzhanskaya via llvm-dev wrote:
> >
> > I want to identify, that %s is pointer to struct, determine what this
> > struct is and determine the size of every component? With every
> > component is more or less ok, but the operand %s is not a struct but a
> > pointer. Is there a convenient way to track this structure usage in
> > getelementptr?
>
> If you have a Type* object that you know it a pointer, you can cast it
> to PointerType*, and then obtain the pointee type via getElementType
> member function.
>

Note: Please don't rely on this, eventually pointer element types will go
away. GEP does have a value type you can access directly.
(GetElementPointer::getValueType, if I recall correctly)


>
> If you have a Type* object that is a structure, you can cast it to
> StructType*, which then has iterators that allow you to inspect every
> member type.
>
> Look in include/llvm/IR/DerivedTypes.h for more information.
>
> -Krzysztof
>
>
> --
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> hosted by The Linux Foundation
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170831/f20dfdcc/attachment.html>


More information about the llvm-dev mailing list