[polly] r249544 - IRBuilder: Ensure we do not add empty map elements
Tobias Grosser via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 7 06:19:06 PDT 2015
Author: grosser
Date: Wed Oct 7 08:19:06 2015
New Revision: 249544
URL: http://llvm.org/viewvc/llvm-project?rev=249544&view=rev
Log:
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.
Modified:
polly/trunk/lib/CodeGen/IRBuilder.cpp
Modified: polly/trunk/lib/CodeGen/IRBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IRBuilder.cpp?rev=249544&r1=249543&r2=249544&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IRBuilder.cpp (original)
+++ polly/trunk/lib/CodeGen/IRBuilder.cpp Wed Oct 7 08:19:06 2015
@@ -146,12 +146,22 @@ void ScopAnnotator::annotate(Instruction
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);
More information about the llvm-commits
mailing list