diff options
| author | Alina Sbirlea <asbirlea@google.com> | 2019-11-20 16:09:37 -0800 |
|---|---|---|
| committer | Alina Sbirlea <asbirlea@google.com> | 2019-11-20 17:11:00 -0800 |
| commit | 5c5cf899ef2fda1d3306b1e5c384ae062b80b672 (patch) | |
| tree | ae648e474f1a0b2b50c22f3c94f8f37d11323db5 /llvm/lib/Analysis | |
| parent | 27da569a7a54e9dcb3b2c09fbdfd6b70bd6fd912 (diff) | |
| download | bcm5719-llvm-5c5cf899ef2fda1d3306b1e5c384ae062b80b672.tar.gz bcm5719-llvm-5c5cf899ef2fda1d3306b1e5c384ae062b80b672.zip | |
[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.
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/LoopInfo.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/Analysis/MemorySSAUpdater.cpp | 8 |
2 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp index 663b42c55f1..3e3303cbb02 100644 --- a/llvm/lib/Analysis/LoopInfo.cpp +++ b/llvm/lib/Analysis/LoopInfo.cpp @@ -106,7 +106,8 @@ bool Loop::makeLoopInvariant(Instruction *I, bool &Changed, I->moveBefore(InsertPt); if (MSSAU) if (auto *MUD = MSSAU->getMemorySSA()->getMemoryAccess(I)) - MSSAU->moveToPlace(MUD, InsertPt->getParent(), MemorySSA::End); + MSSAU->moveToPlace(MUD, InsertPt->getParent(), + MemorySSA::BeforeTerminator); // There is possibility of hoisting this instruction above some arbitrary // condition. Any metadata defined on it can be control dependent on this diff --git a/llvm/lib/Analysis/MemorySSAUpdater.cpp b/llvm/lib/Analysis/MemorySSAUpdater.cpp index f2d56b05d96..473268982f2 100644 --- a/llvm/lib/Analysis/MemorySSAUpdater.cpp +++ b/llvm/lib/Analysis/MemorySSAUpdater.cpp @@ -1159,7 +1159,13 @@ void MemorySSAUpdater::moveAfter(MemoryUseOrDef *What, MemoryUseOrDef *Where) { void MemorySSAUpdater::moveToPlace(MemoryUseOrDef *What, BasicBlock *BB, MemorySSA::InsertionPlace Where) { - return moveTo(What, BB, Where); + if (Where != MemorySSA::InsertionPlace::BeforeTerminator) + return moveTo(What, BB, Where); + + if (auto *Where = MSSA->getMemoryAccess(BB->getTerminator())) + return moveBefore(What, Where); + else + return moveTo(What, BB, MemorySSA::InsertionPlace::End); } // All accesses in To used to be in From. Move to end and update access lists. |

