[MemorySSA] Fix def optimization handling
authorGeorge Burgess IV <george.burgess.iv@gmail.com>
Thu, 23 Aug 2018 21:29:11 +0000 (21:29 +0000)
committerGeorge Burgess IV <george.burgess.iv@gmail.com>
Thu, 23 Aug 2018 21:29:11 +0000 (21:29 +0000)
commit6f6fe701a09549988cb590f58e368e3978e8c7d2
treec5bb970fcd21eb7a1fc7fbb1f7e6d8ca0d522f18
parent14b838a1ca404bef35edb8458ae4fc12d33fc09a
[MemorySSA] Fix def optimization handling

In order for more complex updates of MSSA to happen (e.g. those in
D45299), MemoryDefs need to be actual `Use`s of what they're optimized
to. This patch makes that happen.

In addition, this patch changes our optimization behavior for Defs
slightly: we'll now consider a Def optimization invalid if the
MemoryAccess it's optimized to changes. That we weren't doing this
before was a bug, but given that we were tracking these with a WeakVH
before, it was sort of difficult for that to matter.

We're already have both of these behaviors for MemoryUses. The
difference is that a MemoryUse's defining access is always its optimized
access, and defining accesses are always `Use`s (in the LLVM sense).

Nothing exploded when testing a stage3 clang+llvm locally, so...

This also includes the test-case promised in r340461.

llvm-svn: 340577
llvm/include/llvm/Analysis/MemorySSA.h
llvm/unittests/Analysis/MemorySSA.cpp