aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/LazyCallGraph.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Analysis/LazyCallGraph.cpp')
-rw-r--r--llvm/lib/Analysis/LazyCallGraph.cpp39
1 files changed, 29 insertions, 10 deletions
diff --git a/llvm/lib/Analysis/LazyCallGraph.cpp b/llvm/lib/Analysis/LazyCallGraph.cpp
index c086670..f7cf8c6 100644
--- a/llvm/lib/Analysis/LazyCallGraph.cpp
+++ b/llvm/lib/Analysis/LazyCallGraph.cpp
@@ -606,6 +606,28 @@ LazyCallGraph::RefSCC::switchInternalEdgeToCall(Node &SourceN, Node &TargetN) {
return DeletedSCCs;
}
+void LazyCallGraph::RefSCC::switchTrivialInternalEdgeToRef(Node &SourceN,
+ Node &TargetN) {
+ assert(SourceN[TargetN].isCall() && "Must start with a call edge!");
+
+#ifndef NDEBUG
+ // In a debug build, verify the RefSCC is valid to start with and when this
+ // routine finishes.
+ verify();
+ auto VerifyOnExit = make_scope_exit([&]() { verify(); });
+#endif
+
+ assert(G->lookupRefSCC(SourceN) == this &&
+ "Source must be in this RefSCC.");
+ assert(G->lookupRefSCC(TargetN) == this &&
+ "Target must be in this RefSCC.");
+ assert(G->lookupSCC(SourceN) != G->lookupSCC(TargetN) &&
+ "Source and Target must be in separate SCCs for this to be trivial!");
+
+ // Set the edge kind.
+ SourceN.setEdgeKind(TargetN.getFunction(), Edge::Ref);
+}
+
iterator_range<LazyCallGraph::RefSCC::iterator>
LazyCallGraph::RefSCC::switchInternalEdgeToRef(Node &SourceN, Node &TargetN) {
assert(SourceN[TargetN].isCall() && "Must start with a call edge!");
@@ -617,22 +639,19 @@ LazyCallGraph::RefSCC::switchInternalEdgeToRef(Node &SourceN, Node &TargetN) {
auto VerifyOnExit = make_scope_exit([&]() { verify(); });
#endif
- SCC &SourceSCC = *G->lookupSCC(SourceN);
- SCC &TargetSCC = *G->lookupSCC(TargetN);
-
- assert(&SourceSCC.getOuterRefSCC() == this &&
+ assert(G->lookupRefSCC(SourceN) == this &&
"Source must be in this RefSCC.");
- assert(&TargetSCC.getOuterRefSCC() == this &&
+ assert(G->lookupRefSCC(TargetN) == this &&
"Target must be in this RefSCC.");
+ SCC &TargetSCC = *G->lookupSCC(TargetN);
+ assert(G->lookupSCC(SourceN) == &TargetSCC && "Source and Target must be in "
+ "the same SCC to require the "
+ "full CG update.");
+
// Set the edge kind.
SourceN.setEdgeKind(TargetN.getFunction(), Edge::Ref);
- // If this call edge is just connecting two separate SCCs within this RefSCC,
- // there is nothing to do.
- if (&SourceSCC != &TargetSCC)
- return make_range(SCCs.end(), SCCs.end());
-
// Otherwise we are removing a call edge from a single SCC. This may break
// the cycle. In order to compute the new set of SCCs, we need to do a small
// DFS over the nodes within the SCC to form any sub-cycles that remain as