[llvm-dev] How could I get some semantic information from IR?

mats petersson via llvm-dev llvm-dev at lists.llvm.org
Sun Dec 27 04:20:42 PST 2015


You will need to find out the argument for the getElementPtr, and get the
type of that, then use the index for the GEP to find what element it is in
the struct.

Why do you want to do this at LLVM level, shouldn't AST be a better place
to do this? [You haven't exactly said what it is you're trying to do, so
it's hard to give specific advice, but knowing about structures and such
seems more like something the C/AST level should deal with]

--
Mats

On 25 December 2015 at 03:11, 周书林 via llvm-dev <llvm-dev at lists.llvm.org>
wrote:

> I am working on my first llvm Pass to analyze some structure variables in
> source code, but in IR, there are only getelementptr to calculate the
> memory address to fetch the value of a specific member in the structure.
> For example, when I try to get the member  name of Structure S in statement
> "if(ss.aaaa == b)", where ss is a object of Structure S and b is an
> integer,
> [image: 内嵌图片 2]
> [image: 内嵌图片 4]
> I can only get the following IR structures, and the variable %aaaa1 is
> just a temporary name
> [image: 内嵌图片 1]
>
> So, the problem is, how could I get the member name of a structure in IR?
> more specific, how could I get the name "aaaa" while access to the
> "ss.aaaa"?
>
> Thanks a lot.
>
> _______________________________________________
> 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/20151227/9c0875c8/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1-3.png
Type: image/png
Size: 3263 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151227/9c0875c8/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1-1.png
Type: image/png
Size: 22134 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151227/9c0875c8/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1-2.png
Type: image/png
Size: 1302 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151227/9c0875c8/attachment-0002.png>


More information about the llvm-dev mailing list