Eric Lu
2013-Jul-12 02:45 UTC
[LLVMdev] How to recognize the declaring code scopes of stack variables
Hi, If I want to know where the stack variables are declared? For example, whether it is declared within a loop or not? Like variables a[100] and temp. int a[100]; for( int i = 0; i < N; i++){ int temp; } Can this be done in LLVM IR? Or should be implemented in Clang. Thanks! Eric -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130712/21e98579/attachment.html>
David Blaikie
2013-Jul-12 02:57 UTC
[LLVMdev] How to recognize the declaring code scopes of stack variables
Clang can/now emits lifetime intrinsics to mark this information, I believe - but I'm not sure if they'll suit your needs. What are you trying to do with this information? On Thu, Jul 11, 2013 at 7:45 PM, Eric Lu <eirc.lew at gmail.com> wrote:> Hi, > > If I want to know where the stack variables are declared? For example, > whether it is declared within a loop or not? Like variables a[100] and > temp. > > int a[100]; > for( int i = 0; i < N; i++){ > int temp; > } > > Can this be done in LLVM IR? Or should be implemented in Clang. > > > Thanks! > > > Eric > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
David Blaikie
2013-Jul-12 03:23 UTC
[LLVMdev] How to recognize the declaring code scopes of stack variables
On Thu, Jul 11, 2013 at 8:19 PM, Eric Lu <eirc.lew at gmail.com> wrote:> When parallelize the loop with OpenMP like models, I need to know what > variables will be shared among different threads.I imagined you'd want to recognize loops, not scopes. Sounds like a backend kind of optimization type thing, just detecting values that don't escape the loop. (this would catch cases where a variable is declared outside the loop but never actually used in such a way, eg: int i; for (...) { i = ...; ... } // no use of 'i' here> So I want to know whether they are declared in loop scopes. > > > On Fri, Jul 12, 2013 at 10:57 AM, David Blaikie <dblaikie at gmail.com> wrote: >> >> Clang can/now emits lifetime intrinsics to mark this information, I >> believe - but I'm not sure if they'll suit your needs. >> >> What are you trying to do with this information? >> >> On Thu, Jul 11, 2013 at 7:45 PM, Eric Lu <eirc.lew at gmail.com> wrote: >> > Hi, >> > >> > If I want to know where the stack variables are declared? For example, >> > whether it is declared within a loop or not? Like variables a[100] and >> > temp. >> > >> > int a[100]; >> > for( int i = 0; i < N; i++){ >> > int temp; >> > } >> > >> > Can this be done in LLVM IR? Or should be implemented in Clang. >> > >> > >> > Thanks! >> > >> > >> > Eric >> > >> > _______________________________________________ >> > LLVM Developers mailing list >> > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> > > >
David Blaikie
2013-Jul-12 04:42 UTC
[LLVMdev] How to recognize the declaring code scopes of stack variables
On Thu, Jul 11, 2013 at 9:33 PM, Eric Lu <eirc.lew at gmail.com> wrote:> Hi, David > yes, it is similar to your description. And do you know any methods to do > this in LLVM IR?I don't know the mid-level optimizers especially well - I doubt there's a thing that does exactly what you need - but a combination of existing passes/analyses might be able to tell you what you need. Sorry I can't be more precise, it's just not my area. I imagine it's possibly more a case of treating any values that don't enter phi's after the loop as separate - and then ensuring that the values that do enter phi's after the loop body are appropriately shared. - David> > Thanks! > > Eric > > > On Fri, Jul 12, 2013 at 11:23 AM, David Blaikie <dblaikie at gmail.com> wrote: >> >> On Thu, Jul 11, 2013 at 8:19 PM, Eric Lu <eirc.lew at gmail.com> wrote: >> > When parallelize the loop with OpenMP like models, I need to know what >> > variables will be shared among different threads. >> >> I imagined you'd want to recognize loops, not scopes. Sounds like a >> backend kind of optimization type thing, just detecting values that >> don't escape the loop. (this would catch cases where a variable is >> declared outside the loop but never actually used in such a way, eg: >> >> int i; >> for (...) { >> i = ...; >> ... >> } >> >> // no use of 'i' here >> >> >> >> > So I want to know whether they are declared in loop scopes. >> > >> > >> > On Fri, Jul 12, 2013 at 10:57 AM, David Blaikie <dblaikie at gmail.com> >> > wrote: >> >> >> >> Clang can/now emits lifetime intrinsics to mark this information, I >> >> believe - but I'm not sure if they'll suit your needs. >> >> >> >> What are you trying to do with this information? >> >> >> >> On Thu, Jul 11, 2013 at 7:45 PM, Eric Lu <eirc.lew at gmail.com> wrote: >> >> > Hi, >> >> > >> >> > If I want to know where the stack variables are declared? For >> >> > example, >> >> > whether it is declared within a loop or not? Like variables a[100] >> >> > and >> >> > temp. >> >> > >> >> > int a[100]; >> >> > for( int i = 0; i < N; i++){ >> >> > int temp; >> >> > } >> >> > >> >> > Can this be done in LLVM IR? Or should be implemented in Clang. >> >> > >> >> > >> >> > Thanks! >> >> > >> >> > >> >> > Eric >> >> > >> >> > _______________________________________________ >> >> > LLVM Developers mailing list >> >> > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> >> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> >> > >> > >> > > >
Maybe Matching Threads
- [LLVMdev] How to recognize the declaring code scopes of stack variables
- [LLVMdev] How to recognize the declaring code scopes of stack variables
- [LLVMdev] what is the Line number of Phi Node with addr2line
- [LLVMdev] what is the Line number of Phi Node with addr2line
- [LLVMdev] Use clang to generate LLVM IR with -O3, how to visit these load operations after -reg2mem