diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -41,7 +41,7 @@
   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
--- a/mlir/include/mlir/IR/SymbolTable.h
+++ b/mlir/include/mlir/IR/SymbolTable.h
@@ -189,17 +189,17 @@
   /// '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
--- a/mlir/include/mlir/Pass/PassManager.h
+++ b/mlir/include/mlir/Pass/PassManager.h
@@ -178,7 +178,6 @@
   /// 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
--- a/mlir/include/mlir/Support/LogicalResult.h
+++ b/mlir/include/mlir/Support/LogicalResult.h
@@ -16,36 +16,53 @@
 
 /// 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) {}
+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
--- a/mlir/include/mlir/Transforms/DialectConversion.h
+++ b/mlir/include/mlir/Transforms/DialectConversion.h
@@ -829,11 +829,11 @@
 /// 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 @@
 /// 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 @@
 /// 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
--- a/mlir/include/mlir/Transforms/LoopUtils.h
+++ b/mlir/include/mlir/Transforms/LoopUtils.h
@@ -85,7 +85,6 @@
 /// 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 @@
 
 /// 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 @@
 /// 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
--- a/mlir/lib/Analysis/Presburger/Simplex.cpp
+++ b/mlir/lib/Analysis/Presburger/Simplex.cpp
@@ -272,7 +272,7 @@
 
     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> 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 @@
     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
--- a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp
+++ b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp
@@ -379,7 +379,8 @@
     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 @@
     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
--- a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
+++ b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
@@ -128,7 +128,7 @@
     // 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
--- a/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
+++ b/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
@@ -62,7 +62,7 @@
     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
--- a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
+++ b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
@@ -208,7 +208,8 @@
     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
--- a/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp
+++ b/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp
@@ -295,7 +295,7 @@
     // 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
--- a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
+++ b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
@@ -888,9 +888,9 @@
                   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 @@
           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
--- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
+++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
@@ -3115,9 +3115,10 @@
       }
     } 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
--- a/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp
+++ b/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp
@@ -214,8 +214,8 @@
   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
--- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
+++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
@@ -77,7 +77,7 @@
   if (isa<tosa::TanhOp>(op) && elementTy.isa<FloatType>())
     return rewriter.create<mlir::TanhOp>(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
--- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp
+++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp
@@ -60,7 +60,7 @@
     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
--- a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
+++ b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
@@ -713,7 +713,7 @@
     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
--- a/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp
@@ -155,7 +155,7 @@
       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 @@
   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 @@
     // 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 @@
   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
--- a/mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/LoopTiling.cpp
@@ -185,7 +185,7 @@
     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
--- a/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp
@@ -96,7 +96,7 @@
         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
--- a/mlir/lib/Dialect/Affine/Transforms/LoopUnrollAndJam.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/LoopUnrollAndJam.cpp
@@ -74,5 +74,5 @@
   // 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
--- a/mlir/lib/Dialect/Affine/Transforms/SimplifyAffineStructures.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/SimplifyAffineStructures.cpp
@@ -95,6 +95,6 @@
     // 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
--- a/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp
@@ -779,7 +779,7 @@
     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 @@
                                 &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
--- a/mlir/lib/Dialect/Affine/Utils/Utils.cpp
+++ b/mlir/lib/Dialect/Affine/Utils/Utils.cpp
@@ -192,7 +192,7 @@
   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 @@
 
   // 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
--- a/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp
+++ b/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp
@@ -135,7 +135,7 @@
         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
--- a/mlir/lib/Dialect/Linalg/Transforms/CodegenStrategy.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/CodegenStrategy.cpp
@@ -65,8 +65,8 @@
     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 @@
   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 @@
       .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
--- a/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp
@@ -221,7 +221,7 @@
     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 @@
                       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
--- a/mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp
@@ -1116,7 +1116,7 @@
     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 @@
     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
--- a/mlir/lib/Dialect/Linalg/Transforms/Generalization.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Generalization.cpp
@@ -146,7 +146,7 @@
   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
--- a/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
@@ -73,7 +73,7 @@
 
       // 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
--- a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
@@ -592,7 +592,7 @@
   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
--- a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
@@ -340,7 +340,7 @@
 
   // 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
--- a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
@@ -588,9 +588,9 @@
   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
--- a/mlir/lib/Dialect/Quant/Transforms/ConvertConst.cpp
+++ b/mlir/lib/Dialect/Quant/Transforms/ConvertConst.cpp
@@ -96,7 +96,7 @@
   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
--- a/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp
+++ b/mlir/lib/Dialect/Quant/Transforms/ConvertSimQuant.cpp
@@ -129,7 +129,7 @@
   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
--- a/mlir/lib/Dialect/Shape/Transforms/RemoveShapeConstraints.cpp
+++ b/mlir/lib/Dialect/Shape/Transforms/RemoveShapeConstraints.cpp
@@ -49,7 +49,7 @@
     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
--- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
+++ b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
@@ -3120,9 +3120,9 @@
   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
--- a/mlir/lib/Dialect/StandardOps/Transforms/DecomposeCallGraphTypes.cpp
+++ b/mlir/lib/Dialect/StandardOps/Transforms/DecomposeCallGraphTypes.cpp
@@ -69,7 +69,8 @@
     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 @@
 
     // 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 @@
     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
--- a/mlir/lib/Dialect/Tosa/Transforms/TosaMakeBroadcastable.cpp
+++ b/mlir/lib/Dialect/Tosa/Transforms/TosaMakeBroadcastable.cpp
@@ -265,7 +265,7 @@
     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
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -633,10 +633,10 @@
     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
--- a/mlir/lib/IR/BuiltinTypes.cpp
+++ b/mlir/lib/IR/BuiltinTypes.cpp
@@ -445,13 +445,14 @@
   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
--- a/mlir/lib/Pass/Pass.cpp
+++ b/mlir/lib/Pass/Pass.cpp
@@ -783,7 +783,7 @@
   // 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
--- a/mlir/lib/Support/MlirOptMain.cpp
+++ b/mlir/lib/Support/MlirOptMain.cpp
@@ -115,8 +115,8 @@
   // 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
--- a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
+++ b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
@@ -689,8 +689,8 @@
       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
--- a/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp
+++ b/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp
@@ -285,7 +285,7 @@
     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
--- a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp
+++ b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp
@@ -1371,7 +1371,7 @@
   // the same OpLine information.
   opBuilder.create<spirv::BranchOp>(loc, target);
 
-  clearDebugLine();
+  (void)clearDebugLine();
   return success();
 }
 
