Skip to content

Commit a10409f

Browse files
committed
[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.
1 parent 1f9e437 commit a10409f

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

llvm/lib/Analysis/MemorySSAUpdater.cpp

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -822,25 +822,30 @@ void MemorySSAUpdater::applyUpdates(ArrayRef<CFGUpdate> Updates,
822822
}
823823

824824
if (!DeleteUpdates.empty()) {
825-
if (!UpdateDT) {
826-
SmallVector<CFGUpdate, 0> Empty;
827-
// Deletes are reversed applied, because this CFGView is pretending the
828-
// deletes did not happen yet, hence the edges still exist.
829-
DT.applyUpdates(Empty, RevDeleteUpdates);
825+
if (!InsertUpdates.empty()) {
826+
if (!UpdateDT) {
827+
SmallVector<CFGUpdate, 0> Empty;
828+
// Deletes are reversed applied, because this CFGView is pretending the
829+
// deletes did not happen yet, hence the edges still exist.
830+
DT.applyUpdates(Empty, RevDeleteUpdates);
831+
} else {
832+
// Apply all updates, with the RevDeleteUpdates as PostCFGView.
833+
DT.applyUpdates(Updates, RevDeleteUpdates);
834+
}
835+
836+
// Note: the MSSA update below doesn't distinguish between a GD with
837+
// (RevDelete,false) and (Delete, true), but this matters for the DT
838+
// updates above; for "children" purposes they are equivalent; but the
839+
// updates themselves convey the desired update, used inside DT only.
840+
GraphDiff<BasicBlock *> GD(RevDeleteUpdates);
841+
applyInsertUpdates(InsertUpdates, DT, &GD);
842+
// Update DT to redelete edges; this matches the real CFG so we can
843+
// perform the standard update without a postview of the CFG.
844+
DT.applyUpdates(DeleteUpdates);
830845
} else {
831-
// Apply all updates, with the RevDeleteUpdates as PostCFGView.
832-
DT.applyUpdates(Updates, RevDeleteUpdates);
846+
if (UpdateDT)
847+
DT.applyUpdates(DeleteUpdates);
833848
}
834-
835-
// Note: the MSSA update below doesn't distinguish between a GD with
836-
// (RevDelete,false) and (Delete, true), but this matters for the DT
837-
// updates above; for "children" purposes they are equivalent; but the
838-
// updates themselves convey the desired update, used inside DT only.
839-
GraphDiff<BasicBlock *> GD(RevDeleteUpdates);
840-
applyInsertUpdates(InsertUpdates, DT, &GD);
841-
// Update DT to redelete edges; this matches the real CFG so we can perform
842-
// the standard update without a postview of the CFG.
843-
DT.applyUpdates(DeleteUpdates);
844849
} else {
845850
if (UpdateDT)
846851
DT.applyUpdates(Updates);

0 commit comments

Comments
 (0)