]> granicus.if.org Git - llvm/commitdiff
[LoadStoreVectorizer] vectorizeStoreChain - ensure we find a store type.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Mon, 6 May 2019 10:25:11 +0000 (10:25 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Mon, 6 May 2019 10:25:11 +0000 (10:25 +0000)
Properly initialize store type to null then ensure we find a real store type in the chain.

Fixes scan-build null dereference warning and makes the code clearer.

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

lib/Transforms/Vectorize/LoadStoreVectorizer.cpp

index e0b793f08fd17f5447b41f9630c63f06434b280f..19daa050d1cc84f6f60e79ca41eef906e5a9ea7a 100644 (file)
@@ -926,7 +926,7 @@ bool Vectorizer::vectorizeStoreChain(
   StoreInst *S0 = cast<StoreInst>(Chain[0]);
 
   // If the vector has an int element, default to int for the whole store.
-  Type *StoreTy;
+  Type *StoreTy = nullptr;
   for (Instruction *I : Chain) {
     StoreTy = cast<StoreInst>(I)->getValueOperand()->getType();
     if (StoreTy->isIntOrIntVectorTy())
@@ -938,6 +938,7 @@ bool Vectorizer::vectorizeStoreChain(
       break;
     }
   }
+  assert(StoreTy && "Failed to find store type");
 
   unsigned Sz = DL.getTypeSizeInBits(StoreTy);
   unsigned AS = S0->getPointerAddressSpace();