diff options
author | Alexandros Lamprineas <alexandros.lamprineas@arm.com> | 2018-09-11 14:29:59 +0000 |
---|---|---|
committer | Alexandros Lamprineas <alexandros.lamprineas@arm.com> | 2018-09-11 14:29:59 +0000 |
commit | 96762b37e1e59ac5e1706979d59bd80b21b75665 (patch) | |
tree | 896f0a18028421816f99415af3020dbd5b2b0eb7 /llvm/lib/Analysis/MemorySSAUpdater.cpp | |
parent | 4beb2f964b4d8b1017b17c19b48a3ddfdfcf1312 (diff) | |
download | bcm5719-llvm-96762b37e1e59ac5e1706979d59bd80b21b75665.tar.gz bcm5719-llvm-96762b37e1e59ac5e1706979d59bd80b21b75665.zip |
[MemorySSAUpdater] Avoid creating self-referencing MemoryDefs
Fix for https://bugs.llvm.org/show_bug.cgi?id=38807, which occurred
while compiling SemaTemplateInstantiate.cpp with clang and GVNHoist
enabled. In the following example:
1=def(entry)
/ \
2=def(1) 4=def(1)
3=def(2) 5=def(4)
When removing the MemoryDef 2=def(1) from its basic block, and just
before adding it to the end of the parent basic block, we first
replace all its uses with the defining memory access:
3=def(2) -> 3=def(1)
Then we call insertDef for adding 2=def(1) to the parent basic block,
where we replace the uses of 1=def(entry) with 2=def(1). Doing so we
create a self reference:
2=def(1) -> 2=def(2) (bad)
3=def(1) -> 3=def(2) (ok)
4=def(1) -> 4=def(2) (ok)
Differential Revision: https://reviews.llvm.org/D51801
llvm-svn: 341947
Diffstat (limited to 'llvm/lib/Analysis/MemorySSAUpdater.cpp')
-rw-r--r-- | llvm/lib/Analysis/MemorySSAUpdater.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/MemorySSAUpdater.cpp b/llvm/lib/Analysis/MemorySSAUpdater.cpp index 502f884705c..51a5733a3ef 100644 --- a/llvm/lib/Analysis/MemorySSAUpdater.cpp +++ b/llvm/lib/Analysis/MemorySSAUpdater.cpp @@ -266,16 +266,15 @@ void MemorySSAUpdater::insertDef(MemoryDef *MD, bool RenameUses) { for (auto UI = DefBefore->use_begin(), UE = DefBefore->use_end(); UI != UE;) { Use &U = *UI++; - // Leave the uses alone - if (isa<MemoryUse>(U.getUser())) + // Leave the MemoryUses alone. + // Also make sure we skip ourselves to avoid self references. + if (isa<MemoryUse>(U.getUser()) || U.getUser() == MD) continue; U.set(MD); } } // and that def is now our defining access. - // We change them in this order otherwise we will appear in the use list - // above and reset ourselves. MD->setDefiningAccess(DefBefore); SmallVector<WeakVH, 8> FixupList(InsertedPHIs.begin(), InsertedPHIs.end()); |