]> granicus.if.org Git - llvm/commit
[MemorySSA] Add previous def to cache when found, even if trivial.
authorAlina Sbirlea <asbirlea@google.com>
Fri, 12 Apr 2019 21:58:52 +0000 (21:58 +0000)
committerAlina Sbirlea <asbirlea@google.com>
Fri, 12 Apr 2019 21:58:52 +0000 (21:58 +0000)
commit145d06055b9975b22182efd4ac0d5aa81d531e3b
tree97cd3e83417f930d8f48c6b83aef25e7d0a901d1
parente95bdd94424bab5fb1a890e0eab5c8bfce0c7528
[MemorySSA] Add previous def to cache when found, even if trivial.

Summary:
When inserting a new Def, MemorySSA may be have non-minimal number of Phis.
While inserting, the walk to find the previous definition may cleanup minimal Phis.
When the last definition is trivial to obtain, we do not cache it.

It is possible while getting the previous definition for a Def to get two different answers:
- one that was straight-forward to find when walking the first path (a trivial phi in this case), and
- another that follows a cleanup of the trivial phi, it determines it may need additional Phi nodes, it inserts them and returns a new phi in the same position as the former trivial one.
While the Phis added for the second path are all redundant, they are not complete (the walk is only done upwards), and they are not properly cleaned up afterwards.

A way to fix this problem is to cache the straight-forward answer we got on the first walk.
The caching is only kept for the duration of a getPreviousDef call, and for Phis we use TrackingVH, so removing the trivial phi will lead to replacing it with the next dominating phi in the cache.
Resolves PR40749.

Reviewers: george.burgess.iv

Subscribers: jlebar, Prazek, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D60634

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358313 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/MemorySSAUpdater.cpp
test/Analysis/MemorySSA/pr40749_2.ll [new file with mode: 0644]