[Mlir-commits] [mlir] dc3b936 - [mlir] Silence warnings when building with MSVC

Alexandre Ganea llvmlistbot at llvm.org
Sun Jan 30 14:31:46 PST 2022


Author: Alexandre Ganea
Date: 2022-01-30T17:31:35-05:00
New Revision: dc3b9365b66ea9900fe043429ab66221df08ec9e

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

LOG: [mlir] Silence warnings when building with MSVC

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

Added: 
    

Modified: 
    mlir/include/mlir/IR/EnumAttr.td
    mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
    mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp
    mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp
    mlir/lib/Parser/TypeParser.cpp
    mlir/unittests/ExecutionEngine/Invoke.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/EnumAttr.td b/mlir/include/mlir/IR/EnumAttr.td
index 0a493f923a5f1..ba0b0cfb36d47 100644
--- a/mlir/include/mlir/IR/EnumAttr.td
+++ b/mlir/include/mlir/IR/EnumAttr.td
@@ -28,7 +28,7 @@ class EnumParameter<EnumAttrInfo enumInfo>
                           enumInfo.stringToSymbolFnName # [{(enumKeyword);
     if (maybeEnum)
       return *maybeEnum;
-    return {$_parser.emitError(loc, "expected }] #
+    return {(::mlir::LogicalResult)$_parser.emitError(loc, "expected }] #
     cppType # [{ to be one of: }] #
     !interleave(!foreach(enum, enumInfo.enumerants, enum.str), ", ") # [{")};
   }()}];

diff  --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
index ba405f5ab1e98..8d98fb0a3a93b 100644
--- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
+++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
@@ -1624,7 +1624,7 @@ class ResizeConverter : public OpRewritePattern<tosa::ResizeOp> {
       }
 
       auto unitVal = rewriter.create<arith::ConstantOp>(
-          loc, rewriter.getIntegerAttr(resultElementTy, 1 << shift));
+          loc, rewriter.getIntegerAttr(resultElementTy, 1LL << shift));
       Value rightPart = dx;
       Value leftPart = rewriter.create<arith::SubIOp>(loc, unitVal, dx);
 

diff  --git a/mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp b/mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp
index 81c8772cc2063..ddb5bcd7ebeb9 100644
--- a/mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp
+++ b/mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp
@@ -241,6 +241,7 @@ struct GpuAllReduceRewriter {
                  : getCmpFactory<arith::CmpIOp, arith::CmpIPredicate,
                                  arith::CmpIPredicate::ult>();
     }
+    llvm_unreachable("unknown GPU AllReduceOperation");
   }
 
   /// Returns an accumulator factory that creates an op of type T.

diff  --git a/mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp b/mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp
index 6e49d065f8d41..89dbf64fc5b57 100644
--- a/mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp
+++ b/mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp
@@ -314,10 +314,10 @@ AtanApproximation::matchAndRewrite(math::AtanOp op,
 
   // Perform the Taylor series approximation for atan over the range
   // [-1.0, 1.0].
-  auto n1 = broadcast(builder, f32Cst(builder, 0.14418283), shape);
-  auto n2 = broadcast(builder, f32Cst(builder, -0.34999234), shape);
-  auto n3 = broadcast(builder, f32Cst(builder, -0.01067831), shape);
-  auto n4 = broadcast(builder, f32Cst(builder, 1.00209986), shape);
+  auto n1 = broadcast(builder, f32Cst(builder, 0.14418283f), shape);
+  auto n2 = broadcast(builder, f32Cst(builder, -0.34999234f), shape);
+  auto n3 = broadcast(builder, f32Cst(builder, -0.01067831f), shape);
+  auto n4 = broadcast(builder, f32Cst(builder, 1.00209986f), shape);
 
   Value p = builder.create<math::FmaOp>(x, n1, n2);
   p = builder.create<math::FmaOp>(x, p, n3);
@@ -388,7 +388,7 @@ Atan2Approximation::matchAndRewrite(math::Atan2Op op,
   Value yLt = builder.create<arith::CmpFOp>(arith::CmpFPredicate::OLT, y, zero);
   Value isNegativeHalfPiPi = builder.create<arith::AndIOp>(xZero, yLt);
   auto negativeHalfPiPi =
-      broadcast(builder, f32Cst(builder, -1.57079632679), shape);
+      broadcast(builder, f32Cst(builder, -1.57079632679f), shape);
   result =
       builder.create<SelectOp>(isNegativeHalfPiPi, negativeHalfPiPi, result);
 
@@ -1063,8 +1063,8 @@ LogicalResult SinAndCosApproximation<isSine, OpTy>::matchAndRewrite(
     return builder.create<arith::OrIOp>(a, b);
   };
 
-  Value twoOverPi = bcast(f32Cst(builder, TWO_OVER_PI));
-  Value piOverTwo = bcast(f32Cst(builder, PI_OVER_2));
+  Value twoOverPi = bcast(f32Cst(builder, (float)TWO_OVER_PI));
+  Value piOverTwo = bcast(f32Cst(builder, (float)PI_OVER_2));
 
   Value x = op.getOperand();
 

diff  --git a/mlir/lib/Parser/TypeParser.cpp b/mlir/lib/Parser/TypeParser.cpp
index 533ed6b4a5d49..c4699ee5b7290 100644
--- a/mlir/lib/Parser/TypeParser.cpp
+++ b/mlir/lib/Parser/TypeParser.cpp
@@ -570,7 +570,8 @@ ParseResult Parser::parseIntegerInDimensionList(int64_t &value) {
   } else {
     // Make sure this integer value is in bound and valid.
     Optional<uint64_t> dimension = getToken().getUInt64IntegerValue();
-    if (!dimension || *dimension > std::numeric_limits<int64_t>::max())
+    if (!dimension ||
+        *dimension > (uint64_t)std::numeric_limits<int64_t>::max())
       return emitError("invalid dimension");
     value = (int64_t)dimension.getValue();
     consumeToken(Token::integer);

diff  --git a/mlir/unittests/ExecutionEngine/Invoke.cpp b/mlir/unittests/ExecutionEngine/Invoke.cpp
index 00fdeb59e63e5..68b9f876492a9 100644
--- a/mlir/unittests/ExecutionEngine/Invoke.cpp
+++ b/mlir/unittests/ExecutionEngine/Invoke.cpp
@@ -31,6 +31,9 @@
 
 using namespace mlir;
 
+// The JIT isn't supported on Windows at that time
+#ifndef _WIN32
+
 static struct LLVMInitializer {
   LLVMInitializer() {
     llvm::InitializeNativeTarget();
@@ -49,9 +52,6 @@ static LogicalResult lowerToLLVMDialect(ModuleOp module) {
   return pm.run(module);
 }
 
-// The JIT isn't supported on Windows at that time
-#ifndef _WIN32
-
 TEST(MLIRExecutionEngine, AddInteger) {
   std::string moduleStr = R"mlir(
   func @foo(%arg0 : i32) -> i32 attributes { llvm.emit_c_interface } {


        


More information about the Mlir-commits mailing list