[llvm-bugs] [Bug 35637] New: Really bad codegen for libc++ vector

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Dec 11 21:00:37 PST 2017


https://bugs.llvm.org/show_bug.cgi?id=35637

            Bug ID: 35637
           Summary: Really bad codegen for libc++ vector
           Product: clang
           Version: trunk
          Hardware: Macintosh
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: mclow.lists at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

Given the following code:

        #include <vector>
        #include <memory>

        auto f1()
        {
                return std::vector<unsigned char>( 1920*1080*4 );
        }

        auto f2()
        {
                return new std::vector<unsigned char>( 1920*1080*4 );
        }

        int main() {}

clang generates fine code for "f1", noticing that it has to zero 8+MB of data,
and calling memset to do so.

For "f2", it generates a loop. Clearing a byte? at a time, and recalculating
the pointer each time.  Reproduced on godbolt with "-std=c++1z -Wall -W -O3
-stdlib=libc++" with both clang 5.0 and clang trunk.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171212/f92482e6/attachment.html>


More information about the llvm-bugs mailing list