<div dir="ltr">On Tue, Feb 26, 2013 at 5:42 AM, Duncan Sands <span dir="ltr"><<a href="mailto:baldrick@free.fr" target="_blank">baldrick@free.fr</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Vinod,<div><div class="h5"><br>
<br>
On 23/02/13 02:20, Vinod Grover wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Sorry if this has been discussed before, but I would appreciate any pointers.<br>
I am trying to understand why mem2reg only looks at allocas in entry blocks, and<br>
not for any allocas in a function. One case where allocas could be used to build<br>
local data structures like linked list (and so on make it unsafe), and for that<br>
the existing conditions in IsAllocaPromotable (i.e. the alloca pointer cannot<br>
escape or be stored or cast etc) should guard against that, regardless of the<br>
position of the alloca. right? Is there a reason for this?<br>
</blockquote>
<br></div></div>
an alloca outside of the entry block might be inside a loop, in which case the<br>
semantics are that it would allocate more stack space on every loop iteration.<br>
I think some of the optimizers that run later try to move allocas into the entry<br>
block if possible, but in general it is simpler to have the front-end just put<br>
them there in the first place.<br></blockquote><div><br></div><div style>Mem2reg is already changing that semantic, though.  If I use an "alloca i32" in the entry block, then I am saying I want 4 bytes of stack space, but mem2reg may replace that with registers.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Ciao, Duncan.<br>
______________________________<u></u>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvmdev</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><br><div>Thanks,</div><div><br></div><div>Justin Holewinski</div>
</div></div>