Rather than trying to use the loop block sequence *or* the function
authorChandler Carruth <chandlerc@gmail.com>
Tue, 15 Nov 2011 06:26:43 +0000 (06:26 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Tue, 15 Nov 2011 06:26:43 +0000 (06:26 +0000)
commit3273c8937b8c3ebdd1cfc0c67054ce5571f0afc9
treea07198cd5b11b45fba3bbb0e7e08ccf476b8f25e
parent4c077a1f04c97210793d62debef250b974d168bc
Rather than trying to use the loop block sequence *or* the function
block sequence when recovering from unanalyzable control flow
constructs, *always* use the function sequence. I'm not sure why I ever
went down the path of trying to use the loop sequence, it is
fundamentally not the correct sequence to use. We're trying to preserve
the incoming layout in the cases of unreasonable control flow, and that
is only encoded at the function level. We already have a filter to
select *exactly* the sub-set of blocks within the function that we're
trying to form into a chain.

The resulting code layout is also significantly better because of this.
In several places we were ending up with completely unreasonable control
flow constructs due to the ordering chosen by the loop structure for its
internal storage. This change removes a completely wasteful vector of
basic blocks, saving memory allocation in the common case even though it
costs us CPU in the fairly rare case of unnatural loops. Finally, it
fixes the latest crasher reduced out of GCC's single source. Thanks
again to Benjamin Kramer for the reduction, my bugpoint skills failed at
it.

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