[LLVMdev] How to recognize the declaring code scopes of stack variables
David Blaikie
dblaikie at gmail.com
Thu Jul 11 21:42:26 PDT 2013
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
>> >> >
>> >
>> >
>
>
More information about the llvm-dev
mailing list