[PATCH] D40802: [MemDep] Don't use cached results from a previous larger query

Dan Gohman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 6 12:30:19 PST 2017


sunfish marked an inline comment as done.
sunfish added inline comments.


================
Comment at: lib/Analysis/MemoryDependenceAnalysis.cpp:1129
   if (!Pair.second) {
-    if (CacheInfo->Size < Loc.Size) {
-      // The query's Size is greater than the cached one. Throw out the
-      // cached data and proceed with the query at the greater size.
+    if (CacheInfo->Size != Loc.Size) {
+      // The query's Size differs from the cached one. Throw out the
----------------
sanjoy wrote:
> You can still use the result if `CacheInfo->Size` is UnknownSize, right?
> 
> And, secondly, any reason to not add the size to the cache key as well?
Yes, I think reusing the result from an `UnknownSize` query would be conservatively correct, though it would be less precise. Also, yes, we could add the size, and the AATags too for that matter, to the key, however it would make the DenseMap use more memory.

My expectation, which seems supported by some ad-hoc experiments, is that repeated queries with the same pointer and differing sizes aren't very common. Assuming this is true in general, it seems best to avoid pessimizing common cases to optimize it.


Repository:
  rL LLVM

https://reviews.llvm.org/D40802





More information about the llvm-commits mailing list