[llvm] d337c50 - [SLP][NFCI] Address issues seen in downstream Coverity scan. (#93757)
via llvm-commits
llvm-commits at lists.llvm.org
Fri May 31 18:34:27 PDT 2024
Author: Tyler Lanphear
Date: 2024-05-31T18:34:23-07:00
New Revision: d337c504ef3652e9ccd75b21bbc79d010ee6c637
URL: https://github.com/llvm/llvm-project/commit/d337c504ef3652e9ccd75b21bbc79d010ee6c637
DIFF: https://github.com/llvm/llvm-project/commit/d337c504ef3652e9ccd75b21bbc79d010ee6c637.diff
LOG: [SLP][NFCI] Address issues seen in downstream Coverity scan. (#93757)
- Prevent null dereference: if the Mask given to
`ShuffleInstructionBuilder::adjustExtracts()` is empty or all-poison,
then `VecBase` will be `nullptr` and the call to
`castToScalarTyElem(VecBase)` will dereference it. Add an assert
to guard against this.
- Prevent use of uninitialized scalar: in the unlikely event that
`CandidateVFs` is empty, then `AnyProfitableGraph` will be
uninitialized in `if` condition following the loop. (This seems like a
false-positive, but I submitted this change anyways as initializing
bools costs nothing and is generally good practice)
Added:
Modified:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index f044a8cdd2f31..ae0819c964bef 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -11697,8 +11697,8 @@ class BoUpSLP::ShuffleInstructionBuilder final : public BaseShuffleAnalysis {
R.eraseInstruction(EI);
}
if (NumParts == 1 || UniqueBases.size() == 1) {
- VecBase = castToScalarTyElem(VecBase);
- return VecBase;
+ assert(VecBase && "Expected vectorized value.");
+ return castToScalarTyElem(VecBase);
}
UseVecBaseAsInput = true;
auto TransformToIdentity = [](MutableArrayRef<int> Mask) {
@@ -15844,7 +15844,7 @@ bool SLPVectorizerPass::vectorizeStores(
while (true) {
++Repeat;
bool RepeatChanged = false;
- bool AnyProfitableGraph;
+ bool AnyProfitableGraph = false;
for (unsigned Size : CandidateVFs) {
AnyProfitableGraph = false;
unsigned StartIdx = std::distance(
More information about the llvm-commits
mailing list