summaryrefslogtreecommitdiffstats
path: root/polly
diff options
context:
space:
mode:
authorTobias Grosser <tobias@grosser.es>2015-10-07 13:19:06 +0000
committerTobias Grosser <tobias@grosser.es>2015-10-07 13:19:06 +0000
commitd79cb0378b14a840e7a0cd43e0e4798bf82b20ff (patch)
tree6a839e08c2a6d6f7694ecfeb02676d45e1c7bc7e /polly
parent73725b8ba591027dc12a538c40b87640f6af273a (diff)
downloadbcm5719-llvm-d79cb0378b14a840e7a0cd43e0e4798bf82b20ff.tar.gz
bcm5719-llvm-d79cb0378b14a840e7a0cd43e0e4798bf82b20ff.zip
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
Diffstat (limited to 'polly')
-rw-r--r--polly/lib/CodeGen/IRBuilder.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/polly/lib/CodeGen/IRBuilder.cpp b/polly/lib/CodeGen/IRBuilder.cpp
index 7eb1e08c0bb..fc9a718d8b8 100644
--- a/polly/lib/CodeGen/IRBuilder.cpp
+++ b/polly/lib/CodeGen/IRBuilder.cpp
@@ -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);
OpenPOWER on IntegriCloud