[Mlir-commits] [mlir] a9f13f8 - Fix a few unitialized class members in MLIR (NFC)

Mehdi Amini llvmlistbot at llvm.org
Fri Dec 31 17:42:25 PST 2021


Author: Mehdi Amini
Date: 2022-01-01T01:40:36Z
New Revision: a9f13f80658c20bfc1b41187cefc2e90fdc0fd6f

URL: https://github.com/llvm/llvm-project/commit/a9f13f80658c20bfc1b41187cefc2e90fdc0fd6f
DIFF: https://github.com/llvm/llvm-project/commit/a9f13f80658c20bfc1b41187cefc2e90fdc0fd6f.diff

LOG: Fix a few unitialized class members in MLIR (NFC)

Flagged by Coverity.

Added: 
    

Modified: 
    mlir/include/mlir/Analysis/AffineAnalysis.h
    mlir/include/mlir/Analysis/Liveness.h
    mlir/include/mlir/Analysis/NestedMatcher.h
    mlir/include/mlir/Analysis/Utils.h
    mlir/include/mlir/IR/AffineMap.h
    mlir/include/mlir/IR/AttributeSupport.h
    mlir/include/mlir/Reducer/ReductionNode.h
    mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp
    mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp
    mlir/lib/Pass/PassCrashRecovery.cpp
    mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
    mlir/lib/Target/SPIRV/Deserialization/Deserializer.h
    mlir/lib/Transforms/BufferOptimizations.cpp
    mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Analysis/AffineAnalysis.h b/mlir/include/mlir/Analysis/AffineAnalysis.h
index fa793a9e17f84..4c10bed1690c4 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<int64_t> 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 74891520139d8..3b20506914300 100644
--- a/mlir/include/mlir/Analysis/Liveness.h
+++ b/mlir/include/mlir/Analysis/Liveness.h
@@ -131,7 +131,7 @@ class LivenessBlockInfo {
 
 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 f0a7088bd8fcd..fb725e3ec8645 100644
--- a/mlir/include/mlir/Analysis/NestedMatcher.h
+++ b/mlir/include/mlir/Analysis/NestedMatcher.h
@@ -65,7 +65,7 @@ class NestedMatch {
   NestedMatch() = default;
 
   /// Payload, holds a NestedMatch and all its children along this branch.
-  Operation *matchedOperation;
+  Operation *matchedOperation = nullptr;
   ArrayRef<NestedMatch> matchedChildren;
 };
 

diff  --git a/mlir/include/mlir/Analysis/Utils.h b/mlir/include/mlir/Analysis/Utils.h
index 7c5b5b1d2aa0f..ee231e1713e0c 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 14bddf5794b5e..28a4261b9b80a 100644
--- a/mlir/include/mlir/IR/AffineMap.h
+++ b/mlir/include/mlir/IR/AffineMap.h
@@ -353,11 +353,11 @@ struct MutableAffineMap {
 private:
   // Same meaning as AffineMap's fields.
   SmallVector<AffineExpr, 8> 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 97e120208d399..9745207fd2ef1 100644
--- a/mlir/include/mlir/IR/AttributeSupport.h
+++ b/mlir/include/mlir/IR/AttributeSupport.h
@@ -152,7 +152,7 @@ class alignas(8) AttributeStorage : public StorageUniquer::BaseStorage {
   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 c938a1b5453d0..442bc59589f3e 100644
--- a/mlir/include/mlir/Reducer/ReductionNode.h
+++ b/mlir/include/mlir/Reducer/ReductionNode.h
@@ -145,19 +145,19 @@ class ReductionNode {
   OwningOpRef<ModuleOp> 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 7ecc6750bcca4..036cc6b03f76e 100644
--- a/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp
@@ -755,7 +755,7 @@ struct VectorizationState {
   DenseMap<Operation *, Value> 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 05b5dafb8a682..b66f569c352d9 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 ea642ce44f5de..d2d646dc7a32d 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<std::unique_ptr<RecoveryReproducerContext>> activeContexts;
@@ -190,7 +190,7 @@ struct PassCrashReproducerGenerator::Impl {
   SetVector<std::pair<Pass *, Operation *>> 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 65f0fc9b38499..366a3d7ce24a8 100644
--- a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
+++ b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
@@ -105,7 +105,7 @@ class Importer {
   /// 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 402bfcbae1d9d..d5a9e9913851b 100644
--- a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.h
+++ b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.h
@@ -500,7 +500,7 @@ class Deserializer {
 
   OpBuilder opBuilder;
 
-  spirv::Version version;
+  spirv::Version version = spirv::Version::V_1_0;
 
   /// The list of capabilities used by the module.
   llvm::SmallSetVector<spirv::Capability, 4> capabilities;

diff  --git a/mlir/lib/Transforms/BufferOptimizations.cpp b/mlir/lib/Transforms/BufferOptimizations.cpp
index 27e00a14c0d4d..9421e85193b12 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 22b9b36c908dc..8042ecc6fe969 100644
--- a/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp
+++ b/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp
@@ -265,8 +265,8 @@ class AttrOrTypeFormat {
   std::vector<std::unique_ptr<Element>> elements;
 
   /// Flags for printing spaces.
-  bool shouldEmitSpace;
-  bool lastWasPunctuation;
+  bool shouldEmitSpace = false;
+  bool lastWasPunctuation = false;
 };
 } // namespace
 


        


More information about the Mlir-commits mailing list