<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 6, 2015 at 3:02 AM, David Chisnall <span dir="ltr"><<a href="mailto:David.Chisnall@cl.cam.ac.uk" target="_blank">David.Chisnall@cl.cam.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 5 Apr 2015, at 16:52, Dave Pitsbawn <<a href="mailto:dpitsbawn@gmail.com">dpitsbawn@gmail.com</a>> wrote:<br>
><br>
> David why do you say it is particularly bad IR (other than not having gone through SROA).<br>
<br>
</span>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.<br>
<br>
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.<br></blockquote><div><br></div><div>Maybe the IR doc should be updated to reflect these fine points.</div><div> </div></div></div></div>