[MemorySSA] Moving at the end often means before terminator.
authorAlina Sbirlea <asbirlea@google.com>
Thu, 21 Nov 2019 00:09:37 +0000 (16:09 -0800)
committerAlina Sbirlea <asbirlea@google.com>
Thu, 21 Nov 2019 01:11:00 +0000 (17:11 -0800)
commit5c5cf899ef2fda1d3306b1e5c384ae062b80b672
treeae648e474f1a0b2b50c22f3c94f8f37d11323db5
parent27da569a7a54e9dcb3b2c09fbdfd6b70bd6fd912
[MemorySSA] Moving at the end often means before terminator.

Moving accesses in MemorySSA at InsertionPlace::End, when an instruction is
moved into a block, almost always means insert at the end of the block, but
before the block terminator. This matters when the block terminator is a
MemoryAccess itself (an invoke), and the insertion must be done before
the terminator for the update to be correct.

Insert an additional position: InsertionPlace:BeforeTerminator and update
current usages where this applies.

Resolves PR44027.
llvm/include/llvm/Analysis/MemorySSA.h
llvm/lib/Analysis/LoopInfo.cpp
llvm/lib/Analysis/MemorySSAUpdater.cpp
llvm/lib/Transforms/Scalar/GVNHoist.cpp
llvm/lib/Transforms/Scalar/LICM.cpp
llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
llvm/test/Analysis/MemorySSA/pr44027.ll [new file with mode: 0644]