From a10409fe23c35a7eed0f39d12624af229d3877e1 Mon Sep 17 00:00:00 2001 From: Alina Sbirlea Date: Wed, 1 Sep 2021 14:38:53 -0700 Subject: [PATCH] [MemorySSAUpdater] Simplify updates when only deleting edges. When performing only edge deletion, we don't need to do the DT updates back and forth. Check for the existance of insert updates to simplify this. --- llvm/lib/Analysis/MemorySSAUpdater.cpp | 39 +++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/llvm/lib/Analysis/MemorySSAUpdater.cpp b/llvm/lib/Analysis/MemorySSAUpdater.cpp index 616864f..0eb3383 100644 --- a/llvm/lib/Analysis/MemorySSAUpdater.cpp +++ b/llvm/lib/Analysis/MemorySSAUpdater.cpp @@ -822,25 +822,30 @@ void MemorySSAUpdater::applyUpdates(ArrayRef Updates, } if (!DeleteUpdates.empty()) { - if (!UpdateDT) { - SmallVector Empty; - // Deletes are reversed applied, because this CFGView is pretending the - // deletes did not happen yet, hence the edges still exist. - DT.applyUpdates(Empty, RevDeleteUpdates); + if (!InsertUpdates.empty()) { + if (!UpdateDT) { + SmallVector Empty; + // Deletes are reversed applied, because this CFGView is pretending the + // deletes did not happen yet, hence the edges still exist. + DT.applyUpdates(Empty, RevDeleteUpdates); + } else { + // Apply all updates, with the RevDeleteUpdates as PostCFGView. + DT.applyUpdates(Updates, RevDeleteUpdates); + } + + // Note: the MSSA update below doesn't distinguish between a GD with + // (RevDelete,false) and (Delete, true), but this matters for the DT + // updates above; for "children" purposes they are equivalent; but the + // updates themselves convey the desired update, used inside DT only. + GraphDiff GD(RevDeleteUpdates); + applyInsertUpdates(InsertUpdates, DT, &GD); + // Update DT to redelete edges; this matches the real CFG so we can + // perform the standard update without a postview of the CFG. + DT.applyUpdates(DeleteUpdates); } else { - // Apply all updates, with the RevDeleteUpdates as PostCFGView. - DT.applyUpdates(Updates, RevDeleteUpdates); + if (UpdateDT) + DT.applyUpdates(DeleteUpdates); } - - // Note: the MSSA update below doesn't distinguish between a GD with - // (RevDelete,false) and (Delete, true), but this matters for the DT - // updates above; for "children" purposes they are equivalent; but the - // updates themselves convey the desired update, used inside DT only. - GraphDiff GD(RevDeleteUpdates); - applyInsertUpdates(InsertUpdates, DT, &GD); - // Update DT to redelete edges; this matches the real CFG so we can perform - // the standard update without a postview of the CFG. - DT.applyUpdates(DeleteUpdates); } else { if (UpdateDT) DT.applyUpdates(Updates); -- 2.7.4