[llvm-dev] Skipping construction/destruction of stack allocated objects

Alexandre Isoard via llvm-dev llvm-dev at lists.llvm.org
Tue Jan 15 18:09:32 PST 2019


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[64][64] __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

Do you see this as a good idea? Do we already have a better way of
achieving this?

I'm worried about the fact that for non-POD types it is not safe to ignore
that attribute, which probably means using an attribute is not a good fit...

*Alexandre Isoard*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190115/d0e22529/attachment.html>

More information about the llvm-dev mailing list