summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2016-12-28 02:24:58 +0000
committerChandler Carruth <chandlerc@gmail.com>2016-12-28 02:24:58 +0000
commitc6334579e997f35c00d3fac251d3f8b462737df6 (patch)
treee94ca71ce6e83640125f97787bf18b1d791f2165 /llvm/lib
parente635289ee29ab92495cd376faefc2a7dcbe11c59 (diff)
downloadbcm5719-llvm-c6334579e997f35c00d3fac251d3f8b462737df6.tar.gz
bcm5719-llvm-c6334579e997f35c00d3fac251d3f8b462737df6.zip
[LCG] Teach the ref edge removal to handle a ref edge that is trivial
due to a call cycle. This actually crashed the ref removal before. I've added a unittest that covers this kind of interesting graph structure and mutation. llvm-svn: 290645
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/LazyCallGraph.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/LazyCallGraph.cpp b/llvm/lib/Analysis/LazyCallGraph.cpp
index 9bc0747fba4..c08667022b2 100644
--- a/llvm/lib/Analysis/LazyCallGraph.cpp
+++ b/llvm/lib/Analysis/LazyCallGraph.cpp
@@ -1117,6 +1117,13 @@ LazyCallGraph::RefSCC::removeInternalRefEdge(Node &SourceN, Node &TargetN) {
if (&SourceN == &TargetN)
return Result;
+ // If this ref edge is within an SCC then there are sufficient other edges to
+ // form a cycle without this edge so removing it is a no-op.
+ SCC &SourceC = *G->lookupSCC(SourceN);
+ SCC &TargetC = *G->lookupSCC(TargetN);
+ if (&SourceC == &TargetC)
+ return Result;
+
// We build somewhat synthetic new RefSCCs by providing a postorder mapping
// for each inner SCC. We also store these associated with *nodes* rather
// than SCCs because this saves a round-trip through the node->SCC map and in
@@ -1139,7 +1146,6 @@ LazyCallGraph::RefSCC::removeInternalRefEdge(Node &SourceN, Node &TargetN) {
// and handle participants in that cycle without walking all the edges that
// form the connections, and instead by relying on the fundamental guarantee
// coming into this operation.
- SCC &TargetC = *G->lookupSCC(TargetN);
for (Node &N : TargetC)
PostOrderMapping[&N] = RootPostOrderNumber;
OpenPOWER on IntegriCloud