Switch this code away from Value::isUsedInBasicBlock. That code either
authorChandler Carruth <chandlerc@gmail.com>
Fri, 25 Jan 2013 05:40:09 +0000 (05:40 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Fri, 25 Jan 2013 05:40:09 +0000 (05:40 +0000)
commitceff222dea8266f7edeee65e5d1fdf62adc1d120
treef503003365f5afc21d766f8d2f05096d47381f23
parent2d765204d9ccae1489e343a12d8ee7c42f414250
Switch this code away from Value::isUsedInBasicBlock. That code either
loops over instructions in the basic block or the use-def list of the
value, neither of which are really efficient when repeatedly querying
about values in the same basic block.

What's more, we already know that the CondBB is small, and so we can do
a much more efficient test by counting the uses in CondBB, and seeing if
those account for all of the uses.

Finally, we shouldn't blanket fail on any such instruction, instead we
should conservatively assume that those instructions are part of the
cost.

Note that this actually fixes a bug in the pass because
isUsedInBasicBlock has a really terrible bug in it. I'll fix that in my
next commit, but the fix for it would make this code suddenly take the
compile time hit I thought it already was taking, so I wanted to go
ahead and migrate this code to a faster & better pattern.

The bug in isUsedInBasicBlock was also causing other tests to test the
wrong thing entirely: for example we weren't actually disabling
speculation for floating point operations as intended (and tested), but
the test passed because we failed to speculate them due to the
isUsedInBasicBlock failure.

llvm-svn: 173417
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/Transforms/SimplifyCFG/SpeculativeExec.ll