[Mlir-commits] [mlir] e21adfa - [mlir] Mark LogicalResult as LLVM_NODISCARD

River Riddle llvmlistbot at llvm.org
Thu Feb 4 15:10:26 PST 2021


Author: River Riddle
Date: 2021-02-04T15:10:10-08:00
New Revision: e21adfa32d8822f9ea4058c3e365a841d87cb3ee

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

LOG: [mlir] Mark LogicalResult as LLVM_NODISCARD

This makes ignoring a result explicit by the user, and helps to prevent accidental errors with dropped results. Marking LogicalResult as no discard was always the intention from the beginning, but got lost along the way.

Differential Revision: https://reviews.llvm.org/D95841

Added: 
    

Modified: 
    mlir/include/mlir/IR/OpDefinition.h
    mlir/include/mlir/IR/SymbolTable.h
    mlir/include/mlir/Pass/PassManager.h
    mlir/include/mlir/Support/LogicalResult.h
    mlir/include/mlir/Transforms/DialectConversion.h
    mlir/include/mlir/Transforms/LoopUtils.h
    mlir/lib/Analysis/Presburger/Simplex.cpp
    mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp
    mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
    mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
    mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
    mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp
    mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
    mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
    mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp
    mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
    mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp
    mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
    mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp
    mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp
    mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp
    mlir/lib/Dialect/Affine/Transforms/LoopUnrollAndJam.cpp
    mlir/lib/Dialect/Affine/Transforms/SimplifyAffineStructures.cpp
    mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp
    mlir/lib/Dialect/Affine/Utils/Utils.cpp
    mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp
    mlir/lib/Dialect/Linalg/Transforms/CodegenStrategy.cpp
    mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp
    mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp
    mlir/lib/Dialect/Linalg/Transforms/Generalization.cpp
    mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
    mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
    mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
    mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
    mlir/lib/Dialect/Quant/Transforms/ConvertConst.cpp
    mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp
    mlir/lib/Dialect/Shape/Transforms/RemoveShapeConstraints.cpp
    mlir/lib/Dialect/StandardOps/IR/Ops.cpp
    mlir/lib/Dialect/StandardOps/Transforms/DecomposeCallGraphTypes.cpp
    mlir/lib/Dialect/Tosa/Transforms/TosaMakeBroadcastable.cpp
    mlir/lib/IR/AsmPrinter.cpp
    mlir/lib/IR/BuiltinTypes.cpp
    mlir/lib/Pass/Pass.cpp
    mlir/lib/Support/MlirOptMain.cpp
    mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
    mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp
    mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp
    mlir/lib/Target/SPIRV/Serialization/Serialization.cpp
    mlir/lib/Transforms/Canonicalizer.cpp
    mlir/lib/Transforms/Inliner.cpp
    mlir/lib/Transforms/NormalizeMemRefs.cpp
    mlir/lib/Transforms/SCCP.cpp
    mlir/lib/Transforms/Utils/LoopFusionUtils.cpp
    mlir/lib/Transforms/Utils/LoopUtils.cpp
    mlir/lib/Translation/Translation.cpp
    mlir/test/lib/Dialect/Affine/TestAffineDataCopy.cpp
    mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp
    mlir/test/lib/Dialect/SPIRV/TestGLSLCanonicalization.cpp
    mlir/test/lib/Dialect/Test/TestPatterns.cpp
    mlir/test/lib/Dialect/Test/TestTraits.cpp
    mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp
    mlir/test/lib/IR/TestSlicing.cpp
    mlir/test/lib/Transforms/TestConvVectorization.cpp
    mlir/test/lib/Transforms/TestDynamicPipeline.cpp
    mlir/test/lib/Transforms/TestExpandTanh.cpp
    mlir/test/lib/Transforms/TestGpuRewrite.cpp
    mlir/test/lib/Transforms/TestLinalgFusionTransforms.cpp
    mlir/test/lib/Transforms/TestLinalgTransforms.cpp
    mlir/test/lib/Transforms/TestLoopUnrolling.cpp
    mlir/test/lib/Transforms/TestMemRefBoundCheck.cpp
    mlir/test/lib/Transforms/TestSCFUtils.cpp
    mlir/test/lib/Transforms/TestSparsification.cpp
    mlir/test/lib/Transforms/TestVectorTransforms.cpp
    mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp
    mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
    mlir/tools/mlir-vulkan-runner/VulkanRuntime.cpp
    mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h
index 3b5e661fdef73..79024174375b7 100644
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -41,7 +41,7 @@ class ParseResult : public LogicalResult {
   ParseResult(const Diagnostic &) : LogicalResult(failure()) {}
 
   /// Failure is true in a boolean context.
-  explicit operator bool() const { return failed(*this); }
+  explicit operator bool() const { return failed(); }
 };
 /// This class implements `Optional` functionality for ParseResult. We don't
 /// directly use Optional here, because it provides an implicit conversion

