diff options
author | Alina Sbirlea <asbirlea@google.com> | 2019-08-20 22:29:06 +0000 |
---|---|---|
committer | Alina Sbirlea <asbirlea@google.com> | 2019-08-20 22:29:06 +0000 |
commit | 1c528e8f1b29b48bcb37a3a6e5e4c97572300102 (patch) | |
tree | 30a3697530e59759a01859b99992348108ddd25f /llvm/lib/Analysis | |
parent | 4f41779cca7d9a14fdf273d0dd3e056bbb0d1320 (diff) | |
download | bcm5719-llvm-1c528e8f1b29b48bcb37a3a6e5e4c97572300102.tar.gz bcm5719-llvm-1c528e8f1b29b48bcb37a3a6e5e4c97572300102.zip |
[MemorySSA] Fix existing phis when inserting defs.
Summary:
When inserting a new Def, and inserting Phis in the IDF when needed,
also mark the already existing Phis in the IDF as non-optimized, since
these may need fixing as well.
In the test attached, there is a Phi in the IDF that happens to be
trivial, and is wrongfully removed by the call to getLastDef that
follows. This is a valid situation and the existing IDF Phis need to
marked as "may need fixing" as well.
Resolves PR43044.
Reviewers: george.burgess.iv
Subscribers: Prazek, sanjoy.google, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D66495
llvm-svn: 369464
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/MemorySSAUpdater.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/llvm/lib/Analysis/MemorySSAUpdater.cpp b/llvm/lib/Analysis/MemorySSAUpdater.cpp index 87818c59176..e63a9b8c341 100644 --- a/llvm/lib/Analysis/MemorySSAUpdater.cpp +++ b/llvm/lib/Analysis/MemorySSAUpdater.cpp @@ -341,16 +341,20 @@ void MemorySSAUpdater::insertDef(MemoryDef *MD, bool RenameUses) { IDFs.setDefiningBlocks(DefiningBlocks); IDFs.calculate(IDFBlocks); SmallVector<AssertingVH<MemoryPhi>, 4> NewInsertedPHIs; - for (auto *BBIDF : IDFBlocks) - if (!MSSA->getMemoryAccess(BBIDF)) { - auto *MPhi = MSSA->createMemoryPhi(BBIDF); + for (auto *BBIDF : IDFBlocks) { + auto *MPhi = MSSA->getMemoryAccess(BBIDF); + if (!MPhi) { + MPhi = MSSA->createMemoryPhi(BBIDF); NewInsertedPHIs.push_back(MPhi); - // Add the phis created into the IDF blocks to NonOptPhis, so they are - // not optimized out as trivial by the call to getPreviousDefFromEnd - // below. Once they are complete, all these Phis are added to the - // FixupList, and removed from NonOptPhis inside fixupDefs(). - NonOptPhis.insert(MPhi); } + // Add the phis created into the IDF blocks to NonOptPhis, so they are + // not optimized out as trivial by the call to getPreviousDefFromEnd + // below. Once they are complete, all these Phis are added to the + // FixupList, and removed from NonOptPhis inside fixupDefs(). + // Existing Phis in IDF may need fixing as well, and potentially be + // trivial before this insertion, hence add all IDF Phis. See PR43044. + NonOptPhis.insert(MPhi); + } for (auto &MPhi : NewInsertedPHIs) { auto *BBIDF = MPhi->getBlock(); |