[PATCH] D22527: Make MemorySSA::dominates/locallydominates constant time

Daniel Berlin via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 19 15:51:28 PDT 2016


dberlin marked 3 inline comments as done.

================
Comment at: include/llvm/Transforms/Utils/MemorySSA.h:635
@@ +634,3 @@
+  // global.
+  mutable DenseMap<const BasicBlock *, bool> BlockNumberingValid;
+  mutable DenseMap<const MemoryAccess *, unsigned long> BlockNumbering;
----------------
george.burgess.iv wrote:
> Given that we only ever store `true` for the value, can this be a `DenseSet` instead?
Replaced with SmallPtrSet

================
Comment at: lib/Transforms/Utils/MemorySSA.cpp:1205
@@ -1207,3 +1204,3 @@
 
 MemoryPhi *MemorySSA::createMemoryPhi(BasicBlock *BB) {
   assert(!getMemoryAccess(BB) && "MemoryPhi already exists for this BB");
----------------
george.burgess.iv wrote:
> Do we need to invalidate numbering here, as well? (Alternatively, we could start all counts from 2, and always give a newly-created phi a value of 1, but that could also be done later as a part of the "number with a stride of N" optimization)
Fixed.
We can actually just answer PHI queries without ever numbering, them ever.
There is only ever one phi. It always must be first :)

so after the equality/etc checks in dominates, you could do

```

if (isa<MemoryPhi>(Dominator))
  return true;
if (isa<MemoryPhi>(Dominatee))
  return false;
```
But we can do this in a followup if it matters.



https://reviews.llvm.org/D22527





More information about the llvm-commits mailing list