CodeGenPrepare: Don't crash when TLI is not available.

This happens when codegenprepare is invoked via opt.

llvm-svn: 159457
This commit is contained in:
Benjamin Kramer 2012-06-29 19:58:21 +00:00
parent 2794ad59aa
commit 396b3adc10
1 changed files with 2 additions and 1 deletions

View File

@ -1133,7 +1133,8 @@ static bool isFormingBranchFromSelectProfitable(SelectInst *SI) {
bool CodeGenPrepare::OptimizeSelectInst(SelectInst *SI) {
// If we have a SelectInst that will likely profit from branch prediction,
// turn it into a branch.
if (DisableSelectToBranch || OptSize || !TLI->isPredictableSelectExpensive())
if (DisableSelectToBranch || OptSize || !TLI ||
!TLI->isPredictableSelectExpensive())
return false;
if (!SI->getCondition()->getType()->isIntegerTy(1) ||