Shen Liu
2015-Jul-18 01:32 UTC
[LLVMdev] How can i differentiate pointer type int 32* from int 32** ?
John, thanks for your helpful advice. My ultimate goal is to construct a full instruction-level program dependence graph for a given IR file. The hard point is how to establish the correct data dependence edges when some function arguments are multi-level pointers. To solve this problem I hope to check the point-to level for each pointer variable. I think the data dependence through pointers can be described more accurately in this way. Unfortunately i didn't find any available interface to finish this job, so i guess i have to write it by myself. Best regards, Shen On Fri, Jul 17, 2015 at 2:22 PM, John Criswell <jtcriswel at gmail.com> wrote:> On 7/17/15 1:06 PM, Shen Liu wrote: > > John, thanks for you answer! But as far as I know LLVM doesn't provide > any interface for finding the pointee of a pointer directly, so i have to > process a multi-level pointer i need to write my own function to check > pointers level by level, is that right? > > > I'm not sure what you're trying to do. If you're trying to determine the > LLVM pointer type and the LLVM type to which it points, what I've said will > work. > > If you're trying to do something more complicated, then you need to > explain more clearly what you want to do. I think it would also help if > you "jumped up a level" and explained what your end goal is so that the > community can give you better advice. Based on your previous emails, it > seems like you're asking very specific questions instead of asking how to > best achieve your overall goal. > > Regards, > > John Criswell > > > > On Fri, Jul 17, 2015 at 1:47 PM, John Criswell <jtcriswel at gmail.com> > wrote: > >> On 7/17/15 12:38 PM, Shen Liu wrote: >> >> Hi all, as a LLVM beginner I would like to know how can i check the >> pointer types with different levels like int 32* and int 32**, int 32***? >> >> By using value->getType()->isPointerTy() i can just know they are >> pointers. But the dump results clearly show they are different. Is there a >> good way to calculate their actual point to levels? Thanks! >> >> >> You will need to use dyn_cast<PointerType> to cast the Type * into a >> PointerType *. Once you do that, you can find the Type * that the >> PointerType points to. >> >> Regards, >> >> John Criswell >> >> >> >> Best regards, >> >> Shen >> >> >> _______________________________________________ >> LLVM Developers mailing listLLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> >> >> >> -- >> John Criswell >> Assistant Professor >> Department of Computer Science, University of Rochesterhttp://www.cs.rochester.edu/u/criswell >> >> > > > -- > John Criswell > Assistant Professor > Department of Computer Science, University of Rochesterhttp://www.cs.rochester.edu/u/criswell > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150717/06d47dfc/attachment.html>
Daniel Berlin
2015-Jul-18 02:48 UTC
[LLVMdev] How can i differentiate pointer type int 32* from int 32** ?
Points-to level does not tell you much. It is entirely possible for the relationship to go in the wrong direction. LLVM does not say it is illegal :) (IE it does not say that int *** can only point to int **) On Fri, Jul 17, 2015 at 6:32 PM, Shen Liu <shl413 at lehigh.edu> wrote:> John, thanks for your helpful advice. > > My ultimate goal is to construct a full instruction-level program dependence > graph for a given IR file. The hard point is how to establish the correct > data dependence edges when some function arguments are multi-level pointers. > To solve this problem I hope to check the point-to level for each pointer > variable. I think the data dependence through pointers can be described more > accurately in this way. Unfortunately i didn't find any available interface > to finish this job, so i guess i have to write it by myself. > > Best regards, > > Shen > > > > On Fri, Jul 17, 2015 at 2:22 PM, John Criswell <jtcriswel at gmail.com> wrote: >> >> On 7/17/15 1:06 PM, Shen Liu wrote: >> >> John, thanks for you answer! But as far as I know LLVM doesn't provide >> any interface for finding the pointee of a pointer directly, so i have to >> process a multi-level pointer i need to write my own function to check >> pointers level by level, is that right? >> >> >> I'm not sure what you're trying to do. If you're trying to determine the >> LLVM pointer type and the LLVM type to which it points, what I've said will >> work. >> >> If you're trying to do something more complicated, then you need to >> explain more clearly what you want to do. I think it would also help if you >> "jumped up a level" and explained what your end goal is so that the >> community can give you better advice. Based on your previous emails, it >> seems like you're asking very specific questions instead of asking how to >> best achieve your overall goal. >> >> Regards, >> >> John Criswell >> >> >> >> On Fri, Jul 17, 2015 at 1:47 PM, John Criswell <jtcriswel at gmail.com> >> wrote: >>> >>> On 7/17/15 12:38 PM, Shen Liu wrote: >>> >>> Hi all, as a LLVM beginner I would like to know how can i check the >>> pointer types with different levels like int 32* and int 32**, int 32***? >>> >>> By using value->getType()->isPointerTy() i can just know they are >>> pointers. But the dump results clearly show they are different. Is there a >>> good way to calculate their actual point to levels? Thanks! >>> >>> >>> You will need to use dyn_cast<PointerType> to cast the Type * into a >>> PointerType *. Once you do that, you can find the Type * that the >>> PointerType points to. >>> >>> Regards, >>> >>> John Criswell >>> >>> >>> >>> Best regards, >>> >>> Shen >>> >>> >>> _______________________________________________ >>> LLVM Developers mailing list >>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >>> >>> >>> >>> -- >>> John Criswell >>> Assistant Professor >>> Department of Computer Science, University of Rochester >>> http://www.cs.rochester.edu/u/criswell >> >> >> >> >> -- >> John Criswell >> Assistant Professor >> Department of Computer Science, University of Rochester >> http://www.cs.rochester.edu/u/criswell > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Shen Liu
2015-Jul-18 13:51 UTC
[LLVMdev] How can i differentiate pointer type int 32* from int 32** ?
Yes i agree, so for the data dependencies through pointers, i first use inter-procedure alias analysis to find the alias pointer sets, and set up dependency between those store/load instructions whose memory locations are aliases. The reason I want to exactly know point-to level is, for a function with multi-level pointer as arguments, like func(int ***p), i hope to demonstrate the memory read/write process for each level on my graph, if necessary i will add some dummy nodes to represent the intermediate memory read/write. Best regards, Shen On Fri, Jul 17, 2015 at 10:48 PM, Daniel Berlin <dberlin at dberlin.org> wrote:> Points-to level does not tell you much. > > It is entirely possible for the relationship to go in the wrong direction. > LLVM does not say it is illegal :) > > (IE it does not say that int *** can only point to int **) > > > > On Fri, Jul 17, 2015 at 6:32 PM, Shen Liu <shl413 at lehigh.edu> wrote: > > John, thanks for your helpful advice. > > > > My ultimate goal is to construct a full instruction-level program > dependence > > graph for a given IR file. The hard point is how to establish the correct > > data dependence edges when some function arguments are multi-level > pointers. > > To solve this problem I hope to check the point-to level for each pointer > > variable. I think the data dependence through pointers can be described > more > > accurately in this way. Unfortunately i didn't find any available > interface > > to finish this job, so i guess i have to write it by myself. > > > > Best regards, > > > > Shen > > > > > > > > On Fri, Jul 17, 2015 at 2:22 PM, John Criswell <jtcriswel at gmail.com> > wrote: > >> > >> On 7/17/15 1:06 PM, Shen Liu wrote: > >> > >> John, thanks for you answer! But as far as I know LLVM doesn't provide > >> any interface for finding the pointee of a pointer directly, so i have > to > >> process a multi-level pointer i need to write my own function to check > >> pointers level by level, is that right? > >> > >> > >> I'm not sure what you're trying to do. If you're trying to determine > the > >> LLVM pointer type and the LLVM type to which it points, what I've said > will > >> work. > >> > >> If you're trying to do something more complicated, then you need to > >> explain more clearly what you want to do. I think it would also help > if you > >> "jumped up a level" and explained what your end goal is so that the > >> community can give you better advice. Based on your previous emails, it > >> seems like you're asking very specific questions instead of asking how > to > >> best achieve your overall goal. > >> > >> Regards, > >> > >> John Criswell > >> > >> > >> > >> On Fri, Jul 17, 2015 at 1:47 PM, John Criswell <jtcriswel at gmail.com> > >> wrote: > >>> > >>> On 7/17/15 12:38 PM, Shen Liu wrote: > >>> > >>> Hi all, as a LLVM beginner I would like to know how can i check the > >>> pointer types with different levels like int 32* and int 32**, int > 32***? > >>> > >>> By using value->getType()->isPointerTy() i can just know they are > >>> pointers. But the dump results clearly show they are different. Is > there a > >>> good way to calculate their actual point to levels? Thanks! > >>> > >>> > >>> You will need to use dyn_cast<PointerType> to cast the Type * into a > >>> PointerType *. Once you do that, you can find the Type * that the > >>> PointerType points to. > >>> > >>> Regards, > >>> > >>> John Criswell > >>> > >>> > >>> > >>> Best regards, > >>> > >>> Shen > >>> > >>> > >>> _______________________________________________ > >>> LLVM Developers mailing list > >>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >>> > >>> > >>> > >>> -- > >>> John Criswell > >>> Assistant Professor > >>> Department of Computer Science, University of Rochester > >>> http://www.cs.rochester.edu/u/criswell > >> > >> > >> > >> > >> -- > >> John Criswell > >> Assistant Professor > >> Department of Computer Science, University of Rochester > >> http://www.cs.rochester.edu/u/criswell > > > > > > > > _______________________________________________ > > 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/20150718/161f289e/attachment.html>
John Criswell
2015-Jul-18 14:54 UTC
[LLVMdev] How can i differentiate pointer type int 32* from int 32** ?
On 7/17/15 8:32 PM, Shen Liu wrote:> John, thanks for your helpful advice. > > My ultimate goal is to construct a full instruction-level program > dependence graph for a given IR file. The hard point is how to > establish the correct data dependence edges when some function > arguments are multi-level pointers. To solve this problem I hope to > check the point-to level for each pointer variable. I think the data > dependence through pointers can be described more accurately in this > way. Unfortunately i didn't find any available interface to finish > this job, so i guess i have to write it by myself.It sounds like you need a shape graph. DSA can provide that, and it currently works with LLVM mainline. You can find it in the poolalloc module (svn co http://llvm.org/svn/llvm-project/poolalloc/trunk poolalloc) or a slightly older version on my Github page (https://github.com/jtcriswell/llvm-dsa). Please note that the version from LLVM SVN will only compile lib/DSA. I don't think anyone has brought lib/PoolAllocate up to date. There is documentation which gives a very basic overview of the DSA passes and how to use the shape graph. The open question is whether DSA will be sufficiently accurate for your needs. Of that, I'm not sure. You would need to try it out and see if it's sufficient accurate for you. Regards, John Criswell> > Best regards, > > Shen > > > > On Fri, Jul 17, 2015 at 2:22 PM, John Criswell <jtcriswel at gmail.com > <mailto:jtcriswel at gmail.com>> wrote: > > On 7/17/15 1:06 PM, Shen Liu wrote: >> John, thanks for you answer! But as far as I know LLVM doesn't >> provide any interface for finding the pointee of a pointer >> directly, so i have to process a multi-level pointer i need to >> write my own function to check pointers level by level, is that >> right? > > I'm not sure what you're trying to do. If you're trying to > determine the LLVM pointer type and the LLVM type to which it > points, what I've said will work. > > If you're trying to do something more complicated, then you need > to explain more clearly what you want to do. I think it would > also help if you "jumped up a level" and explained what your end > goal is so that the community can give you better advice. Based > on your previous emails, it seems like you're asking very specific > questions instead of asking how to best achieve your overall goal. > > Regards, > > John Criswell > > >> >> On Fri, Jul 17, 2015 at 1:47 PM, John Criswell >> <jtcriswel at gmail.com <mailto:jtcriswel at gmail.com>> wrote: >> >> On 7/17/15 12:38 PM, Shen Liu wrote: >>> Hi all, as a LLVM beginner I would like to know how can i >>> check the pointer types with different levels like int 32* >>> and int 32**, int 32***? >>> >>> By using value->getType()->isPointerTy() i can just know >>> they are pointers. But the dump results clearly show they >>> are different. Is there a good way to calculate their actual >>> point to levels? Thanks! >> >> You will need to use dyn_cast<PointerType> to cast the Type * >> into a PointerType *. Once you do that, you can find the >> Type * that the PointerType points to. >> >> Regards, >> >> John Criswell >> >>> >>> >>> Best regards, >>> >>> Shen >>> >>> >>> _______________________________________________ >>> LLVM Developers mailing list >>> LLVMdev at cs.uiuc.edu <mailto:LLVMdev at cs.uiuc.edu> http://llvm.cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> >> >> -- >> John Criswell >> Assistant Professor >> Department of Computer Science, University of Rochester >> http://www.cs.rochester.edu/u/criswell >> >> > > > -- > John Criswell > Assistant Professor > Department of Computer Science, University of Rochester > http://www.cs.rochester.edu/u/criswell > >-- John Criswell Assistant Professor Department of Computer Science, University of Rochester http://www.cs.rochester.edu/u/criswell -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150718/9ca455b4/attachment.html>
Shen Liu
2015-Jul-18 15:18 UTC
[LLVMdev] How can i differentiate pointer type int 32* from int 32** ?
Mr. John, really appreciate your help! I will try DSA and see whether it works or not, Thank you! On Sat, Jul 18, 2015 at 10:54 AM, John Criswell <jtcriswel at gmail.com> wrote:> On 7/17/15 8:32 PM, Shen Liu wrote: > > John, thanks for your helpful advice. > > My ultimate goal is to construct a full instruction-level program > dependence graph for a given IR file. The hard point is how to establish > the correct data dependence edges when some function arguments are > multi-level pointers. To solve this problem I hope to check the point-to > level for each pointer variable. I think the data dependence through > pointers can be described more accurately in this way. Unfortunately i > didn't find any available interface to finish this job, so i guess i have > to write it by myself. > > > It sounds like you need a shape graph. DSA can provide that, and it > currently works with LLVM mainline. You can find it in the poolalloc > module (svn co http://llvm.org/svn/llvm-project/poolalloc/trunk > poolalloc) or a slightly older version on my Github page ( > https://github.com/jtcriswell/llvm-dsa). Please note that the version > from LLVM SVN will only compile lib/DSA. I don't think anyone has brought > lib/PoolAllocate up to date. > > There is documentation which gives a very basic overview of the DSA passes > and how to use the shape graph. > > The open question is whether DSA will be sufficiently accurate for your > needs. Of that, I'm not sure. You would need to try it out and see if > it's sufficient accurate for you. > > > Regards, > > John Criswell > > > > > Best regards, > > Shen > > > > On Fri, Jul 17, 2015 at 2:22 PM, John Criswell <jtcriswel at gmail.com> > wrote: > >> On 7/17/15 1:06 PM, Shen Liu wrote: >> >> John, thanks for you answer! But as far as I know LLVM doesn't provide >> any interface for finding the pointee of a pointer directly, so i have to >> process a multi-level pointer i need to write my own function to check >> pointers level by level, is that right? >> >> >> I'm not sure what you're trying to do. If you're trying to determine >> the LLVM pointer type and the LLVM type to which it points, what I've said >> will work. >> >> If you're trying to do something more complicated, then you need to >> explain more clearly what you want to do. I think it would also help if >> you "jumped up a level" and explained what your end goal is so that the >> community can give you better advice. Based on your previous emails, it >> seems like you're asking very specific questions instead of asking how to >> best achieve your overall goal. >> >> Regards, >> >> John Criswell >> >> >> >> On Fri, Jul 17, 2015 at 1:47 PM, John Criswell <jtcriswel at gmail.com> >> wrote: >> >>> On 7/17/15 12:38 PM, Shen Liu wrote: >>> >>> Hi all, as a LLVM beginner I would like to know how can i check the >>> pointer types with different levels like int 32* and int 32**, int 32***? >>> >>> By using value->getType()->isPointerTy() i can just know they are >>> pointers. But the dump results clearly show they are different. Is there a >>> good way to calculate their actual point to levels? Thanks! >>> >>> >>> You will need to use dyn_cast<PointerType> to cast the Type * into a >>> PointerType *. Once you do that, you can find the Type * that the >>> PointerType points to. >>> >>> Regards, >>> >>> John Criswell >>> >>> >>> >>> Best regards, >>> >>> Shen >>> >>> >>> _______________________________________________ >>> LLVM Developers mailing listLLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >>> >>> >>> >>> -- >>> John Criswell >>> Assistant Professor >>> Department of Computer Science, University of Rochesterhttp://www.cs.rochester.edu/u/criswell >>> >>> >> >> >> -- >> John Criswell >> Assistant Professor >> Department of Computer Science, University of Rochesterhttp://www.cs.rochester.edu/u/criswell >> >> > > > -- > John Criswell > Assistant Professor > Department of Computer Science, University of Rochesterhttp://www.cs.rochester.edu/u/criswell > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150718/65cf8e43/attachment.html>