Unify error messages to start with lower-case.

PiperOrigin-RevId: 269803466
diff --git a/examples/toy/Ch2/mlir/MLIRGen.cpp b/examples/toy/Ch2/mlir/MLIRGen.cpp
index 6f29490..ab5a584 100644
--- a/examples/toy/Ch2/mlir/MLIRGen.cpp
+++ b/examples/toy/Ch2/mlir/MLIRGen.cpp
@@ -84,7 +84,7 @@
     // this won't do much, but it should at least check some structural
     // properties of the generated MLIR module.
     if (failed(mlir::verify(theModule))) {
-      theModule.emitError("Module verification error");
+      theModule.emitError("module verification error");
       return nullptr;
     }
 
@@ -224,7 +224,7 @@
       op_name = "toy.mul";
       break;
     default:
-      emitError(location, "Error: invalid binary operator '")
+      emitError(location, "error: invalid binary operator '")
           << binop.getOp() << "'";
       return nullptr;
     }
@@ -244,7 +244,7 @@
     if (auto *variable = symbolTable.lookup(expr.getName()))
       return variable;
 
-    emitError(loc(expr.loc()), "Error: unknown variable '")
+    emitError(loc(expr.loc()), "error: unknown variable '")
         << expr.getName() << "'";
     return nullptr;
   }
@@ -413,7 +413,7 @@
     auto init = vardecl.getInitVal();
     if (!init) {
       emitError(loc(vardecl.loc()),
-                "Missing initializer in variable declaration");
+                "missing initializer in variable declaration");
       return nullptr;
     }
 
diff --git a/examples/toy/Ch3/mlir/MLIRGen.cpp b/examples/toy/Ch3/mlir/MLIRGen.cpp
index 572f0ee..9bd3fa6 100644
--- a/examples/toy/Ch3/mlir/MLIRGen.cpp
+++ b/examples/toy/Ch3/mlir/MLIRGen.cpp
@@ -85,7 +85,7 @@
     // this won't do much, but it should at least check some structural
     // properties.
     if (failed(mlir::verify(*theModule))) {
-      emitError(mlir::UnknownLoc::get(&context), "Module verification error");
+      emitError(mlir::UnknownLoc::get(&context), "module verification error");
       return nullptr;
     }
 
@@ -223,7 +223,7 @@
     case '*':
       return builder->create<MulOp>(location, L, R).getResult();
     default:
-      emitError(loc(binop.loc()), "Error: invalid binary operator '")
+      emitError(loc(binop.loc()), "error: invalid binary operator '")
           << binop.getOp() << "'";
       return nullptr;
     }
@@ -235,7 +235,7 @@
   mlir::Value *mlirGen(VariableExprAST &expr) {
     if (symbolTable.count(expr.getName()))
       return symbolTable.lookup(expr.getName());
-    emitError(loc(expr.loc()), "Error: unknown variable '")
+    emitError(loc(expr.loc()), "error: unknown variable '")
         << expr.getName() << "'";
     return nullptr;
   }
@@ -413,7 +413,7 @@
       }
     } else {
       emitError(loc(vardecl.loc()),
-                "Missing initializer in variable declaration");
+                "missing initializer in variable declaration");
       return nullptr;
     }
     // Register the value in the symbol table
