From a9f13f80658c20bfc1b41187cefc2e90fdc0fd6f Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Sat, 1 Jan 2022 01:39:04 +0000 Subject: [PATCH] Fix a few unitialized class members in MLIR (NFC) Flagged by Coverity. --- mlir/include/mlir/Analysis/AffineAnalysis.h | 2 +- mlir/include/mlir/Analysis/Liveness.h | 2 +- mlir/include/mlir/Analysis/NestedMatcher.h | 2 +- mlir/include/mlir/Analysis/Utils.h | 2 +- mlir/include/mlir/IR/AffineMap.h | 6 +++--- mlir/include/mlir/IR/AttributeSupport.h | 2 +- mlir/include/mlir/Reducer/ReductionNode.h | 8 ++++---- mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp | 2 +- mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp | 2 +- mlir/lib/Pass/PassCrashRecovery.cpp | 4 ++-- mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp | 2 +- mlir/lib/Target/SPIRV/Deserialization/Deserializer.h | 2 +- mlir/lib/Transforms/BufferOptimizations.cpp | 2 +- mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp | 4 ++-- 14 files changed, 21 insertions(+), 21 deletions(-) diff --git a/mlir/include/mlir/Analysis/AffineAnalysis.h b/mlir/include/mlir/Analysis/AffineAnalysis.h index fa793a9..4c10bed1 100644 --- a/mlir/include/mlir/Analysis/AffineAnalysis.h +++ b/mlir/include/mlir/Analysis/AffineAnalysis.h @@ -137,7 +137,7 @@ struct MemRefAccess { // lb < ub. Note that ub/lb == None means unbounded. struct DependenceComponent { // The AffineForOp Operation associated with this dependence component. - Operation *op; + Operation *op = nullptr; // The lower bound of the dependence distance. Optional lb; // The upper bound of the dependence distance (inclusive). diff --git a/mlir/include/mlir/Analysis/Liveness.h b/mlir/include/mlir/Analysis/Liveness.h index 7489152..3b20506 100644 --- a/mlir/include/mlir/Analysis/Liveness.h +++ b/mlir/include/mlir/Analysis/Liveness.h @@ -131,7 +131,7 @@ public: private: /// The underlying block. - Block *block; + Block *block = nullptr; /// The set of all live in values. ValueSetT inValues; diff --git a/mlir/include/mlir/Analysis/NestedMatcher.h b/mlir/include/mlir/Analysis/NestedMatcher.h index f0a7088..fb725e3 100644 --- a/mlir/include/mlir/Analysis/NestedMatcher.h +++ b/mlir/include/mlir/Analysis/NestedMatcher.h @@ -65,7 +65,7 @@ private: NestedMatch() = default; /// Payload, holds a NestedMatch and all its children along this branch. - Operation *matchedOperation; + Operation *matchedOperation = nullptr; ArrayRef matchedChildren; }; diff --git a/mlir/include/mlir/Analysis/Utils.h b/mlir/include/mlir/Analysis/Utils.h index 7c5b5b1..ee231e1 100644 --- a/mlir/include/mlir/Analysis/Utils.h +++ b/mlir/include/mlir/Analysis/Utils.h @@ -333,7 +333,7 @@ struct MemRefRegion { Value memref; /// Read or write. - bool write; + bool write = false; /// If there is more than one load/store op associated with the region, the /// location information would correspond to one of those op's. diff --git a/mlir/include/mlir/IR/AffineMap.h b/mlir/include/mlir/IR/AffineMap.h index 14bddf5..28a4261 100644 --- a/mlir/include/mlir/IR/AffineMap.h +++ b/mlir/include/mlir/IR/AffineMap.h @@ -353,11 +353,11 @@ public: private: // Same meaning as AffineMap's fields. SmallVector results; - unsigned numDims; - unsigned numSymbols; + unsigned numDims = 0; + unsigned numSymbols = 0; /// A pointer to the IR's context to store all newly created /// AffineExprStorage's. - MLIRContext *context; + MLIRContext *context = nullptr; }; /// Simplifies an affine map by simplifying its underlying AffineExpr results. diff --git a/mlir/include/mlir/IR/AttributeSupport.h b/mlir/include/mlir/IR/AttributeSupport.h index 97e1202..9745207 100644 --- a/mlir/include/mlir/IR/AttributeSupport.h +++ b/mlir/include/mlir/IR/AttributeSupport.h @@ -152,7 +152,7 @@ private: Type type; /// The abstract descriptor for this attribute. - const AbstractAttribute *abstractAttribute; + const AbstractAttribute *abstractAttribute = nullptr; }; /// Default storage type for attributes that require no additional diff --git a/mlir/include/mlir/Reducer/ReductionNode.h b/mlir/include/mlir/Reducer/ReductionNode.h index c938a1b..442bc59 100644 --- a/mlir/include/mlir/Reducer/ReductionNode.h +++ b/mlir/include/mlir/Reducer/ReductionNode.h @@ -145,19 +145,19 @@ private: OwningOpRef module; /// The region of certain operation we're reducing in the module - Region *region; + Region *region = nullptr; /// The node we are reduced from. It means we will be in variants of parent /// node. - ReductionNode *parent; + ReductionNode *parent = nullptr; /// The size of module after applying the reducer patterns with range /// constraints. This is only valid while the interestingness has been tested. - size_t size; + size_t size = 0; /// This is true if the module has been evaluated and it exhibits the /// interesting behavior. - Tester::Interestingness interesting; + Tester::Interestingness interesting = Tester::Interestingness::Untested; /// `ranges` represents the selected subset of operations in the region. We /// implicitly number each operation in the region and ReductionTreePass will diff --git a/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp b/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp index 7ecc675..036cc6b 100644 --- a/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp @@ -755,7 +755,7 @@ struct VectorizationState { DenseMap vecLoopToMask; // The strategy drives which loop to vectorize by which amount. - const VectorizationStrategy *strategy; + const VectorizationStrategy *strategy = nullptr; private: /// Internal implementation to map input scalar values to new vector or scalar diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp index 05b5daf..b66f569 100644 --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp @@ -773,7 +773,7 @@ struct spirv::detail::StructTypeStorage : public TypeStorage { /// in order to mutate the storage object providing the actual content. StructTypeStorage(StringRef identifier) : memberTypesAndIsBodySet(nullptr, false), offsetInfo(nullptr), - numMemberDecorations(0), memberDecorationsInfo(nullptr), + numMembers(0), numMemberDecorations(0), memberDecorationsInfo(nullptr), identifier(identifier) {} /// Construct a storage object for a literal struct type. A struct type diff --git a/mlir/lib/Pass/PassCrashRecovery.cpp b/mlir/lib/Pass/PassCrashRecovery.cpp index ea642ce..d2d646d 100644 --- a/mlir/lib/Pass/PassCrashRecovery.cpp +++ b/mlir/lib/Pass/PassCrashRecovery.cpp @@ -180,7 +180,7 @@ struct PassCrashReproducerGenerator::Impl { /// Flag indicating if reproducer generation should be localized to the /// failing pass. - bool localReproducer; + bool localReproducer = false; /// A record of all of the currently active reproducer contexts. SmallVector> activeContexts; @@ -190,7 +190,7 @@ struct PassCrashReproducerGenerator::Impl { SetVector> runningPasses; /// Various pass manager flags that get emitted when generating a reproducer. - bool pmFlagVerifyPasses; + bool pmFlagVerifyPasses = false; }; PassCrashReproducerGenerator::PassCrashReproducerGenerator( diff --git a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp index 65f0fc9..366a3d7c 100644 --- a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp @@ -105,7 +105,7 @@ private: /// The current module being created. ModuleOp module; /// The entry block of the current function being processed. - Block *currentEntryBlock; + Block *currentEntryBlock = nullptr; /// Globals are inserted before the first function, if any. Block::iterator getGlobalInsertPt() { diff --git a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.h b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.h index 402bfcb..d5a9e99 100644 --- a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.h +++ b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.h @@ -500,7 +500,7 @@ private: OpBuilder opBuilder; - spirv::Version version; + spirv::Version version = spirv::Version::V_1_0; /// The list of capabilities used by the module. llvm::SmallSetVector capabilities; diff --git a/mlir/lib/Transforms/BufferOptimizations.cpp b/mlir/lib/Transforms/BufferOptimizations.cpp index 27e00a1..9421e85 100644 --- a/mlir/lib/Transforms/BufferOptimizations.cpp +++ b/mlir/lib/Transforms/BufferOptimizations.cpp @@ -284,7 +284,7 @@ struct BufferAllocationLoopHoistingState : BufferAllocationHoistingStateBase { using BufferAllocationHoistingStateBase::BufferAllocationHoistingStateBase; /// Remembers the dominator block of all aliases. - Block *aliasDominatorBlock; + Block *aliasDominatorBlock = nullptr; /// Computes the upper bound for the placement block search. Block *computeUpperBound(Block *dominatorBlock, Block *dependencyBlock) { diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp index 22b9b36..8042ecc 100644 --- a/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp +++ b/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp @@ -265,8 +265,8 @@ private: std::vector> elements; /// Flags for printing spaces. - bool shouldEmitSpace; - bool lastWasPunctuation; + bool shouldEmitSpace = false; + bool lastWasPunctuation = false; }; } // namespace -- 2.7.4