diff  --git a/mlir/include/mlir/IR/SymbolTable.h b/mlir/include/mlir/IR/SymbolTable.h
index edeaab21aabe6..0db01cce6ce21 100644
--- a/mlir/include/mlir/IR/SymbolTable.h
+++ b/mlir/include/mlir/IR/SymbolTable.h
@@ -189,17 +189,17 @@ class SymbolTable {
   /// 'from'. This does not traverse into any nested symbol tables. If there are
   /// any unknown operations that may potentially be symbol tables, no uses are
   /// replaced and failure is returned.
-  LLVM_NODISCARD static LogicalResult replaceAllSymbolUses(StringRef oldSymbol,
-                                                           StringRef newSymbol,
-                                                           Operation *from);
-  LLVM_NODISCARD static LogicalResult
-  replaceAllSymbolUses(Operation *oldSymbol, StringRef newSymbolName,
-                       Operation *from);
-  LLVM_NODISCARD static LogicalResult
-  replaceAllSymbolUses(StringRef oldSymbol, StringRef newSymbol, Region *from);
-  LLVM_NODISCARD static LogicalResult
-  replaceAllSymbolUses(Operation *oldSymbol, StringRef newSymbolName,
-                       Region *from);
+  static LogicalResult replaceAllSymbolUses(StringRef oldSymbol,
+                                            StringRef newSymbol,
+                                            Operation *from);
+  static LogicalResult replaceAllSymbolUses(Operation *oldSymbol,
+                                            StringRef newSymbolName,
+                                            Operation *from);
+  static LogicalResult replaceAllSymbolUses(StringRef oldSymbol,
+                                            StringRef newSymbol, Region *from);
+  static LogicalResult replaceAllSymbolUses(Operation *oldSymbol,
+                                            StringRef newSymbolName,
+                                            Region *from);
 
 private:
   Operation *symbolTableOp;

diff  --git a/mlir/include/mlir/Pass/PassManager.h b/mlir/include/mlir/Pass/PassManager.h
index e73459f835f26..99798bdd551d7 100644
--- a/mlir/include/mlir/Pass/PassManager.h
+++ b/mlir/include/mlir/Pass/PassManager.h
@@ -178,7 +178,6 @@ class PassManager : public OpPassManager {
   /// Run the passes within this manager on the provided operation. The
   /// specified operation must have the same name as the one provided the pass
   /// manager on construction.
-  LLVM_NODISCARD
   LogicalResult run(Operation *op);
 
   /// Return an instance of the context.

diff  --git a/mlir/include/mlir/Support/LogicalResult.h b/mlir/include/mlir/Support/LogicalResult.h
index 3e30e9e81567d..0281cb5b0053c 100644
--- a/mlir/include/mlir/Support/LogicalResult.h
+++ b/mlir/include/mlir/Support/LogicalResult.h
@@ -14,38 +14,62 @@
 
 namespace mlir {
 
-/// Values that can be used to signal success/failure. This should be used in
-/// conjunction with the utility functions below.
-struct LogicalResult {
-  enum ResultEnum { Success, Failure } value;
-  LogicalResult(ResultEnum v) : value(v) {}
+/// This class represents an efficient way to signal success or failure. It
+/// should be preferred over the use of `bool` when appropriate, as it avoids
+/// all of the ambiguity that arises in interpreting a boolean result. This
+/// class is marked as NODISCARD to ensure that the result is processed. Users
+/// may explicitly discard a result by using `(void)`, e.g.
+/// `(void)functionThatReturnsALogicalResult();`. Given the intended nature of
+/// this class, it generally shouldn't be used as the result of functions that
+/// very frequently have the result ignored. This class is intended to be used
+/// in conjunction with the utility functions below.
+struct LLVM_NODISCARD LogicalResult {
+public:
+  /// If isSuccess is true a `success` result is generated, otherwise a
+  /// 'failure' result is generated.
+  static LogicalResult success(bool isSuccess = true) {
+    return LogicalResult(isSuccess);
+  }
+
+  /// If isFailure is true a `failure` result is generated, otherwise a
+  /// 'success' result is generated.
+  static LogicalResult failure(bool isFailure = true) {
+    return success(!isFailure);
+  }
+
+  /// Returns true if the provided LogicalResult corresponds to a success value.
+  bool succeeded() const { return isSuccess; }
+
+  /// Returns true if the provided LogicalResult corresponds to a failure value.
+  bool failed() const { return !succeeded(); }
+
+private:
+  LogicalResult(bool isSuccess) : isSuccess(isSuccess) {}
+
+  /// Boolean indicating if this is a success result, if false this is a
+  /// failure result.
+  bool isSuccess;
 };
 
 /// Utility function to generate a LogicalResult. If isSuccess is true a
 /// `success` result is generated, otherwise a 'failure' result is generated.
 inline LogicalResult success(bool isSuccess = true) {
-  return LogicalResult{isSuccess ? LogicalResult::Success
-                                 : LogicalResult::Failure};
+  return LogicalResult::success(isSuccess);
 }
 
 /// Utility function to generate a LogicalResult. If isFailure is true a
 /// `failure` result is generated, otherwise a 'success' result is generated.
 inline LogicalResult failure(bool isFailure = true) {
-  return LogicalResult{isFailure ? LogicalResult::Failure
-                                 : LogicalResult::Success};
+  return LogicalResult::failure(isFailure);
 }
 
 /// Utility function that returns true if the provided LogicalResult corresponds
 /// to a success value.
-inline bool succeeded(LogicalResult result) {
-  return result.value == LogicalResult::Success;
-}
+inline bool succeeded(LogicalResult result) { return result.succeeded(); }
 
 /// Utility function that returns true if the provided LogicalResult corresponds
 /// to a failure value.
-inline bool failed(LogicalResult result) {
-  return result.value == LogicalResult::Failure;
-}
+inline bool failed(LogicalResult result) { return result.failed(); }
 
 /// This class provides support for representing a failure result, or a valid
 /// value of type `T`. This allows for integrating with LogicalResult, while

diff  --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h
index a67c993b6ab55..0c1161b9945cd 100644
--- a/mlir/include/mlir/Transforms/DialectConversion.h
+++ b/mlir/include/mlir/Transforms/DialectConversion.h
@@ -829,11 +829,11 @@ class ConversionTarget {
 /// legalizable to the given `target` are placed within that set. (Note that if
 /// there is an op explicitly marked as illegal, the conversion terminates and
 /// the `unconvertedOps` set will not necessarily be complete.)
-LLVM_NODISCARD LogicalResult
+LogicalResult
 applyPartialConversion(ArrayRef<Operation *> ops, ConversionTarget &target,
                        const FrozenRewritePatternList &patterns,
                        DenseSet<Operation *> *unconvertedOps = nullptr);
-LLVM_NODISCARD LogicalResult
+LogicalResult
 applyPartialConversion(Operation *op, ConversionTarget &target,
                        const FrozenRewritePatternList &patterns,
                        DenseSet<Operation *> *unconvertedOps = nullptr);
@@ -842,12 +842,11 @@ applyPartialConversion(Operation *op, ConversionTarget &target,
 /// operations. This method returns failure if the conversion of any operation
 /// fails, or if there are unreachable blocks in any of the regions nested
 /// within 'ops'.
-LLVM_NODISCARD LogicalResult
-applyFullConversion(ArrayRef<Operation *> ops, ConversionTarget &target,
-                    const FrozenRewritePatternList &patterns);
-LLVM_NODISCARD LogicalResult
-applyFullConversion(Operation *op, ConversionTarget &target,
-                    const FrozenRewritePatternList &patterns);
+LogicalResult applyFullConversion(ArrayRef<Operation *> ops,
+                                  ConversionTarget &target,
+                                  const FrozenRewritePatternList &patterns);
+LogicalResult applyFullConversion(Operation *op, ConversionTarget &target,
+                                  const FrozenRewritePatternList &patterns);
 
 /// Apply an analysis conversion on the given operations, and all nested
 /// operations. This method analyzes which operations would be successfully
@@ -857,14 +856,13 @@ applyFullConversion(Operation *op, ConversionTarget &target,
 /// operations on success and only pre-existing operations are added to the set.
 /// This method only returns failure if there are unreachable blocks in any of
 /// the regions nested within 'ops'.
-LLVM_NODISCARD LogicalResult
-applyAnalysisConversion(ArrayRef<Operation *> ops, ConversionTarget &target,
-                        const FrozenRewritePatternList &patterns,
-                        DenseSet<Operation *> &convertedOps);
-LLVM_NODISCARD LogicalResult
-applyAnalysisConversion(Operation *op, ConversionTarget &target,
-                        const FrozenRewritePatternList &patterns,
-                        DenseSet<Operation *> &convertedOps);
+LogicalResult applyAnalysisConversion(ArrayRef<Operation *> ops,
+                                      ConversionTarget &target,
+                                      const FrozenRewritePatternList &patterns,
+                                      DenseSet<Operation *> &convertedOps);
+LogicalResult applyAnalysisConversion(Operation *op, ConversionTarget &target,
+                                      const FrozenRewritePatternList &patterns,
+                                      DenseSet<Operation *> &convertedOps);
 } // end namespace mlir
 
 #endif // MLIR_TRANSFORMS_DIALECTCONVERSION_H_

diff  --git a/mlir/include/mlir/Transforms/LoopUtils.h b/mlir/include/mlir/Transforms/LoopUtils.h
index 6e11249054bc4..72936acd2df57 100644
--- a/mlir/include/mlir/Transforms/LoopUtils.h
+++ b/mlir/include/mlir/Transforms/LoopUtils.h
@@ -85,7 +85,6 @@ void promoteSingleIterationLoops(FuncOp f);
 /// order, and are multiplied by the loop 'step' before being applied. If
 /// `unrollPrologueEpilogue` is set, fully unroll the prologue and epilogue
 /// loops when possible.
-LLVM_NODISCARD
 LogicalResult affineForOpBodySkew(AffineForOp forOp, ArrayRef<uint64_t> shifts,
                                   bool unrollPrologueEpilogue = false);
 
@@ -97,7 +96,6 @@ void getTileableBands(FuncOp f,
 
 /// Tiles the specified band of perfectly nested loops creating tile-space loops
 /// and intra-tile loops. A band is a contiguous set of loops.
-LLVM_NODISCARD
 LogicalResult
 tilePerfectlyNested(MutableArrayRef<AffineForOp> input,
                     ArrayRef<unsigned> tileSizes,
@@ -106,7 +104,6 @@ tilePerfectlyNested(MutableArrayRef<AffineForOp> input,
 /// Tiles the specified band of perfectly nested loops creating tile-space
 /// loops and intra-tile loops, using SSA values as tiling parameters. A band
 /// is a contiguous set of loops.
-LLVM_NODISCARD
 LogicalResult tilePerfectlyNestedParametric(
     MutableArrayRef<AffineForOp> input, ArrayRef<Value> tileSizes,
     SmallVectorImpl<AffineForOp> *tiledNest = nullptr);

diff  --git a/mlir/lib/Analysis/Presburger/Simplex.cpp b/mlir/lib/Analysis/Presburger/Simplex.cpp
index f3e35f8b25381..325a23a53852e 100644
--- a/mlir/lib/Analysis/Presburger/Simplex.cpp
+++ b/mlir/lib/Analysis/Presburger/Simplex.cpp
@@ -272,7 +272,7 @@ LogicalResult Simplex::restoreRow(Unknown &u) {
 
     pivot(*maybePivot);
     if (u.orientation == Orientation::Column)
-      return LogicalResult::Success; // the unknown is unbounded above.
+      return success(); // the unknown is unbounded above.
   }
   return success(tableau(u.pos, 1) >= 0);
 }
@@ -509,7 +509,7 @@ Optional<Fraction> Simplex::computeOptimum(Direction direction, Unknown &u) {
   Optional<Fraction> optimum = computeRowOptimum(direction, row);
   if (u.restricted && direction == Direction::Down &&
       (!optimum || *optimum < Fraction(0, 1)))
-    restoreRow(u);
+    (void)restoreRow(u);
   return optimum;
 }
 
@@ -572,7 +572,7 @@ void Simplex::detectRedundant() {
     if (!minimum || *minimum < Fraction(0, 1)) {
       // Constraint is unbounded below or can attain negative sample values and
       // hence is not redundant.
-      restoreRow(u);
+      (void)restoreRow(u);
       continue;
     }
 

diff  --git a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp
index 896fc411bcdd3..5a2fe919382cf 100644
--- a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp
+++ b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp
@@ -379,7 +379,8 @@ static Value getIdentityValue(AtomicRMWKind op, OpBuilder &builder,
     return builder.create<ConstantOp>(loc, builder.getI32IntegerAttr(1));
   // TODO: Add remaining reduction operations.
   default:
-    emitOptionalError(loc, "Reduction operation type not supported");
+    (void)emitOptionalError(loc, "Reduction operation type not supported");
+    break;
   }
   return nullptr;
 }
@@ -399,7 +400,8 @@ static Value getReductionOp(AtomicRMWKind op, OpBuilder &builder, Location loc,
     return builder.create<MulIOp>(loc, lhs, rhs);
   // TODO: Add remaining reduction operations.
   default:
-    emitOptionalError(loc, "Reduction operation type not supported");
+    (void)emitOptionalError(loc, "Reduction operation type not supported");
+    break;
   }
   return nullptr;
 }

diff  --git a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
index f99b7cace5027..e706f90bf1a56 100644
--- a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
+++ b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
@@ -128,7 +128,7 @@ struct LowerGpuOpsToNVVMOpsPass
     // which need to be lowered further, which is not supported by a single
     // conversion pass.
     populateGpuRewritePatterns(m.getContext(), patterns);
-    applyPatternsAndFoldGreedily(m, std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(m, std::move(patterns));
 
     populateStdToLLVMConversionPatterns(converter, llvmPatterns);
     populateGpuToNVVMConversionPatterns(converter, llvmPatterns);

diff  --git a/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp b/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
index 7aa8e60216507..5f55b6cbecadb 100644
--- a/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
+++ b/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
@@ -62,7 +62,7 @@ struct LowerGpuOpsToROCDLOpsPass
     OwningRewritePatternList patterns, llvmPatterns;
 
     populateGpuRewritePatterns(m.getContext(), patterns);
-    applyPatternsAndFoldGreedily(m, std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(m, std::move(patterns));
 
     populateVectorToLLVMConversionPatterns(converter, llvmPatterns);
     populateVectorToROCDLConversionPatterns(converter, llvmPatterns);

diff  --git a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
index d66f9c66c1dac..544487bf23028 100644
--- a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
+++ b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
@@ -208,7 +208,8 @@ lowerAsEntryFunction(gpu::GPUFuncOp funcOp, TypeConverter &typeConverter,
     return nullptr;
   rewriter.eraseOp(funcOp);
 
-  spirv::setABIAttrs(newFuncOp, entryPointInfo, argABIInfo);
+  if (failed(spirv::setABIAttrs(newFuncOp, entryPointInfo, argABIInfo)))
+    return nullptr;
   return newFuncOp;
 }
 

diff  --git a/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp b/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp
index 604b4576fc1b3..7471b4b7a4851 100644
--- a/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp
+++ b/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp
@@ -295,7 +295,7 @@ class LowerHostCodeToLLVM
     // Finally, modify the kernel function in SPIR-V modules to avoid symbolic
     // conflicts.
     for (auto spvModule : module.getOps<spirv::ModuleOp>())
-      encodeKernelName(spvModule);
+      (void)encodeKernelName(spvModule);
   }
 };
 } // namespace

diff  --git a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
index 0c868cb549b7e..87026e4483e6e 100644
--- a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
+++ b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
@@ -888,9 +888,9 @@ class LoadStorePattern : public SPIRVToLLVMConversion<SPIRVop> {
                   ConversionPatternRewriter &rewriter) const override {
 
     if (!op.memory_access().hasValue()) {
-      replaceWithLoadOrStore(op, rewriter, this->typeConverter, /*alignment=*/0,
-                             /*isVolatile=*/false, /*isNonTemporal=*/false);
-      return success();
+      return replaceWithLoadOrStore(
+          op, rewriter, this->typeConverter, /*alignment=*/0,
+          /*isVolatile=*/false, /*isNonTemporal=*/false);
     }
     auto memoryAccess = op.memory_access().getValue();
     switch (memoryAccess) {
@@ -902,9 +902,8 @@ class LoadStorePattern : public SPIRVToLLVMConversion<SPIRVop> {
           memoryAccess == spirv::MemoryAccess::Aligned ? *op.alignment() : 0;
       bool isNonTemporal = memoryAccess == spirv::MemoryAccess::Nontemporal;
       bool isVolatile = memoryAccess == spirv::MemoryAccess::Volatile;
-      replaceWithLoadOrStore(op, rewriter, this->typeConverter, alignment,
-                             isVolatile, isNonTemporal);
-      return success();
+      return replaceWithLoadOrStore(op, rewriter, this->typeConverter,
+                                    alignment, isVolatile, isNonTemporal);
     }
     default:
       // There is no support of other memory access attributes.

diff  --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
index bb6376cf20f3d..794f4a5d6c1e1 100644
--- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
+++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
@@ -3111,9 +3111,10 @@ struct ReturnOpLowering : public ConvertOpToLLVMPattern<ReturnOp> {
       }
     } else {
       updatedOperands = llvm::to_vector<4>(operands);
-      copyUnrankedDescriptors(rewriter, loc, *getTypeConverter(),
-                              op.getOperands().getTypes(), updatedOperands,
-                              /*toDynamic=*/true);
+      (void)copyUnrankedDescriptors(rewriter, loc, *getTypeConverter(),
+                                    op.getOperands().getTypes(),
+                                    updatedOperands,
+                                    /*toDynamic=*/true);
     }
 
     // If ReturnOp has 0 or 1 operand, create it and return immediately.

diff  --git a/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp b/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp
index 96fdcb593c042..4c4705da6a480 100644
--- a/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp
+++ b/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp
@@ -214,8 +214,8 @@ void SPIRVLegalization::runOnOperation() {
   OwningRewritePatternList patterns;
   auto *context = &getContext();
   populateStdLegalizationPatternsForSPIRVLowering(context, patterns);
-  applyPatternsAndFoldGreedily(getOperation()->getRegions(),
-                               std::move(patterns));
+  (void)applyPatternsAndFoldGreedily(getOperation()->getRegions(),
+                                     std::move(patterns));
 }
 
 std::unique_ptr<Pass> mlir::createLegalizeStdOpsForSPIRVLoweringPass() {

diff  --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
index dd4bb2a3d0167..8ecd15d62b884 100644
--- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
+++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
@@ -137,7 +137,7 @@ createLinalgBodyCalculationForElementwiseOp(Operation *op, ValueRange args,
   if (isa<tosa::FloorOp>(op) && elementTy.isa<FloatType>())
     return rewriter.create<mlir::FloorFOp>(loc, resultTypes, args);
 
-  rewriter.notifyMatchFailure(
+  (void)rewriter.notifyMatchFailure(
       op, "unhandled op for linalg body calculation for elementwise op");
   return nullptr;
 }

diff  --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp
index 910524041bed0..0657361c7c73f 100644
--- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp
+++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp
@@ -61,7 +61,7 @@ void LowerVectorToLLVMPass::runOnOperation() {
     populateVectorToVectorCanonicalizationPatterns(patterns, &getContext());
     populateVectorSlicesLoweringPatterns(patterns, &getContext());
     populateVectorContractLoweringPatterns(patterns, &getContext());
-    applyPatternsAndFoldGreedily(getOperation(), std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns));
   }
 
   // Convert to the LLVM IR dialect.

diff  --git a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
index b0f1b46b2459b..503a2f0013455 100644
--- a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
+++ b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
@@ -713,7 +713,7 @@ struct ConvertVectorToSCFPass
     auto *context = getFunction().getContext();
     populateVectorToSCFConversionPatterns(
         patterns, context, VectorTransferToSCFOptions().setUnroll(fullUnroll));
-    applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
   }
 };
 

diff  --git a/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp b/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp
index 1fce7d9519c00..1131e6ecec229 100644
--- a/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp
@@ -155,7 +155,7 @@ AffineDataCopyGeneration::runOnBlock(Block *block,
       if (recurseInner) {
         // We'll recurse and do the copies at an inner level for 'forInst'.
         // Recurse onto the body of this loop.
-        runOnBlock(forOp.getBody(), copyNests);
+        (void)runOnBlock(forOp.getBody(), copyNests);
       } else {
         // We have enough capacity, i.e., copies will be computed for the
         // portion of the block until 'it', and for 'it', which is 'forOp'. Note
@@ -207,7 +207,7 @@ void AffineDataCopyGeneration::runOnFunction() {
   copyNests.clear();
 
   for (auto &block : f)
-    runOnBlock(&block, copyNests);
+    (void)runOnBlock(&block, copyNests);
 
   // Promote any single iteration loops in the copy nests and collect
   // load/stores to simplify.
@@ -217,7 +217,7 @@ void AffineDataCopyGeneration::runOnFunction() {
     // continuation of the walk or the collection of load/store ops.
     nest->walk([&](Operation *op) {
       if (auto forOp = dyn_cast<AffineForOp>(op))
-        promoteIfSingleIteration(forOp);
+        (void)promoteIfSingleIteration(forOp);
       else if (isa<AffineLoadOp, AffineStoreOp>(op))
         copyOps.push_back(op);
     });
@@ -230,5 +230,5 @@ void AffineDataCopyGeneration::runOnFunction() {
   AffineStoreOp::getCanonicalizationPatterns(patterns, &getContext());
   FrozenRewritePatternList frozenPatterns(std::move(patterns));
   for (Operation *op : copyOps)
-    applyOpPatternsAndFold(op, frozenPatterns);
+    (void)applyOpPatternsAndFold(op, frozenPatterns);
 }

diff  --git a/mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp b/mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp
index 56469482c7632..5a42c569dbefe 100644
--- a/mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp
@@ -185,7 +185,7 @@ void LoopTiling::runOnFunction() {
     if (separate) {
       auto intraTileLoops =
           MutableArrayRef<AffineForOp>(tiledNest).drop_front(band.size());
-      separateFullTiles(intraTileLoops);
+      (void)separateFullTiles(intraTileLoops);
     }
   }
 }

diff  --git a/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp b/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp
index 26669967ff329..9682104b356e7 100644
--- a/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp
@@ -96,7 +96,7 @@ void LoopUnroll::runOnFunction() {
         loops.push_back(forOp);
     });
     for (auto forOp : loops)
-      loopUnrollFull(forOp);
+      (void)loopUnrollFull(forOp);
     return;
   }
 

diff  --git a/mlir/lib/Dialect/Affine/Transforms/LoopUnrollAndJam.cpp b/mlir/lib/Dialect/Affine/Transforms/LoopUnrollAndJam.cpp
index 28830dac3660f..55964db7810d1 100644
--- a/mlir/lib/Dialect/Affine/Transforms/LoopUnrollAndJam.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/LoopUnrollAndJam.cpp
@@ -74,5 +74,5 @@ void LoopUnrollAndJam::runOnFunction() {
   // any for operation.
   auto &entryBlock = getFunction().front();
   if (auto forOp = dyn_cast<AffineForOp>(entryBlock.front()))
-    loopUnrollJamByFactor(forOp, unrollJamFactor);
+    (void)loopUnrollJamByFactor(forOp, unrollJamFactor);
 }

diff  --git a/mlir/lib/Dialect/Affine/Transforms/SimplifyAffineStructures.cpp b/mlir/lib/Dialect/Affine/Transforms/SimplifyAffineStructures.cpp
index eb6d7b2cb1a8f..918fec42b2fd6 100644
--- a/mlir/lib/Dialect/Affine/Transforms/SimplifyAffineStructures.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/SimplifyAffineStructures.cpp
@@ -95,6 +95,6 @@ void SimplifyAffineStructures::runOnFunction() {
     // The simplification of the attribute will likely simplify the op. Try to
     // fold / apply canonicalization patterns when we have affine dialect ops.
     if (isa<AffineForOp, AffineIfOp, AffineApplyOp>(op))
-      applyOpPatternsAndFold(op, frozenPatterns);
+      (void)applyOpPatternsAndFold(op, frozenPatterns);
   });
 }

diff  --git a/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp b/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp
index e2f3d8e41f72c..3540b51066207 100644
--- a/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp
@@ -779,7 +779,7 @@ static LogicalResult vectorizeRootOrTerminal(Value iv,
     auto permutationMap =
         makePermutationMap(opInst, indices, state->strategy->loopToVectorDim);
     if (!permutationMap)
-      return LogicalResult::Failure;
+      return failure();
     LLVM_DEBUG(dbgs() << "\n[early-vect]+++++ permutationMap: ");
     LLVM_DEBUG(permutationMap.print(dbgs()));
     auto transfer = b.create<vector::TransferReadOp>(
@@ -1292,7 +1292,7 @@ static void vectorizeLoops(Operation *parentOp, DenseSet<Operation *> &loops,
                                 &strategy);
       // TODO: if pattern does not apply, report it; alter the
       // cost/benefit.
-      vectorizeRootMatch(m, strategy);
+      (void)vectorizeRootMatch(m, strategy);
       // TODO: some diagnostics if failure to vectorize occurs.
     }
   }

diff  --git a/mlir/lib/Dialect/Affine/Utils/Utils.cpp b/mlir/lib/Dialect/Affine/Utils/Utils.cpp
index c66e111fb9cff..acd854d2731cc 100644
--- a/mlir/lib/Dialect/Affine/Utils/Utils.cpp
+++ b/mlir/lib/Dialect/Affine/Utils/Utils.cpp
@@ -192,7 +192,7 @@ LogicalResult mlir::hoistAffineIfOp(AffineIfOp ifOp, bool *folded) {
   AffineIfOp::getCanonicalizationPatterns(patterns, ifOp.getContext());
   bool erased;
   FrozenRewritePatternList frozenPatterns(std::move(patterns));
-  applyOpPatternsAndFold(ifOp, frozenPatterns, &erased);
+  (void)applyOpPatternsAndFold(ifOp, frozenPatterns, &erased);
   if (erased) {
     if (folded)
       *folded = true;
@@ -220,7 +220,7 @@ LogicalResult mlir::hoistAffineIfOp(AffineIfOp ifOp, bool *folded) {
 
   // Canonicalize to remove dead else blocks (happens whenever an 'if' moves up
   // a sequence of affine.fors that are all perfectly nested).
-  applyPatternsAndFoldGreedily(
+  (void)applyPatternsAndFoldGreedily(
       hoistedIfOp->getParentWithTrait<OpTrait::IsIsolatedFromAbove>(),
       frozenPatterns);
 

diff  --git a/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp b/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp
index 1b0fecab36c98..c1d0820e1cc72 100644
--- a/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp
+++ b/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp
@@ -135,7 +135,7 @@ static void mapParallelOp(ParallelOp parallelOp,
         getHardwareIdForMapping(mappingLevel, i), b.getDimIdentityMap(),
         b.getDimIdentityMap()));
   }
-  setMappingAttr(parallelOp, attrs);
+  (void)setMappingAttr(parallelOp, attrs);
   ++mappingLevel;
   // Parallel loop operations are immediately nested, so do not use
   // walk but just iterate over the operations.

diff  --git a/mlir/lib/Dialect/Linalg/Transforms/CodegenStrategy.cpp b/mlir/lib/Dialect/Linalg/Transforms/CodegenStrategy.cpp
index 5c9d1df0c0562..fc79e68e4eb70 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/CodegenStrategy.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/CodegenStrategy.cpp
@@ -65,8 +65,8 @@ void mlir::linalg::CodegenStrategy::transform(FuncOp func) const {
     hoistRedundantVectorTransfers(cast<FuncOp>(op));
     return success();
   };
-  linalg::applyStagedPatterns(func, stage1Patterns, std::move(stage2Patterns),
-                              stage3Transforms);
+  (void)linalg::applyStagedPatterns(
+      func, stage1Patterns, std::move(stage2Patterns), stage3Transforms);
 
   //===--------------------------------------------------------------------===//
   // Post staged patterns transforms
@@ -76,7 +76,7 @@ void mlir::linalg::CodegenStrategy::transform(FuncOp func) const {
   OwningRewritePatternList patterns;
   patterns.insert<vector::VectorTransferFullPartialRewriter>(
       context, vectorTransformsOptions);
-  applyPatternsAndFoldGreedily(func, std::move(patterns));
+  (void)applyPatternsAndFoldGreedily(func, std::move(patterns));
 
   // Programmatic controlled lowering of vector.contract only.
   OwningRewritePatternList vectorContractLoweringPatterns;
@@ -84,13 +84,14 @@ void mlir::linalg::CodegenStrategy::transform(FuncOp func) const {
       .insert<ContractionOpToOuterProductOpLowering,
               ContractionOpToMatmulOpLowering, ContractionOpLowering>(
           vectorTransformsOptions, context);
-  applyPatternsAndFoldGreedily(func, std::move(vectorContractLoweringPatterns));
+  (void)applyPatternsAndFoldGreedily(func,
+                                     std::move(vectorContractLoweringPatterns));
 
   // Programmatic controlled lowering of vector.transfer only.
   OwningRewritePatternList vectorToLoopsPatterns;
   populateVectorToSCFConversionPatterns(vectorToLoopsPatterns, context,
                                         vectorToSCFOptions);
-  applyPatternsAndFoldGreedily(func, std::move(vectorToLoopsPatterns));
+  (void)applyPatternsAndFoldGreedily(func, std::move(vectorToLoopsPatterns));
 
   // Ensure we drop the marker in the end.
   func.walk([](LinalgOp op) {

diff  --git a/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp b/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp
index 3c7b2223ee49e..8db4824cbbd2c 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp
@@ -221,7 +221,7 @@ struct FoldUnitDimLoops : public OpRewritePattern<GenericOpTy> {
     rewriter.startRootUpdate(op);
     op.indexing_mapsAttr(newIndexingMapAttr);
     op.iterator_typesAttr(ArrayAttr::get(newIteratorTypes, context));
-    replaceBlockArgForUnitDimLoops(op, unitDims, rewriter);
+    (void)replaceBlockArgForUnitDimLoops(op, unitDims, rewriter);
     rewriter.finalizeRootUpdate(op);
     return success();
   }
@@ -513,7 +513,7 @@ struct LinalgFoldUnitExtentDimsPass
                       FoldUnitDimLoops<IndexedGenericOp>>(context);
     else
       populateLinalgFoldUnitExtentDimsPatterns(context, patterns);
-    applyPatternsAndFoldGreedily(funcOp.getBody(), std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(funcOp.getBody(), std::move(patterns));
   }
 };
 } // namespace

diff  --git a/mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp b/mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp
index 0c5b8486824ff..9d0b789f64436 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp
@@ -1116,7 +1116,7 @@ struct FusionOfTensorOpsPass
     OwningRewritePatternList patterns;
     Operation *op = getOperation();
     populateLinalgTensorOpsFusionPatterns(op->getContext(), patterns);
-    applyPatternsAndFoldGreedily(op->getRegions(), std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(op->getRegions(), std::move(patterns));
   }
 };
 
@@ -1129,7 +1129,7 @@ struct FoldReshapeOpsByLinearizationPass
     OwningRewritePatternList patterns;
     Operation *op = getOperation();
     populateFoldReshapeOpsByLinearizationPatterns(op->getContext(), patterns);
-    applyPatternsAndFoldGreedily(op->getRegions(), std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(op->getRegions(), std::move(patterns));
   }
 };
 

diff  --git a/mlir/lib/Dialect/Linalg/Transforms/Generalization.cpp b/mlir/lib/Dialect/Linalg/Transforms/Generalization.cpp
index 997fa692c2b1e..0be1c55c1ea78 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Generalization.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Generalization.cpp
@@ -146,7 +146,7 @@ void LinalgGeneralizationPass::runOnFunction() {
   OwningRewritePatternList patterns;
   linalg::populateLinalgConvGeneralizationPatterns(&getContext(), patterns);
   linalg::populateLinalgNamedOpsGeneralizationPatterns(&getContext(), patterns);
-  applyPatternsAndFoldGreedily(func.getBody(), std::move(patterns));
+  (void)applyPatternsAndFoldGreedily(func.getBody(), std::move(patterns));
 }
 
 linalg::GenericOp GeneralizeConvOp::createGenericOp(linalg::ConvOp convOp,

diff  --git a/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp b/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
index cf546152da8df..699be7817e0e2 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
@@ -73,7 +73,7 @@ void mlir::linalg::hoistViewAllocOps(FuncOp func) {
 
       // Move AllocOp before the loop.
       if (isa<AllocOp, AllocaOp>(op))
-        loop.moveOutOfLoop({op});
+        (void)loop.moveOutOfLoop({op});
       else // Move DeallocOp outside of the loop.
         op->moveAfter(loop);
       changed = true;

diff  --git a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
index 09b5c5ee562b0..391562b032a76 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
@@ -592,7 +592,7 @@ static void lowerLinalgToLoopsImpl(FuncOp funcOp,
   AffineApplyOp::getCanonicalizationPatterns(patterns, context);
   patterns.insert<FoldAffineOp>(context);
   // Just apply the patterns greedily.
-  applyPatternsAndFoldGreedily(funcOp, std::move(patterns));
+  (void)applyPatternsAndFoldGreedily(funcOp, std::move(patterns));
 }
 
 namespace {

diff  --git a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
index 5b01dd04b55f9..f99bf85d3cbee 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
@@ -340,7 +340,7 @@ promoteSubViews(OpBuilder &b, LinalgOp op,
 
   // 4. Dealloc all local buffers.
   for (const auto &pi : *promotedBuffersAndViews)
-    options.deallocationFn(b, pi.second.fullLocalView);
+    (void)options.deallocationFn(b, pi.second.fullLocalView);
   return op;
 }
 

diff  --git a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
index ce41560f75571..f48100e25dd88 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
@@ -588,9 +588,9 @@ static void applyTilingToLoopPatterns(LinalgTilingLoopType loopType,
   MLIRContext *ctx = funcOp.getContext();
   OwningRewritePatternList patterns;
   insertTilingPatterns(patterns, options, ctx);
-  applyPatternsAndFoldGreedily(funcOp, std::move(patterns));
-  applyPatternsAndFoldGreedily(funcOp,
-                               getLinalgTilingCanonicalizationPatterns(ctx));
+  (void)applyPatternsAndFoldGreedily(funcOp, std::move(patterns));
+  (void)applyPatternsAndFoldGreedily(
+      funcOp, getLinalgTilingCanonicalizationPatterns(ctx));
   // Drop the marker.
   funcOp.walk([](LinalgOp op) {
     op.removeAttr(LinalgTransforms::kLinalgTransformMarker);

diff  --git a/mlir/lib/Dialect/Quant/Transforms/ConvertConst.cpp b/mlir/lib/Dialect/Quant/Transforms/ConvertConst.cpp
index 8eae27d263c5d..9e8b3ad2ff671 100644
--- a/mlir/lib/Dialect/Quant/Transforms/ConvertConst.cpp
+++ b/mlir/lib/Dialect/Quant/Transforms/ConvertConst.cpp
@@ -96,7 +96,7 @@ void ConvertConstPass::runOnFunction() {
   auto func = getFunction();
   auto *context = &getContext();
   patterns.insert<QuantizedConstRewrite>(context);
-  applyPatternsAndFoldGreedily(func, std::move(patterns));
+  (void)applyPatternsAndFoldGreedily(func, std::move(patterns));
 }
 
 std::unique_ptr<OperationPass<FuncOp>> mlir::quant::createConvertConstPass() {

diff  --git a/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp b/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp
index ed665df81855f..daa1cda8ae99f 100644
--- a/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp
+++ b/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp
@@ -129,7 +129,7 @@ void ConvertSimulatedQuantPass::runOnFunction() {
   auto ctx = func.getContext();
   patterns.insert<ConstFakeQuantRewrite, ConstFakeQuantPerAxisRewrite>(
       ctx, &hadFailure);
-  applyPatternsAndFoldGreedily(func, std::move(patterns));
+  (void)applyPatternsAndFoldGreedily(func, std::move(patterns));
   if (hadFailure)
     signalPassFailure();
 }

diff  --git a/mlir/lib/Dialect/Shape/Transforms/RemoveShapeConstraints.cpp b/mlir/lib/Dialect/Shape/Transforms/RemoveShapeConstraints.cpp
index 4337909e12e9c..492abce92577b 100644
--- a/mlir/lib/Dialect/Shape/Transforms/RemoveShapeConstraints.cpp
+++ b/mlir/lib/Dialect/Shape/Transforms/RemoveShapeConstraints.cpp
@@ -49,7 +49,7 @@ class RemoveShapeConstraintsPass
     OwningRewritePatternList patterns;
     populateRemoveShapeConstraintsPatterns(patterns, &ctx);
 
-    applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
   }
 };
 

diff  --git a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
index 04f4b1083e4a6..c085c1cd33a71 100644
--- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
+++ b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
@@ -3020,9 +3020,9 @@ static SubViewVerificationResult isRankReducedType(Type originalType,
   int64_t originalOffset, candidateReducedOffset;
   SmallVector<int64_t, 4> originalStrides, candidateReducedStrides, keepStrides;
   SmallVector<bool, 4> keepMask = optionalMask.getValue();
-  getStridesAndOffset(original, originalStrides, originalOffset);
-  getStridesAndOffset(candidateReduced, candidateReducedStrides,
-                      candidateReducedOffset);
+  (void)getStridesAndOffset(original, originalStrides, originalOffset);
+  (void)getStridesAndOffset(candidateReduced, candidateReducedStrides,
+                            candidateReducedOffset);
 
   // Filter strides based on the mask and check that they are the same
   // as candidateReduced ones.

diff  --git a/mlir/lib/Dialect/StandardOps/Transforms/DecomposeCallGraphTypes.cpp b/mlir/lib/Dialect/StandardOps/Transforms/DecomposeCallGraphTypes.cpp
index 52c3249df58bb..8d1d6befa66fa 100644
--- a/mlir/lib/Dialect/StandardOps/Transforms/DecomposeCallGraphTypes.cpp
+++ b/mlir/lib/Dialect/StandardOps/Transforms/DecomposeCallGraphTypes.cpp
@@ -69,7 +69,8 @@ struct DecomposeCallGraphTypesForFuncArgs
     TypeConverter::SignatureConversion conversion(functionType.getNumInputs());
     for (auto argType : llvm::enumerate(functionType.getInputs())) {
       SmallVector<Type, 2> decomposedTypes;
-      getTypeConverter()->convertType(argType.value(), decomposedTypes);
+      if (failed(typeConverter->convertType(argType.value(), decomposedTypes)))
+        return failure();
       if (!decomposedTypes.empty())
         conversion.addInputs(argType.index(), decomposedTypes);
     }
@@ -81,7 +82,9 @@ struct DecomposeCallGraphTypesForFuncArgs
 
     // Update the signature of the function.
     SmallVector<Type, 2> newResultTypes;
-    getTypeConverter()->convertTypes(functionType.getResults(), newResultTypes);
+    if (failed(typeConverter->convertTypes(functionType.getResults(),
+                                           newResultTypes)))
+      return failure();
     rewriter.updateRootInPlace(op, [&] {
       op.setType(rewriter.getFunctionType(conversion.getConvertedTypes(),
                                           newResultTypes));
@@ -146,7 +149,8 @@ struct DecomposeCallGraphTypesForCallOp
     SmallVector<SmallVector<unsigned, 2>, 4> expandedResultIndices;
     for (Type resultType : op.getResultTypes()) {
       unsigned oldSize = newResultTypes.size();
-      getTypeConverter()->convertType(resultType, newResultTypes);
+      if (failed(typeConverter->convertType(resultType, newResultTypes)))
+        return failure();
       auto &resultMapping = expandedResultIndices.emplace_back();
       for (unsigned i = oldSize, e = newResultTypes.size(); i < e; i++)
         resultMapping.push_back(i);

diff  --git a/mlir/lib/Dialect/Tosa/Transforms/TosaMakeBroadcastable.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaMakeBroadcastable.cpp
index d9b0b3bd832d1..7d2b8962d04a3 100644
--- a/mlir/lib/Dialect/Tosa/Transforms/TosaMakeBroadcastable.cpp
+++ b/mlir/lib/Dialect/Tosa/Transforms/TosaMakeBroadcastable.cpp
@@ -265,7 +265,7 @@ struct TosaMakeBroadcastable
     patterns.insert<ConvertTosaOp<tosa::LogicalLeftShiftOp>>(ctx);
     patterns.insert<ConvertTosaOp<tosa::ArithmeticRightShiftOp>>(ctx);
     patterns.insert<ConvertTosaOp<tosa::LogicalRightShiftOp>>(ctx);
-    applyPatternsAndFoldGreedily(func, std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(func, std::move(patterns));
   }
 };
 } // end anonymous namespace

diff  --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index d6d81801dc30d..4f4778dcf408a 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -633,10 +633,10 @@ LogicalResult AliasInitializer::generateAlias(
     T symbol, llvm::MapVector<StringRef, std::vector<T>> &aliasToSymbol) {
   SmallString<16> tempBuffer;
   for (const auto &interface : interfaces) {
-    interface.getAlias(symbol, aliasOS);
-    StringRef name = aliasOS.str();
-    if (name.empty())
+    if (failed(interface.getAlias(symbol, aliasOS)))
       continue;
+    StringRef name = aliasOS.str();
+    assert(!name.empty() && "expected valid alias name");
     name = sanitizeIdentifier(name, tempBuffer, /*allowedPunctChars=*/"$_-",
                               /*allowTrailingDigit=*/false);
     name = name.copy(aliasAllocator);

diff  --git a/mlir/lib/IR/BuiltinTypes.cpp b/mlir/lib/IR/BuiltinTypes.cpp
index e7e912aa83183..b61073f699efa 100644
--- a/mlir/lib/IR/BuiltinTypes.cpp
+++ b/mlir/lib/IR/BuiltinTypes.cpp
@@ -445,13 +445,14 @@ MemRefType MemRefType::getImpl(ArrayRef<int64_t> shape, Type elementType,
   auto *context = elementType.getContext();
 
   if (!BaseMemRefType::isValidElementType(elementType))
-    return emitOptionalError(location, "invalid memref element type"),
+    return (void)emitOptionalError(location, "invalid memref element type"),
            MemRefType();
 
   for (int64_t s : shape) {
     // Negative sizes are not allowed except for `-1` that means dynamic size.
     if (s < -1)
-      return emitOptionalError(location, "invalid memref size"), MemRefType();
+      return (void)emitOptionalError(location, "invalid memref size"),
+             MemRefType();
   }
 
   // Check that the structure of the composition is valid, i.e. that each

diff  --git a/mlir/lib/Pass/Pass.cpp b/mlir/lib/Pass/Pass.cpp
index 66c8f66d7c8c8..a78adde2e9410 100644
--- a/mlir/lib/Pass/Pass.cpp
+++ b/mlir/lib/Pass/Pass.cpp
@@ -783,7 +783,7 @@ void RecoveryReproducerContext::crashHandler(void *) {
   // a reproducer for all of them.
   std::string ignored;
   for (RecoveryReproducerContext *context : *reproducerSet)
-    context->generate(ignored);
+    (void)context->generate(ignored);
 }
 
 void RecoveryReproducerContext::registerSignalHandler() {

diff  --git a/mlir/lib/Support/MlirOptMain.cpp b/mlir/lib/Support/MlirOptMain.cpp
index f7d837259f656..85891fd591f72 100644
--- a/mlir/lib/Support/MlirOptMain.cpp
+++ b/mlir/lib/Support/MlirOptMain.cpp
@@ -115,8 +115,8 @@ static LogicalResult processBuffer(raw_ostream &os,
   // Do any processing requested by command line flags.  We don't care whether
   // these actions succeed or fail, we only care what diagnostics they produce
   // and whether they match our expectations.
-  performActions(os, verifyDiagnostics, verifyPasses, sourceMgr, &context,
-                 passPipeline);
+  (void)performActions(os, verifyDiagnostics, verifyPasses, sourceMgr, &context,
+                       passPipeline);
 
   // Verify the diagnostic handler to make sure that each of the diagnostics
   // matched.

diff  --git a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
index 863ab021301f6..0a8a113378599 100644
--- a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
+++ b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
@@ -689,8 +689,8 @@ LogicalResult Importer::processInstruction(llvm::Instruction *inst) {
       ops.push_back(processValue(op.get()));
 
     SmallVector<Value, 4> normalArgs, unwindArgs;
-    processBranchArgs(ii, ii->getNormalDest(), normalArgs);
-    processBranchArgs(ii, ii->getUnwindDest(), unwindArgs);
+    (void)processBranchArgs(ii, ii->getNormalDest(), normalArgs);
+    (void)processBranchArgs(ii, ii->getUnwindDest(), unwindArgs);
 
     Operation *op;
     if (llvm::Function *callee = ii->getCalledFunction()) {

diff  --git a/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp b/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp
index 58f2a7eed5935..df9e27f8e8c47 100644
--- a/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp
+++ b/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp
@@ -286,7 +286,7 @@ LogicalResult spirv::Deserializer::processOpWithoutGrammarAttr(
     valueMap[valueID] = op->getResult(0);
 
   if (op->hasTrait<OpTrait::IsTerminator>())
-    clearDebugLine();
+    (void)clearDebugLine();
 
   return success();
 }

diff  --git a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp
index 3b98c2efbb2a9..8ae92a50cedc5 100644
--- a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp
+++ b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp
@@ -1421,7 +1421,7 @@ LogicalResult spirv::Deserializer::processBranch(ArrayRef<uint32_t> operands) {
   // the same OpLine information.
   opBuilder.create<spirv::BranchOp>(loc, target);
 
-  clearDebugLine();
+  (void)clearDebugLine();
   return success();
 }
 
@@ -1455,7 +1455,7 @@ spirv::Deserializer::processBranchConditional(ArrayRef<uint32_t> operands) {
       /*trueArguments=*/ArrayRef<Value>(), falseBlock,
       /*falseArguments=*/ArrayRef<Value>(), weights);
 
-  clearDebugLine();
+  (void)clearDebugLine();
   return success();
 }
 

diff  --git a/mlir/lib/Target/SPIRV/Serialization/Serialization.cpp b/mlir/lib/Target/SPIRV/Serialization/Serialization.cpp
index c8421293cdceb..e4792a9024b56 100644
--- a/mlir/lib/Target/SPIRV/Serialization/Serialization.cpp
+++ b/mlir/lib/Target/SPIRV/Serialization/Serialization.cpp
@@ -622,8 +622,8 @@ uint32_t Serializer::getOrCreateFunctionID(StringRef fnName) {
 
 void Serializer::processCapability() {
   for (auto cap : module.vce_triple()->getCapabilities())
-    encodeInstructionInto(capabilities, spirv::Opcode::OpCapability,
-                          {static_cast<uint32_t>(cap)});
+    (void)encodeInstructionInto(capabilities, spirv::Opcode::OpCapability,
+                                {static_cast<uint32_t>(cap)});
 }
 
 void Serializer::processDebugInfo() {
@@ -634,8 +634,8 @@ void Serializer::processDebugInfo() {
   fileID = getNextID();
   SmallVector<uint32_t, 16> operands;
   operands.push_back(fileID);
-  spirv::encodeStringLiteralInto(operands, fileName);
-  encodeInstructionInto(debug, spirv::Opcode::OpString, operands);
+  (void)spirv::encodeStringLiteralInto(operands, fileName);
+  (void)encodeInstructionInto(debug, spirv::Opcode::OpString, operands);
   // TODO: Encode more debug instructions.
 }
 
@@ -643,8 +643,10 @@ void Serializer::processExtension() {
   llvm::SmallVector<uint32_t, 16> extName;
   for (spirv::Extension ext : module.vce_triple()->getExtensions()) {
     extName.clear();
-    spirv::encodeStringLiteralInto(extName, spirv::stringifyExtension(ext));
-    encodeInstructionInto(extensions, spirv::Opcode::OpExtension, extName);
+    (void)spirv::encodeStringLiteralInto(extName,
+                                         spirv::stringifyExtension(ext));
+    (void)encodeInstructionInto(extensions, spirv::Opcode::OpExtension,
+                                extName);
   }
 }
 
@@ -652,7 +654,8 @@ void Serializer::processMemoryModel() {
   uint32_t mm = module->getAttrOfType<IntegerAttr>("memory_model").getInt();
   uint32_t am = module->getAttrOfType<IntegerAttr>("addressing_model").getInt();
 
-  encodeInstructionInto(memoryModel, spirv::Opcode::OpMemoryModel, {am, mm});
+  (void)encodeInstructionInto(memoryModel, spirv::Opcode::OpMemoryModel,
+                              {am, mm});
 }
 
 LogicalResult Serializer::processConstantOp(spirv::ConstantOp op) {
@@ -669,7 +672,7 @@ LogicalResult Serializer::processSpecConstantOp(spirv::SpecConstantOp op) {
     // Emit the OpDecorate instruction for SpecId.
     if (auto specID = op->getAttrOfType<IntegerAttr>("spec_id")) {
       auto val = static_cast<uint32_t>(specID.getInt());
-      emitDecoration(resultID, spirv::Decoration::SpecId, {val});
+      (void)emitDecoration(resultID, spirv::Decoration::SpecId, {val});
     }
 
     specConstIDMap[op.sym_name()] = resultID;
@@ -707,8 +710,8 @@ Serializer::processSpecConstantCompositeOp(spirv::SpecConstantCompositeOp op) {
     operands.push_back(constituentID);
   }
 
-  encodeInstructionInto(typesGlobalValues,
-                        spirv::Opcode::OpSpecConstantComposite, operands);
+  (void)encodeInstructionInto(typesGlobalValues,
+                              spirv::Opcode::OpSpecConstantComposite, operands);
   specConstIDMap[op.sym_name()] = resultID;
 
   return processName(resultID, op.sym_name());
@@ -750,8 +753,8 @@ Serializer::processSpecConstantOperationOp(spirv::SpecConstantOperationOp op) {
     operands.push_back(id);
   }
 
-  encodeInstructionInto(typesGlobalValues, spirv::Opcode::OpSpecConstantOp,
-                        operands);
+  (void)encodeInstructionInto(typesGlobalValues,
+                              spirv::Opcode::OpSpecConstantOp, operands);
   valueIDMap[op.getResult()] = resultID;
 
   return success();
@@ -873,7 +876,7 @@ LogicalResult Serializer::processFuncOp(spirv::FuncOp op) {
 
   uint32_t fnTypeID = 0;
   // Generate type of the function.
-  processType(op.getLoc(), op.getType(), fnTypeID);
+  (void)processType(op.getLoc(), op.getType(), fnTypeID);
 
   // Add the function definition.
   SmallVector<uint32_t, 4> operands;
@@ -892,7 +895,8 @@ LogicalResult Serializer::processFuncOp(spirv::FuncOp op) {
   operands.push_back(funcID);
   operands.push_back(static_cast<uint32_t>(op.function_control()));
   operands.push_back(fnTypeID);
-  encodeInstructionInto(functionHeader, spirv::Opcode::OpFunction, operands);
+  (void)encodeInstructionInto(functionHeader, spirv::Opcode::OpFunction,
+                              operands);
 
   // Add function name.
   if (failed(processName(funcID, op.getName()))) {
@@ -907,8 +911,9 @@ LogicalResult Serializer::processFuncOp(spirv::FuncOp op) {
     }
     auto argValueID = getNextID();
     valueIDMap[arg] = argValueID;
-    encodeInstructionInto(functionHeader, spirv::Opcode::OpFunctionParameter,
-                          {argTypeID, argValueID});
+    (void)encodeInstructionInto(functionHeader,
+                                spirv::Opcode::OpFunctionParameter,
+                                {argTypeID, argValueID});
   }
 
   // Process the body.
@@ -920,9 +925,9 @@ LogicalResult Serializer::processFuncOp(spirv::FuncOp op) {
   // block in the function. These instructions will be put in functionHeader.
   // Thus, we put the label in functionHeader first, and omit it from the first
   // block.
-  encodeInstructionInto(functionHeader, spirv::Opcode::OpLabel,
-                        {getOrCreateBlockID(&op.front())});
-  processBlock(&op.front(), /*omitLabel=*/true);
+  (void)encodeInstructionInto(functionHeader, spirv::Opcode::OpLabel,
+                              {getOrCreateBlockID(&op.front())});
+  (void)processBlock(&op.front(), /*omitLabel=*/true);
   if (failed(visitInPrettyBlockOrder(
           &op.front(), [&](Block *block) { return processBlock(block); },
           /*skipHeader=*/true))) {
@@ -982,8 +987,9 @@ LogicalResult Serializer::processVariableOp(spirv::VariableOp op) {
     }
     operands.push_back(argID);
   }
-  emitDebugLine(functionHeader, op.getLoc());
-  encodeInstructionInto(functionHeader, spirv::Opcode::OpVariable, operands);
+  (void)emitDebugLine(functionHeader, op.getLoc());
+  (void)encodeInstructionInto(functionHeader, spirv::Opcode::OpVariable,
+                              operands);
   for (auto attr : op->getAttrs()) {
     if (llvm::any_of(elidedAttrs,
                      [&](StringRef elided) { return attr.first == elided; })) {
@@ -1045,7 +1051,7 @@ Serializer::processGlobalVariableOp(spirv::GlobalVariableOp varOp) {
     elidedAttrs.push_back("initializer");
   }
 
-  emitDebugLine(typesGlobalValues, varOp.getLoc());
+  (void)emitDebugLine(typesGlobalValues, varOp.getLoc());
   if (failed(encodeInstructionInto(typesGlobalValues, spirv::Opcode::OpVariable,
                                    operands))) {
     elidedAttrs.push_back("initializer");
@@ -1239,9 +1245,9 @@ LogicalResult Serializer::prepareBasicType(
       forwardPtrOperands.push_back(
           static_cast<uint32_t>(ptrType.getStorageClass()));
 
-      encodeInstructionInto(typesGlobalValues,
-                            spirv::Opcode::OpTypeForwardPointer,
-                            forwardPtrOperands);
+      (void)encodeInstructionInto(typesGlobalValues,
+                                  spirv::Opcode::OpTypeForwardPointer,
+                                  forwardPtrOperands);
 
       // 2. Find the pointee (enclosing) struct.
       auto structType = spirv::StructType::getIdentified(
@@ -1283,7 +1289,7 @@ LogicalResult Serializer::prepareBasicType(
 
   if (auto structType = type.dyn_cast<spirv::StructType>()) {
     if (structType.isIdentified()) {
-      processName(resultID, structType.getIdentifier());
+      (void)processName(resultID, structType.getIdentifier());
       serializationCtx.insert(structType.getIdentifier());
     }
 
@@ -1448,7 +1454,7 @@ uint32_t Serializer::prepareArrayConstant(Location loc, Type constType,
     }
   }
   spirv::Opcode opcode = spirv::Opcode::OpConstantComposite;
-  encodeInstructionInto(typesGlobalValues, opcode, operands);
+  (void)encodeInstructionInto(typesGlobalValues, opcode, operands);
 
   return resultID;
 }
@@ -1492,7 +1498,7 @@ Serializer::prepareDenseElementsConstant(Location loc, Type constType,
     }
   }
   spirv::Opcode opcode = spirv::Opcode::OpConstantComposite;
-  encodeInstructionInto(typesGlobalValues, opcode, operands);
+  (void)encodeInstructionInto(typesGlobalValues, opcode, operands);
 
   return resultID;
 }
@@ -1533,7 +1539,7 @@ uint32_t Serializer::prepareConstantBool(Location loc, BoolAttr boolAttr,
                               : spirv::Opcode::OpConstantTrue)
                     : (isSpec ? spirv::Opcode::OpSpecConstantFalse
                               : spirv::Opcode::OpConstantFalse);
-  encodeInstructionInto(typesGlobalValues, opcode, {typeID, resultID});
+  (void)encodeInstructionInto(typesGlobalValues, opcode, {typeID, resultID});
 
   if (!isSpec) {
     constIDMap[boolAttr] = resultID;
@@ -1575,7 +1581,8 @@ uint32_t Serializer::prepareConstantInt(Location loc, IntegerAttr intAttr,
     } else {
       word = static_cast<uint32_t>(value.getZExtValue());
     }
-    encodeInstructionInto(typesGlobalValues, opcode, {typeID, resultID, word});
+    (void)encodeInstructionInto(typesGlobalValues, opcode,
+                                {typeID, resultID, word});
   }
   // According to SPIR-V spec: "When the type's bit width is larger than one
   // word, the literal’s low-order words appear first."
@@ -1589,8 +1596,8 @@ uint32_t Serializer::prepareConstantInt(Location loc, IntegerAttr intAttr,
     } else {
       words = llvm::bit_cast<DoubleWord>(value.getZExtValue());
     }
-    encodeInstructionInto(typesGlobalValues, opcode,
-                          {typeID, resultID, words.word1, words.word2});
+    (void)encodeInstructionInto(typesGlobalValues, opcode,
+                                {typeID, resultID, words.word1, words.word2});
   } else {
     std::string valueStr;
     llvm::raw_string_ostream rss(valueStr);
@@ -1631,18 +1638,20 @@ uint32_t Serializer::prepareConstantFp(Location loc, FloatAttr floatAttr,
 
   if (&value.getSemantics() == &APFloat::IEEEsingle()) {
     uint32_t word = llvm::bit_cast<uint32_t>(value.convertToFloat());
-    encodeInstructionInto(typesGlobalValues, opcode, {typeID, resultID, word});
+    (void)encodeInstructionInto(typesGlobalValues, opcode,
+                                {typeID, resultID, word});
   } else if (&value.getSemantics() == &APFloat::IEEEdouble()) {
     struct DoubleWord {
       uint32_t word1;
       uint32_t word2;
     } words = llvm::bit_cast<DoubleWord>(value.convertToDouble());
-    encodeInstructionInto(typesGlobalValues, opcode,
-                          {typeID, resultID, words.word1, words.word2});
+    (void)encodeInstructionInto(typesGlobalValues, opcode,
+                                {typeID, resultID, words.word1, words.word2});
   } else if (&value.getSemantics() == &APFloat::IEEEhalf()) {
     uint32_t word =
         static_cast<uint32_t>(value.bitcastToAPInt().getZExtValue());
-    encodeInstructionInto(typesGlobalValues, opcode, {typeID, resultID, word});
+    (void)encodeInstructionInto(typesGlobalValues, opcode,
+                                {typeID, resultID, word});
   } else {
     std::string valueStr;
     llvm::raw_string_ostream rss(valueStr);
@@ -1681,7 +1690,8 @@ Serializer::processBlock(Block *block, bool omitLabel,
                << "[block] " << block << " (id = " << blockID << ")\n");
 
     // Emit OpLabel for this block.
-    encodeInstructionInto(functionBody, spirv::Opcode::OpLabel, {blockID});
+    (void)encodeInstructionInto(functionBody, spirv::Opcode::OpLabel,
+                                {blockID});
   }
 
   // Emit OpPhi instructions for block arguments, if any.
@@ -1771,7 +1781,7 @@ LogicalResult Serializer::emitPhiForBlockArguments(Block *block) {
       phiArgs.push_back(predBlockId);
     }
 
-    encodeInstructionInto(functionBody, spirv::Opcode::OpPhi, phiArgs);
+    (void)encodeInstructionInto(functionBody, spirv::Opcode::OpPhi, phiArgs);
     valueIDMap[arg] = phiID;
   }
 
@@ -1794,9 +1804,9 @@ LogicalResult Serializer::processSelectionOp(spirv::SelectionOp selectionOp) {
   // We need to emit an OpSelectionMerge instruction before the selection header
   // block's terminator.
   auto emitSelectionMerge = [&]() {
-    emitDebugLine(functionBody, loc);
+    (void)emitDebugLine(functionBody, loc);
     lastProcessedWasMergeInst = true;
-    encodeInstructionInto(
+    (void)encodeInstructionInto(
         functionBody, spirv::Opcode::OpSelectionMerge,
         {mergeID, static_cast<uint32_t>(selectionOp.selection_control())});
   };
@@ -1846,7 +1856,8 @@ LogicalResult Serializer::processLoopOp(spirv::LoopOp loopOp) {
   // preceding and following ops. So we need to emit unconditional branches to
   // jump to this LoopOp's SPIR-V blocks and jumping back to the normal flow
   // afterwards.
-  encodeInstructionInto(functionBody, spirv::Opcode::OpBranch, {headerID});
+  (void)encodeInstructionInto(functionBody, spirv::Opcode::OpBranch,
+                              {headerID});
 
   // LoopOp's entry block is just there for satisfying MLIR's structural
   // requirements so we omit it and start serialization from the loop header
@@ -1856,9 +1867,9 @@ LogicalResult Serializer::processLoopOp(spirv::LoopOp loopOp) {
   // need to emit an OpLoopMerge instruction before the loop header block's
   // terminator.
   auto emitLoopMerge = [&]() {
-    emitDebugLine(functionBody, loc);
+    (void)emitDebugLine(functionBody, loc);
     lastProcessedWasMergeInst = true;
-    encodeInstructionInto(
+    (void)encodeInstructionInto(
         functionBody, spirv::Opcode::OpLoopMerge,
         {mergeID, continueID, static_cast<uint32_t>(loopOp.loop_control())});
   };
@@ -1896,13 +1907,13 @@ LogicalResult Serializer::processBranchConditionalOp(
       arguments.push_back(val.cast<IntegerAttr>().getInt());
   }
 
-  emitDebugLine(functionBody, condBranchOp.getLoc());
+  (void)emitDebugLine(functionBody, condBranchOp.getLoc());
   return encodeInstructionInto(functionBody, spirv::Opcode::OpBranchConditional,
                                arguments);
 }
 
 LogicalResult Serializer::processBranchOp(spirv::BranchOp branchOp) {
-  emitDebugLine(functionBody, branchOp.getLoc());
+  (void)emitDebugLine(functionBody, branchOp.getLoc());
   return encodeInstructionInto(functionBody, spirv::Opcode::OpBranch,
                                {getOrCreateBlockID(branchOp.getTarget())});
 }
@@ -2024,13 +2035,13 @@ LogicalResult Serializer::processOpWithoutGrammarAttr(Operation *op,
   for (Value operand : op->getOperands())
     operands.push_back(getValueID(operand));
 
-  emitDebugLine(functionBody, loc);
+  (void)emitDebugLine(functionBody, loc);
 
   if (extInstSet.empty()) {
-    encodeInstructionInto(functionBody, static_cast<spirv::Opcode>(opcode),
-                          operands);
+    (void)encodeInstructionInto(functionBody,
+                                static_cast<spirv::Opcode>(opcode), operands);
   } else {
-    encodeExtensionInstruction(op, extInstSet, opcode, operands);
+    (void)encodeExtensionInstruction(op, extInstSet, opcode, operands);
   }
 
   if (op->getNumResults() != 0) {
@@ -2060,7 +2071,7 @@ Serializer::processOp<spirv::EntryPointOp>(spirv::EntryPointOp op) {
   }
   operands.push_back(funcID);
   // Add the name of the function.
-  spirv::encodeStringLiteralInto(operands, op.fn());
+  (void)spirv::encodeStringLiteralInto(operands, op.fn());
 
   // Add the interface values.
   if (auto interface = op.interface()) {
@@ -2211,8 +2222,9 @@ Serializer::processOp<spirv::CopyMemoryOp>(spirv::CopyMemoryOp op) {
   }
 
   elidedAttrs.push_back("source_alignment");
-  emitDebugLine(functionBody, op.getLoc());
-  encodeInstructionInto(functionBody, spirv::Opcode::OpCopyMemory, operands);
+  (void)emitDebugLine(functionBody, op.getLoc());
+  (void)encodeInstructionInto(functionBody, spirv::Opcode::OpCopyMemory,
+                              operands);
 
   return success();
 }
@@ -2247,8 +2259,9 @@ LogicalResult Serializer::emitDebugLine(SmallVectorImpl<uint32_t> &binary,
 
   auto fileLoc = loc.dyn_cast<FileLineColLoc>();
   if (fileLoc)
-    encodeInstructionInto(binary, spirv::Opcode::OpLine,
-                          {fileID, fileLoc.getLine(), fileLoc.getColumn()});
+    (void)encodeInstructionInto(
+        binary, spirv::Opcode::OpLine,
+        {fileID, fileLoc.getLine(), fileLoc.getColumn()});
   return success();
 }
 

diff  --git a/mlir/lib/Transforms/Canonicalizer.cpp b/mlir/lib/Transforms/Canonicalizer.cpp
index 81dfa9b74c5d0..cf0b21735362c 100644
--- a/mlir/lib/Transforms/Canonicalizer.cpp
+++ b/mlir/lib/Transforms/Canonicalizer.cpp
@@ -30,7 +30,7 @@ struct Canonicalizer : public CanonicalizerBase<Canonicalizer> {
     patterns = std::move(owningPatterns);
   }
   void runOnOperation() override {
-    applyPatternsAndFoldGreedily(getOperation()->getRegions(), patterns);
+    (void)applyPatternsAndFoldGreedily(getOperation()->getRegions(), patterns);
   }
 
   FrozenRewritePatternList patterns;

diff  --git a/mlir/lib/Transforms/Inliner.cpp b/mlir/lib/Transforms/Inliner.cpp
index 42ab8f0ce4df4..4beb7e7360a5c 100644
--- a/mlir/lib/Transforms/Inliner.cpp
+++ b/mlir/lib/Transforms/Inliner.cpp
@@ -755,7 +755,7 @@ LogicalResult InlinerPass::initializeOptions(StringRef options) {
   if (!defaultPipelineStr.empty()) {
     std::string defaultPipelineCopy = defaultPipelineStr;
     defaultPipeline = [=](OpPassManager &pm) {
-      parsePassPipeline(defaultPipelineCopy, pm);
+      (void)parsePassPipeline(defaultPipelineCopy, pm);
     };
   } else if (defaultPipelineStr.getNumOccurrences()) {
     defaultPipeline = nullptr;

diff  --git a/mlir/lib/Transforms/NormalizeMemRefs.cpp b/mlir/lib/Transforms/NormalizeMemRefs.cpp
index e9bc92f0dd354..110e30234af22 100644
--- a/mlir/lib/Transforms/NormalizeMemRefs.cpp
+++ b/mlir/lib/Transforms/NormalizeMemRefs.cpp
@@ -329,7 +329,7 @@ void NormalizeMemRefs::normalizeFuncOpMemRefs(FuncOp funcOp,
   SmallVector<AllocOp, 4> allocOps;
   funcOp.walk([&](AllocOp op) { allocOps.push_back(op); });
   for (AllocOp allocOp : allocOps)
-    normalizeMemRef(allocOp);
+    (void)normalizeMemRef(allocOp);
 
   // We use this OpBuilder to create new memref layout later.
   OpBuilder b(funcOp);

diff  --git a/mlir/lib/Transforms/SCCP.cpp b/mlir/lib/Transforms/SCCP.cpp
index 266a3c67f1cdd..ec550d9d7dd29 100644
--- a/mlir/lib/Transforms/SCCP.cpp
+++ b/mlir/lib/Transforms/SCCP.cpp
@@ -358,7 +358,7 @@ void SCCPSolver::rewrite(MLIRContext *context,
     // Replace any block arguments with constants.
     builder.setInsertionPointToStart(block);
     for (BlockArgument arg : block->getArguments())
-      replaceWithConstant(builder, folder, arg);
+      (void)replaceWithConstant(builder, folder, arg);
 
     for (Operation &op : llvm::make_early_inc_range(*block)) {
       builder.setInsertionPoint(&op);

diff  --git a/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp b/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp
index 9749a8de23516..61dad71c20d8b 100644
--- a/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp
+++ b/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp
@@ -388,7 +388,7 @@ void mlir::fuseLoops(AffineForOp srcForOp, AffineForOp dstForOp,
 
   // Promote any single iteration slice loops.
   for (AffineForOp forOp : sliceLoops)
-    promoteIfSingleIteration(forOp);
+    (void)promoteIfSingleIteration(forOp);
 }
 
 /// Collect loop nest statistics (eg. loop trip count and operation count)

diff  --git a/mlir/lib/Transforms/Utils/LoopUtils.cpp b/mlir/lib/Transforms/Utils/LoopUtils.cpp
index fd868bf9937c5..e73d60897abb7 100644
--- a/mlir/lib/Transforms/Utils/LoopUtils.cpp
+++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp
@@ -234,9 +234,9 @@ void mlir::promoteSingleIterationLoops(FuncOp f) {
   // Gathers all innermost loops through a post order pruned walk.
   f.walk([](Operation *op) {
     if (auto forOp = dyn_cast<AffineForOp>(op))
-      promoteIfSingleIteration(forOp);
+      (void)promoteIfSingleIteration(forOp);
     else if (auto forOp = dyn_cast<scf::ForOp>(op))
-      promoteIfSingleIteration(forOp);
+      (void)promoteIfSingleIteration(forOp);
   });
 }
 
@@ -392,7 +392,7 @@ LogicalResult mlir::affineForOpBodySkew(AffineForOp forOp,
         OwningRewritePatternList patterns;
         AffineForOp::getCanonicalizationPatterns(patterns, res.getContext());
         bool erased;
-        applyOpPatternsAndFold(res, std::move(patterns), &erased);
+        (void)applyOpPatternsAndFold(res, std::move(patterns), &erased);
 
         if (!erased && !prologue)
           prologue = res;
@@ -423,9 +423,9 @@ LogicalResult mlir::affineForOpBodySkew(AffineForOp forOp,
   forOp.erase();
 
   if (unrollPrologueEpilogue && prologue)
-    loopUnrollFull(prologue);
+    (void)loopUnrollFull(prologue);
   if (unrollPrologueEpilogue && !epilogue && epilogue != prologue)
-    loopUnrollFull(epilogue);
+    (void)loopUnrollFull(epilogue);
 
   return success();
 }
@@ -585,7 +585,7 @@ LogicalResult checkIfHyperRectangular(MutableArrayRef<AffineForOp> input,
                                       unsigned width) {
   FlatAffineConstraints cst;
   SmallVector<Operation *, 8> ops(input.begin(), input.end());
-  getIndexSet(ops, &cst);
+  (void)getIndexSet(ops, &cst);
   if (!cst.isHyperRectangular(0, width)) {
     rootAffineForOp.emitError("tiled code generation unimplemented for the "
                               "non-hyperrectangular case");
@@ -1135,7 +1135,7 @@ LogicalResult mlir::loopUnrollByFactor(AffineForOp forOp,
            "can always be determined");
     cleanupForOp.setLowerBound(cleanupOperands, cleanupMap);
     // Promote the loop body up if this has turned into a single iteration loop.
-    promoteIfSingleIteration(cleanupForOp);
+    (void)promoteIfSingleIteration(cleanupForOp);
 
     // Adjust upper bound of the original loop; this is the same as the lower
     // bound of the cleanup loop.
@@ -1156,7 +1156,7 @@ LogicalResult mlir::loopUnrollByFactor(AffineForOp forOp,
                        /*iterArgs=*/{}, /*yieldedValues=*/{});
 
   // Promote the loop body up if this has turned into a single iteration loop.
-  promoteIfSingleIteration(forOp);
+  (void)promoteIfSingleIteration(forOp);
   return success();
 }
 
@@ -1248,7 +1248,7 @@ LogicalResult mlir::loopUnrollByFactor(scf::ForOp forOp,
       std::get<0>(e).replaceAllUsesWith(std::get<1>(e));
       epilogueForOp->replaceUsesOfWith(std::get<2>(e), std::get<0>(e));
     }
-    promoteIfSingleIteration(epilogueForOp);
+    (void)promoteIfSingleIteration(epilogueForOp);
   }
 
   // Create unrolled loop.
@@ -1268,7 +1268,7 @@ LogicalResult mlir::loopUnrollByFactor(scf::ForOp forOp,
       },
       iterArgs, yieldedValues);
   // Promote the loop body up if this has turned into a single iteration loop.
-  promoteIfSingleIteration(forOp);
+  (void)promoteIfSingleIteration(forOp);
   return success();
 }
 
@@ -1358,7 +1358,7 @@ LogicalResult mlir::loopUnrollJamByFactor(AffineForOp forOp,
     cleanupAffineForOp.setLowerBound(cleanupOperands, cleanupMap);
 
     // Promote the cleanup loop if it has turned into a single iteration loop.
-    promoteIfSingleIteration(cleanupAffineForOp);
+    (void)promoteIfSingleIteration(cleanupAffineForOp);
 
     // Adjust the upper bound of the original loop - it will be the same as the
     // cleanup loop's lower bound. Its lower bound remains unchanged.
@@ -1396,7 +1396,7 @@ LogicalResult mlir::loopUnrollJamByFactor(AffineForOp forOp,
   }
 
   // Promote the loop body up if this has turned into a single iteration loop.
-  promoteIfSingleIteration(forOp);
+  (void)promoteIfSingleIteration(forOp);
   return success();
 }
 
@@ -1897,7 +1897,7 @@ TileLoops mlir::extractFixedOuterLoops(scf::ForOp rootForOp,
   // TODO: for now we just ignore the result of band isolation.
   // In the future, mapping decisions may be impacted by the ability to
   // isolate perfectly nested bands.
-  tryIsolateBands(tileLoops);
+  (void)tryIsolateBands(tileLoops);
 
   return tileLoops;
 }
@@ -2583,12 +2583,12 @@ static LogicalResult generateCopy(
     prevOfBegin = std::prev(begin);
 
   // *Only* those uses within the range [begin, end) of 'block' are replaced.
-  replaceAllMemRefUsesWith(memref, fastMemRef,
-                           /*extraIndices=*/{}, indexRemap,
-                           /*extraOperands=*/regionSymbols,
-                           /*symbolOperands=*/{},
-                           /*domInstFilter=*/&*begin,
-                           /*postDomInstFilter=*/&*postDomFilter);
+  (void)replaceAllMemRefUsesWith(memref, fastMemRef,
+                                 /*extraIndices=*/{}, indexRemap,
+                                 /*extraOperands=*/regionSymbols,
+                                 /*symbolOperands=*/{},
+                                 /*domInstFilter=*/&*begin,
+                                 /*postDomInstFilter=*/&*postDomFilter);
 
   *nBegin = isBeginAtStartOfBlock ? block->begin() : std::next(prevOfBegin);
 
@@ -2941,7 +2941,7 @@ static AffineIfOp createSeparationCondition(MutableArrayRef<AffineForOp> loops,
   ops.reserve(loops.size());
   for (AffineForOp forOp : loops)
     ops.push_back(forOp);
-  getIndexSet(ops, &cst);
+  (void)getIndexSet(ops, &cst);
 
   // Remove constraints that are independent of these loop IVs.
   cst.removeIndependentConstraints(/*pos=*/0, /*num=*/loops.size());
@@ -3026,7 +3026,7 @@ createFullTiles(MutableArrayRef<AffineForOp> inputNest,
       return failure();
     }
     SmallVector<Operation *, 1> loopOp{loop.getOperation()};
-    getIndexSet(loopOp, &cst);
+    (void)getIndexSet(loopOp, &cst);
     // We will mark everything other than this loop IV as symbol for getting a
     // pair of <lb, ub> with a constant 
diff erence.
     cst.setDimSymbolSeparation(cst.getNumDimAndSymbolIds() - 1);

diff  --git a/mlir/lib/Translation/Translation.cpp b/mlir/lib/Translation/Translation.cpp
index 3c17ea2370857..a797c5aa60606 100644
--- a/mlir/lib/Translation/Translation.cpp
+++ b/mlir/lib/Translation/Translation.cpp
@@ -189,7 +189,7 @@ LogicalResult mlir::mlirTranslateMain(int argc, char **argv,
     // failed (in most cases, it is expected to fail). Instead, we check if the
     // diagnostics were produced as expected.
     SourceMgrDiagnosticVerifierHandler sourceMgrHandler(sourceMgr, &context);
-    (*translationRequested)(sourceMgr, os, &context);
+    (void)(*translationRequested)(sourceMgr, os, &context);
     return sourceMgrHandler.verify();
   };
 

diff  --git a/mlir/test/lib/Dialect/Affine/TestAffineDataCopy.cpp b/mlir/test/lib/Dialect/Affine/TestAffineDataCopy.cpp
index 03433f19f8d66..d05d61fdf1648 100644
--- a/mlir/test/lib/Dialect/Affine/TestAffineDataCopy.cpp
+++ b/mlir/test/lib/Dialect/Affine/TestAffineDataCopy.cpp
@@ -84,8 +84,8 @@ void TestAffineDataCopy::runOnFunction() {
   } else if (clTestGenerateCopyForMemRegion) {
     CopyGenerateResult result;
     MemRefRegion region(loopNest.getLoc());
-    region.compute(load, /*loopDepth=*/0);
-    generateCopyForMemRegion(region, loopNest, copyOptions, result);
+    (void)region.compute(load, /*loopDepth=*/0);
+    (void)generateCopyForMemRegion(region, loopNest, copyOptions, result);
   }
 
   // Promote any single iteration loops in the copy nests and simplify
@@ -96,7 +96,7 @@ void TestAffineDataCopy::runOnFunction() {
     // continuation of the walk or the collection of load/store ops.
     nest->walk([&](Operation *op) {
       if (auto forOp = dyn_cast<AffineForOp>(op))
-        promoteIfSingleIteration(forOp);
+        (void)promoteIfSingleIteration(forOp);
       else if (auto loadOp = dyn_cast<AffineLoadOp>(op))
         copyOps.push_back(loadOp);
       else if (auto storeOp = dyn_cast<AffineStoreOp>(op))
@@ -115,7 +115,7 @@ void TestAffineDataCopy::runOnFunction() {
       assert(isa<AffineStoreOp>(op) && "expected affine store op");
       AffineStoreOp::getCanonicalizationPatterns(patterns, &getContext());
     }
-    applyOpPatternsAndFold(op, std::move(patterns));
+    (void)applyOpPatternsAndFold(op, std::move(patterns));
   }
 }
 

diff  --git a/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp b/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp
index 006c68bb408ae..351ade4220e35 100644
--- a/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp
+++ b/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp
@@ -231,7 +231,7 @@ void VectorizerTestPass::testVecAffineLoopNest() {
   strategy.loopToVectorDim[outermostLoop] = 0;
   std::vector<SmallVector<AffineForOp, 2>> loopsToVectorize;
   loopsToVectorize.push_back({outermostLoop});
-  vectorizeAffineLoopNest(loopsToVectorize, strategy);
+  (void)vectorizeAffineLoopNest(loopsToVectorize, strategy);
 }
 
 void VectorizerTestPass::runOnFunction() {

diff  --git a/mlir/test/lib/Dialect/SPIRV/TestGLSLCanonicalization.cpp b/mlir/test/lib/Dialect/SPIRV/TestGLSLCanonicalization.cpp
index 158601fbc17ab..d80f912f070c5 100644
--- a/mlir/test/lib/Dialect/SPIRV/TestGLSLCanonicalization.cpp
+++ b/mlir/test/lib/Dialect/SPIRV/TestGLSLCanonicalization.cpp
@@ -27,7 +27,7 @@ class TestGLSLCanonicalizationPass
 void TestGLSLCanonicalizationPass::runOnOperation() {
   OwningRewritePatternList patterns;
   spirv::populateSPIRVGLSLCanonicalizationPatterns(patterns, &getContext());
-  applyPatternsAndFoldGreedily(getOperation(), std::move(patterns));
+  (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns));
 }
 
 namespace mlir {

diff  --git a/mlir/test/lib/Dialect/Test/TestPatterns.cpp b/mlir/test/lib/Dialect/Test/TestPatterns.cpp
index fe14b9698832f..740d3712df656 100644
--- a/mlir/test/lib/Dialect/Test/TestPatterns.cpp
+++ b/mlir/test/lib/Dialect/Test/TestPatterns.cpp
@@ -84,7 +84,7 @@ struct TestPatternDriver : public PassWrapper<TestPatternDriver, FunctionPass> {
     // Verify named pattern is generated with expected name.
     patterns.insert<FoldingPattern, TestNamedPatternRule>(&getContext());
 
-    applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
   }
 };
 } // end anonymous namespace
@@ -1033,8 +1033,8 @@ struct TestSelectiveReplacementPatternDriver
     mlir::OwningRewritePatternList patterns;
     MLIRContext *context = &getContext();
     patterns.insert<TestSelectiveOpReplacementPattern>(context);
-    applyPatternsAndFoldGreedily(getOperation()->getRegions(),
-                                 std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(getOperation()->getRegions(),
+                                       std::move(patterns));
   }
 };
 } // namespace

diff  --git a/mlir/test/lib/Dialect/Test/TestTraits.cpp b/mlir/test/lib/Dialect/Test/TestTraits.cpp
index d398c44c6bc1f..87bd782f0f6f6 100644
--- a/mlir/test/lib/Dialect/Test/TestTraits.cpp
+++ b/mlir/test/lib/Dialect/Test/TestTraits.cpp
@@ -33,7 +33,8 @@ OpFoldResult TestInvolutionTraitSuccesfulOperationFolderOp::fold(
 namespace {
 struct TestTraitFolder : public PassWrapper<TestTraitFolder, FunctionPass> {
   void runOnFunction() override {
-    applyPatternsAndFoldGreedily(getFunction(), OwningRewritePatternList());
+    (void)applyPatternsAndFoldGreedily(getFunction(),
+                                       OwningRewritePatternList());
   }
 };
 } // end anonymous namespace

diff  --git a/mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp b/mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp
index 3e8c4bdc6865f..416bbca45c07d 100644
--- a/mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp
+++ b/mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp
@@ -189,7 +189,7 @@ void TosaTestQuantUtilAPI::runOnFunction() {
 
   patterns.insert<ConvertTosaNegateOp>(ctx);
   patterns.insert<ConvertTosaConv2DOp>(ctx);
-  applyPatternsAndFoldGreedily(func, std::move(patterns));
+  (void)applyPatternsAndFoldGreedily(func, std::move(patterns));
 }
 
 } // anonymous namespace

diff  --git a/mlir/test/lib/IR/TestSlicing.cpp b/mlir/test/lib/IR/TestSlicing.cpp
index ccf1961a5793c..12a8934c70832 100644
--- a/mlir/test/lib/IR/TestSlicing.cpp
+++ b/mlir/test/lib/IR/TestSlicing.cpp
@@ -65,7 +65,7 @@ void SliceAnalysisTestPass::runOnOperation() {
         return WalkResult::advance();
       std::string append =
           std::string("__backward_slice__") + std::to_string(opNum);
-      createBackwardSliceFunction(op, append);
+      (void)createBackwardSliceFunction(op, append);
       opNum++;
       return WalkResult::advance();
     });

diff  --git a/mlir/test/lib/Transforms/TestConvVectorization.cpp b/mlir/test/lib/Transforms/TestConvVectorization.cpp
index 51c2807394d8b..3b07465aadb84 100644
--- a/mlir/test/lib/Transforms/TestConvVectorization.cpp
+++ b/mlir/test/lib/Transforms/TestConvVectorization.cpp
@@ -80,8 +80,9 @@ void TestConvVectorization::runOnOperation() {
     return success();
   };
 
-  linalg::applyStagedPatterns(module, frozenStage1Patterns,
-                              std::move(stage2Patterns), stage3Transforms);
+  (void)linalg::applyStagedPatterns(module, frozenStage1Patterns,
+                                    std::move(stage2Patterns),
+                                    stage3Transforms);
 
   //===--------------------------------------------------------------------===//
   // Post staged patterns transforms
@@ -96,7 +97,7 @@ void TestConvVectorization::runOnOperation() {
   // VectorTransforms.cpp
   vectorTransferPatterns.insert<VectorTransferFullPartialRewriter>(
       context, vectorTransformsOptions);
-  applyPatternsAndFoldGreedily(module, std::move(vectorTransferPatterns));
+  (void)applyPatternsAndFoldGreedily(module, std::move(vectorTransferPatterns));
 
   // Programmatic controlled lowering of linalg.copy and linalg.fill.
   PassManager pm(context);
@@ -108,14 +109,14 @@ void TestConvVectorization::runOnOperation() {
   OwningRewritePatternList vectorContractLoweringPatterns;
   populateVectorContractLoweringPatterns(vectorContractLoweringPatterns,
                                          context, vectorTransformsOptions);
-  applyPatternsAndFoldGreedily(module,
-                               std::move(vectorContractLoweringPatterns));
+  (void)applyPatternsAndFoldGreedily(module,
+                                     std::move(vectorContractLoweringPatterns));
 
   // Programmatic controlled lowering of vector.transfer only.
   OwningRewritePatternList vectorToLoopsPatterns;
   populateVectorToSCFConversionPatterns(vectorToLoopsPatterns, context,
                                         VectorTransferToSCFOptions());
-  applyPatternsAndFoldGreedily(module, std::move(vectorToLoopsPatterns));
+  (void)applyPatternsAndFoldGreedily(module, std::move(vectorToLoopsPatterns));
 
   // Ensure we drop the marker in the end.
   module.walk([](linalg::LinalgOp op) {

diff  --git a/mlir/test/lib/Transforms/TestDynamicPipeline.cpp b/mlir/test/lib/Transforms/TestDynamicPipeline.cpp
index a6a83dd9b3694..d1295c96d51bd 100644
--- a/mlir/test/lib/Transforms/TestDynamicPipeline.cpp
+++ b/mlir/test/lib/Transforms/TestDynamicPipeline.cpp
@@ -27,7 +27,7 @@ class TestDynamicPipelinePass
   void getDependentDialects(DialectRegistry &registry) const override {
     OpPassManager pm(ModuleOp::getOperationName(),
                      OpPassManager::Nesting::Implicit);
-    parsePassPipeline(pipeline, pm, llvm::errs());
+    (void)parsePassPipeline(pipeline, pm, llvm::errs());
     pm.getDependentDialects(registry);
   }
 
@@ -58,7 +58,7 @@ class TestDynamicPipelinePass
     if (!pm) {
       pm = std::make_unique<OpPassManager>(currentOp->getName().getIdentifier(),
                                            OpPassManager::Nesting::Implicit);
-      parsePassPipeline(pipeline, *pm, llvm::errs());
+      (void)parsePassPipeline(pipeline, *pm, llvm::errs());
     }
 
     // Check that running on the parent operation always immediately fails.

diff  --git a/mlir/test/lib/Transforms/TestExpandTanh.cpp b/mlir/test/lib/Transforms/TestExpandTanh.cpp
index 4baffacfae15a..64aeb0d1bc827 100644
--- a/mlir/test/lib/Transforms/TestExpandTanh.cpp
+++ b/mlir/test/lib/Transforms/TestExpandTanh.cpp
@@ -26,7 +26,7 @@ struct TestExpandTanhPass
 void TestExpandTanhPass::runOnFunction() {
   OwningRewritePatternList patterns;
   populateExpandTanhPattern(patterns, &getContext());
-  applyPatternsAndFoldGreedily(getOperation(), std::move(patterns));
+  (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns));
 }
 
 namespace mlir {

diff  --git a/mlir/test/lib/Transforms/TestGpuRewrite.cpp b/mlir/test/lib/Transforms/TestGpuRewrite.cpp
index a7155d4ff3ebc..56512386f3140 100644
--- a/mlir/test/lib/Transforms/TestGpuRewrite.cpp
+++ b/mlir/test/lib/Transforms/TestGpuRewrite.cpp
@@ -26,7 +26,7 @@ struct TestGpuRewritePass
   void runOnOperation() override {
     OwningRewritePatternList patterns;
     populateGpuRewritePatterns(&getContext(), patterns);
-    applyPatternsAndFoldGreedily(getOperation(), std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns));
   }
 };
 } // namespace

diff  --git a/mlir/test/lib/Transforms/TestLinalgFusionTransforms.cpp b/mlir/test/lib/Transforms/TestLinalgFusionTransforms.cpp
index 20e0166d73316..921f177d5d1c7 100644
--- a/mlir/test/lib/Transforms/TestLinalgFusionTransforms.cpp
+++ b/mlir/test/lib/Transforms/TestLinalgFusionTransforms.cpp
@@ -114,7 +114,7 @@ struct TestLinalgFusionTransforms
     LinalgDependenceGraph dependenceGraph =
         LinalgDependenceGraph::buildDependenceGraph(alias, funcOp);
     fillFusionPatterns<LoopType>(context, dependenceGraph, fusionPatterns);
-    applyPatternsAndFoldGreedily(funcOp, std::move(fusionPatterns));
+    (void)applyPatternsAndFoldGreedily(funcOp, std::move(fusionPatterns));
   }
 };
 } // namespace
@@ -186,7 +186,7 @@ struct TestLinalgGreedyFusion
     patterns.insert<AffineMinSCFCanonicalizationPattern>(context);
     FrozenRewritePatternList frozenPatterns(std::move(patterns));
     while (succeeded(fuseLinalgOpsGreedily(getFunction()))) {
-      applyPatternsAndFoldGreedily(getFunction(), frozenPatterns);
+      (void)applyPatternsAndFoldGreedily(getFunction(), frozenPatterns);
       PassManager pm(context);
       pm.addPass(createLoopInvariantCodeMotionPass());
       pm.addPass(createCanonicalizerPass());

diff  --git a/mlir/test/lib/Transforms/TestLinalgTransforms.cpp b/mlir/test/lib/Transforms/TestLinalgTransforms.cpp
index 3a6ac1dd77abd..a1a2aaaf8228d 100644
--- a/mlir/test/lib/Transforms/TestLinalgTransforms.cpp
+++ b/mlir/test/lib/Transforms/TestLinalgTransforms.cpp
@@ -224,7 +224,7 @@ static void applyPatterns(FuncOp funcOp) {
           Identifier::get("_promote_views_aligned_", ctx),
           Identifier::get("_views_aligned_promoted_", ctx)));
 
-  applyPatternsAndFoldGreedily(funcOp, std::move(patterns));
+  (void)applyPatternsAndFoldGreedily(funcOp, std::move(patterns));
 
   // Drop the marker.
   funcOp.walk([](LinalgOp op) {
@@ -308,12 +308,10 @@ static void fillPromotionCallBackPatterns(MLIRContext *ctx,
           .setAllocationDeallocationFns(allocCallBackFn, deallocCallBackFn)
           .setCopyInOutFns(
               [](OpBuilder &b, Value src, Value dst) -> LogicalResult {
-                copyCallBackFn(b, src, dst, false);
-                return success();
+                return copyCallBackFn(b, src, dst, false);
               },
               [](OpBuilder &b, Value src, Value dst) -> LogicalResult {
-                copyCallBackFn(b, src, dst, true);
-                return success();
+                return copyCallBackFn(b, src, dst, true);
               }),
       LinalgTransformationFilter(Identifier::get("PROMOTE", ctx)));
 }
@@ -477,14 +475,15 @@ applyMatmulToVectorPatterns(FuncOp funcOp,
   llvm::move(stage1Patterns, std::back_inserter(frozenStage1Patterns));
   FrozenRewritePatternList stage2Patterns =
       getLinalgTilingCanonicalizationPatterns(ctx);
-  applyStagedPatterns(funcOp, frozenStage1Patterns, std::move(stage2Patterns));
+  (void)applyStagedPatterns(funcOp, frozenStage1Patterns,
+                            std::move(stage2Patterns));
 }
 
 static void applyVectorTransferForwardingPatterns(FuncOp funcOp) {
   OwningRewritePatternList forwardPattern;
   forwardPattern.insert<LinalgCopyVTRForwardingPattern>(funcOp.getContext());
   forwardPattern.insert<LinalgCopyVTWForwardingPattern>(funcOp.getContext());
-  applyPatternsAndFoldGreedily(funcOp, std::move(forwardPattern));
+  (void)applyPatternsAndFoldGreedily(funcOp, std::move(forwardPattern));
 }
 
 static void applyLinalgToVectorPatterns(FuncOp funcOp) {
@@ -492,7 +491,7 @@ static void applyLinalgToVectorPatterns(FuncOp funcOp) {
   patterns.insert<LinalgVectorizationPattern>(
       LinalgTransformationFilter()
           .addOpFilter<ContractionOpInterface, FillOp, CopyOp, GenericOp>());
-  applyPatternsAndFoldGreedily(funcOp, std::move(patterns));
+  (void)applyPatternsAndFoldGreedily(funcOp, std::move(patterns));
 }
 
 static void applyAffineMinSCFCanonicalizationPatterns(FuncOp funcOp) {
@@ -503,7 +502,7 @@ static void applyAffineMinSCFCanonicalizationPatterns(FuncOp funcOp) {
   // Explicitly walk and apply the pattern locally to avoid more general folding
   // on the rest of the IR.
   funcOp.walk([&frozenPatterns](AffineMinOp minOp) {
-    applyOpPatternsAndFold(minOp, frozenPatterns);
+    (void)applyOpPatternsAndFold(minOp, frozenPatterns);
   });
 }
 
@@ -525,7 +524,7 @@ static void applyTileAndPadPattern(FuncOp funcOp) {
       context, linalgTilingOptions,
       linalg::LinalgTransformationFilter(
           Identifier::get("tile-and-pad", context)));
-  applyPatternsAndFoldGreedily(funcOp, std::move(tilingPattern));
+  (void)applyPatternsAndFoldGreedily(funcOp, std::move(tilingPattern));
 }
 
 /// Apply transformations specified as patterns.
@@ -540,13 +539,13 @@ void TestLinalgTransforms::runOnFunction() {
   if (testPromotionOptions) {
     OwningRewritePatternList patterns;
     fillPromotionCallBackPatterns(&getContext(), patterns);
-    applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
     return;
   }
   if (testTileAndDistributionOptions) {
     OwningRewritePatternList patterns;
     fillTileAndDistributePatterns(&getContext(), patterns);
-    applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
     return;
   }
   if (testPatterns)
@@ -565,7 +564,7 @@ void TestLinalgTransforms::runOnFunction() {
     return applyTileAndPadPattern(getFunction());
   if (testHoistPadding2Levels) {
     getFunction().walk([](linalg::PadTensorOp padTensorOp) {
-      linalg::hoistPaddingOnTensors(padTensorOp, 2);
+      (void)linalg::hoistPaddingOnTensors(padTensorOp, 2);
     });
   }
 }

diff  --git a/mlir/test/lib/Transforms/TestLoopUnrolling.cpp b/mlir/test/lib/Transforms/TestLoopUnrolling.cpp
index f67be1d3f2dab..abdce69631976 100644
--- a/mlir/test/lib/Transforms/TestLoopUnrolling.cpp
+++ b/mlir/test/lib/Transforms/TestLoopUnrolling.cpp
@@ -48,9 +48,8 @@ class TestLoopUnrollingPass
       if (getNestingDepth(forOp) == loopDepth)
         loops.push_back(forOp);
     });
-    for (auto loop : loops) {
-      loopUnrollByFactor(loop, unrollFactor);
-    }
+    for (auto loop : loops)
+      (void)loopUnrollByFactor(loop, unrollFactor);
   }
   Option<uint64_t> unrollFactor{*this, "unroll-factor",
                                 llvm::cl::desc("Loop unroll factor."),

diff  --git a/mlir/test/lib/Transforms/TestMemRefBoundCheck.cpp b/mlir/test/lib/Transforms/TestMemRefBoundCheck.cpp
index a2df8706a3395..1188cc48ff7f1 100644
--- a/mlir/test/lib/Transforms/TestMemRefBoundCheck.cpp
+++ b/mlir/test/lib/Transforms/TestMemRefBoundCheck.cpp
@@ -39,7 +39,7 @@ void TestMemRefBoundCheck::runOnFunction() {
   getFunction().walk([](Operation *opInst) {
     TypeSwitch<Operation *>(opInst)
         .Case<AffineReadOpInterface, AffineWriteOpInterface>(
-            [](auto op) { boundCheckLoadOrStoreOp(op); });
+            [](auto op) { (void)boundCheckLoadOrStoreOp(op); });
 
     // TODO: do this for DMA ops as well.
   });

diff  --git a/mlir/test/lib/Transforms/TestSCFUtils.cpp b/mlir/test/lib/Transforms/TestSCFUtils.cpp
index c4e2328fbe287..01423639d65a4 100644
--- a/mlir/test/lib/Transforms/TestSCFUtils.cpp
+++ b/mlir/test/lib/Transforms/TestSCFUtils.cpp
@@ -38,7 +38,7 @@ class TestSCFForUtilsPass
       auto loop = fakeRead->getParentOfType<scf::ForOp>();
 
       OpBuilder b(loop);
-      loop.moveOutOfLoop({fakeRead});
+      (void)loop.moveOutOfLoop({fakeRead});
       fakeWrite->moveAfter(loop);
       auto newLoop = cloneWithNewYields(b, loop, fakeRead->getResult(0),
                                         fakeCompute->getResult(0));

diff  --git a/mlir/test/lib/Transforms/TestSparsification.cpp b/mlir/test/lib/Transforms/TestSparsification.cpp
index f5c0ae67836c1..dfcaf08a3cabf 100644
--- a/mlir/test/lib/Transforms/TestSparsification.cpp
+++ b/mlir/test/lib/Transforms/TestSparsification.cpp
@@ -100,7 +100,7 @@ struct TestSparsification
     // Apply rewriting.
     linalg::populateSparsificationPatterns(ctx, patterns, options);
     vector::populateVectorToVectorCanonicalizationPatterns(patterns, ctx);
-    applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
   }
 };
 

diff  --git a/mlir/test/lib/Transforms/TestVectorTransforms.cpp b/mlir/test/lib/Transforms/TestVectorTransforms.cpp
index 11e4ee24cb407..ea4b6f998db02 100644
--- a/mlir/test/lib/Transforms/TestVectorTransforms.cpp
+++ b/mlir/test/lib/Transforms/TestVectorTransforms.cpp
@@ -45,7 +45,7 @@ struct TestVectorToVectorConversion
     }
     populateVectorToVectorCanonicalizationPatterns(patterns, ctx);
     populateVectorToVectorTransformationPatterns(patterns, ctx);
-    applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
   }
 
 private:
@@ -68,7 +68,7 @@ struct TestVectorSlicesConversion
   void runOnFunction() override {
     OwningRewritePatternList patterns;
     populateVectorSlicesLoweringPatterns(patterns, &getContext());
-    applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
   }
 };
 
@@ -105,7 +105,7 @@ struct TestVectorContractionConversion
       VectorTransformsOptions options{lowering};
       patterns.insert<ContractionOpToOuterProductOpLowering>(options,
                                                              &getContext());
-      applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
+      (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
       return;
     }
 
@@ -121,7 +121,7 @@ struct TestVectorContractionConversion
               return failure();
             return success();
           });
-      applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
+      (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
       return;
     }
 
@@ -135,7 +135,7 @@ struct TestVectorContractionConversion
       transposeLowering = VectorTransposeLowering::Flat;
     VectorTransformsOptions options{contractLowering, transposeLowering};
     populateVectorContractLoweringPatterns(patterns, &getContext(), options);
-    applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
   }
 };
 
@@ -182,7 +182,7 @@ struct TestVectorUnrollingPatterns
     }
     populateVectorToVectorCanonicalizationPatterns(patterns, ctx);
     populateVectorToVectorTransformationPatterns(patterns, ctx);
-    applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
   }
 
   Option<bool> unrollBasedOnType{
@@ -237,7 +237,7 @@ struct TestVectorDistributePatterns
     });
     patterns.insert<PointwiseExtractPattern>(ctx);
     populateVectorToVectorTransformationPatterns(patterns, ctx);
-    applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
   }
 };
 
@@ -297,7 +297,7 @@ struct TestVectorToLoopPatterns
     });
     patterns.insert<PointwiseExtractPattern>(ctx);
     populateVectorToVectorTransformationPatterns(patterns, ctx);
-    applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
   }
 };
 
@@ -319,7 +319,7 @@ struct TestVectorTransferUnrollingPatterns
             }));
     populateVectorToVectorCanonicalizationPatterns(patterns, ctx);
     populateVectorToVectorTransformationPatterns(patterns, ctx);
-    applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
   }
 };
 
@@ -348,7 +348,7 @@ struct TestVectorTransferFullPartialSplitPatterns
     else
       options.setVectorTransferSplit(VectorTransferSplit::VectorTransfer);
     patterns.insert<VectorTransferFullPartialRewriter>(ctx, options);
-    applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
   }
 };
 

diff  --git a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp
index 3ca9909efc40a..a222d67bcb4e2 100644
--- a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp
+++ b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp
@@ -618,31 +618,33 @@ AffineExpr AffineParser::getAffineBinaryOpExpr(AffineHighPrecOp op,
   switch (op) {
   case Mul:
     if (!lhs.isSymbolicOrConstant() && !rhs.isSymbolicOrConstant()) {
-      parser.emitError(opLoc,
-                       "non-affine expression: at least one of the multiply "
-                       "operands has to be either a constant or symbolic");
+      (void)parser.emitError(
+          opLoc, "non-affine expression: at least one of the multiply "
+                 "operands has to be either a constant or symbolic");
       return nullptr;
     }
     return lhs * rhs;
   case FloorDiv:
     if (!rhs.isSymbolicOrConstant()) {
-      parser.emitError(opLoc,
-                       "non-affine expression: right operand of floordiv "
-                       "has to be either a constant or symbolic");
+      (void)parser.emitError(opLoc,
+                             "non-affine expression: right operand of floordiv "
+                             "has to be either a constant or symbolic");
       return nullptr;
     }
     return lhs.floorDiv(rhs);
   case CeilDiv:
     if (!rhs.isSymbolicOrConstant()) {
-      parser.emitError(opLoc, "non-affine expression: right operand of ceildiv "
-                              "has to be either a constant or symbolic");
+      (void)parser.emitError(opLoc,
+                             "non-affine expression: right operand of ceildiv "
+                             "has to be either a constant or symbolic");
       return nullptr;
     }
     return lhs.ceilDiv(rhs);
   case Mod:
     if (!rhs.isSymbolicOrConstant()) {
-      parser.emitError(opLoc, "non-affine expression: right operand of mod "
-                              "has to be either a constant or symbolic");
+      (void)parser.emitError(opLoc,
+                             "non-affine expression: right operand of mod "
+                             "has to be either a constant or symbolic");
       return nullptr;
     }
     return lhs % rhs;
@@ -748,7 +750,8 @@ AffineExpr AffineParser::parseParentheticalExpr() {
   if (failed(parser.parseToken(Token::Kind::l_paren, "expected '('")))
     return nullptr;
   if (parser.curToken.is(Token::Kind::r_paren))
-    return (parser.emitError("no expression inside parentheses"), nullptr);
+    return ((void)parser.emitError("no expression inside parentheses"),
+            nullptr);
 
   auto expr = parseAffineExpr();
   if (!expr)
@@ -773,7 +776,7 @@ AffineExpr AffineParser::parseNegateExpression(AffineExpr lhs) {
   if (!operand)
     // Extra error message although parseAffineOperandExpr would have
     // complained. Leads to a better diagnostic.
-    return (parser.emitError("missing operand of negation"), nullptr);
+    return ((void)parser.emitError("missing operand of negation"), nullptr);
   return (-1) * operand;
 }
 
@@ -788,7 +791,7 @@ AffineExpr AffineParser::parseAttrUseOrBareIdExpr() {
 ///   affine-expr ::= bare-id
 AffineExpr AffineParser::parseBareIdExpr() {
   if (parser.curToken.isNot(Token::Kind::id))
-    return (parser.emitError("expected id"), nullptr);
+    return ((void)parser.emitError("expected id"), nullptr);
 
   StringRef sRef = parser.curToken.getSpelling();
   for (auto &list : {dims, symbols}) {
@@ -807,7 +810,7 @@ AffineExpr AffineParser::parseBareIdExpr() {
     return expr;
   }
 
-  return (parser.emitError("use of undeclared id"), nullptr);
+  return ((void)parser.emitError("use of undeclared id"), nullptr);
 }
 
 /// Parse a positive integral constant appearing in an affine expression.
@@ -816,7 +819,7 @@ AffineExpr AffineParser::parseBareIdExpr() {
 AffineExpr AffineParser::parseIntegerExpr() {
   auto val = parser.curToken.getUInt64IntegerValue();
   if (!val.hasValue() || (int64_t)val.getValue() < 0)
-    return (parser.emitError("constant too large for index"), nullptr);
+    return ((void)parser.emitError("constant too large for index"), nullptr);
 
   parser.consumeToken(Token::Kind::integer);
   return getAffineConstantExpr((int64_t)val.getValue(), parser.context);
@@ -847,15 +850,15 @@ AffineExpr AffineParser::parseAffineOperandExpr(AffineExpr lhs) {
   case Token::Kind::plus:
   case Token::Kind::star:
     if (lhs)
-      parser.emitError("missing right operand of binary operator");
+      (void)parser.emitError("missing right operand of binary operator");
     else
-      parser.emitError("missing left operand of binary operator");
+      (void)parser.emitError("missing left operand of binary operator");
     return nullptr;
   default:
     if (lhs)
-      parser.emitError("missing right operand of binary operator");
+      (void)parser.emitError("missing right operand of binary operator");
     else
-      parser.emitError("expected affine expression");
+      (void)parser.emitError("expected affine expression");
     return nullptr;
   }
 }
@@ -943,7 +946,9 @@ AffineExpr AffineParser::parseAffineExpr() {
 
 SmallVector<AffineExpr, 4> AffineParser::parseAffineExprs(Token::Kind lDelim,
                                                           Token::Kind rDelim) {
-  parser.parseToken(lDelim, "expected lDelim at start of affine expr list");
+  if (failed(parser.parseToken(lDelim,
+                               "expected lDelim at start of affine expr list")))
+    return {};
 
   SmallVector<AffineExpr, 4> exprs;
   auto parseElt = [&]() -> LogicalResult {
@@ -1376,7 +1381,8 @@ LogicalResult TCParser::parseAttrDef() {
   SmallVector<uint64_t, 4> vectorDims;
   while (parser.curToken.is(Token::Kind::integer)) {
     uint64_t value;
-    parser.parseInteger(value);
+    if (failed(parser.parseInteger(value)))
+      return failure();
     vectorDims.push_back(value);
 
     StringRef spelling = parser.curToken.getSpelling();
@@ -1550,10 +1556,8 @@ TCParser::parseOneComprehension(StringRef cppOpName, StringRef linalgOpName,
   unsigned idx = 0;
   auto parseExpr = [&]() -> LogicalResult {
     std::unique_ptr<Expression> expr;
-    if (idx >= definitions.size()) {
-      parser.emitError("Fewer LHS definitions than RHS expressions");
-      return failure();
-    }
+    if (idx >= definitions.size())
+      return parser.emitError("Fewer LHS definitions than RHS expressions");
     if (failed(parseExpression(definitions[idx++], expr, state)))
       return failure();
     state.expressions.push_back(std::move(expr));
@@ -1562,10 +1566,8 @@ TCParser::parseOneComprehension(StringRef cppOpName, StringRef linalgOpName,
   if (failed(parser.parseCommaSeparatedListUntil(
           Token::Kind::semicolon, parseExpr, /*allowEmptyList=*/true)))
     return failure();
-  if (idx != definitions.size()) {
-    parser.emitError("Fewer RHS expressions than LHS definitions");
-    return failure();
-  }
+  if (idx != definitions.size())
+    return parser.emitError("Fewer RHS expressions than LHS definitions");
 
   // 3. Postprocess.
   // 3.a. Normalize all maps to the proper state.dims and symbols counts.
@@ -1586,10 +1588,8 @@ TCParser::parseOneComprehension(StringRef cppOpName, StringRef linalgOpName,
   // 3.b. Traverse definitions
   llvm::DenseSet<StringRef> seenDefs;
   for (auto &def : definitions) {
-    if (seenDefs.count(def.tensorId) > 0) {
-      parser.emitError("Unexpected multi-write to a single tensor");
-      return failure();
-    }
+    if (seenDefs.count(def.tensorId) > 0)
+      return parser.emitError("Unexpected multi-write to a single tensor");
     seenDefs.insert(def.tensorId);
     auto tensorIter = registeredTensors.find(def.tensorId);
     assert(tensorIter != registeredTensors.end() && "unregistered tensor");
@@ -1612,7 +1612,7 @@ TCParser::parseOneComprehension(StringRef cppOpName, StringRef linalgOpName,
       auto &tensor = tensorIter->getValue();
       if (tensor.indexingMap && state.orderedTensorArgs.count(use) == 0) {
         LLVM_DEBUG(llvm::dbgs() << "\nexisting: " << tensor.indexingMap);
-        parser.emitError(
+        (void)parser.emitError(
             "Unexpected multi-read of a tensor with 
diff erent accesses");
         failed = true;
         return;
@@ -1752,15 +1752,14 @@ LogicalResult TCParser::parseAndEmitODSDef(llvm::raw_ostream &os) {
                                      perComprehensionStates.back())))
       return failure();
   };
-  parser.parseToken(Token::Kind::r_brace, "expected '}'");
+  if (failed(parser.parseToken(Token::Kind::r_brace, "expected '}'")))
+    return failure();
 
   // Print.
   auto nComprehensions = perComprehensionStates.size();
-  if (nComprehensions != 1) {
-    parser.emitError("only 1 comprehension supported for now, got: " +
-                     llvm::Twine(nComprehensions));
-    return failure();
-  }
+  if (nComprehensions != 1)
+    return parser.emitError("only 1 comprehension supported for now, got: " +
+                            llvm::Twine(nComprehensions));
   if (genODSDecl) {
     auto &state = perComprehensionStates.back();
     printODS(os, cppOpName, tcName, interfaces, state);
@@ -1800,8 +1799,8 @@ void TCParser::printODS(llvm::raw_ostream &os, StringRef cppOpName,
                               .Case("i64", "I64")
                               .Default("");
     if (odsType.empty()) {
-      parser.emitError("unimplemented support for attribute element type: " +
-                       elementType);
+      (void)parser.emitError(
+          "unimplemented support for attribute element type: " + elementType);
       return;
     }
 
@@ -2088,7 +2087,8 @@ void TCParser::printReferenceIndexingMaps(llvm::raw_ostream &os,
     assert(it != registeredAttrs.end() && "uses should point to valid attr!");
     std::string getValueFn = it->second.getValueFn(attrUse.value().indices);
     if (getValueFn.empty()) {
-      parser.emitError("unimplemented getValueFn for attribute: " + attrName);
+      (void)parser.emitError("unimplemented getValueFn for attribute: " +
+                             attrName);
       return;
     }
     std::string cstVal = llvm::formatv("{0}().{1}", attrName, getValueFn);
@@ -2283,7 +2283,7 @@ int main(int argc, char **argv) {
   llvm::SourceMgr mgr;
   mgr.AddNewSourceBuffer(std::move(file), llvm::SMLoc());
   Parser parser(mgr, &context);
-  parseAndEmitAllTensorComprehensions(output->os(), parser);
+  (void)parseAndEmitAllTensorComprehensions(output->os(), parser);
   output->keep();
 
   return 0;

diff  --git a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
index 20bf8773b137b..bb02a7993e43b 100644
--- a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
+++ b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
@@ -709,13 +709,15 @@ static void emitSerializationFunction(const Record *attrClass,
                             elidedAttrs, os);
 
   if (record->isSubClassOf("SPV_ExtInstOp")) {
-    os << formatv("  encodeExtensionInstruction({0}, \"{1}\", {2}, {3});\n",
-                  opVar, record->getValueAsString("extendedInstSetName"),
-                  record->getValueAsInt("extendedInstOpcode"), operands);
+    os << formatv(
+        "  (void)encodeExtensionInstruction({0}, \"{1}\", {2}, {3});\n", opVar,
+        record->getValueAsString("extendedInstSetName"),
+        record->getValueAsInt("extendedInstOpcode"), operands);
   } else {
     // Emit debug info.
-    os << formatv("  emitDebugLine(functionBody, {0}.getLoc());\n", opVar);
-    os << formatv("  encodeInstructionInto("
+    os << formatv("  (void)emitDebugLine(functionBody, {0}.getLoc());\n",
+                  opVar);
+    os << formatv("  (void)encodeInstructionInto("
                   "functionBody, spirv::Opcode::{1}, {2});\n",
                   op.getQualCppClassName(),
                   record->getValueAsString("spirvOpName"), operands);
@@ -987,7 +989,7 @@ static void emitDeserializationFunction(const Record *attrClass,
   // this instruction, up to the first occurrence of any of the following: the
   // next end of block.
   os << formatv("  if ({0}.hasTrait<OpTrait::IsTerminator>())\n", opVar);
-  os << formatv("    clearDebugLine();\n");
+  os << formatv("    (void)clearDebugLine();\n");
   os << "  return success();\n";
   os << "}\n\n";
 }

diff  --git a/mlir/tools/mlir-vulkan-runner/VulkanRuntime.cpp b/mlir/tools/mlir-vulkan-runner/VulkanRuntime.cpp
index 649d731fc16c7..db9f47938fc28 100644
--- a/mlir/tools/mlir-vulkan-runner/VulkanRuntime.cpp
+++ b/mlir/tools/mlir-vulkan-runner/VulkanRuntime.cpp
@@ -855,7 +855,7 @@ LogicalResult VulkanRuntime::submitCommandBuffersToQueue() {
 
 LogicalResult VulkanRuntime::updateHostMemoryBuffers() {
   // First copy back the data to the staging buffer.
-  copyResource(/*deviceToHost=*/true);
+  (void)copyResource(/*deviceToHost=*/true);
 
   // For each descriptor set.
   for (auto &resourceDataMapPair : resourceData) {

diff  --git a/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp b/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp
index 76fa66145e7ed..e3802807ed873 100644
--- a/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp
+++ b/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp
@@ -189,11 +189,11 @@ TEST_F(DeserializationTest, OpMemberNameSuccess) {
   std::swap(typeDecl, binary);
 
   SmallVector<uint32_t, 5> operands1 = {structType, 0};
-  spirv::encodeStringLiteralInto(operands1, "i1");
+  (void)spirv::encodeStringLiteralInto(operands1, "i1");
   addInstruction(spirv::Opcode::OpMemberName, operands1);
 
   SmallVector<uint32_t, 5> operands2 = {structType, 1};
-  spirv::encodeStringLiteralInto(operands2, "i2");
+  (void)spirv::encodeStringLiteralInto(operands2, "i2");
   addInstruction(spirv::Opcode::OpMemberName, operands2);
 
   binary.append(typeDecl.begin(), typeDecl.end());
@@ -228,7 +228,7 @@ TEST_F(DeserializationTest, OpMemberNameExcessOperands) {
   std::swap(typeDecl, binary);
 
   SmallVector<uint32_t, 5> operands = {structType, 0};
-  spirv::encodeStringLiteralInto(operands, "int32");
+  (void)spirv::encodeStringLiteralInto(operands, "int32");
   operands.push_back(42);
   addInstruction(spirv::Opcode::OpMemberName, operands);
 


        


More information about the Mlir-commits mailing list