MemCmpExpansion::getCompareLoadPairs - assert we find a comparison diff. NFCI.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 18 May 2019 11:31:48 +0000 (11:31 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 18 May 2019 11:31:48 +0000 (11:31 +0000)
Fix scan-build uninitialized warning and assert the final diff isn't null.

llvm-svn: 361095

llvm/lib/CodeGen/ExpandMemCmp.cpp

index a3a979008dc06ed82655006a5c5b1ed9fdc9e892..06c171a457b36d40abef9d94b2291446ca03b2d5 100644 (file)
@@ -323,7 +323,7 @@ Value *MemCmpExpansion::getCompareLoadPairs(unsigned BlockIndex,
   assert(LoadIndex < getNumLoads() &&
          "getCompareLoadPairs() called with no remaining loads");
   std::vector<Value *> XorList, OrList;
-  Value *Diff;
+  Value *Diff = nullptr;
 
   const unsigned NumLoads =
       std::min(getNumLoads() - LoadIndex, NumLoadsPerBlockForZeroCmp);
@@ -400,6 +400,8 @@ Value *MemCmpExpansion::getCompareLoadPairs(unsigned BlockIndex,
     while (OrList.size() != 1) {
       OrList = pairWiseOr(OrList);
     }
+
+    assert(Diff && "Failed to find comparison diff");
     Cmp = Builder.CreateICmpNE(OrList[0], ConstantInt::get(Diff->getType(), 0));
   }