<div dir="ltr">Forwarding to cfe-dev as per Chandler's suggestion.<br><br><div class="gmail_quote"><div dir="ltr">---------- Forwarded message ---------<br>From: <strong class="gmail_sendername" dir="auto">Eli Friedman</strong> <span dir="ltr"><<a href="mailto:efriedma@codeaurora.org">efriedma@codeaurora.org</a>></span><br>Date: Tue, Jan 15, 2019 at 7:16 PM<br>Subject: Re: [llvm-dev] Skipping construction/destruction of stack allocated objects<br>To: Alexandre Isoard <<a href="mailto:alexandre.isoard@gmail.com">alexandre.isoard@gmail.com</a>>, llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>><br></div><br><br>On 1/15/2019 6:09 PM, Alexandre Isoard via llvm-dev wrote:<br>
> Hello,<br>
><br>
> For performance reasons, I would like to provide a way to skip <br>
> construction/destruction of objects that are stack allocated. <br>
> Typically, C-style arrays of std::complex create an initialization <br>
> loops that is almost always unnecessary.<br>
><br>
> I am thinking of providing an __attribute__((uninitialized)) that can <br>
> be applied to an object declaration:<br>
><br>
> {<br>
> std::complex<float> foo[64][64] __attribute__((uninitialized));<br>
> // does not need to generate a zeroinitializer loop here<br>
> somefunction(foo);<br>
> // does not need to generate a destructor loop here <br>
> (std::complex<float> don't have one anyway)<br>
> }<br>
><br>
> Formally speaking, we won't call constructors/destructors on those <br>
> objects anymore. We would provide "uninitialized" memory in the same <br>
> meaning as malloc/free.<br>
><br>
> Do you see this as a good idea? Do we already have a better way of <br>
> achieving this?<br>
<br>
The standard way to allocate uninitialized storage in C++ is <br>
std::aligned_storage. The proposed extension doesn't really seem like <br>
an improvement over that.<br>
<br>
-Eli<br>
<br>
-- <br>
Employee of Qualcomm Innovation Center, Inc.<br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project<br>
<br>
</div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><b>Alexandre Isoard</b><br></div></div></div>