diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-20 20:14:09 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-20 20:14:09 +0000 |
commit | 3c406c2da52302eb5cced431373f240b9c037841 (patch) | |
tree | 0036fa3b9a770cedd54db3a83bfd890cb2799c2a | |
parent | 07320e403001cc192f8565d77001d281d41f4572 (diff) | |
download | bcm5719-llvm-3c406c2da52302eb5cced431373f240b9c037841.tar.gz bcm5719-llvm-3c406c2da52302eb5cced431373f240b9c037841.zip |
IR: Use SmallVector instead of std::vector of TrackingMDRef
Don't use std::vector<TrackingMDRef>, since (at least in some versions
of libc++) std::vector apparently copies values on grow operations
instead of moving them. Found this when I was temporarily deleting the
copy constructor for TrackingMDRef to investigate a performance
bottleneck.
llvm-svn: 266909
-rw-r--r-- | llvm/include/llvm/IR/DIBuilder.h | 6 | ||||
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 7 | ||||
-rw-r--r-- | llvm/lib/IR/DIBuilder.cpp | 2 |
3 files changed, 12 insertions, 3 deletions
diff --git a/llvm/include/llvm/IR/DIBuilder.h b/llvm/include/llvm/IR/DIBuilder.h index f8f003e8a0c..7ae3860dcd5 100644 --- a/llvm/include/llvm/IR/DIBuilder.h +++ b/llvm/include/llvm/IR/DIBuilder.h @@ -51,7 +51,11 @@ namespace llvm { bool AllowUnresolvedNodes; /// Each subprogram's preserved local variables. - DenseMap<MDNode *, std::vector<TrackingMDNodeRef>> PreservedVariables; + /// + /// Do not use a std::vector. Some versions of libc++ apparently copy + /// instead of move on grow operations, and TrackingMDRef is expensive to + /// copy. + DenseMap<MDNode *, SmallVector<TrackingMDNodeRef, 1>> PreservedVariables; DIBuilder(const DIBuilder &) = delete; void operator=(const DIBuilder &) = delete; diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 9c65eecad81..ae1f98f0fd6 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -107,7 +107,12 @@ class BitcodeReaderMetadataList { bool AnyFwdRefs; unsigned MinFwdRef; unsigned MaxFwdRef; - std::vector<TrackingMDRef> MetadataPtrs; + + /// Array of metadata references. + /// + /// Don't use std::vector here. Some versions of libc++ copy (instead of + /// move) on resize, and TrackingMDRef is very expensive to copy. + SmallVector<TrackingMDRef, 1> MetadataPtrs; LLVMContext &Context; public: diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp index 690918ce8a6..e46de241dfc 100644 --- a/llvm/lib/IR/DIBuilder.cpp +++ b/llvm/lib/IR/DIBuilder.cpp @@ -614,7 +614,7 @@ DIGlobalVariable *DIBuilder::createTempGlobalVariableFwdDecl( static DILocalVariable *createLocalVariable( LLVMContext &VMContext, - DenseMap<MDNode *, std::vector<TrackingMDNodeRef>> &PreservedVariables, + DenseMap<MDNode *, SmallVector<TrackingMDNodeRef, 1>> &PreservedVariables, DIScope *Scope, StringRef Name, unsigned ArgNo, DIFile *File, unsigned LineNo, DIType *Ty, bool AlwaysPreserve, unsigned Flags) { // FIXME: Why getNonCompileUnitScope()? |