diff --git a/examples/toy/Ch3/mlir/ToyDialect.cpp b/examples/toy/Ch3/mlir/ToyDialect.cpp
index b682dbc..7272ea2 100644
--- a/examples/toy/Ch3/mlir/ToyDialect.cpp
+++ b/examples/toy/Ch3/mlir/ToyDialect.cpp
@@ -104,7 +104,7 @@
 mlir::Type ToyDialect::parseType(StringRef tyData, mlir::Location loc) const {
   // Sanity check: we only support array or array<...>
   if (!tyData.startswith("array")) {
-    emitError(loc, "Invalid Toy type '" + tyData + "', array expected");
+    emitError(loc, "invalid Toy type '" + tyData + "', array expected");
     return nullptr;
   }
   // Drop the "array" prefix from the type name, we expect either an empty
@@ -119,7 +119,7 @@
   SmallVector<StringRef, 4> matches;
   auto shapeRegex = llvm::Regex("^<([0-9]+)(, ([0-9]+))*>$");
   if (!shapeRegex.match(tyData, &matches)) {
-    emitError(loc, "Invalid toy array shape '" + tyData + "'");
+    emitError(loc, "invalid toy array shape '" + tyData + "'");
     return nullptr;
   }
   SmallVector<int64_t, 4> shape;
@@ -133,7 +133,7 @@
     // Convert the capture to an integer
     unsigned long long dim;
     if (getAsUnsignedInteger(dimStr, /* Radix = */ 10, dim)) {
-      emitError(loc, "Couldn't parse dimension as integer, matched: " + dimStr);
+      emitError(loc, "couldn't parse dimension as integer, matched: " + dimStr);
       return mlir::Type();
     }
     shape.push_back(dim);
diff --git a/examples/toy/Ch4/mlir/MLIRGen.cpp b/examples/toy/Ch4/mlir/MLIRGen.cpp
index bd0ad01..d0f3de1 100644
--- a/examples/toy/Ch4/mlir/MLIRGen.cpp
+++ b/examples/toy/Ch4/mlir/MLIRGen.cpp
@@ -85,7 +85,7 @@
     // this won't do much, but it should at least check some structural
     // properties.
     if (failed(mlir::verify(*theModule))) {
-      emitError(mlir::UnknownLoc::get(&context), "Module verification error");
+      emitError(mlir::UnknownLoc::get(&context), "module verification error");
       return nullptr;
     }
 
@@ -223,7 +223,7 @@
     case '*':
       return builder->create<MulOp>(location, L, R).getResult();
     default:
-      emitError(location, "Error: invalid binary operator '")
+      emitError(location, "error: invalid binary operator '")
           << binop.getOp() << "'";
       return nullptr;
     }
@@ -235,7 +235,7 @@
   mlir::Value *mlirGen(VariableExprAST &expr) {
     if (symbolTable.count(expr.getName()))
       return symbolTable.lookup(expr.getName());
-    emitError(loc(expr.loc()), "Error: unknown variable '")
+    emitError(loc(expr.loc()), "error: unknown variable '")
         << expr.getName() << "'";
     return nullptr;
   }
@@ -413,7 +413,7 @@
       }
     } else {
       emitError(loc(vardecl.loc()),
-                "Missing initializer in variable declaration");
+                "missing initializer in variable declaration");
       return nullptr;
     }
     // Register the value in the symbol table
diff --git a/examples/toy/Ch4/mlir/ShapeInferencePass.cpp b/examples/toy/Ch4/mlir/ShapeInferencePass.cpp
index 6c0d8df..1600b99 100644
--- a/examples/toy/Ch4/mlir/ShapeInferencePass.cpp
+++ b/examples/toy/Ch4/mlir/ShapeInferencePass.cpp
@@ -124,7 +124,7 @@
     auto main = module.lookupSymbol<mlir::FuncOp>("main");
     if (!main) {
       emitError(mlir::UnknownLoc::get(module.getContext()),
-                "Shape inference failed: can't find a main function\n");
+                "shape inference failed: can't find a main function\n");
       signalPassFailure();
       return;
     }
@@ -269,7 +269,7 @@
         auto rhsRank = rhs.getShape().size();
         if (lhsRank != rhsRank) {
           return mulOp.emitOpError(
-              "Shape mismatch: LHS and RHS must have the same "
+              "shape mismatch: LHS and RHS must have the same "
               "rank for multiplication, got " +
               Twine(lhsRank) + " vs  " + Twine(lhsRank));
         }
