[Mlir-commits] [llvm] [mlir] eliminating g++ warnings (PR #105520)

Frank Schlimbach llvmlistbot at llvm.org
Fri Oct 18 05:45:26 PDT 2024


https://github.com/fschlimb updated https://github.com/llvm/llvm-project/pull/105520

>From 6b6526e174b14026f95b9b35507782d371c1e362 Mon Sep 17 00:00:00 2001
From: "Schlimbach, Frank" <frank.schlimbach at intel.com>
Date: Wed, 21 Aug 2024 15:10:25 +0200
Subject: [PATCH 01/13] eliminating g++ warnings

---
 mlir/include/mlir/IR/OpDefinition.h                    | 7 ++++---
 mlir/include/mlir/Pass/Pass.h                          | 1 +
 mlir/include/mlir/Query/Matcher/Marshallers.h          | 9 ++++-----
 mlir/lib/CAPI/IR/IR.cpp                                | 2 ++
 mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp      | 6 ++++++
 mlir/lib/Conversion/IndexToSPIRV/IndexToSPIRV.cpp      | 2 ++
 mlir/lib/Debug/DebuggerExecutionContextHook.cpp        | 4 ++--
 mlir/lib/Dialect/AMDGPU/IR/AMDGPUDialect.cpp           | 2 +-
 mlir/lib/Dialect/ArmSME/Transforms/TileAllocation.cpp  | 2 ++
 mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp | 1 +
 mlir/lib/Dialect/Index/IR/IndexOps.cpp                 | 2 ++
 mlir/unittests/Bytecode/BytecodeTest.cpp               | 2 +-
 mlir/unittests/Support/CyclicReplacerCacheTest.cpp     | 3 ++-
 13 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h
index 59f094d6690991..1121de858aa632 100644
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -1593,7 +1593,8 @@ foldTrait(Operation *, ArrayRef<Attribute>, SmallVectorImpl<OpFoldResult> &) {
 /// Given a tuple type containing a set of traits, return the result of folding
 /// the given operation.
 template <typename... Ts>
-static LogicalResult foldTraits(Operation *op, ArrayRef<Attribute> operands,
+static LogicalResult foldTraits([[maybe_unused]] Operation *op,
+                                [[maybe_unused]] ArrayRef<Attribute> operands,
                                 SmallVectorImpl<OpFoldResult> &results) {
   return success((succeeded(foldTrait<Ts>(op, operands, results)) || ...));
 }
@@ -1629,7 +1630,7 @@ verifyTrait(Operation *) {
 
 /// Given a set of traits, return the result of verifying the given operation.
 template <typename... Ts>
-LogicalResult verifyTraits(Operation *op) {
+LogicalResult verifyTraits([[maybe_unused]] Operation *op) {
   return success((succeeded(verifyTrait<Ts>(op)) && ...));
 }
 
@@ -1649,7 +1650,7 @@ verifyRegionTrait(Operation *) {
 /// Given a set of traits, return the result of verifying the regions of the
 /// given operation.
 template <typename... Ts>
-LogicalResult verifyRegionTraits(Operation *op) {
+LogicalResult verifyRegionTraits([[maybe_unused]] Operation *op) {
   return success((succeeded(verifyRegionTrait<Ts>(op)) && ...));
 }
 } // namespace op_definition_impl
diff --git a/mlir/include/mlir/Pass/Pass.h b/mlir/include/mlir/Pass/Pass.h
index 7725a3a2910bd4..e7ed0a1ac61395 100644
--- a/mlir/include/mlir/Pass/Pass.h
+++ b/mlir/include/mlir/Pass/Pass.h
@@ -94,6 +94,7 @@ class Pass {
     Option(Pass &parent, StringRef arg, Args &&...args)
         : detail::PassOptions::Option<DataType, OptionParser>(
               parent.passOptions, arg, std::forward<Args>(args)...) {}
+    Option &operator=(const Option &other) = default; // gcc11
     using detail::PassOptions::Option<DataType, OptionParser>::operator=;
   };
   /// This class represents a specific pass option that contains a list of
diff --git a/mlir/include/mlir/Query/Matcher/Marshallers.h b/mlir/include/mlir/Query/Matcher/Marshallers.h
index 6ed35ac0ddccc7..d230df042aed04 100644
--- a/mlir/include/mlir/Query/Matcher/Marshallers.h
+++ b/mlir/include/mlir/Query/Matcher/Marshallers.h
@@ -150,11 +150,10 @@ inline bool checkArgTypeAtIndex(llvm::StringRef matcherName,
 
 // Marshaller function for fixed number of arguments
 template <typename ReturnType, typename... ArgTypes, size_t... Is>
-static VariantMatcher
-matcherMarshallFixedImpl(void (*matcherFunc)(), llvm::StringRef matcherName,
-                         SourceRange nameRange,
-                         llvm::ArrayRef<ParserValue> args, Diagnostics *error,
-                         std::index_sequence<Is...>) {
+static VariantMatcher matcherMarshallFixedImpl(
+    void (*matcherFunc)(), [[maybe_unused]] llvm::StringRef matcherName,
+    SourceRange nameRange, llvm::ArrayRef<ParserValue> args, Diagnostics *error,
+    std::index_sequence<Is...>) {
   using FuncType = ReturnType (*)(ArgTypes...);
 
   // Check if the argument count matches the expected count
diff --git a/mlir/lib/CAPI/IR/IR.cpp b/mlir/lib/CAPI/IR/IR.cpp
index 5eb531b70aee05..eb057bcc9d5e56 100644
--- a/mlir/lib/CAPI/IR/IR.cpp
+++ b/mlir/lib/CAPI/IR/IR.cpp
@@ -736,6 +736,8 @@ static mlir::WalkResult unwrap(MlirWalkResult result) {
   case MlirWalkResultSkip:
     return mlir::WalkResult::skip();
   }
+  assert("unknown result in WalkResult::unwrap" == nullptr);
+  return {};
 }
 
 void mlirOperationWalk(MlirOperation op, MlirOperationWalkCallback callback,
diff --git a/mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp b/mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp
index f1fa411b82914a..c8e10bc669bb6a 100644
--- a/mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp
+++ b/mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp
@@ -81,6 +81,8 @@ static Operation *createLoadTileSliceIntrinsic(
       break;
     }
   }
+  assert("unknown type in createLoadTileSliceIntrinsic" == nullptr);
+  return nullptr;
 }
 
 /// Helper to create an arm_sme.intr.st1*.(horiz|vert)' intrinsic.
@@ -125,6 +127,8 @@ static Operation *createStoreTileSliceIntrinsic(
           loc, maskOp, ptr, tileId, tileSliceI32);
     }
   }
+  assert("unknown type in createStoreTileSliceIntrinsic" == nullptr);
+  return nullptr;
 }
 
 IntegerAttr getTileIdOrError(arm_sme::ArmSMETileOpInterface op) {
@@ -850,6 +854,8 @@ struct StreamingVLOpConversion
       case arm_sme::TypeSize::Double:
         return rewriter.create<arm_sme::aarch64_sme_cntsd>(loc, i64Type);
       }
+      assert("unknown type in StreamingVLOpConversion" == nullptr);
+      return nullptr;
     }();
     rewriter.replaceOpWithNewOp<arith::IndexCastOp>(
         streamingVlOp, rewriter.getIndexType(), intrOp->getResult(0));
diff --git a/mlir/lib/Conversion/IndexToSPIRV/IndexToSPIRV.cpp b/mlir/lib/Conversion/IndexToSPIRV/IndexToSPIRV.cpp
index b4cc8324883eeb..f2197d17a5edcb 100644
--- a/mlir/lib/Conversion/IndexToSPIRV/IndexToSPIRV.cpp
+++ b/mlir/lib/Conversion/IndexToSPIRV/IndexToSPIRV.cpp
@@ -310,6 +310,8 @@ struct ConvertIndexCmpPattern final : OpConversionPattern<CmpOp> {
     case IndexCmpPredicate::ULT:
       return rewriteCmpOp<spirv::ULessThanOp>(op, adaptor, rewriter);
     }
+    assert("Unknown predicate in ConvertIndexCmpPattern" == nullptr);
+    return failure();
   }
 };
 
diff --git a/mlir/lib/Debug/DebuggerExecutionContextHook.cpp b/mlir/lib/Debug/DebuggerExecutionContextHook.cpp
index 744a0380ec710b..342888cc9cbcbe 100644
--- a/mlir/lib/Debug/DebuggerExecutionContextHook.cpp
+++ b/mlir/lib/Debug/DebuggerExecutionContextHook.cpp
@@ -301,7 +301,7 @@ void mlirDebuggerAddFileLineColLocBreakpoint(const char *file, int line,
 
 LLVM_ATTRIBUTE_NOINLINE void mlirDebuggerBreakpointHook() {
   static LLVM_THREAD_LOCAL void *volatile sink;
-  sink = (void *)&sink;
+  sink = (void *)const_cast<void **>(&sink);
 }
 
 static void preventLinkerDeadCodeElim() {
@@ -321,7 +321,7 @@ static void preventLinkerDeadCodeElim() {
     sink = (void *)mlirDebuggerAddTagBreakpoint;
     sink = (void *)mlirDebuggerAddRewritePatternBreakpoint;
     sink = (void *)mlirDebuggerAddFileLineColLocBreakpoint;
-    sink = (void *)&sink;
+    sink = (void *)const_cast<void **>(&sink);
     return true;
   }();
   (void)initialized;
diff --git a/mlir/lib/Dialect/AMDGPU/IR/AMDGPUDialect.cpp b/mlir/lib/Dialect/AMDGPU/IR/AMDGPUDialect.cpp
index 63447baa31eb0c..492e4781f57810 100644
--- a/mlir/lib/Dialect/AMDGPU/IR/AMDGPUDialect.cpp
+++ b/mlir/lib/Dialect/AMDGPU/IR/AMDGPUDialect.cpp
@@ -349,7 +349,7 @@ LogicalResult DPPOp::verify() {
       return emitOpError("quad_perm attribute must have exactly 4 elements");
     }
     for (auto elem : quadPermAttr.getAsRange<IntegerAttr>()) {
-      uint32_t num = elem.getInt();
+      int32_t num = elem.getInt();
       if (num < 0 || num > 3) {
         return emitOpError(
             "Each element of quad_perm must be in the range [0, 3]");
diff --git a/mlir/lib/Dialect/ArmSME/Transforms/TileAllocation.cpp b/mlir/lib/Dialect/ArmSME/Transforms/TileAllocation.cpp
index 3a2042d23e5346..1ec0e3cd48863f 100644
--- a/mlir/lib/Dialect/ArmSME/Transforms/TileAllocation.cpp
+++ b/mlir/lib/Dialect/ArmSME/Transforms/TileAllocation.cpp
@@ -137,6 +137,8 @@ static ArrayRef<TileMask> getMasks(ArmSMETileType type) {
   case ArmSMETileType::ZAQ:
     return ZA_Q_MASKS;
   }
+  assert("unknown type in getMasks" == nullptr);
+  return {};
 }
 
 class TileAllocator {
diff --git a/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp b/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp
index 8c3e25355f6087..1db38232e77fe7 100644
--- a/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp
+++ b/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp
@@ -175,6 +175,7 @@ ArrayRef<BlockArgument> ParallelComputeFunctionArgs::lowerBounds() {
   return args.drop_front(2 + 1 * numLoops).take_front(numLoops);
 }
 
+[[maybe_unused]]
 ArrayRef<BlockArgument> ParallelComputeFunctionArgs::upperBounds() {
   return args.drop_front(2 + 2 * numLoops).take_front(numLoops);
 }
diff --git a/mlir/lib/Dialect/Index/IR/IndexOps.cpp b/mlir/lib/Dialect/Index/IR/IndexOps.cpp
index 42401dae217ce1..cb5f48f2d603ad 100644
--- a/mlir/lib/Dialect/Index/IR/IndexOps.cpp
+++ b/mlir/lib/Dialect/Index/IR/IndexOps.cpp
@@ -594,6 +594,8 @@ static bool compareSameArgs(IndexCmpPredicate pred) {
   case IndexCmpPredicate::ULT:
     return false;
   }
+  assert("unknown predicate in compareSameArgs" == nullptr);
+  return {};
 }
 
 OpFoldResult CmpOp::fold(FoldAdaptor adaptor) {
diff --git a/mlir/unittests/Bytecode/BytecodeTest.cpp b/mlir/unittests/Bytecode/BytecodeTest.cpp
index 0342f294f38d6d..baf5d5c650e309 100644
--- a/mlir/unittests/Bytecode/BytecodeTest.cpp
+++ b/mlir/unittests/Bytecode/BytecodeTest.cpp
@@ -54,7 +54,7 @@ TEST(Bytecode, MultiModuleWithResource) {
   constexpr size_t kAlignment = 0x20;
   size_t bufferSize = buffer.size();
   buffer.reserve(bufferSize + kAlignment - 1);
-  size_t pad = ~(uintptr_t)buffer.data() + 1 & kAlignment - 1;
+  size_t pad = (~(uintptr_t)buffer.data() + 1) & (kAlignment - 1);
   buffer.insert(0, pad, ' ');
   StringRef alignedBuffer(buffer.data() + pad, bufferSize);
 
diff --git a/mlir/unittests/Support/CyclicReplacerCacheTest.cpp b/mlir/unittests/Support/CyclicReplacerCacheTest.cpp
index 64a8ab72b69b7d..26f0709f7d8310 100644
--- a/mlir/unittests/Support/CyclicReplacerCacheTest.cpp
+++ b/mlir/unittests/Support/CyclicReplacerCacheTest.cpp
@@ -225,7 +225,8 @@ class CachedCyclicReplacerGraphReplacement : public ::testing::Test {
     /// Add a recursive-self-node, i.e. a duplicate of the original node that is
     /// meant to represent an indirection to it.
     std::pair<Node, int64_t> addRecursiveSelfNode(Graph::Node originalId) {
-      return {addNode(originalId, nextRecursionId), nextRecursionId++};
+      auto node = addNode(originalId, nextRecursionId);
+      return {node, nextRecursionId++};
     }
     void addEdge(Node src, Node sink) { connections.addEdge(src, sink); }
 

>From d5a9f3e54f42f18c8ae76b3f017cdcbe155b0e52 Mon Sep 17 00:00:00 2001
From: "Schlimbach, Frank" <frank.schlimbach at intel.com>
Date: Wed, 21 Aug 2024 15:35:55 +0200
Subject: [PATCH 02/13] using llvm_unreachable

---
 mlir/lib/CAPI/IR/IR.cpp                               | 3 +--
 mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp     | 9 +++------
 mlir/lib/Conversion/IndexToSPIRV/IndexToSPIRV.cpp     | 3 +--
 mlir/lib/Dialect/ArmSME/Transforms/TileAllocation.cpp | 3 +--
 mlir/lib/Dialect/Index/IR/IndexOps.cpp                | 3 +--
 5 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/mlir/lib/CAPI/IR/IR.cpp b/mlir/lib/CAPI/IR/IR.cpp
index eb057bcc9d5e56..e7e6b11c81b9d3 100644
--- a/mlir/lib/CAPI/IR/IR.cpp
+++ b/mlir/lib/CAPI/IR/IR.cpp
@@ -736,8 +736,7 @@ static mlir::WalkResult unwrap(MlirWalkResult result) {
   case MlirWalkResultSkip:
     return mlir::WalkResult::skip();
   }
-  assert("unknown result in WalkResult::unwrap" == nullptr);
-  return {};
+  llvm_unreachable("unknown result in WalkResult::unwrap");
 }
 
 void mlirOperationWalk(MlirOperation op, MlirOperationWalkCallback callback,
diff --git a/mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp b/mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp
index c8e10bc669bb6a..843110206d84e9 100644
--- a/mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp
+++ b/mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp
@@ -81,8 +81,7 @@ static Operation *createLoadTileSliceIntrinsic(
       break;
     }
   }
-  assert("unknown type in createLoadTileSliceIntrinsic" == nullptr);
-  return nullptr;
+  llvm_unreachable("unknown type in createLoadTileSliceIntrinsic");
 }
 
 /// Helper to create an arm_sme.intr.st1*.(horiz|vert)' intrinsic.
@@ -127,8 +126,7 @@ static Operation *createStoreTileSliceIntrinsic(
           loc, maskOp, ptr, tileId, tileSliceI32);
     }
   }
-  assert("unknown type in createStoreTileSliceIntrinsic" == nullptr);
-  return nullptr;
+  llvm_unreachable("unknown type in createStoreTileSliceIntrinsic");
 }
 
 IntegerAttr getTileIdOrError(arm_sme::ArmSMETileOpInterface op) {
@@ -854,8 +852,7 @@ struct StreamingVLOpConversion
       case arm_sme::TypeSize::Double:
         return rewriter.create<arm_sme::aarch64_sme_cntsd>(loc, i64Type);
       }
-      assert("unknown type in StreamingVLOpConversion" == nullptr);
-      return nullptr;
+      llvm_unreachable("unknown type in StreamingVLOpConversion");
     }();
     rewriter.replaceOpWithNewOp<arith::IndexCastOp>(
         streamingVlOp, rewriter.getIndexType(), intrOp->getResult(0));
diff --git a/mlir/lib/Conversion/IndexToSPIRV/IndexToSPIRV.cpp b/mlir/lib/Conversion/IndexToSPIRV/IndexToSPIRV.cpp
index f2197d17a5edcb..7c441830e1e3be 100644
--- a/mlir/lib/Conversion/IndexToSPIRV/IndexToSPIRV.cpp
+++ b/mlir/lib/Conversion/IndexToSPIRV/IndexToSPIRV.cpp
@@ -310,8 +310,7 @@ struct ConvertIndexCmpPattern final : OpConversionPattern<CmpOp> {
     case IndexCmpPredicate::ULT:
       return rewriteCmpOp<spirv::ULessThanOp>(op, adaptor, rewriter);
     }
-    assert("Unknown predicate in ConvertIndexCmpPattern" == nullptr);
-    return failure();
+    llvm_unreachable("Unknown predicate in ConvertIndexCmpPattern");
   }
 };
 
