[LLVMdev] mem2reg for non entry blocks?

Justin Holewinski justin.holewinski at gmail.com
Tue Feb 26 05:13:07 PST 2013


On Tue, Feb 26, 2013 at 5:42 AM, Duncan Sands <baldrick at free.fr> wrote:

> Hi Vinod,
>
>
> On 23/02/13 02:20, Vinod Grover wrote:
>
>> Sorry if this has been discussed before, but I would appreciate any
>> pointers.
>> I am trying to understand why mem2reg only looks at allocas in entry
>> blocks, and
>> not for any allocas in a function. One case where allocas could be used
>> to build
>> local data structures like linked list (and so on make it unsafe), and
>> for that
>> the existing conditions in IsAllocaPromotable (i.e. the alloca pointer
>> cannot
>> escape or be stored or cast etc) should guard against that, regardless of
>> the
>> position of the alloca. right? Is there a reason for this?
>>
>
> an alloca outside of the entry block might be inside a loop, in which case
> the
> semantics are that it would allocate more stack space on every loop
> iteration.
> I think some of the optimizers that run later try to move allocas into the
> entry
> block if possible, but in general it is simpler to have the front-end just
> put
> them there in the first place.
>

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.


>
> Ciao, Duncan.
> ______________________________**_________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/**mailman/listinfo/llvmdev<http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev>
>



-- 

Thanks,

Justin Holewinski
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130226/bd539e02/attachment.html>


More information about the llvm-dev mailing list