@@ -279,7 +279,7 @@
           dims.push_back(1);
         } else if (lhsRank != 2) {
           return op->emitOpError(
-              "Shape mismatch: expect rank 1 or 2 for mul operands, got " +
+              "shape mismatch: expect rank 1 or 2 for mul operands, got " +
               Twine(lhsRank));
         } else {
           dims.push_back(lhs.getShape()[0]);
@@ -298,7 +298,7 @@
         auto calleeName = callOp.getCalleeName();
         auto callee = getModule().lookupSymbol<mlir::FuncOp>(calleeName);
         if (!callee) {
-          f.emitError("Shape inference failed, call to unknown '")
+          f.emitError("shape inference failed, call to unknown '")
               << calleeName << "'";
           signalPassFailure();
           return mlir::failure();
@@ -338,7 +338,7 @@
     if (!opWorklist.empty()) {
       std::string str;
       llvm::raw_string_ostream errorMsg(str);
-      errorMsg << "Shape inference failed, " << opWorklist.size()
+      errorMsg << "shape inference failed, " << opWorklist.size()
                << " operations couldn't be inferred\n";
       for (auto *ope : opWorklist)
         errorMsg << " - " << *ope << "\n";
diff --git a/examples/toy/Ch4/mlir/ToyDialect.cpp b/examples/toy/Ch4/mlir/ToyDialect.cpp
index dfab06d..db0deda 100644
--- a/examples/toy/Ch4/mlir/ToyDialect.cpp
+++ b/examples/toy/Ch4/mlir/ToyDialect.cpp
@@ -104,7 +104,7 @@
 mlir::Type ToyDialect::parseType(StringRef tyData, mlir::Location loc) const {
   // Sanity check: we only support array or array<...>
   if (!tyData.startswith("array")) {
-    emitError(loc, "Invalid Toy type '" + tyData + "', array expected");
+    emitError(loc, "invalid Toy type '" + tyData + "', array expected");
     return nullptr;
   }
   // Drop the "array" prefix from the type name, we expect either an empty
@@ -119,7 +119,7 @@
   SmallVector<StringRef, 4> matches;
   auto shapeRegex = llvm::Regex("^<([0-9]+)(, ([0-9]+))*>$");
   if (!shapeRegex.match(tyData, &matches)) {
-    emitError(loc, "Invalid toy array shape '" + tyData + "'");
+    emitError(loc, "invalid toy array shape '" + tyData + "'");
     return nullptr;
   }
   SmallVector<int64_t, 4> shape;
@@ -133,7 +133,7 @@
     // Convert the capture to an integer
     unsigned long long dim;
     if (getAsUnsignedInteger(dimStr, /* Radix = */ 10, dim)) {
-      emitError(loc, "Couldn't parse dimension as integer, matched: " + dimStr);
+      emitError(loc, "couldn't parse dimension as integer, matched: " + dimStr);
       return mlir::Type();
     }
     shape.push_back(dim);
diff --git a/examples/toy/Ch5/mlir/LateLowering.cpp b/examples/toy/Ch5/mlir/LateLowering.cpp
index cbcf149..95585f9 100644
--- a/examples/toy/Ch5/mlir/LateLowering.cpp
+++ b/examples/toy/Ch5/mlir/LateLowering.cpp
@@ -365,7 +365,7 @@
     if (failed(applyPartialConversion(getModule(), target, toyPatterns,
                                       &typeConverter))) {
       emitError(UnknownLoc::get(getModule().getContext()),
-                "Error lowering Toy\n");
+                "error lowering Toy\n");
       signalPassFailure();
     }
 
diff --git a/examples/toy/Ch5/mlir/MLIRGen.cpp b/examples/toy/Ch5/mlir/MLIRGen.cpp
index eba2933..8f80da9 100644
--- a/examples/toy/Ch5/mlir/MLIRGen.cpp
+++ b/examples/toy/Ch5/mlir/MLIRGen.cpp
@@ -85,7 +85,7 @@
     // this won't do much, but it should at least check some structural
     // properties.
     if (failed(mlir::verify(*theModule))) {
-      emitError(mlir::UnknownLoc::get(&context), "Module verification error");
+      emitError(mlir::UnknownLoc::get(&context), "module verification error");
       return nullptr;
     }
 
@@ -223,7 +223,7 @@
     case '*':
       return builder->create<MulOp>(location, L, R).getResult();
     default:
-      emitError(loc(binop.loc()), "Error: invalid binary operator '")
+      emitError(loc(binop.loc()), "error: invalid binary operator '")
           << binop.getOp() << "'";
       return nullptr;
     }
@@ -235,7 +235,7 @@
   mlir::Value *mlirGen(VariableExprAST &expr) {
     if (symbolTable.count(expr.getName()))
       return symbolTable.lookup(expr.getName());
-    emitError(loc(expr.loc()), "Error: unknown variable '")
+    emitError(loc(expr.loc()), "error: unknown variable '")
         << expr.getName() << "'";
     return nullptr;
   }
@@ -413,7 +413,7 @@
       }
     } else {
       emitError(loc(vardecl.loc()),
-                "Missing initializer in variable declaration");
+                "missing initializer in variable declaration");
       return nullptr;
     }
     // Register the value in the symbol table
