[LLVMdev] alloca not in first bb behaving differently
Gabriel Dos Reis
gdr at integrable-solutions.net
Mon Apr 6 05:33:17 PDT 2015
On Mon, Apr 6, 2015 at 3:02 AM, David Chisnall <David.Chisnall at cl.cam.ac.uk>
wrote:
> On 5 Apr 2015, at 16:52, Dave Pitsbawn <dpitsbawn at gmail.com> wrote:
> >
> > David why do you say it is particularly bad IR (other than not having
> gone through SROA).
>
> If you place all of your allocas (other than ones for things like C VLAs
> in loops) at the start of the entry basic block and then use the lifetime
> markers for local variables with restricted scope, you make it much easier
> for the optimisers to handle the code. For something this simple, it
> probably doesn't make a difference (I'd expect SROA + SimplifyCFG to
> optimise the whole thing away), but in more complex code having allocas
> outside of the first basic block can cause problems.
>
> It's generally a good idea to keep around an IRBuilder with an insert
> point initialised to the start of the entry BB and use this to create
> allocas.
>
Maybe the IR doc should be updated to reflect these fine points.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150406/234edea2/attachment.html>
More information about the llvm-dev
mailing list