[PATCH] D72469: SCC: Allow ReplaceNode to safely support insertion
Warren Ristow via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 14 10:33:17 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf7e9f4f4c502: SCC: Allow ReplaceNode to safely support insertion (authored by wristow).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72469/new/
https://reviews.llvm.org/D72469
Files:
llvm/include/llvm/ADT/SCCIterator.h
Index: llvm/include/llvm/ADT/SCCIterator.h
===================================================================
--- llvm/include/llvm/ADT/SCCIterator.h
+++ llvm/include/llvm/ADT/SCCIterator.h
@@ -134,7 +134,10 @@
/// has been deleted, and \c New is to be used in its place.
void ReplaceNode(NodeRef Old, NodeRef New) {
assert(nodeVisitNumbers.count(Old) && "Old not in scc_iterator?");
- nodeVisitNumbers[New] = nodeVisitNumbers[Old];
+ // Do the assignment in two steps, in case 'New' is not yet in the map, and
+ // inserting it causes the map to grow.
+ auto tempVal = nodeVisitNumbers[Old];
+ nodeVisitNumbers[New] = tempVal;
nodeVisitNumbers.erase(Old);
}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72469.238035.patch
Type: text/x-patch
Size: 698 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200114/cacd3e2a/attachment.bin>
More information about the llvm-commits
mailing list