diff --git a/examples/toy/Ch5/mlir/ShapeInferencePass.cpp b/examples/toy/Ch5/mlir/ShapeInferencePass.cpp
index 057c7ec..e85d1af 100644
--- a/examples/toy/Ch5/mlir/ShapeInferencePass.cpp
+++ b/examples/toy/Ch5/mlir/ShapeInferencePass.cpp
@@ -125,7 +125,7 @@
     auto main = moduleManager.lookupSymbol<mlir::FuncOp>("main");
     if (!main) {
       emitError(mlir::UnknownLoc::get(module.getContext()),
-                "Shape inference failed: can't find a main function\n");
+                "shape inference failed: can't find a main function\n");
       signalPassFailure();
       return;
     }
@@ -271,7 +271,7 @@
         auto lhsRank = lhs.getShape().size();
         auto rhsRank = rhs.getShape().size();
         if (lhsRank != rhsRank) {
-          return op->emitError("Shape mismatch: LHS and RHS must have the same "
+          return op->emitError("shape mismatch: LHS and RHS must have the same "
                                "rank for multiplication, got ")
                  << lhsRank << " vs  " << lhsRank;
         }
@@ -281,7 +281,7 @@
           dims.push_back(1);
         } else {
           if (lhsRank != 2) {
-            return op->emitError("Shape mismatch: expect rank 1 or 2 for mul "
+            return op->emitError("shape mismatch: expect rank 1 or 2 for mul "
                                  "operands, got ")
                    << lhsRank;
           }
@@ -302,7 +302,7 @@
         auto callee = moduleManager.lookupSymbol<mlir::FuncOp>(calleeName);
         if (!callee) {
           signalPassFailure();
-          return f.emitError("Shape inference failed, call to unknown '")
+          return f.emitError("shape inference failed, call to unknown '")
                  << calleeName << "'";
         }
         auto mangledName = mangle(calleeName, op->getOpOperands());
@@ -340,7 +340,7 @@
     // If the operation worklist isn't empty, this indicates a failure.
     if (!opWorklist.empty()) {
       signalPassFailure();
-      auto diag = f.emitError("Shape inference failed, ")
+      auto diag = f.emitError("shape inference failed, ")
                   << opWorklist.size() << " operations couldn't be inferred\n";
       for (auto *ope : opWorklist)
         diag << " - " << *ope << "\n";
diff --git a/examples/toy/Ch5/mlir/ToyDialect.cpp b/examples/toy/Ch5/mlir/ToyDialect.cpp
index 5e06323..4b471a6 100644
--- a/examples/toy/Ch5/mlir/ToyDialect.cpp
+++ b/examples/toy/Ch5/mlir/ToyDialect.cpp
@@ -109,7 +109,7 @@
 mlir::Type ToyDialect::parseType(StringRef tyData, mlir::Location loc) const {
   // Sanity check: we only support array or array<...>
   if (!tyData.startswith("array")) {
-    emitError(loc, "Invalid Toy type '" + tyData + "', array expected");
+    emitError(loc, "invalid Toy type '" + tyData + "', array expected");
     return nullptr;
   }
   // Drop the "array" prefix from the type name, we expect either an empty
@@ -124,7 +124,7 @@
   SmallVector<StringRef, 4> matches;
   auto shapeRegex = llvm::Regex("^<([0-9]+)(, ([0-9]+))*>$");
   if (!shapeRegex.match(tyData, &matches)) {
-    emitError(loc, "Invalid toy array shape '" + tyData + "'");
+    emitError(loc, "invalid toy array shape '" + tyData + "'");
     return nullptr;
   }
   SmallVector<int64_t, 4> shape;
@@ -138,7 +138,7 @@
     // Convert the capture to an integer
     unsigned long long dim;
     if (getAsUnsignedInteger(dimStr, /* Radix = */ 10, dim)) {
-      emitError(loc, "Couldn't parse dimension as integer, matched: " + dimStr);
+      emitError(loc, "couldn't parse dimension as integer, matched: " + dimStr);
       return mlir::Type();
     }
     shape.push_back(dim);
diff --git a/lib/Analysis/SliceAnalysis.cpp b/lib/Analysis/SliceAnalysis.cpp
index 2f7eddf..718db0e 100644
--- a/lib/Analysis/SliceAnalysis.cpp
+++ b/lib/Analysis/SliceAnalysis.cpp
@@ -117,7 +117,7 @@
           getBackwardSliceImpl(loopOp, backwardSlice, filter);
       } else if (blockArg->getOwner() !=
                  &op->getParentOfType<FuncOp>().getBody().front()) {
-        op->emitError("Unsupported CF for operand ") << en.index();
+        op->emitError("unsupported CF for operand ") << en.index();
         llvm_unreachable("Unsupported control flow");
       }
       continue;
diff --git a/lib/Analysis/Utils.cpp b/lib/Analysis/Utils.cpp
index 3f94aa8..59bc5b3 100644
--- a/lib/Analysis/Utils.cpp
+++ b/lib/Analysis/Utils.cpp
@@ -916,7 +916,7 @@
     if (failed(
             region->compute(opInst,
                             /*loopDepth=*/getNestingDepth(*block.begin())))) {
-      return opInst->emitError("Error obtaining memory region\n");
+      return opInst->emitError("error obtaining memory region\n");
     }
 
     auto it = regions.find(region->memref);
diff --git a/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp b/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
index 2cefa78..a69fe81 100644
--- a/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
+++ b/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp
@@ -120,7 +120,7 @@
     const llvm::Target *target =
         llvm::TargetRegistry::lookupTarget("", triple, error);
     if (target == nullptr) {
-      function.emitError("Cannot initialize target triple");
+      function.emitError("cannot initialize target triple");
       return {};
     }
     targetMachine.reset(
@@ -148,7 +148,7 @@
   auto cubin = convertModuleToCubin(*llvmModule, function);
 
   if (!cubin) {
-    return function.emitError("Translation to CUDA binary failed.");
+    return function.emitError("translation to CUDA binary failed.");
   }
 
   function.setAttr(kCubinAnnotation,
diff --git a/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp b/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp
index 29e9d28..c53a52d 100644
--- a/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp
+++ b/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp
@@ -317,7 +317,7 @@
   auto cubinGetter =
       kernelFunction.getAttrOfType<SymbolRefAttr>(kCubinGetterAnnotation);
   if (!cubinGetter) {
-    kernelFunction.emitError("Missing ")
+    kernelFunction.emitError("missing ")
         << kCubinGetterAnnotation << " attribute.";
     return signalPassFailure();
   }
diff --git a/lib/Transforms/MaterializeVectors.cpp b/lib/Transforms/MaterializeVectors.cpp
index 737af70..08bd664 100644
--- a/lib/Transforms/MaterializeVectors.cpp
+++ b/lib/Transforms/MaterializeVectors.cpp
@@ -264,7 +264,7 @@
       assert(res.second && "Insertion failed");
       return res.first->second;
     }
-    v->getDefiningOp()->emitError("Missing substitution");
+    v->getDefiningOp()->emitError("missing substitution");
     return nullptr;
   }
   return it->second;
@@ -578,7 +578,7 @@
     return op->emitError("NYI: ops with != 1 results"), true;
   }
   if (op->getResult(0)->getType() != state->superVectorType) {
-    return op->emitError("Op does not return a supervector."), true;
+    return op->emitError("op does not return a supervector."), true;
   }
   auto *clone =
       instantiate(b, op, state->hwVectorType, state->substitutionsMap);
@@ -630,7 +630,7 @@
     for (auto *op : *slice) {
       auto fail = instantiateMaterialization(op, &scopedState);
       if (fail) {
-        op->emitError("Unhandled super-vector materialization failure");
+        op->emitError("unhandled super-vector materialization failure");
         return true;
       }
     }
diff --git a/lib/Transforms/Utils/LoopUtils.cpp b/lib/Transforms/Utils/LoopUtils.cpp
index 15da55b..e038512 100644
--- a/lib/Transforms/Utils/LoopUtils.cpp
+++ b/lib/Transforms/Utils/LoopUtils.cpp
@@ -1667,7 +1667,7 @@
       LLVM_DEBUG(llvm::dbgs() << "over-approximating to the entire memref\n");
       if (!getFullMemRefAsRegion(opInst, copyDepth, region.get())) {
         LLVM_DEBUG(
-            opInst->emitError("Non-constant memref sizes not yet supported"));
+            opInst->emitError("non-constant memref sizes not yet supported"));
         error = true;
         return;
       }
@@ -1702,7 +1702,7 @@
             // If the union fails, we will overapproximate.
             if (!getFullMemRefAsRegion(opInst, copyDepth, region.get())) {
               LLVM_DEBUG(opInst->emitError(
-                  "Non-constant memref sizes not yet supported"));
+                  "non-constant memref sizes not yet supported"));
               error = true;
               return true;
             }