@@ -1405,7 +1405,7 @@
       /*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
--- a/mlir/lib/Target/SPIRV/Serialization/Serialization.cpp
+++ b/mlir/lib/Target/SPIRV/Serialization/Serialization.cpp
@@ -622,8 +622,8 @@
 
 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 @@
   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 @@
   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 @@
   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 @@
     // 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 @@
     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 @@
     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 @@
 
   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 @@
   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 @@
     }
     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 @@
   // 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 @@
     }
     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 @@
     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");
@@ -1223,9 +1229,9 @@
       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(
@@ -1267,7 +1273,7 @@
 
   if (auto structType = type.dyn_cast<spirv::StructType>()) {
     if (structType.isIdentified()) {
-      processName(resultID, structType.getIdentifier());
+      (void)processName(resultID, structType.getIdentifier());
       serializationCtx.insert(structType.getIdentifier());
     }
 
@@ -1432,7 +1438,7 @@
     }
   }
   spirv::Opcode opcode = spirv::Opcode::OpConstantComposite;
-  encodeInstructionInto(typesGlobalValues, opcode, operands);
+  (void)encodeInstructionInto(typesGlobalValues, opcode, operands);
 
   return resultID;
 }
@@ -1476,7 +1482,7 @@
     }
   }
   spirv::Opcode opcode = spirv::Opcode::OpConstantComposite;
-  encodeInstructionInto(typesGlobalValues, opcode, operands);
+  (void)encodeInstructionInto(typesGlobalValues, opcode, operands);
 
   return resultID;
 }
@@ -1517,7 +1523,7 @@
                               : 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;
@@ -1559,7 +1565,8 @@
     } 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."
@@ -1573,8 +1580,8 @@
     } 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);
@@ -1615,18 +1622,20 @@
 
   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);
@@ -1665,7 +1674,8 @@
                << "[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.
@@ -1755,7 +1765,7 @@
       phiArgs.push_back(predBlockId);
     }
 
-    encodeInstructionInto(functionBody, spirv::Opcode::OpPhi, phiArgs);
+    (void)encodeInstructionInto(functionBody, spirv::Opcode::OpPhi, phiArgs);
     valueIDMap[arg] = phiID;
   }
 
@@ -1778,9 +1788,9 @@
   // 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())});
   };
@@ -1830,7 +1840,8 @@
   // 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
@@ -1840,9 +1851,9 @@
   // 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())});
   };
@@ -1880,13 +1891,13 @@
       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())});
 }
@@ -2008,13 +2019,13 @@
   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) {
@@ -2044,7 +2055,7 @@
   }
   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()) {
@@ -2195,8 +2206,9 @@
   }
 
   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();
 }
@@ -2231,8 +2243,9 @@
 
   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
--- a/mlir/lib/Transforms/Canonicalizer.cpp
+++ b/mlir/lib/Transforms/Canonicalizer.cpp
@@ -30,7 +30,7 @@
     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
--- a/mlir/lib/Transforms/Inliner.cpp
+++ b/mlir/lib/Transforms/Inliner.cpp
@@ -755,7 +755,7 @@
   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
--- a/mlir/lib/Transforms/NormalizeMemRefs.cpp
+++ b/mlir/lib/Transforms/NormalizeMemRefs.cpp
@@ -329,7 +329,7 @@
   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
--- a/mlir/lib/Transforms/SCCP.cpp
+++ b/mlir/lib/Transforms/SCCP.cpp
@@ -358,7 +358,7 @@
     // 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
--- a/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp
+++ b/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp
@@ -388,7 +388,7 @@
 
   // 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
--- a/mlir/lib/Transforms/Utils/LoopUtils.cpp
+++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp
@@ -234,9 +234,9 @@
   // 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 @@
         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 @@
   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 @@
                                       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 @@
            "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 @@
                        /*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 @@
       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 @@
       },
       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 @@
     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 @@
   }
 
   // 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 @@
   // 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 @@
     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 @@
   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 @@
       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 difference.
     cst.setDimSymbolSeparation(cst.getNumDimAndSymbolIds() - 1);
diff --git a/mlir/lib/Translation/Translation.cpp b/mlir/lib/Translation/Translation.cpp
--- a/mlir/lib/Translation/Translation.cpp
+++ b/mlir/lib/Translation/Translation.cpp
@@ -189,7 +189,7 @@
     // 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
--- a/mlir/test/lib/Dialect/Affine/TestAffineDataCopy.cpp
+++ b/mlir/test/lib/Dialect/Affine/TestAffineDataCopy.cpp
@@ -84,8 +84,8 @@
   } 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 @@
     // 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 @@
       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
--- a/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp
+++ b/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp
@@ -231,7 +231,7 @@
   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
--- a/mlir/test/lib/Dialect/SPIRV/TestGLSLCanonicalization.cpp
+++ b/mlir/test/lib/Dialect/SPIRV/TestGLSLCanonicalization.cpp
@@ -27,7 +27,7 @@
 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
--- a/mlir/test/lib/Dialect/Test/TestPatterns.cpp
+++ b/mlir/test/lib/Dialect/Test/TestPatterns.cpp
@@ -84,7 +84,7 @@
     // 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
@@ -993,8 +993,8 @@
     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
--- a/mlir/test/lib/Dialect/Test/TestTraits.cpp
+++ b/mlir/test/lib/Dialect/Test/TestTraits.cpp
@@ -33,7 +33,8 @@
 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
--- a/mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp
+++ b/mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp
@@ -189,7 +189,7 @@
 
   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
--- a/mlir/test/lib/IR/TestSlicing.cpp
+++ b/mlir/test/lib/IR/TestSlicing.cpp
@@ -65,7 +65,7 @@
         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
--- a/mlir/test/lib/Transforms/TestConvVectorization.cpp
+++ b/mlir/test/lib/Transforms/TestConvVectorization.cpp
@@ -80,8 +80,9 @@
     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 @@
   // 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 @@
   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
--- a/mlir/test/lib/Transforms/TestDynamicPipeline.cpp
+++ b/mlir/test/lib/Transforms/TestDynamicPipeline.cpp
@@ -27,7 +27,7 @@
   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 @@
     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
--- a/mlir/test/lib/Transforms/TestExpandTanh.cpp
+++ b/mlir/test/lib/Transforms/TestExpandTanh.cpp
@@ -26,7 +26,7 @@
 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
--- a/mlir/test/lib/Transforms/TestGpuRewrite.cpp
+++ b/mlir/test/lib/Transforms/TestGpuRewrite.cpp
@@ -26,7 +26,7 @@
   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
--- a/mlir/test/lib/Transforms/TestLinalgFusionTransforms.cpp
+++ b/mlir/test/lib/Transforms/TestLinalgFusionTransforms.cpp
@@ -114,7 +114,7 @@
     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 @@
     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
--- a/mlir/test/lib/Transforms/TestLinalgTransforms.cpp
+++ b/mlir/test/lib/Transforms/TestLinalgTransforms.cpp
@@ -227,7 +227,7 @@
           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) {
@@ -312,12 +312,10 @@
           .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)));
 }
@@ -481,14 +479,15 @@
   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) {
@@ -500,7 +499,7 @@
       LinalgVectorizationPattern<VecmatOp>, LinalgVectorizationPattern<DotOp>,
       LinalgVectorizationPattern<FillOp>, LinalgVectorizationPattern<CopyOp>,
       LinalgVectorizationPattern<GenericOp>>(funcOp.getContext());
-  applyPatternsAndFoldGreedily(funcOp, std::move(patterns));
+  (void)applyPatternsAndFoldGreedily(funcOp, std::move(patterns));
 }
 
 static void applyAffineMinSCFCanonicalizationPatterns(FuncOp funcOp) {
@@ -511,7 +510,7 @@
   // 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);
   });
 }
 
@@ -533,7 +532,7 @@
       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.
@@ -548,13 +547,13 @@
   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)
@@ -573,7 +572,7 @@
     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
--- a/mlir/test/lib/Transforms/TestLoopUnrolling.cpp
+++ b/mlir/test/lib/Transforms/TestLoopUnrolling.cpp
@@ -48,9 +48,8 @@
       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
--- a/mlir/test/lib/Transforms/TestMemRefBoundCheck.cpp
+++ b/mlir/test/lib/Transforms/TestMemRefBoundCheck.cpp
@@ -39,7 +39,7 @@
   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
--- a/mlir/test/lib/Transforms/TestSCFUtils.cpp
+++ b/mlir/test/lib/Transforms/TestSCFUtils.cpp
@@ -38,7 +38,7 @@
       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
--- a/mlir/test/lib/Transforms/TestSparsification.cpp
+++ b/mlir/test/lib/Transforms/TestSparsification.cpp
@@ -100,7 +100,7 @@
     // 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
--- a/mlir/test/lib/Transforms/TestVectorTransforms.cpp
+++ b/mlir/test/lib/Transforms/TestVectorTransforms.cpp
@@ -45,7 +45,7 @@
     }
     populateVectorToVectorCanonicalizationPatterns(patterns, ctx);
     populateVectorToVectorTransformationPatterns(patterns, ctx);
-    applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
   }
 
 private:
@@ -68,7 +68,7 @@
   void runOnFunction() override {
     OwningRewritePatternList patterns;
     populateVectorSlicesLoweringPatterns(patterns, &getContext());
-    applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
   }
 };
 
@@ -105,7 +105,7 @@
       VectorTransformsOptions options{lowering};
       patterns.insert<ContractionOpToOuterProductOpLowering>(options,
                                                              &getContext());
-      applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
+      (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
       return;
     }
 
@@ -121,7 +121,7 @@
               return failure();
             return success();
           });
-      applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
+      (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
       return;
     }
 
@@ -135,7 +135,7 @@
       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 @@
     }
     populateVectorToVectorCanonicalizationPatterns(patterns, ctx);
     populateVectorToVectorTransformationPatterns(patterns, ctx);
-    applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
   }
 
   Option<bool> unrollBasedOnType{
@@ -237,7 +237,7 @@
     });
     patterns.insert<PointwiseExtractPattern>(ctx);
     populateVectorToVectorTransformationPatterns(patterns, ctx);
-    applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
   }
 };
 
@@ -297,7 +297,7 @@
     });
     patterns.insert<PointwiseExtractPattern>(ctx);
     populateVectorToVectorTransformationPatterns(patterns, ctx);
-    applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
   }
 };
 
@@ -319,7 +319,7 @@
             }));
     populateVectorToVectorCanonicalizationPatterns(patterns, ctx);
     populateVectorToVectorTransformationPatterns(patterns, ctx);
-    applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
+    (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
   }
 };
 
@@ -348,7 +348,7 @@
     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
--- a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp
+++ b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp
@@ -615,31 +615,33 @@
   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;
@@ -745,7 +747,8 @@
   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)
@@ -770,7 +773,7 @@
   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;
 }
 
@@ -785,7 +788,7 @@
 ///   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}) {
@@ -804,7 +807,7 @@
     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.
@@ -813,7 +816,7 @@
 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);
@@ -844,15 +847,15 @@
   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;
   }
 }
@@ -940,7 +943,9 @@
 
 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 {
@@ -1372,7 +1377,8 @@
   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();
@@ -1546,10 +1552,8 @@
   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));
@@ -1558,10 +1562,8 @@
   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.
@@ -1582,10 +1584,8 @@
   // 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");
@@ -1608,7 +1608,7 @@
       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 different accesses");
         failed = true;
         return;
@@ -1723,15 +1723,14 @@
                                      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, state);
@@ -1771,8 +1770,8 @@
                               .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;
     }
 
@@ -2047,7 +2046,8 @@
     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);
@@ -2242,7 +2242,7 @@
   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
--- a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
+++ b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
@@ -709,13 +709,15 @@
                             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 @@
   // 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
--- a/mlir/tools/mlir-vulkan-runner/VulkanRuntime.cpp
+++ b/mlir/tools/mlir-vulkan-runner/VulkanRuntime.cpp
@@ -855,7 +855,7 @@
 
 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
--- a/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp
+++ b/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp
@@ -189,11 +189,11 @@
   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 @@
   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);