[PM] Fix a nasty bug in the new PM where we failed to properly
authorChandler Carruth <chandlerc@gmail.com>
Sun, 9 Jul 2017 13:45:11 +0000 (13:45 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Sun, 9 Jul 2017 13:45:11 +0000 (13:45 +0000)
commitc213c67df8044bf277529c1dacaca669cd3d39e7
treed277d640358ecf4e221646d6209ce3a53e462db0
parent7c8964d885b2cf3f3f9f4aedaf16c15d9bcdf1a3
[PM] Fix a nasty bug in the new PM where we failed to properly
invalidation of analyses when merging SCCs.

While I've added a bunch of testing of this, it takes something much
more like the inliner to really trigger this as you need to have
partially-analyzed SCCs with updates at just the right time. So I've
added a direct test for this using the inliner and verifying the
domtree. Without the changes here, this test ends up finding a stale
dominator tree.

However, to handle this properly, we need to invalidate analyses
*before* merging the SCCs. After talking to Philip and Sanjoy about this
they convinced me this was the right approach. To do this, we need
a callback mechanism when merging SCCs so we can observe the cycle that
will be merged before the merge happens. This API update ended up being
surprisingly easy.

With this commit, the new PM passes the test-suite again. It hadn't
since MemorySSA was enabled for EarlyCSE as that also will find this bug
very quickly.

llvm-svn: 307498
llvm/include/llvm/Analysis/LazyCallGraph.h
llvm/lib/Analysis/CGSCCPassManager.cpp
llvm/lib/Analysis/LazyCallGraph.cpp
llvm/test/Transforms/Inline/cgscc-incremental-invalidate.ll
llvm/unittests/Analysis/LazyCallGraphTest.cpp