[PATCH] D59151: [BasicAA] Reduce no of map searches. Assert map entry exists. [NFCI]
Alina Sbirlea via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 20 22:01:49 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356644: [BasicAA] Reduce no of map seaches [NFCI]. (authored by asbirlea, committed by ).
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59151/new/
https://reviews.llvm.org/D59151
Files:
llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
Index: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
===================================================================
--- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
+++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
@@ -1585,10 +1585,15 @@
// that causes a MayAlias.
// Pretend the phis do not alias.
AliasResult Alias = NoAlias;
- assert(AliasCache.count(Locs) &&
- "There must exist an entry for the phi node");
- AliasResult OrigAliasResult = AliasCache[Locs];
- AliasCache[Locs] = NoAlias;
+ AliasResult OrigAliasResult;
+ {
+ // Limited lifetime iterator invalidated by the aliasCheck call below.
+ auto CacheIt = AliasCache.find(Locs);
+ assert((CacheIt != AliasCache.end()) &&
+ "There must exist an entry for the phi node");
+ OrigAliasResult = CacheIt->second;
+ CacheIt->second = NoAlias;
+ }
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
AliasResult ThisAlias =
@@ -1601,9 +1606,11 @@
}
// Reset if speculation failed.
- if (Alias != NoAlias)
- AliasCache[Locs] = OrigAliasResult;
-
+ if (Alias != NoAlias) {
+ auto Pair = AliasCache.insert(std::make_pair(Locs, OrigAliasResult));
+ assert(!Pair.second && "Entry must have existed");
+ Pair.first->second = OrigAliasResult;
+ }
return Alias;
}
@@ -1824,8 +1831,11 @@
if (const PHINode *PN = dyn_cast<PHINode>(V1)) {
AliasResult Result = aliasPHI(PN, V1Size, V1AAInfo,
V2, V2Size, V2AAInfo, O2);
- if (Result != MayAlias)
- return AliasCache[Locs] = Result;
+ if (Result != MayAlias) {
+ Pair = AliasCache.insert(std::make_pair(Locs, Result));
+ assert(!Pair.second && "Entry must have existed");
+ return Pair.first->second = Result;
+ }
}
if (isa<SelectInst>(V2) && !isa<SelectInst>(V1)) {
@@ -1837,8 +1847,11 @@
if (const SelectInst *S1 = dyn_cast<SelectInst>(V1)) {
AliasResult Result =
aliasSelect(S1, V1Size, V1AAInfo, V2, V2Size, V2AAInfo, O2);
- if (Result != MayAlias)
- return AliasCache[Locs] = Result;
+ if (Result != MayAlias) {
+ Pair = AliasCache.insert(std::make_pair(Locs, Result));
+ assert(!Pair.second && "Entry must have existed");
+ return Pair.first->second = Result;
+ }
}
// If both pointers are pointing into the same object and one of them
@@ -1846,14 +1859,19 @@
if (O1 == O2)
if (V1Size.isPrecise() && V2Size.isPrecise() &&
(isObjectSize(O1, V1Size.getValue(), DL, TLI, NullIsValidLocation) ||
- isObjectSize(O2, V2Size.getValue(), DL, TLI, NullIsValidLocation)))
- return AliasCache[Locs] = PartialAlias;
+ isObjectSize(O2, V2Size.getValue(), DL, TLI, NullIsValidLocation))) {
+ Pair = AliasCache.insert(std::make_pair(Locs, PartialAlias));
+ assert(!Pair.second && "Entry must have existed");
+ return Pair.first->second = PartialAlias;
+ }
// Recurse back into the best AA results we have, potentially with refined
// memory locations. We have already ensured that BasicAA has a MayAlias
// cache result for these, so any recursion back into BasicAA won't loop.
AliasResult Result = getBestAAResults().alias(Locs.first, Locs.second);
- return AliasCache[Locs] = Result;
+ Pair = AliasCache.insert(std::make_pair(Locs, Result));
+ assert(!Pair.second && "Entry must have existed");
+ return Pair.first->second = Result;
}
/// Check whether two Values can be considered equivalent.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59151.191631.patch
Type: text/x-patch
Size: 3617 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190321/17e070a1/attachment.bin>
More information about the llvm-commits
mailing list