diff options
| author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-19 16:57:24 +0000 |
|---|---|---|
| committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-19 16:57:24 +0000 |
| commit | a4810fac198c496d8e16c99da0fe57b89be8598e (patch) | |
| tree | aa1f2f025f2d9403e8732dafc1845b529fb25134 | |
| parent | a1202bf5944ad4a28d1e391a0a2da175bd9b27d0 (diff) | |
| download | bcm5719-llvm-a4810fac198c496d8e16c99da0fe57b89be8598e.tar.gz bcm5719-llvm-a4810fac198c496d8e16c99da0fe57b89be8598e.zip | |
Linker: Avoid constructing ValueMap::MDMapT
Calling ValueMap::MD lazily constructs a ValueMap, which mallocs the
buckets. Instead of swapping constructed maps, move around the
underlying Optional<MDMapT>. This gets rid of some unnecessary malloc
traffic from r266579 (not that it showed up on a profile).
llvm-svn: 266761
| -rw-r--r-- | llvm/include/llvm/IR/ValueMap.h | 1 | ||||
| -rw-r--r-- | llvm/lib/Linker/IRMover.cpp | 4 |
2 files changed, 3 insertions, 2 deletions
diff --git a/llvm/include/llvm/IR/ValueMap.h b/llvm/include/llvm/IR/ValueMap.h index 043e813b09b..85379ad468c 100644 --- a/llvm/include/llvm/IR/ValueMap.h +++ b/llvm/include/llvm/IR/ValueMap.h @@ -109,6 +109,7 @@ public: MDMap.emplace(); return *MDMap; } + Optional<MDMapT> &getMDMap() { return MDMap; } bool mayMapMetadata() const { return MayMapMetadata; } void enableMapMetadata() { MayMapMetadata = true; } diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp index 81858bd421f..b4d91d186e1 100644 --- a/llvm/lib/Linker/IRMover.cpp +++ b/llvm/lib/Linker/IRMover.cpp @@ -483,11 +483,11 @@ public: &GValMaterializer), AliasMCID(Mapper.registerAlternateMappingContext(AliasValueMap, &LValMaterializer)) { - ValueMap.MD().swap(SharedMDs); + ValueMap.getMDMap() = std::move(SharedMDs); for (GlobalValue *GV : ValuesToLink) maybeAdd(GV); } - ~IRLinker() { ValueMap.MD().swap(SharedMDs); } + ~IRLinker() { SharedMDs = std::move(*ValueMap.getMDMap()); } bool run(); Value *materializeDeclFor(Value *V, bool ForAlias); |

