<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 20, 2016 at 1:14 PM, Duncan P. N. Exon Smith via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: dexonsmith<br>
Date: Wed Apr 20 15:14:09 2016<br>
New Revision: 266909<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=266909&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=266909&view=rev</a><br>
Log:<br>
IR: Use SmallVector instead of std::vector of TrackingMDRef<br>
<br>
Don't use std::vector<TrackingMDRef>, since (at least in some versions<br>
of libc++) std::vector apparently copies values on grow operations<br>
instead of moving them. Found this when I was temporarily deleting the<br>
copy constructor for TrackingMDRef to investigate a performance<br>
bottleneck.<br></blockquote><div><br></div><div>Got a build log? That seems unlikely, since we have vectors of unique_ptr in the codebase. Perhaps you used some specific operation that required a copy?<br><br>I imagine the append you had in the previous patch? Should've been an append with move_iterators? (& maybe that should've been 'assign' instead, I think - in passing)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Modified:<br>
llvm/trunk/include/llvm/IR/DIBuilder.h<br>
llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp<br>
llvm/trunk/lib/IR/DIBuilder.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/IR/DIBuilder.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DIBuilder.h?rev=266909&r1=266908&r2=266909&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DIBuilder.h?rev=266909&r1=266908&r2=266909&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/IR/DIBuilder.h (original)<br>
+++ llvm/trunk/include/llvm/IR/DIBuilder.h Wed Apr 20 15:14:09 2016<br>
@@ -51,7 +51,11 @@ namespace llvm {<br>
bool AllowUnresolvedNodes;<br>
<br>
/// Each subprogram's preserved local variables.<br>
- DenseMap<MDNode *, std::vector<TrackingMDNodeRef>> PreservedVariables;<br>
+ ///<br>
+ /// Do not use a std::vector. Some versions of libc++ apparently copy<br>
+ /// instead of move on grow operations, and TrackingMDRef is expensive to<br>
+ /// copy.<br>
+ DenseMap<MDNode *, SmallVector<TrackingMDNodeRef, 1>> PreservedVariables;<br>
<br>
DIBuilder(const DIBuilder &) = delete;<br>
void operator=(const DIBuilder &) = delete;<br>
<br>
Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=266909&r1=266908&r2=266909&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=266909&r1=266908&r2=266909&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)<br>
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Wed Apr 20 15:14:09 2016<br>
@@ -107,7 +107,12 @@ class BitcodeReaderMetadataList {<br>
bool AnyFwdRefs;<br>
unsigned MinFwdRef;<br>
unsigned MaxFwdRef;<br>
- std::vector<TrackingMDRef> MetadataPtrs;<br>
+<br>
+ /// Array of metadata references.<br>
+ ///<br>
+ /// Don't use std::vector here. Some versions of libc++ copy (instead of<br>
+ /// move) on resize, and TrackingMDRef is very expensive to copy.<br>
+ SmallVector<TrackingMDRef, 1> MetadataPtrs;<br>
<br>
LLVMContext &Context;<br>
public:<br>
<br>
Modified: llvm/trunk/lib/IR/DIBuilder.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DIBuilder.cpp?rev=266909&r1=266908&r2=266909&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DIBuilder.cpp?rev=266909&r1=266908&r2=266909&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/IR/DIBuilder.cpp (original)<br>
+++ llvm/trunk/lib/IR/DIBuilder.cpp Wed Apr 20 15:14:09 2016<br>
@@ -614,7 +614,7 @@ DIGlobalVariable *DIBuilder::createTempG<br>
<br>
static DILocalVariable *createLocalVariable(<br>
LLVMContext &VMContext,<br>
- DenseMap<MDNode *, std::vector<TrackingMDNodeRef>> &PreservedVariables,<br>
+ DenseMap<MDNode *, SmallVector<TrackingMDNodeRef, 1>> &PreservedVariables,<br>
DIScope *Scope, StringRef Name, unsigned ArgNo, DIFile *File,<br>
unsigned LineNo, DIType *Ty, bool AlwaysPreserve, unsigned Flags) {<br>
// FIXME: Why getNonCompileUnitScope()?<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>