Thank you John and John :P
these optimizations (mem2reg and the "few additional" ones) I have to
enable
then or something like this?? (I compile the .ll to .o with the sequence
llvm-as, llc, as)
Yet about dynamic stack allocation, what is (generally) better? to pre alloc
everything at start, or let it be?
Imagine this pseudo-code
while (x) {
int b = 0;
...
}
using alloca where b is declared, it will grow the stack dynamically, but it
will shrink it at } or in llvm's words in the end of a block where b is not
accessible anymore? Can I force its deallocation??
Thanks again
On Mon, Mar 14, 2011 at 10:23 PM, John McCall <rjmccall at apple.com>
wrote:
> On Mar 14, 2011, at 5:56 PM, John Criswell wrote:
> > On 3/14/11 7:52 PM, Judison wrote:
> >>
> >> 2) does the LLVM optimizes this:
> >>
> >> ; this code (arg -> var) is very similar to what gcc generates
> >> define void @foo(i32 %arg0) {
> >> entry:
> >> %var0 = alloca i32
> >> store i32 %arg0, i32* var0
> >> ...
> >> %x = load i32* %var0
> >> ....
> >> ; never more stores to %var0 or pass it to any function
> >> }
> >>
> >> to something like:
> >>
> >> define void @foo(i32 arg0) {
> >> entry:
> >> ; no alloca
> >> ....
> >> %x = %arg0
> >> ....
> >> }
> >>
> >> does it???
> >
> > I suspect that mem2reg plus a few additional optimizations will do
this
> for you.
>
> mem2reg is sufficient. There's also no limit on the number of loads
> and stores you can do without disturbing the optimization; just
> don't do anything too opaque with the address.
>
> John.
--
Judison
judison at gmail.com
"O ignorante que procura se instruir é como um sábio; o sábio que fala sem
discernimento se assemelha a um ignorante." Imam Ali (as)
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20110314/8497cd56/attachment.html>