[PATCH] D77855: [CallGraphUpdater] Remove nodes from their SCC (old PM)
Johannes Doerfert via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 9 20:08:28 PDT 2020
jdoerfert created this revision.
jdoerfert added reviewers: lebedev.ri, hfinkel, fhahn, probinson, wristow, loladiro.
Herald added subscribers: uenoku, bollu, hiraditya.
Herald added a reviewer: sstefan1.
Herald added a reviewer: uenoku.
Herald added a project: LLVM.
We can and should remove deleted nodes from their respective SCCs. We
did not do this before and this was a potential problem even though I
couldn't locally trigger an issue. Since the `DeleteNode` would assert
if the node was not in the SCC, we know we only remove nodes from their
SCC and only once (when run on all the Attributor tests).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D77855
Files:
llvm/include/llvm/Analysis/CallGraphSCCPass.h
llvm/lib/Analysis/CallGraphSCCPass.cpp
llvm/lib/Transforms/Utils/CallGraphUpdater.cpp
Index: llvm/lib/Transforms/Utils/CallGraphUpdater.cpp
===================================================================
--- llvm/lib/Transforms/Utils/CallGraphUpdater.cpp
+++ llvm/lib/Transforms/Utils/CallGraphUpdater.cpp
@@ -103,6 +103,10 @@
DeadFunctionsInComdats.push_back(&DeadFn);
else
DeadFunctions.push_back(&DeadFn);
+
+ // For the old call graph we remove the function from the SCC right away.
+ if (CGSCC && !ReplacedFunctions.count(&DeadFn))
+ CGSCC->DeleteNode((*CG)[&DeadFn]);
}
void CallGraphUpdater::replaceFunctionWith(Function &OldFn, Function &NewFn) {
Index: llvm/lib/Analysis/CallGraphSCCPass.cpp
===================================================================
--- llvm/lib/Analysis/CallGraphSCCPass.cpp
+++ llvm/lib/Analysis/CallGraphSCCPass.cpp
@@ -562,6 +562,10 @@
CGI->ReplaceNode(Old, New);
}
+void CallGraphSCC::DeleteNode(CallGraphNode *Old) {
+ ReplaceNode(Old, /* New */ nullptr);
+}
+
//===----------------------------------------------------------------------===//
// CallGraphSCCPass Implementation
//===----------------------------------------------------------------------===//
Index: llvm/include/llvm/Analysis/CallGraphSCCPass.h
===================================================================
--- llvm/include/llvm/Analysis/CallGraphSCCPass.h
+++ llvm/include/llvm/Analysis/CallGraphSCCPass.h
@@ -103,6 +103,10 @@
/// Old node has been deleted, and New is to be used in its place.
void ReplaceNode(CallGraphNode *Old, CallGraphNode *New);
+ /// DeleteNode - This informs the SCC and the pass manager that the specified
+ /// Old node has been deleted.
+ void DeleteNode(CallGraphNode *Old);
+
using iterator = std::vector<CallGraphNode *>::const_iterator;
iterator begin() const { return Nodes.begin(); }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77855.256492.patch
Type: text/x-patch
Size: 1802 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200410/38ea22a9/attachment-0001.bin>
More information about the llvm-commits
mailing list