diff --git a/mlir/lib/Dialect/ArmSME/Transforms/TileAllocation.cpp b/mlir/lib/Dialect/ArmSME/Transforms/TileAllocation.cpp
index 1ec0e3cd48863f..84556fbefbc9ff 100644
--- a/mlir/lib/Dialect/ArmSME/Transforms/TileAllocation.cpp
+++ b/mlir/lib/Dialect/ArmSME/Transforms/TileAllocation.cpp
@@ -137,8 +137,7 @@ static ArrayRef<TileMask> getMasks(ArmSMETileType type) {
   case ArmSMETileType::ZAQ:
     return ZA_Q_MASKS;
   }
-  assert("unknown type in getMasks" == nullptr);
-  return {};
+  llvm_unreachable("unknown type in getMasks");
 }
 
 class TileAllocator {
diff --git a/mlir/lib/Dialect/Index/IR/IndexOps.cpp b/mlir/lib/Dialect/Index/IR/IndexOps.cpp
index cb5f48f2d603ad..5ad989b7da126e 100644
--- a/mlir/lib/Dialect/Index/IR/IndexOps.cpp
+++ b/mlir/lib/Dialect/Index/IR/IndexOps.cpp
@@ -594,8 +594,7 @@ static bool compareSameArgs(IndexCmpPredicate pred) {
   case IndexCmpPredicate::ULT:
     return false;
   }
-  assert("unknown predicate in compareSameArgs" == nullptr);
-  return {};
+  llvm_unreachable("unknown predicate in compareSameArgs");
 }
 
 OpFoldResult CmpOp::fold(FoldAdaptor adaptor) {

>From bf654a04ac21cec62442661b8abe7eeaa13cf6fc Mon Sep 17 00:00:00 2001
From: Frank Schlimbach <frank.schlimbach at intel.com>
Date: Wed, 21 Aug 2024 19:07:25 +0200
Subject: [PATCH 03/13] Update
 mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp

Co-authored-by: Benjamin Maxwell <macdue at dueutil.tech>
---
 mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp b/mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp
index 843110206d84e9..40a3489f7a4d7b 100644
--- a/mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp
+++ b/mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp
@@ -852,7 +852,7 @@ struct StreamingVLOpConversion
       case arm_sme::TypeSize::Double:
         return rewriter.create<arm_sme::aarch64_sme_cntsd>(loc, i64Type);
       }
