Fix lingering sign compare warnings in exposed by "ninja check-mlir".
authorStella Laurenzo <laurenzo@google.com>
Tue, 14 May 2019 01:10:48 +0000 (18:10 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Mon, 20 May 2019 20:41:11 +0000 (13:41 -0700)
--

PiperOrigin-RevId: 248050178

mlir/examples/Linalg/Linalg1/lib/ConvertToLLVMDialect.cpp
mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp
mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp
mlir/lib/IR/Attributes.cpp
mlir/lib/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Linalg/Transforms/Tiling.cpp
mlir/lib/Parser/Parser.cpp
mlir/lib/Transforms/LoopFusion.cpp

index 02c82d7..8117aed 100644 (file)
@@ -210,7 +210,7 @@ public:
     // dimensions, extracts the size from the memref descriptor.
     auto memrefSize = [int64Ty, pos, i64cst](MemRefType type, Value *memref,
                                              int dim) -> Value * {
-      assert(dim < type.getRank());
+      assert(static_cast<size_t>(dim) < type.getRank());
       if (type.getShape()[dim] != -1) {
         return i64cst(type.getShape()[dim]);
       }
index 5f024ea..907e3f1 100644 (file)
@@ -189,7 +189,7 @@ public:
       // FIXME: this seems like a bug in `cloneInto()` above?
       auto &entryBlock = f->getBlocks().front();
       int blockArgSize = entryBlock.getArguments().size();
-      assert(blockArgSize == f->getType().getInputs().size());
+      assert(blockArgSize == static_cast<int>(f->getType().getInputs().size()));
       entryBlock.addArguments(f->getType().getInputs());
       auto argList = entryBlock.getArguments();
       for (int argNum = 0; argNum < blockArgSize; ++argNum) {
index ab99019..5267586 100644 (file)
@@ -189,7 +189,7 @@ public:
       // FIXME: this seems like a bug in `cloneInto()` above?
       auto &entryBlock = f->getBlocks().front();
       int blockArgSize = entryBlock.getArguments().size();
-      assert(blockArgSize == f->getType().getInputs().size());
+      assert(blockArgSize == static_cast<int>(f->getType().getInputs().size()));
       entryBlock.addArguments(f->getType().getInputs());
       auto argList = entryBlock.getArguments();
       for (int argNum = 0; argNum < blockArgSize; ++argNum) {
index 47a4438..fad12a8 100644 (file)
@@ -340,7 +340,8 @@ APInt DenseElementsAttr::RawElementIterator::operator*() const {
 
 DenseElementsAttr DenseElementsAttr::get(VectorOrTensorType type,
                                          ArrayRef<char> data) {
-  assert((type.getSizeInBits() <= data.size() * APInt::APINT_WORD_SIZE) &&
+  assert((static_cast<uint64_t>(type.getSizeInBits()) <=
+          data.size() * APInt::APINT_WORD_SIZE) &&
          "Input data bit size should be larger than that type requires");
   switch (type.getElementType().getKind()) {
   case StandardTypes::BF16:
index 3a8ead4..d8d72c2 100644 (file)
@@ -576,12 +576,14 @@ static LLVM::LLVMType getInsertExtractValueElementType(OpAsmParser *parser,
              nullptr;
     int position = positionElementAttr.getInt();
     if (llvmContainerType->isArrayTy()) {
-      if (position < 0 || position >= llvmContainerType->getArrayNumElements())
+      if (position < 0 || static_cast<unsigned>(position) >=
+                              llvmContainerType->getArrayNumElements())
         return parser->emitError(attributeLoc, "position out of bounds"),
                nullptr;
       llvmContainerType = llvmContainerType->getArrayElementType();
     } else if (llvmContainerType->isStructTy()) {
-      if (position < 0 || position >= llvmContainerType->getStructNumElements())
+      if (position < 0 || static_cast<unsigned>(position) >=
+                              llvmContainerType->getStructNumElements())
         return parser->emitError(attributeLoc, "position out of bounds"),
                nullptr;
       llvmContainerType = llvmContainerType->getStructElementType(position);
index f50076a..ba1fdbe 100644 (file)
@@ -189,9 +189,9 @@ static SmallVector<Value *, 4> makeTiledViews(FuncBuilder *b, Location loc,
                                               ArrayRef<Value *> ivs,
                                               ArrayRef<Value *> tileSizes,
                                               PerFunctionState &state) {
-  assert(ivs.size() == llvm::count_if(
+  assert(ivs.size() == static_cast<size_t>(llvm::count_if(
                            llvm::make_range(tileSizes.begin(), tileSizes.end()),
-                           [](Value *v) { return !isZero(v); }) &&
+                           [](Value *v) { return !isZero(v); })) &&
          "expected as many ivs as non-zero sizes");
   auto *context = op->getContext();
 
index 31b7766..0fef0cd 100644 (file)
@@ -3292,7 +3292,8 @@ public:
       break;
     }
 
-    if (requiredOperandCount != -1 && result.size() != requiredOperandCount)
+    if (requiredOperandCount != -1 &&
+        result.size() != static_cast<size_t>(requiredOperandCount))
       return emitError(startLoc, "expected ")
              << requiredOperandCount << " operands";
     return success();
index 8a0d63a..3a4d6a9 100644 (file)
@@ -39,6 +39,7 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
 #include <iomanip>
+#include <sstream>
 #define DEBUG_TYPE "affine-loop-fusion"
 
 using llvm::SetVector;