Rephrase the speculating scan of the conditional BB to be phrased in
authorChandler Carruth <chandlerc@gmail.com>
Thu, 24 Jan 2013 11:52:58 +0000 (11:52 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Thu, 24 Jan 2013 11:52:58 +0000 (11:52 +0000)
commit2c107a80206056cdc8c2c7cb715ff9e1db64add9
tree4ab107c9cd5f1b0ce829bb4f90a0bdcdeac624bc
parent29f975f8ffda1f5d78cbf2530c2316abef11aa70
Rephrase the speculating scan of the conditional BB to be phrased in
terms of cost rather than hoisting a single instruction.

This does *not* change the cost model! We still set the cost threshold
at 1 here, it's just that we track it by accumulating cost rather than
by storing an instruction.

The primary advantage is that we no longer leave no-op intrinsics in the
basic block. For example, this will now move both debug info intrinsics
and a single instruction, instead of only moving the instruction and
leaving a basic block with nothing bug debug info intrinsics in it, and
those intrinsics now no longer ordered correctly with the hoisted value.

Instead, we now splice the entire conditional basic block's instruction
sequence.

This also places the code for checking the safety of hoisting next to
the code computing the cost.

Currently, the only observable side-effect of this change is that debug
info intrinsics are no longer abandoned. I'm not sure how to craft
a test case for this, and my real goal was the refactoring, but I'll
talk to Dave or Eric about how to add a test case for this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173339 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Utils/SimplifyCFG.cpp