-      llvm_unreachable("unknown type in StreamingVLOpConversion");
+      llvm_unreachable("unknown type size in StreamingVLOpConversion");
     }();
     rewriter.replaceOpWithNewOp<arith::IndexCastOp>(
         streamingVlOp, rewriter.getIndexType(), intrOp->getResult(0));

>From c0a90f177365639b56aaf9525b16414fbba0151e Mon Sep 17 00:00:00 2001
From: "Schlimbach, Frank" <frank.schlimbach at intel.com>
Date: Fri, 23 Aug 2024 09:57:22 +0200
Subject: [PATCH 04/13] fixed braces

---
 mlir/include/mlir/Pass/Pass.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mlir/include/mlir/Pass/Pass.h b/mlir/include/mlir/Pass/Pass.h
index e7ed0a1ac61395..00d2c2dfbd76db 100644
--- a/mlir/include/mlir/Pass/Pass.h
+++ b/mlir/include/mlir/Pass/Pass.h
@@ -94,7 +94,7 @@ class Pass {
     Option(Pass &parent, StringRef arg, Args &&...args)
         : detail::PassOptions::Option<DataType, OptionParser>(
               parent.passOptions, arg, std::forward<Args>(args)...) {}
-    Option &operator=(const Option &other) = default; // gcc11
+    Option &operator=(const Option &other) = default; // gcc11 -Wdeprecated-copy
     using detail::PassOptions::Option<DataType, OptionParser>::operator=;
   };
   /// This class represents a specific pass option that contains a list of

