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
This commit is contained in:
Duncan P. N. Exon Smith 2016-04-19 16:57:24 +00:00
parent a1202bf594
commit a4810fac19
2 changed files with 3 additions and 2 deletions

View File

@ -109,6 +109,7 @@ public:
MDMap.emplace();
return *MDMap;
}
Optional<MDMapT> &getMDMap() { return MDMap; }
bool mayMapMetadata() const { return MayMapMetadata; }
void enableMapMetadata() { MayMapMetadata = true; }

View File

@ -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);