summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorMichael Zolotukhin <mzolotukhin@apple.com>2018-03-12 20:36:25 +0000
committerMichael Zolotukhin <mzolotukhin@apple.com>2018-03-12 20:36:25 +0000
commita3d8ef0f0821f674a24587f0a477cf33e15ae06e (patch)
tree02e4ed064021baa610395981d121c1285d1f134e /llvm/lib/Transforms
parentd1faa56f3ddfb104aad9a7b6000eca869c42d8c4 (diff)
downloadbcm5719-llvm-a3d8ef0f0821f674a24587f0a477cf33e15ae06e.tar.gz
bcm5719-llvm-a3d8ef0f0821f674a24587f0a477cf33e15ae06e.zip
Improve caching scheme in ProvenanceAnalysis.
Summary: ProvenanceAnalysis::related(A, B) currently memoizes its results, and on big tests the cache grows too large, and we're spending most of the time growing/looking through DenseMap. This patch reduces the size of the cache by normalizing keys first: we do that by calling GetUnderlyingObjCPtr on the input values. The results of GetUnderlyingObjCPtr are also memoized in a separate cache. The patch doesn't bring noticable changes to compile time on CTMark, however significantly helps one of our internal tests. Reviewers: gottesmm Subscribers: hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D44270 llvm-svn: 327328
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/ObjCARC/ProvenanceAnalysis.cpp15
-rw-r--r--llvm/lib/Transforms/ObjCARC/ProvenanceAnalysis.h3
2 files changed, 10 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/ObjCARC/ProvenanceAnalysis.cpp b/llvm/lib/Transforms/ObjCARC/ProvenanceAnalysis.cpp
index f89fc8eb62a..3004fffb974 100644
--- a/llvm/lib/Transforms/ObjCARC/ProvenanceAnalysis.cpp
+++ b/llvm/lib/Transforms/ObjCARC/ProvenanceAnalysis.cpp
@@ -115,14 +115,6 @@ static bool IsStoredObjCPointer(const Value *P) {
bool ProvenanceAnalysis::relatedCheck(const Value *A, const Value *B,
const DataLayout &DL) {
- // Skip past provenance pass-throughs.
- A = GetUnderlyingObjCPtr(A, DL);
- B = GetUnderlyingObjCPtr(B, DL);
-
- // Quick check.
- if (A == B)
- return true;
-
// Ask regular AliasAnalysis, for a first approximation.
switch (AA->alias(A, B)) {
case NoAlias:
@@ -171,6 +163,13 @@ bool ProvenanceAnalysis::relatedCheck(const Value *A, const Value *B,
bool ProvenanceAnalysis::related(const Value *A, const Value *B,
const DataLayout &DL) {
+ A = GetUnderlyingObjCPtrCached(A, DL, UnderlyingObjCPtrCache);
+ B = GetUnderlyingObjCPtrCached(B, DL, UnderlyingObjCPtrCache);
+
+ // Quick check.
+ if (A == B)
+ return true;
+
// Begin by inserting a conservative value into the map. If the insertion
// fails, we have the answer already. If it succeeds, leave it there until we
// compute the real answer to guard against recursive queries.
diff --git a/llvm/lib/Transforms/ObjCARC/ProvenanceAnalysis.h b/llvm/lib/Transforms/ObjCARC/ProvenanceAnalysis.h
index 5e676167a6a..f21ea3666b1 100644
--- a/llvm/lib/Transforms/ObjCARC/ProvenanceAnalysis.h
+++ b/llvm/lib/Transforms/ObjCARC/ProvenanceAnalysis.h
@@ -56,6 +56,8 @@ class ProvenanceAnalysis {
CachedResultsTy CachedResults;
+ DenseMap<const Value *, const Value *> UnderlyingObjCPtrCache;
+
bool relatedCheck(const Value *A, const Value *B, const DataLayout &DL);
bool relatedSelect(const SelectInst *A, const Value *B);
bool relatedPHI(const PHINode *A, const Value *B);
@@ -73,6 +75,7 @@ public:
void clear() {
CachedResults.clear();
+ UnderlyingObjCPtrCache.clear();
}
};
OpenPOWER on IntegriCloud