<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - std::vector ctor for POD type from pointer range results in horrible codegen"
href="http://llvm.org/bugs/show_bug.cgi?id=20830">20830</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>std::vector ctor for POD type from pointer range results in horrible codegen
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>arseny.kapoulkine@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu, mclow.lists@gmail.com
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=12970" name="attach_12970" title="Full disassembly for the problematic code">attachment 12970</a> <a href="attachment.cgi?id=12970&action=edit" title="Full disassembly for the problematic code">[details]</a></span>
Full disassembly for the problematic code
Using clang from Xcode 6 Beta 3:
Apple LLVM version 6.0 (clang-600.0.38) (based on LLVM 3.5svn)
Compiling the following code:
std::vector<char> build(const char* data, size_t size) { return
std::vector<char>(data, data + size); }
Results in the assembly with *this* as an inner loop (clang++ -O3):
LBB0_5: ## =>This Inner Loop Header: Depth=1
testq %rcx, %rcx
movl $0, %eax
je LBB0_7
## BB#6: ## in Loop: Header=BB0_5 Depth=1
movb (%rbx), %al
movb %al, (%rcx)
movq 8(%r14), %rax
LBB0_7: ##
%_ZNSt3__116allocator_traitsINS_9allocatorIcEEE9constructIccEEvRS2_PT_RKT0_.exit.i.i.i
## in Loop: Header=BB0_5 Depth=1
incq %rax
movq %rax, 8(%r14)
incq %rbx
decq %r15
movq %rax, %rcx
jne LBB0_5
With -stdlib=libstdc++ I get "callq _memcpy" instead.
Changing libc++ sources to hoist __end_ into a local does not help very much -
it removes redundant load/store instructions for __end_ but the loop is still
there.
Also I'm not sure why "decq %r15" is here - as far as I can see compiler should
have removed it. Can someone confirm that this part looks like a separate
optimization issue and warrants filing a separate LLVM bug?
Full disassembly dump attached.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>