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:
parent
a1202bf594
commit
a4810fac19
|
@ -109,6 +109,7 @@ public:
|
|||
MDMap.emplace();
|
||||
return *MDMap;
|
||||
}
|
||||
Optional<MDMapT> &getMDMap() { return MDMap; }
|
||||
|
||||
bool mayMapMetadata() const { return MayMapMetadata; }
|
||||
void enableMapMetadata() { MayMapMetadata = true; }
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue