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