[PM] Fix a likely more critical infloop bug in the CGSCC pass manager.
authorChandler Carruth <chandlerc@gmail.com>
Tue, 8 Aug 2017 10:13:23 +0000 (10:13 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Tue, 8 Aug 2017 10:13:23 +0000 (10:13 +0000)
commit6e35c31d2d2c1853113ca0526ceead85e9c8e1ac
tree52e2252a93d643471106d3f9a869e9c10339fad4
parent95bd95c075067d904eaaad9c29a95afd16676952
[PM] Fix a likely more critical infloop bug in the CGSCC pass manager.

This was just a bad oversight on my part. The code in question should
never have worked without this fix. But it turns out, there are
relatively few places that involve libfunctions that participate in
a single SCC, and unless they do, this happens to not matter.

The effect of not having this correct is that each time through this
routine, the edge from write_wrapper to write was toggled between a call
edge and a ref edge. First time through, it becomes a demoted call edge
and is turned into a ref edge. Next time it is a promoted call edge from
a ref edge. On, and on it goes forever.

I've added the asserts which should have always been here to catch silly
mistakes like this in the future as well as a test case that will
actually infloop without the fix.

The other (much scarier) infinite-inlining issue I think didn't actually
occur in practice, and I simply misdiagnosed this minor issue as that
much more scary issue. The other issue *is* still a real issue, but I'm
somewhat relieved that so far it hasn't happened in real-world code
yet...

llvm-svn: 310342
llvm/lib/Analysis/CGSCCPassManager.cpp
llvm/test/Other/cgscc-libcall-update.ll