CodeGenPrepare: Don't crash when TLI is not available.
authorBenjamin Kramer <benny.kra@googlemail.com>
Fri, 29 Jun 2012 19:58:21 +0000 (19:58 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Fri, 29 Jun 2012 19:58:21 +0000 (19:58 +0000)
This happens when codegenprepare is invoked via opt.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159457 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/CodeGenPrepare.cpp

index c95d36af0b322ce7ae1de5f98461de0db2565d54..cbc089ab788ea9ad72fdf857f49e9dd9ff515905 100644 (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) ||