From 0fc49e75a43904bba1fb125d0445f47432641a78 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Mon, 6 May 2019 10:25:11 +0000 Subject: [PATCH] [LoadStoreVectorizer] vectorizeStoreChain - ensure we find a store type. 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp b/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp index e0b793f08fd..19daa050d1c 100644 --- a/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp +++ b/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp @@ -926,7 +926,7 @@ bool Vectorizer::vectorizeStoreChain( StoreInst *S0 = cast(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(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(); -- 2.50.1