[LoadStoreVectorizer] vectorizeLoadChain - ensure we find a valid Type down the load...
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Sun, 15 Sep 2019 16:44:35 +0000 (16:44 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Sun, 15 Sep 2019 16:44:35 +0000 (16:44 +0000)
Silence static analyzer uninitialized variable warning by setting the LoadTy to null and then asserting we find a real value.

llvm-svn: 371936

llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp

index 5f97740..f44976c 100644 (file)
@@ -1092,7 +1092,7 @@ bool Vectorizer::vectorizeLoadChain(
   LoadInst *L0 = cast<LoadInst>(Chain[0]);
 
   // If the vector has an int element, default to int for the whole load.
-  Type *LoadTy;
+  Type *LoadTy = nullptr;
   for (const auto &V : Chain) {
     LoadTy = cast<LoadInst>(V)->getType();
     if (LoadTy->isIntOrIntVectorTy())
@@ -1104,6 +1104,7 @@ bool Vectorizer::vectorizeLoadChain(
       break;
     }
   }
+  assert(LoadTy && "Can't determine LoadInst type from chain");
 
   unsigned Sz = DL.getTypeSizeInBits(LoadTy);
   unsigned AS = L0->getPointerAddressSpace();