intended use/structure of AllocA/local variables

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

intended use/structure of AllocA/local variables

edA-qa mort-ora-y
I'm trying to determine what is the best approach to using AllocA.
Currently I just allocate all my variables at the beginning of the
function but wondering if they should rather be done closer to the scope
they are used. This would also require a way to do a free on the
allocated structure, but there doesn't appear to be such a function.

Is it the intent that all stack variables are alloc'd at the beginning
of the function? I guess this has the advantage that LLVM then knows the
full size of the function's stack at entry and can just use fixed
offsets for all variables. It has the disadvantage that all potentially
used stack variables are always allocated, which uses more stack memory
than is actually required.

What's the intended practice with AllocA?

Can the optimizer determine when the use of two AllocA spaces is
exclusive and share the stack space?

--
edA-qa mort-ora-y
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Sign: Please digitally sign your emails.
Encrypt: I'm also happy to receive encrypted mail.


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

signature.asc (269 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: intended use/structure of AllocA/local variables

Duncan Sands
Hi,

On 02/07/13 05:14, edA-qa mort-ora-y wrote:
> I'm trying to determine what is the best approach to using AllocA.
> Currently I just allocate all my variables at the beginning of the
> function but wondering if they should rather be done closer to the scope
> they are used. This would also require a way to do a free on the
> allocated structure, but there doesn't appear to be such a function.

just allocate them at the start and use lifetime intrinsics to tell LLVM
when they are actually in use.

>
> Is it the intent that all stack variables are alloc'd at the beginning
> of the function? I guess this has the advantage that LLVM then knows the
> full size of the function's stack at entry and can just use fixed
> offsets for all variables. It has the disadvantage that all potentially
> used stack variables are always allocated, which uses more stack memory
> than is actually required.
>
> What's the intended practice with AllocA?
>
> Can the optimizer determine when the use of two AllocA spaces is
> exclusive and share the stack space?

The code generators will reuse stack space if it can.  You can help it out
using the lifetime intrinsics mentioned above.

Ciao, Duncan.

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev