forked from OSchip/llvm-project
IRBuilder: Ensure we do not add empty map elements
Do not use "Map[Key] == nullptr" to check if a Key is in the map, but use "Map.find(Key) == Map.end()". Map[Key] always adds Key into the map, a side-effect we do not want. Found by inspection. This is hard to test outside of a targetted unit test, which seems too much overhead for this individual issue. llvm-svn: 249544
This commit is contained in:
parent
73725b8ba5
commit
d79cb0378b
|
@ -146,12 +146,22 @@ void ScopAnnotator::annotate(Instruction *Inst) {
|
|||
if (!BasePtr)
|
||||
return;
|
||||
|
||||
auto *AliasScope = AliasScopeMap[BasePtr];
|
||||
auto AliasScopeIterator = AliasScopeMap.find(BasePtr);
|
||||
|
||||
if (!AliasScope)
|
||||
BasePtr = AlternativeAliasBases[BasePtr];
|
||||
if (AliasScopeIterator == AliasScopeMap.end()) {
|
||||
auto I = AlternativeAliasBases.find(BasePtr);
|
||||
if (I == AlternativeAliasBases.end())
|
||||
return;
|
||||
|
||||
AliasScope = AliasScopeMap[BasePtr];
|
||||
BasePtr = I->second;
|
||||
AliasScopeIterator = AliasScopeMap.find(BasePtr);
|
||||
if (AliasScopeIterator == AliasScopeMap.end())
|
||||
return;
|
||||
}
|
||||
|
||||
auto AliasScope = AliasScopeIterator->second;
|
||||
assert(OtherAliasScopeListMap.count(BasePtr) &&
|
||||
"BasePtr either expected in AliasScopeMap and OtherAlias...Map");
|
||||
auto *OtherAliasScopeList = OtherAliasScopeListMap[BasePtr];
|
||||
|
||||
Inst->setMetadata("alias.scope", AliasScope);
|
||||
|
|
Loading…
Reference in New Issue