>From 7cb6abdc6fc095cfdd92e93d14db8141644aa65a Mon Sep 17 00:00:00 2001
From: "Schlimbach, Frank" <frank.schlimbach at intel.com>
Date: Fri, 23 Aug 2024 10:06:29 +0200
Subject: [PATCH 05/13] (void *) -> static_cast<void *>(...)

---
 mlir/lib/Debug/DebuggerExecutionContextHook.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mlir/lib/Debug/DebuggerExecutionContextHook.cpp b/mlir/lib/Debug/DebuggerExecutionContextHook.cpp
index 342888cc9cbcbe..863113928d5b4f 100644
--- a/mlir/lib/Debug/DebuggerExecutionContextHook.cpp
+++ b/mlir/lib/Debug/DebuggerExecutionContextHook.cpp
@@ -301,7 +301,7 @@ void mlirDebuggerAddFileLineColLocBreakpoint(const char *file, int line,
 
 LLVM_ATTRIBUTE_NOINLINE void mlirDebuggerBreakpointHook() {
   static LLVM_THREAD_LOCAL void *volatile sink;
-  sink = (void *)const_cast<void **>(&sink);
+  sink = static_cast<void *>(const_cast<void **>(&sink));
 }
 
 static void preventLinkerDeadCodeElim() {
@@ -321,7 +321,7 @@ static void preventLinkerDeadCodeElim() {
     sink = (void *)mlirDebuggerAddTagBreakpoint;
     sink = (void *)mlirDebuggerAddRewritePatternBreakpoint;
     sink = (void *)mlirDebuggerAddFileLineColLocBreakpoint;
-    sink = (void *)const_cast<void **>(&sink);
+    sink = static_cast<void *>(const_cast<void **>(&sink));
     return true;
   }();
   (void)initialized;

>From 19c156bf5841e1893687edb50d62e8449f8a6d4c Mon Sep 17 00:00:00 2001
From: "Schlimbach, Frank" <frank.schlimbach at intel.com>
Date: Fri, 23 Aug 2024 10:40:20 +0200
Subject: [PATCH 06/13] -Wno-unused-but-set-parameter for gcc<14; no
 [[maybe-unused]] for related cases

---
 mlir/CMakeLists.txt                 | 2 +-
 mlir/include/mlir/IR/OpDefinition.h | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index c6d44908a1111d..ec82383b1b3206 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -88,7 +88,7 @@ append_if(C_SUPPORTS_WERROR_MISMATCHED_TAGS "-Werror=mismatched-tags" CMAKE_CXX_
 # cases, by marking SelectedCase as used. See
 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85827 for details. The issue is
 # fixed in GCC 10.
-if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "10.0")
+if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "14.0")
   check_cxx_compiler_flag("-Wno-unused-but-set-parameter" CXX_SUPPORTS_WNO_UNUSED_BUT_SET_PARAMETER)
   append_if(CXX_SUPPORTS_WNO_UNUSED_BUT_SET_PARAMETER "-Wno-unused-but-set-parameter" CMAKE_CXX_FLAGS)
 endif()
diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h
index 1121de858aa632..f6f50a6f024e5c 100644
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -1593,8 +1593,7 @@ foldTrait(Operation *, ArrayRef<Attribute>, SmallVectorImpl<OpFoldResult> &) {
 /// Given a tuple type containing a set of traits, return the result of folding
 /// the given operation.
 template <typename... Ts>
-static LogicalResult foldTraits([[maybe_unused]] Operation *op,
-                                [[maybe_unused]] ArrayRef<Attribute> operands,
+static LogicalResult foldTraits(Operation *op, ArrayRef<Attribute> operands,
                                 SmallVectorImpl<OpFoldResult> &results) {
   return success((succeeded(foldTrait<Ts>(op, operands, results)) || ...));
 }
@@ -1650,7 +1649,7 @@ verifyRegionTrait(Operation *) {
 /// Given a set of traits, return the result of verifying the regions of the
 /// given operation.
 template <typename... Ts>
-LogicalResult verifyRegionTraits([[maybe_unused]] Operation *op) {
+LogicalResult verifyRegionTraits(Operation *op) {
   return success((succeeded(verifyRegionTrait<Ts>(op)) && ...));
 }
 } // namespace op_definition_impl

>From afab866cd8027e1846d44e44d8edb6a51e20f5e2 Mon Sep 17 00:00:00 2001
From: "Schlimbach, Frank" <frank.schlimbach at intel.com>
Date: Tue, 3 Sep 2024 16:31:25 +0200
Subject: [PATCH 07/13] rm [[maybe_unused]]

---
 mlir/include/mlir/Query/Matcher/Marshallers.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/mlir/include/mlir/Query/Matcher/Marshallers.h b/mlir/include/mlir/Query/Matcher/Marshallers.h
index d230df042aed04..6ed35ac0ddccc7 100644
--- a/mlir/include/mlir/Query/Matcher/Marshallers.h
+++ b/mlir/include/mlir/Query/Matcher/Marshallers.h
@@ -150,10 +150,11 @@ inline bool checkArgTypeAtIndex(llvm::StringRef matcherName,
 
 // Marshaller function for fixed number of arguments
 template <typename ReturnType, typename... ArgTypes, size_t... Is>
-static VariantMatcher matcherMarshallFixedImpl(
-    void (*matcherFunc)(), [[maybe_unused]] llvm::StringRef matcherName,
-    SourceRange nameRange, llvm::ArrayRef<ParserValue> args, Diagnostics *error,
-    std::index_sequence<Is...>) {
+static VariantMatcher
+matcherMarshallFixedImpl(void (*matcherFunc)(), llvm::StringRef matcherName,
+                         SourceRange nameRange,
+                         llvm::ArrayRef<ParserValue> args, Diagnostics *error,
+                         std::index_sequence<Is...>) {
   using FuncType = ReturnType (*)(ArgTypes...);
 
   // Check if the argument count matches the expected count

>From 26e77f5480768866df3e53a0f2dbaf969f6fdb0f Mon Sep 17 00:00:00 2001
From: "Schlimbach, Frank" <frank.schlimbach at intel.com>
Date: Tue, 3 Sep 2024 16:40:01 +0200
Subject: [PATCH 08/13] rm [[maybe_unused]]

---
 mlir/include/mlir/IR/OpDefinition.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h
index f6f50a6f024e5c..59f094d6690991 100644
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -1629,7 +1629,7 @@ verifyTrait(Operation *) {
 
 /// Given a set of traits, return the result of verifying the given operation.
 template <typename... Ts>
-LogicalResult verifyTraits([[maybe_unused]] Operation *op) {
+LogicalResult verifyTraits(Operation *op) {
   return success((succeeded(verifyTrait<Ts>(op)) && ...));
 }
 

>From e91882406dae65583c7ea0246a7451b5ea7ee071 Mon Sep 17 00:00:00 2001
From: "Schlimbach, Frank" <frank.schlimbach at intel.com>
Date: Tue, 3 Sep 2024 17:28:03 +0200
Subject: [PATCH 09/13] removing unused
 ParallelComputeFunctionArgs::upperBounds

---
 mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp b/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp
index 1db38232e77fe7..a5921e05777555 100644
--- a/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp
+++ b/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp
@@ -175,11 +175,6 @@ ArrayRef<BlockArgument> ParallelComputeFunctionArgs::lowerBounds() {
   return args.drop_front(2 + 1 * numLoops).take_front(numLoops);
 }
 
-[[maybe_unused]]
-ArrayRef<BlockArgument> ParallelComputeFunctionArgs::upperBounds() {
-  return args.drop_front(2 + 2 * numLoops).take_front(numLoops);
-}
-
 ArrayRef<BlockArgument> ParallelComputeFunctionArgs::steps() {
   return args.drop_front(2 + 3 * numLoops).take_front(numLoops);
 }

>From 86e2ad21d7d6e33a5c82ae84ef2ce6d13114fbbe Mon Sep 17 00:00:00 2001
From: "Schlimbach, Frank" <frank.schlimbach at intel.com>
Date: Tue, 3 Sep 2024 17:35:19 +0200
Subject: [PATCH 10/13] removing unused
 ParallelComputeFunctionArgs::upperBounds

---
 mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp b/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp
index a5921e05777555..273101ce5f3e78 100644
--- a/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp
+++ b/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp
@@ -141,7 +141,6 @@ struct ParallelComputeFunctionArgs {
   BlockArgument blockSize();
   ArrayRef<BlockArgument> tripCounts();
   ArrayRef<BlockArgument> lowerBounds();
-  ArrayRef<BlockArgument> upperBounds();
   ArrayRef<BlockArgument> steps();
   ArrayRef<BlockArgument> captures();
 

>From 3bb728d47205f3818a88f023e5b2554e74069781 Mon Sep 17 00:00:00 2001
From: "Schlimbach, Frank" <frank.schlimbach at intel.com>
Date: Fri, 13 Sep 2024 09:54:15 +0200
Subject: [PATCH 11/13] silencing gcc false positive warning, rebased

---
 llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp |  2 +-
 mlir/CMakeLists.txt                        | 21 ++++++++++++++-------
 mlir/include/mlir/Pass/Pass.h              |  1 -
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 3a8cde7330efc0..4ec3cb4f0937b8 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -2849,7 +2849,7 @@ void AsmPrinter::emitJumpTableSizesSection(const MachineJumpTableInfo *MJTI,
 
   if (isElf) {
     MCSymbolELF *LinkedToSym = dyn_cast<MCSymbolELF>(CurrentFnSym);
-    int Flags = F.hasComdat() ? ELF::SHF_GROUP : 0;
+    int Flags = F.hasComdat() ? (int)ELF::SHF_GROUP : 0;
 
     JumpTableSizesSection = OutContext.getELFSection(
         sectionName, ELF::SHT_LLVM_JT_SIZES, Flags, 0, GroupName, F.hasComdat(),
diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index ec82383b1b3206..599a1cbaafd855 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -84,13 +84,20 @@ check_c_compiler_flag("-Werror=mismatched-tags" C_SUPPORTS_WERROR_MISMATCHED_TAG
 append_if(C_SUPPORTS_WERROR_MISMATCHED_TAGS "-Werror=mismatched-tags" CMAKE_C_FLAGS)
 append_if(C_SUPPORTS_WERROR_MISMATCHED_TAGS "-Werror=mismatched-tags" CMAKE_CXX_FLAGS)
 
-# Silence a false positive GCC -Wunused-but-set-parameter warning in constexpr
-# cases, by marking SelectedCase as used. See
-# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85827 for details. The issue is
-# fixed in GCC 10.
-if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "14.0")
-  check_cxx_compiler_flag("-Wno-unused-but-set-parameter" CXX_SUPPORTS_WNO_UNUSED_BUT_SET_PARAMETER)
-  append_if(CXX_SUPPORTS_WNO_UNUSED_BUT_SET_PARAMETER "-Wno-unused-but-set-parameter" CMAKE_CXX_FLAGS)
+if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+  # Silence a false positive GCC -Wunused-but-set-parameter warning in
+  # constexpr cases. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85827
+  # for details
+  if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "14.0")
+    check_cxx_compiler_flag("-Wno-unused-but-set-parameter" CXX_SUPPORTS_WNO_UNUSED_BUT_SET_PARAMETER)
+    append_if(CXX_SUPPORTS_WNO_UNUSED_BUT_SET_PARAMETER "-Wno-unused-but-set-parameter" CMAKE_CXX_FLAGS)
+  endif()
+  # Silence a false positive GCC -Wdeprecated-copy warning in cases where
+  # a copy operator is defined through "using" a base class copy operator.
+  if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "12.0")
+    check_cxx_compiler_flag("-Wno-deprecated-copy" CXX_SUPPORTS_WNO_DEPRECTAED_COPY)
+    append_if(CXX_SUPPORTS_WNO_DEPRECTAED_COPY "-Wno-deprecated-copy" CMAKE_CXX_FLAGS)
+  endif()
 endif()
 
 # Installing the headers and docs needs to depend on generating any public
diff --git a/mlir/include/mlir/Pass/Pass.h b/mlir/include/mlir/Pass/Pass.h
index 00d2c2dfbd76db..7725a3a2910bd4 100644
--- a/mlir/include/mlir/Pass/Pass.h
+++ b/mlir/include/mlir/Pass/Pass.h
@@ -94,7 +94,6 @@ class Pass {
     Option(Pass &parent, StringRef arg, Args &&...args)
         : detail::PassOptions::Option<DataType, OptionParser>(
               parent.passOptions, arg, std::forward<Args>(args)...) {}
-    Option &operator=(const Option &other) = default; // gcc11 -Wdeprecated-copy
     using detail::PassOptions::Option<DataType, OptionParser>::operator=;
   };
   /// This class represents a specific pass option that contains a list of

>From 616a4433168e0ff12543700c578a0b1ad2d1cab1 Mon Sep 17 00:00:00 2001
From: "Schlimbach, Frank" <frank.schlimbach at intel.com>
Date: Tue, 17 Sep 2024 10:44:26 +0200
Subject: [PATCH 12/13] static_cast

---
 llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 2 +-
 llvm/lib/Target/X86/X86ISelLowering.cpp    | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 4ec3cb4f0937b8..bf4c707cca06d5 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -2849,7 +2849,7 @@ void AsmPrinter::emitJumpTableSizesSection(const MachineJumpTableInfo *MJTI,
 
   if (isElf) {
     MCSymbolELF *LinkedToSym = dyn_cast<MCSymbolELF>(CurrentFnSym);
-    int Flags = F.hasComdat() ? (int)ELF::SHF_GROUP : 0;
+    int Flags = F.hasComdat() ? static_cast<int>(ELF::SHF_GROUP) : 0;
 
     JumpTableSizesSection = OutContext.getELFSection(
         sectionName, ELF::SHT_LLVM_JT_SIZES, Flags, 0, GroupName, F.hasComdat(),
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index ff66eb15508c16..838398c15cdc26 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -29986,8 +29986,14 @@ static SDValue LowerShift(SDValue Op, const X86Subtarget &Subtarget,
           MVT::getVectorVT(NarrowScalarVT, WideNumElts), dl, AmtWideElts);
       AmtWide = DAG.getZExtOrTrunc(AmtWide, dl, WideVT);
       // Perform the actual shift.
+<<<<<<< HEAD
       unsigned LogicalOpc = Opc == ISD::SRA ? ISD::SRL : Opc;
       SDValue ShiftedR = DAG.getNode(LogicalOpc, dl, WideVT, RWide, AmtWide);
+=======
+      unsigned LogicalOpc =
+          Opc == ISD::SRA ? static_cast<unsigned>(ISD::SRL) : Opc;
+      SDValue ShiftedR = DAG.getNode(LogicalOpc, dl, VT16, R16, Amt16);
+>>>>>>> ae2283c2c014 (static_cast)
       // Now we need to construct a mask which will "drop" bits that get
       // shifted past the LSB/MSB. For a logical shift left, it will look
       // like:

>From 9d8f8e1614c8a27612bd1331e63f618844433391 Mon Sep 17 00:00:00 2001
From: "Schlimbach, Frank" <frank.schlimbach at intel.com>
Date: Fri, 27 Sep 2024 09:44:13 +0200
Subject: [PATCH 13/13] rebasing

---
 llvm/lib/Target/X86/X86FastISel.cpp                  |  4 +++-
 llvm/lib/Target/X86/X86ISelLowering.cpp              |  7 +------
 mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp |  2 +-
 mlir/lib/Transforms/Utils/DialectConversion.cpp      | 10 ++++------
 4 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp
index 4bf660b5e234ae..075257cf3a01c0 100644
--- a/llvm/lib/Target/X86/X86FastISel.cpp
+++ b/llvm/lib/Target/X86/X86FastISel.cpp
@@ -3544,7 +3544,9 @@ bool X86FastISel::fastLowerCall(CallLoweringInfo &CLI) {
 
     MIB = BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD, TII.get(CallOpc));
     if (NeedLoad)
-      MIB.addReg(Is64Bit ? X86::RIP : 0).addImm(1).addReg(0);
+      MIB.addReg(Is64Bit ? static_cast<unsigned>(X86::RIP) : 0U)
+          .addImm(1)
+          .addReg(0);
     if (Symbol)
       MIB.addSym(Symbol, OpFlags);
     else
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 838398c15cdc26..59a2bf78c2c7a1 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -29986,14 +29986,9 @@ static SDValue LowerShift(SDValue Op, const X86Subtarget &Subtarget,
           MVT::getVectorVT(NarrowScalarVT, WideNumElts), dl, AmtWideElts);
       AmtWide = DAG.getZExtOrTrunc(AmtWide, dl, WideVT);
       // Perform the actual shift.
-<<<<<<< HEAD
-      unsigned LogicalOpc = Opc == ISD::SRA ? ISD::SRL : Opc;
-      SDValue ShiftedR = DAG.getNode(LogicalOpc, dl, WideVT, RWide, AmtWide);
-=======
       unsigned LogicalOpc =
           Opc == ISD::SRA ? static_cast<unsigned>(ISD::SRL) : Opc;
-      SDValue ShiftedR = DAG.getNode(LogicalOpc, dl, VT16, R16, Amt16);
->>>>>>> ae2283c2c014 (static_cast)
+      SDValue ShiftedR = DAG.getNode(LogicalOpc, dl, WideVT, RWide, AmtWide);
       // Now we need to construct a mask which will "drop" bits that get
       // shifted past the LSB/MSB. For a logical shift left, it will look
       // like:
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
index d39c5fcdbc4286..73e24cba826acc 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
@@ -864,7 +864,7 @@ static uint64_t getTrailingNonUnitLoopDimIdx(LinalgOp linalgOp) {
       "For statically shaped Linalg Ops, only one "
       "non-unit loop dim is expected");
 
-  size_t idx = loopRanges.size() - 1;
+  ssize_t idx = loopRanges.size() - 1;
   for (; idx >= 0; idx--)
     if (loopRanges[idx] != 1)
       break;
diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index 1baddd881f6aa2..b8d0329906a867 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -1045,9 +1045,8 @@ UnresolvedMaterializationRewrite::UnresolvedMaterializationRewrite(
     const TypeConverter *converter, MaterializationKind kind, Type originalType)
     : OperationRewrite(Kind::UnresolvedMaterialization, rewriterImpl, op),
       converterAndKind(converter, kind), originalType(originalType) {
-  assert(!originalType ||
-         kind == MaterializationKind::Target &&
-             "original type is valid only for target materializations");
+  assert((!originalType || kind == MaterializationKind::Target) &&
+         "original type is valid only for target materializations");
   rewriterImpl.unresolvedMaterializations[op] = this;
 }
 
@@ -1337,9 +1336,8 @@ Value ConversionPatternRewriterImpl::buildUnresolvedMaterialization(
     MaterializationKind kind, OpBuilder::InsertPoint ip, Location loc,
     ValueRange inputs, Type outputType, Type originalType,
     const TypeConverter *converter) {
-  assert(!originalType ||
-         kind == MaterializationKind::Target &&
-             "original type is valid only for target materializations");
+  assert((!originalType || kind == MaterializationKind::Target) &&
+         "original type is valid only for target materializations");
 
   // Avoid materializing an unnecessary cast.
   if (inputs.size() == 1 && inputs.front().getType() == outputType)



More information about the Mlir-commits mailing list