[LCG] Incorporate the core trick of improvements on the naive Tarjan's
authorChandler Carruth <chandlerc@gmail.com>
Thu, 24 Apr 2014 11:05:20 +0000 (11:05 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Thu, 24 Apr 2014 11:05:20 +0000 (11:05 +0000)
commitbefdb1a6421e4c3ae77da1fee45b480ef9cb2710
tree159c428d176f92ddbb188a5223ef51fb1489b995
parent6c7af1bde87d8184d2dda773d68efac61ad128e2
[LCG] Incorporate the core trick of improvements on the naive Tarjan's
algorithm here: http://dl.acm.org/citation.cfm?id=177301.

The idea of isolating the roots has even more relevance when using the
stack not just to implement the DFS but also to implement the recursive
step. Because we use it for the recursive step, to isolate the roots we
need to maintain two stacks: one for our recursive DFS walk, and another
of the nodes that have been walked. The nice thing is that the latter
will be half the size. It also fixes a complete hack where we scanned
backwards over the stack to find the next potential-root to continue
processing. Now that is always the top of the DFS stack.

While this is a really nice improvement already (IMO) it further opens
the door for two important simplifications:

1) De-duplicating some of the code across the two different walks. I've
   actually made the duplication a bit worse in some senses with this
   patch because the two are starting to converge.
2) Dramatically simplifying the loop structures of both walks.

I wanted to do those separately as they'll be essentially *just* CFG
restructuring. This patch on the other hand actually uses different
datastructures to implement the algorithm itself.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207098 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Analysis/LazyCallGraph.h
lib/Analysis/LazyCallGraph.cpp