[Mlir-commits] [mlir] 66b1e62 - [mlir] Cleanup: Fix warnings in MLIR

Matthias Springer llvmlistbot at llvm.org
Thu Aug 5 18:36:53 PDT 2021


Author: Matthias Springer
Date: 2021-08-06T10:36:37+09:00
New Revision: 66b1e629d89543cb7542c184f7dfb32deee732e1

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

LOG: [mlir] Cleanup: Fix warnings in MLIR

Tested with gcc-10. Other compilers may generate additional warnings. This does not fix all warnings. There are a few extra ones in LLVMCore and MLIR.

* `OpEmitter::getAttrNameIndex`: -Wunused-function (function is private and not used anywhere)
* `PrintOpPass` copy constructor: -Wextra ("Base class should be explicitly initialized in the copy constructor")
* `LegalizeForLLVMExport.cpp`: -Woverflow (overflow is expected, silence warning by making the cast explicit)

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

Added: 
    

Modified: 
    mlir/lib/Dialect/X86Vector/Transforms/LegalizeForLLVMExport.cpp
    mlir/lib/Transforms/ViewOpGraph.cpp
    mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/X86Vector/Transforms/LegalizeForLLVMExport.cpp b/mlir/lib/Dialect/X86Vector/Transforms/LegalizeForLLVMExport.cpp
index 6cd028a13db0c..c2a7a19e1c46f 100644
--- a/mlir/lib/Dialect/X86Vector/Transforms/LegalizeForLLVMExport.cpp
+++ b/mlir/lib/Dialect/X86Vector/Transforms/LegalizeForLLVMExport.cpp
@@ -115,7 +115,7 @@ struct DotOpConversion : public ConvertOpToLLVMPattern<DotOp> {
     auto opType = adaptor.a().getType();
     Type llvmIntType = IntegerType::get(&getTypeConverter()->getContext(), 8);
     // Dot product of all elements, broadcasted to all elements.
-    auto attr = rewriter.getI8IntegerAttr(0xff);
+    auto attr = rewriter.getI8IntegerAttr(static_cast<int8_t>(0xff));
     Value scale =
         rewriter.create<LLVM::ConstantOp>(op.getLoc(), llvmIntType, attr);
     rewriter.replaceOpWithNewOp<DotIntrOp>(op, opType, adaptor.a(), adaptor.b(),

diff  --git a/mlir/lib/Transforms/ViewOpGraph.cpp b/mlir/lib/Transforms/ViewOpGraph.cpp
index 199c5a330090f..641df2859fb11 100644
--- a/mlir/lib/Transforms/ViewOpGraph.cpp
+++ b/mlir/lib/Transforms/ViewOpGraph.cpp
@@ -71,7 +71,7 @@ struct Node {
 class PrintOpPass : public ViewOpGraphPassBase<PrintOpPass> {
 public:
   PrintOpPass(raw_ostream &os) : os(os) {}
-  PrintOpPass(const PrintOpPass &o) : os(o.os.getOStream()) {}
+  PrintOpPass(const PrintOpPass &o) : PrintOpPass(o.os.getOStream()) {}
 
   void runOnOperation() override {
     emitGraph([&]() {

diff  --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index 1c630e03d3e3c..2a851618938b0 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -341,10 +341,6 @@ class OpEmitter {
   // Generate methods for accessing the attribute names of this operation.
   void genAttrNameGetters();
 
-  // Return the index of the given attribute name. This is a relative ordering
-  // for this name, used in attribute getters.
-  unsigned getAttrNameIndex(StringRef attrName) const;
-
   // Generates the OpAsmOpInterface for this operation if possible.
   void genOpAsmInterface();
 
@@ -750,13 +746,6 @@ void OpEmitter::genAttrNameGetters() {
   }
 }
 
-unsigned OpEmitter::getAttrNameIndex(StringRef attrName) const {
-  auto it = attributeNames.find(attrName);
-  assert(it != attributeNames.end() && "expected attribute name to have been "
-                                       "registered in genAttrNameGetters");
-  return it->second;
-}
-
 void OpEmitter::genAttrGetters() {
   FmtContext fctx;
   fctx.withBuilder("::mlir::Builder((*this)->getContext())");


        


More information about the Mlir-commits mailing list