Thank you John and John :P<br><br>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)<br><br>Yet about dynamic stack allocation, what is (generally) better? to pre alloc everything at start, or let it be?<br>
<br>Imagine this pseudo-code<br><br>while (x) {<br>  int b = 0;<br>  ...<br>}<br><br>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??<br>
<br>Thanks again<br><br><div class="gmail_quote">On Mon, Mar 14, 2011 at 10:23 PM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com">rjmccall@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">On Mar 14, 2011, at 5:56 PM, John Criswell wrote:<br>
> On 3/14/11 7:52 PM, Judison wrote:<br>
>><br>
</div><div class="im">>> 2) does the LLVM optimizes this:<br>
>><br>
>> ; this code (arg -> var) is very similar to what gcc generates<br>
>> define void @foo(i32 %arg0) {<br>
>> entry:<br>
>>     %var0 = alloca i32<br>
>>     store i32 %arg0, i32* var0<br>
>>     ...<br>
>>     %x = load i32* %var0<br>
>>     ....<br>
>>     ; never more stores to %var0 or pass it to any function<br>
>> }<br>
>><br>
>> to something like:<br>
>><br>
>> define void @foo(i32 arg0) {<br>
>> entry:<br>
>>     ; no alloca<br>
>>     ....<br>
>>     %x = %arg0<br>
>>    ....<br>
>> }<br>
>><br>
>> does it???<br>
><br>
> I suspect that mem2reg plus a few additional optimizations will do this for you.<br>
<br>
</div>mem2reg is sufficient.  There's also no limit on the number of loads<br>
and stores you can do without disturbing the optimization;  just<br>
don't do anything too opaque with the address.<br>
<font color="#888888"><br>
John.</font></blockquote></div><br><br clear="all"><br>-- <br>Judison<br><a href="mailto:judison@gmail.com" target="_blank">judison@gmail.com</a><br><br>"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)<br>