<div dir="ltr"><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jun 3, 2014 at 3:14 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi!<div><br></div><div>This patch causes libc++ to use Clang's new __builtin_operator_new and __builtin_operator_delete builtins when possible. These builtins allow optimizations that the standard builtins do not: in particular, if we can remove all uses of an allocation, this permits removing the allocation itself too.</div>

<div><br></div><div>In particular, this allows code using std::vector and its kin to be optimized away to nothing. Previously it would get optimized to the point where only the allocation and deallocation remained.</div>
<div>
<br></div><div>This change has been applied to most calls to ::operator new and ::operator delete in libc++; I believe such optimizations are permitted by the specification of all affected library components.</div><div><br>

</div><div>The exceptions are:</div><div> * get_temporary_buffer wants to call nothrow new, and we don't support that with the builtins (that would require teaching Clang about std::nothrow_t)</div><div> * __refstring is not affected; this doesn't seem particularly worthwhile since the only purpose for it is ABI interoperability with GCC</div>

<div><br></div><div>One other caveat: the patch adds an include of <new> to <valarray>. <new> is extremely light, so I doubt this is a problem, but I thought it was worth calling out.</div></div>
</blockquote></div><br></div>