Move the handling of unanalyzable branches out of the loop-driven chain
authorChandler Carruth <chandlerc@gmail.com>
Sat, 19 Nov 2011 10:26:02 +0000 (10:26 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Sat, 19 Nov 2011 10:26:02 +0000 (10:26 +0000)
commit03300ecaee3ef853669582bcadec34170dbf515f
treeb04a2cf356a8a3f71b24b3329abd348e369a6595
parent6bf57b02724e312399bf6d24ce43cfa6564fea11
Move the handling of unanalyzable branches out of the loop-driven chain
formation phase and into the initial walk of the basic blocks. We
essentially pre-merge all blocks where unanalyzable fallthrough exists,
as we won't be able to update the terminators effectively after any
reorderings. This is quite a bit more principled as there may be CFGs
where the second half of the unanalyzable pair has some analyzable
predecessor that gets placed first. Then it may get placed next,
implicitly breaking the unanalyzable branch even though we never even
looked at the part that isn't analyzable. I've included a test case that
triggers this (thanks Benjamin yet again!), and I'm hoping to synthesize
some more general ones as I dig into related issues.

Also, to make this new scheme work we have to be able to handle branches
into the middle of a chain, so add this check. We always fallback on the
incoming ordering.

Finally, this starts to really underscore a known limitation of the
current implementation -- we don't consider broken predecessors when
merging successors. This can caused major missed opportunities, and is
something I'm planning on looking at next (modulo more bug reports).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144994 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/MachineBlockPlacement.cpp
test/CodeGen/X86/block-placement.ll