- // If this query's TBAATag is inconsistent with the cached one, discard the
- // tag and restart the query.
- if (CacheInfo->TBAATag != Loc.TBAATag) {
- CacheInfo->TBAATag = 0;
- NonLocalPointerDeps.erase(CacheKey);
- return getNonLocalPointerDepFromBB(Pointer, Loc.getWithoutTBAATag(),
- isLoad, StartBB, Result, Visited,
- SkipFirstBlock);
+ // Set up a temporary NLPI value. If the map doesn't yet have an entry for
+ // CacheKey, this value will be inserted as the associated value. Otherwise,
+ // it'll be ignored, and we'll have to check to see if the cached size and
+ // tbaa tag are consistent with the current query.
+ NonLocalPointerInfo InitialNLPI;
+ InitialNLPI.Size = Loc.Size;
+ InitialNLPI.TBAATag = Loc.TBAATag;
+
+ // Get the NLPI for CacheKey, inserting one into the map if it doesn't
+ // already have one.
+ std::pair<CachedNonLocalPointerInfo::iterator, bool> Pair =
+ NonLocalPointerDeps.insert(std::make_pair(CacheKey, InitialNLPI));
+ NonLocalPointerInfo *CacheInfo = &Pair.first->second;
+
+ if (!Pair.second) {
+ // If this query's Size is inconsistent with the cached one, take the
+ // maximum size and restart the query.
+ if (CacheInfo->Size != Loc.Size) {
+ CacheInfo->Size = std::max(CacheInfo->Size, Loc.Size);
+ return getNonLocalPointerDepFromBB(Pointer,
+ Loc.getWithNewSize(CacheInfo->Size),
+ isLoad, StartBB, Result, Visited,
+ SkipFirstBlock);
+ }
+
+ // If this query's TBAATag is inconsistent with the cached one, discard the
+ // tag and restart the query.
+ if (CacheInfo->TBAATag != Loc.TBAATag) {
+ CacheInfo->TBAATag = 0;
+ return getNonLocalPointerDepFromBB(Pointer, Loc.getWithoutTBAATag(),
+ isLoad, StartBB, Result, Visited,
+ SkipFirstBlock);
+ }