OSDN Git Service

[CodeGenPrepare] Ensure we get a non-null result from getTrueOrFalseValue. NFCI.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Thu, 9 May 2019 10:51:26 +0000 (10:51 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Thu, 9 May 2019 10:51:26 +0000 (10:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360328 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenPrepare.cpp

index fad3d4a..76f82c2 100644 (file)
@@ -5904,7 +5904,7 @@ static bool isFormingBranchFromSelectProfitable(const TargetTransformInfo *TTI,
 static Value *getTrueOrFalseValue(
     SelectInst *SI, bool isTrue,
     const SmallPtrSet<const Instruction *, 2> &Selects) {
-  Value *V;
+  Value *V = nullptr;
 
   for (SelectInst *DefSI = SI; DefSI != nullptr && Selects.count(DefSI);
        DefSI = dyn_cast<SelectInst>(V)) {
@@ -5912,6 +5912,8 @@ static Value *getTrueOrFalseValue(
            "The condition of DefSI does not match with SI");
     V = (isTrue ? DefSI->getTrueValue() : DefSI->getFalseValue());
   }
+
+  assert(V && "Failed to get select true/false value");
   return V;
 }