4 changes: 2 additions & 2 deletions mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@ llvm::Constant *mlir::LLVM::detail::getLLVMConstant(
if (auto *arrayTy = dyn_cast<llvm::ArrayType>(llvmType)) {
elementType = arrayTy->getElementType();
numElements = arrayTy->getNumElements();
} else if (auto fVectorTy = dyn_cast<llvm::FixedVectorType>(llvmType)) {
} else if (auto *fVectorTy = dyn_cast<llvm::FixedVectorType>(llvmType)) {
elementType = fVectorTy->getElementType();
numElements = fVectorTy->getNumElements();
} else if (auto sVectorTy = dyn_cast<llvm::ScalableVectorType>(llvmType)) {
} else if (auto *sVectorTy = dyn_cast<llvm::ScalableVectorType>(llvmType)) {
elementType = sVectorTy->getElementType();
numElements = sVectorTy->getMinNumElements();
} else {
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Tools/PDLL/Parser/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,7 @@ FailureOr<ast::Type> Parser::validateMemberAccess(ast::Expr *parentExpr,

// Handle named results.
auto elementNames = tupleType.getElementNames();
auto it = llvm::find(elementNames, name);
const auto *it = llvm::find(elementNames, name);
if (it != elementNames.end())
return tupleType.getElementTypes()[it - elementNames.begin()];
}
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static bool isDefOrUse(const AsmParserState::SMDefinition &def, llvm::SMLoc loc,
}

// Check the uses.
auto useIt = llvm::find_if(def.uses, [&](const llvm::SMRange &range) {
const auto *useIt = llvm::find_if(def.uses, [&](const llvm::SMRange &range) {
return contains(range, loc);
});
if (useIt != def.uses.end()) {
Expand Down
12 changes: 6 additions & 6 deletions mlir/lib/Tools/mlir-reduce/MlirReduceMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ LogicalResult mlir::mlirReduceMain(int argc, char **argv,
MLIRContext &context) {
// Override the default '-h' and use the default PrintHelpMessage() which
// won't print options in categories.
static llvm::cl::opt<bool> Help("h", llvm::cl::desc("Alias for -help"),
static llvm::cl::opt<bool> help("h", llvm::cl::desc("Alias for -help"),
llvm::cl::Hidden);

static llvm::cl::OptionCategory MLIRReduceCategory("mlir-reduce options");
static llvm::cl::OptionCategory mlirReduceCategory("mlir-reduce options");

static llvm::cl::opt<std::string> inputFilename(
llvm::cl::Positional, llvm::cl::desc("<input file>"),
llvm::cl::cat(MLIRReduceCategory));
llvm::cl::cat(mlirReduceCategory));

static llvm::cl::opt<std::string> outputFilename(
"o", llvm::cl::desc("Output filename for the reduced test case"),
llvm::cl::init("-"), llvm::cl::cat(MLIRReduceCategory));
llvm::cl::init("-"), llvm::cl::cat(mlirReduceCategory));

llvm::cl::HideUnrelatedOptions(MLIRReduceCategory);
llvm::cl::HideUnrelatedOptions(mlirReduceCategory);

llvm::InitLLVM y(argc, argv);

Expand All @@ -65,7 +65,7 @@ LogicalResult mlir::mlirReduceMain(int argc, char **argv,
llvm::cl::ParseCommandLineOptions(argc, argv,
"MLIR test case reduction tool.\n");

if (Help) {
if (help) {
llvm::cl::PrintHelpMessage();
return success();
}
Expand Down
5 changes: 3 additions & 2 deletions mlir/lib/Transforms/LoopFusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,15 @@ struct MemRefDependenceGraph {
memrefEdgeCount[value]--;
}
// Remove 'srcId' from 'inEdges[dstId]'.
for (auto it = inEdges[dstId].begin(); it != inEdges[dstId].end(); ++it) {
for (auto *it = inEdges[dstId].begin(); it != inEdges[dstId].end(); ++it) {
if ((*it).id == srcId && (*it).value == value) {
inEdges[dstId].erase(it);
break;
}
}
// Remove 'dstId' from 'outEdges[srcId]'.
for (auto it = outEdges[srcId].begin(); it != outEdges[srcId].end(); ++it) {
for (auto *it = outEdges[srcId].begin(); it != outEdges[srcId].end();
++it) {
if ((*it).id == dstId && (*it).value == value) {
outEdges[srcId].erase(it);
break;
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Transforms/LoopInvariantCodeMotion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ LogicalResult mlir::moveLoopInvariantCode(LoopLikeOpInterface looplike) {

// Helper to check whether an operation is loop invariant wrt. SSA properties.
auto isDefinedOutsideOfBody = [&](Value value) {
auto definingOp = value.getDefiningOp();
auto *definingOp = value.getDefiningOp();
return (definingOp && !!willBeMovedSet.count(definingOp)) ||
looplike.isDefinedOutsideOfLoop(value);
};
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Transforms/NormalizeMemRefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,6 @@ Operation *NormalizeMemRefs::createOpResultsNormalized(FuncOp funcOp,
newRegion->takeBody(oldRegion);
}
return bb.createOperation(result);
} else
return oldOp;
}
return oldOp;
}
2 changes: 1 addition & 1 deletion mlir/lib/Transforms/PipelineDataTransfer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static void findMatchingStartFinishInsts(
// Check for dependence with outgoing DMAs. Doing this conservatively.
// TODO: use the dependence analysis to check for
// dependences between an incoming and outgoing DMA in the same iteration.
auto it = outgoingDmaOps.begin();
auto *it = outgoingDmaOps.begin();
for (; it != outgoingDmaOps.end(); ++it) {
if (it->getDstMemRef() == dmaStartOp.getSrcMemRef())
break;
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Transforms/Utils/FoldUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ LogicalResult OperationFolder::tryToFold(
if (op->getNumOperands() >= 2 && op->hasTrait<OpTrait::IsCommutative>()) {
std::stable_partition(
op->getOpOperands().begin(), op->getOpOperands().end(),
[&](OpOperand &O) { return !matchPattern(O.get(), m_Constant()); });
[&](OpOperand &o) { return !matchPattern(o.get(), m_Constant()); });
}

// Check to see if any operands to the operation is constant and whether
Expand Down
3 changes: 2 additions & 1 deletion mlir/lib/Transforms/Utils/LoopFusionUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ static bool isDependentLoadOrStoreOp(Operation *op,
if (auto loadOp = dyn_cast<AffineReadOpInterface>(op)) {
return values.count(loadOp.getMemRef()) > 0 &&
values[loadOp.getMemRef()] == true;
} else if (auto storeOp = dyn_cast<AffineWriteOpInterface>(op)) {
}
if (auto storeOp = dyn_cast<AffineWriteOpInterface>(op)) {
return values.count(storeOp.getMemRef()) > 0;
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Transforms/Utils/LoopUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3034,7 +3034,7 @@ uint64_t mlir::affineDataCopyGenerate(Block::iterator begin,
auto updateRegion =
[&](const SmallMapVector<Value, std::unique_ptr<MemRefRegion>, 4>
&targetRegions) {
const auto it = targetRegions.find(region->memref);
const auto *const it = targetRegions.find(region->memref);
if (it == targetRegions.end())
return false;

Expand Down
2 changes: 1 addition & 1 deletion mlir/test/lib/Analysis/TestAliasAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct TestAliasAnalysisPass

// Check for aliasing behavior between each of the values.
for (auto it = valsToCheck.begin(), e = valsToCheck.end(); it != e; ++it)
for (auto innerIt = valsToCheck.begin(); innerIt != it; ++innerIt)
for (auto *innerIt = valsToCheck.begin(); innerIt != it; ++innerIt)
printAliasResult(aliasAnalysis.alias(*innerIt, *it), *innerIt, *it);
}

Expand Down
6 changes: 3 additions & 3 deletions mlir/test/lib/Dialect/Math/TestPolynomialApproximation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ struct TestMathPolynomialApproximationPass

void TestMathPolynomialApproximationPass::runOnFunction() {
RewritePatternSet patterns(&getContext());
MathPolynomialApproximationOptions approx_options;
approx_options.enableAvx2 = enableAvx2;
populateMathPolynomialApproximationPatterns(patterns, approx_options);
MathPolynomialApproximationOptions approxOptions;
approxOptions.enableAvx2 = enableAvx2;
populateMathPolynomialApproximationPatterns(patterns, approxOptions);
(void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns));
}

Expand Down
16 changes: 8 additions & 8 deletions mlir/test/lib/Dialect/Test/TestDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -689,24 +689,24 @@ static ParseResult parseWrappingRegionOp(OpAsmParser &parser,
Region &body = *result.addRegion();
body.push_back(new Block);
Block &block = body.back();
Operation *wrapped_op = parser.parseGenericOperation(&block, block.begin());
if (!wrapped_op)
Operation *wrappedOp = parser.parseGenericOperation(&block, block.begin());
if (!wrappedOp)
return failure();

// Create a return terminator in the inner region, pass as operand to the
// terminator the returned values from the wrapped operation.
SmallVector<Value, 8> return_operands(wrapped_op->getResults());
SmallVector<Value, 8> returnOperands(wrappedOp->getResults());
OpBuilder builder(parser.getContext());
builder.setInsertionPointToEnd(&block);
builder.create<TestReturnOp>(wrapped_op->getLoc(), return_operands);
builder.create<TestReturnOp>(wrappedOp->getLoc(), returnOperands);

// Get the results type for the wrapping op from the terminator operands.
Operation &return_op = body.back().back();
result.types.append(return_op.operand_type_begin(),
return_op.operand_type_end());
Operation &returnOp = body.back().back();
result.types.append(returnOp.operand_type_begin(),
returnOp.operand_type_end());

// Use the location of the wrapped op for the "test.wrapping_region" op.
result.location = wrapped_op->getLoc();
result.location = wrappedOp->getLoc();

return success();
}
Expand Down
2 changes: 1 addition & 1 deletion mlir/test/lib/Dialect/Test/TestOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ def OpFuncRef : TEST_Op<"op_funcref"> {
// That way, we will know if operations is called once or twice.
def OpMGetNullAttr : NativeCodeCall<"Attribute()">;
def OpMAttributeIsNull : Constraint<CPred<"! ($_self)">, "Attribute is null">;
def OpMVal : NativeCodeCall<"OpMTest($_builder, $0)">;
def OpMVal : NativeCodeCall<"opMTest($_builder, $0)">;
def : Pat<(OpM $attr, $optAttr), (OpM $attr, (OpMVal $attr) ),
[(OpMAttributeIsNull:$optAttr)]>;

Expand Down
2 changes: 1 addition & 1 deletion mlir/test/lib/Dialect/Test/TestPatterns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static SmallVector<Value, 2> bindMultipleNativeCodeCallResult(Value input1,
// This let us check the number of times OpM_Test was called by inspecting
// the returned value in the MLIR output.
static int64_t opMIncreasingValue = 314159265;
static Attribute OpMTest(PatternRewriter &rewriter, Value val) {
static Attribute opMTest(PatternRewriter &rewriter, Value val) {
int64_t i = opMIncreasingValue++;
return rewriter.getIntegerAttr(rewriter.getIntegerType(32), i);
}
Expand Down
4 changes: 2 additions & 2 deletions mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ ConvertTosaNegateOp::matchAndRewrite(Operation *op,
double typeRangeMax = double(outputElementType.getStorageTypeMax() -
outputElementType.getZeroPoint()) *
outputElementType.getScale();
bool narrow_range = outputElementType.getStorageTypeMin() == 1 ? true : false;
bool narrowRange = outputElementType.getStorageTypeMin() == 1 ? true : false;

auto dstQConstType = RankedTensorType::get(
outputType.getShape(),
Expand All @@ -81,7 +81,7 @@ ConvertTosaNegateOp::matchAndRewrite(Operation *op,
rewriter.getI32IntegerAttr(
outputElementType.getStorageTypeIntegralWidth()),
0, true /* signed */,
rewriter.getBoolAttr(narrow_range)));
rewriter.getBoolAttr(narrowRange)));

ElementsAttr inputElems;
if (!matchPattern(tosaNegateOp.input1(), m_Constant(&inputElems)))
Expand Down
18 changes: 9 additions & 9 deletions mlir/test/lib/IR/TestMatchers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,19 @@ static void test1(FuncOp f) {
llvm::outs() << "Pattern mul(mul(*), mul(*)) matched " << countMatches(f, p7)
<< " times\n";

auto mul_of_mulmul =
auto mulOfMulmul =
m_Op<arith::MulFOp>(m_Op<arith::MulFOp>(), m_Op<arith::MulFOp>());
auto p8 = m_Op<arith::MulFOp>(mul_of_mulmul, mul_of_mulmul);
auto p8 = m_Op<arith::MulFOp>(mulOfMulmul, mulOfMulmul);
llvm::outs()
<< "Pattern mul(mul(mul(*), mul(*)), mul(mul(*), mul(*))) matched "
<< countMatches(f, p8) << " times\n";

// clang-format off
auto mul_of_muladd = m_Op<arith::MulFOp>(m_Op<arith::MulFOp>(), m_Op<arith::AddFOp>());
auto mul_of_anyadd = m_Op<arith::MulFOp>(m_Any(), m_Op<arith::AddFOp>());
auto mulOfMuladd = m_Op<arith::MulFOp>(m_Op<arith::MulFOp>(), m_Op<arith::AddFOp>());
auto mulOfAnyadd = m_Op<arith::MulFOp>(m_Any(), m_Op<arith::AddFOp>());
auto p9 = m_Op<arith::MulFOp>(m_Op<arith::MulFOp>(
mul_of_muladd, m_Op<arith::MulFOp>()),
m_Op<arith::MulFOp>(mul_of_anyadd, mul_of_anyadd));
mulOfMuladd, m_Op<arith::MulFOp>()),
m_Op<arith::MulFOp>(mulOfAnyadd, mulOfAnyadd));
// clang-format on
llvm::outs() << "Pattern mul(mul(mul(mul(*), add(*)), mul(*)), mul(mul(*, "
"add(*)), mul(*, add(*)))) matched "
Expand Down Expand Up @@ -118,12 +118,12 @@ static void test1(FuncOp f) {
llvm::outs() << "Pattern mul(a, add(b, c)) matched " << countMatches(f, p15)
<< " times\n";

auto mul_of_aany = m_Op<arith::MulFOp>(a, m_Any());
auto p16 = m_Op<arith::MulFOp>(mul_of_aany, m_Op<arith::AddFOp>(a, c));
auto mulOfAany = m_Op<arith::MulFOp>(a, m_Any());
auto p16 = m_Op<arith::MulFOp>(mulOfAany, m_Op<arith::AddFOp>(a, c));
llvm::outs() << "Pattern mul(mul(a, *), add(a, c)) matched "
<< countMatches(f, p16) << " times\n";

auto p17 = m_Op<arith::MulFOp>(mul_of_aany, m_Op<arith::AddFOp>(c, b));
auto p17 = m_Op<arith::MulFOp>(mulOfAany, m_Op<arith::AddFOp>(c, b));
llvm::outs() << "Pattern mul(mul(a, *), add(c, b)) matched "
<< countMatches(f, p17) << " times\n";
}
Expand Down
13 changes: 6 additions & 7 deletions mlir/test/lib/IR/TestOpaqueLoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ struct TestOpaqueLoc

void runOnOperation() override {
std::vector<std::unique_ptr<MyLocation>> myLocs;
int last_it = 0;
int lastIt = 0;

getOperation().getBody()->walk([&](Operation *op) {
myLocs.push_back(std::make_unique<MyLocation>(last_it++));
myLocs.push_back(std::make_unique<MyLocation>(lastIt++));

Location loc = op->getLoc();

Expand All @@ -54,14 +54,13 @@ struct TestOpaqueLoc

/// Add the same operation but with fallback location to test the
/// corresponding get method and serialization.
Operation *op_cloned_1 = builder.clone(*op);
op_cloned_1->setLoc(
OpaqueLoc::get<MyLocation *>(myLocs.back().get(), loc));
Operation *opCloned1 = builder.clone(*op);
opCloned1->setLoc(OpaqueLoc::get<MyLocation *>(myLocs.back().get(), loc));

/// Add the same operation but with void* instead of MyLocation* to test
/// getUnderlyingLocationOrNull method.
Operation *op_cloned_2 = builder.clone(*op);
op_cloned_2->setLoc(OpaqueLoc::get<void *>(nullptr, loc));
Operation *opCloned2 = builder.clone(*op);
opCloned2->setLoc(OpaqueLoc::get<void *>(nullptr, loc));
});

ScopedDiagnosticHandler diagHandler(&getContext(), [](Diagnostic &diag) {
Expand Down
4 changes: 2 additions & 2 deletions mlir/test/lib/Transforms/TestLoopFusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ using LoopFunc = function_ref<bool(AffineForOp, AffineForOp, unsigned, unsigned,
// If 'return_on_change' is true, returns on first invocation of 'fn' which
// returns true.
static bool iterateLoops(ArrayRef<SmallVector<AffineForOp, 2>> depthToLoops,
LoopFunc fn, bool return_on_change = false) {
LoopFunc fn, bool returnOnChange = false) {
bool changed = false;
for (unsigned loopDepth = 0, end = depthToLoops.size(); loopDepth < end;
++loopDepth) {
Expand All @@ -167,7 +167,7 @@ static bool iterateLoops(ArrayRef<SmallVector<AffineForOp, 2>> depthToLoops,
if (j != k)
changed |=
fn(loops[j], loops[k], j, k, loopDepth, depthToLoops.size());
if (changed && return_on_change)
if (changed && returnOnChange)
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

#include "mlir/ExecutionEngine/RunnerUtils.h"

// NOLINTBEGIN(*-identifier-naming)

extern "C" void
_mlir_ciface_fillI32Buffer(StridedMemRefType<int32_t, 1> *mem_ref,
int32_t value) {
Expand All @@ -36,3 +38,5 @@ _mlir_ciface_fillF32Buffer3D(StridedMemRefType<float, 3> *mem_ref,
std::fill_n(mem_ref->basePtr,
mem_ref->sizes[0] * mem_ref->sizes[1] * mem_ref->sizes[2], value);
}

// NOLINTEND(*-identifier-naming)
3 changes: 1 addition & 2 deletions mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1009,9 +1009,8 @@ static LogicalResult generateOp(LinalgOpConfig &opConfig,
return success(
succeeded(generateNamedGenericOpOds(opConfig, genContext)) &&
succeeded(generateNamedGenericOpDefns(opConfig, genContext)));
} else {
return emitError(genContext.getLoc()) << "unsupported operation type";
}
return emitError(genContext.getLoc()) << "unsupported operation type";
}

//===----------------------------------------------------------------------===//
Expand Down
7 changes: 4 additions & 3 deletions mlir/tools/mlir-tblgen/DialectGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ findSelectedDialect(ArrayRef<const llvm::Record *> dialectDefs) {
return llvm::None;
}

auto dialectIt = llvm::find_if(dialectDefs, [](const llvm::Record *def) {
return Dialect(def).getName() == selectedDialect;
});
const auto *dialectIt =
llvm::find_if(dialectDefs, [](const llvm::Record *def) {
return Dialect(def).getName() == selectedDialect;
});
if (dialectIt == dialectDefs.end()) {
llvm::errs() << "selected dialect with '-dialect' does not exist\n";
return llvm::None;
Expand Down
12 changes: 6 additions & 6 deletions mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,31 @@
#include "llvm/TableGen/Record.h"
#include "llvm/TableGen/TableGenBackend.h"

static llvm::cl::OptionCategory IntrinsicGenCat("Intrinsics Generator Options");
static llvm::cl::OptionCategory intrinsicGenCat("Intrinsics Generator Options");

static llvm::cl::opt<std::string>
nameFilter("llvmir-intrinsics-filter",
llvm::cl::desc("Only keep the intrinsics with the specified "
"substring in their record name"),
llvm::cl::cat(IntrinsicGenCat));
llvm::cl::cat(intrinsicGenCat));

static llvm::cl::opt<std::string>
opBaseClass("dialect-opclass-base",
llvm::cl::desc("The base class for the ops in the dialect we "
"are planning to emit"),
llvm::cl::init("LLVM_IntrOp"), llvm::cl::cat(IntrinsicGenCat));
llvm::cl::init("LLVM_IntrOp"), llvm::cl::cat(intrinsicGenCat));

static llvm::cl::opt<std::string> accessGroupRegexp(
"llvmir-intrinsics-access-group-regexp",
llvm::cl::desc("Mark intrinsics that match the specified "
"regexp as taking an access group metadata"),
llvm::cl::cat(IntrinsicGenCat));
llvm::cl::cat(intrinsicGenCat));

static llvm::cl::opt<std::string> aliasScopesRegexp(
"llvmir-intrinsics-alias-scopes-regexp",
llvm::cl::desc("Mark intrinsics that match the specified "
"regexp as taking alias.scopes and noalias metadata"),
llvm::cl::cat(IntrinsicGenCat));
llvm::cl::cat(intrinsicGenCat));

// Used to represent the indices of overloadable operands/results.
using IndicesTy = llvm::SmallBitVector;
Expand Down Expand Up @@ -104,7 +104,7 @@ class LLVMIntrinsic {
llvm::SmallVector<llvm::StringRef, 8> chunks;
llvm::StringRef targetPrefix = record.getValueAsString("TargetPrefix");
name.split(chunks, '_');
auto chunksBegin = chunks.begin();
auto *chunksBegin = chunks.begin();
// Remove the target prefix from target specific intrinsics.
if (!targetPrefix.empty()) {
assert(targetPrefix == *chunksBegin &&
Expand Down
2 changes: 1 addition & 1 deletion mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ static void genAttributeVerifier(
emitHelper.isEmittingForOp());

// Prefix with `tblgen_` to avoid hiding the attribute accessor.
Twine varName = tblgenNamePrefix + attrName;
std::string varName = (tblgenNamePrefix + attrName).str();

// If the attribute is not required and we cannot emit the condition, then
// there is nothing to be done.
Expand Down
4 changes: 2 additions & 2 deletions mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ static void emitOperandDeserialization(const Operator &op, ArrayRef<SMLoc> loc,
unsigned operandNum = 0;
for (unsigned i = 0, e = op.getNumArgs(); i < e; ++i) {
auto argument = op.getArg(i);
if (auto valueArg = argument.dyn_cast<NamedTypeConstraint *>()) {
if (auto *valueArg = argument.dyn_cast<NamedTypeConstraint *>()) {
if (valueArg->isVariableLength()) {
if (i != e - 1) {
PrintFatalError(loc, "SPIR-V ops can have Variadic<..> or "
Expand Down Expand Up @@ -921,7 +921,7 @@ static void emitOperandDeserialization(const Operator &op, ArrayRef<SMLoc> loc,
os << tabs << "}\n";
} else {
os << tabs << formatv("if ({0} < {1}.size()) {{\n", wordIndex, words);
auto attr = argument.get<NamedAttribute *>();
auto *attr = argument.get<NamedAttribute *>();
auto newtabs = tabs.str() + " ";
emitAttributeDeserialization(
(attr->attr.isOptional() ? attr->attr.getBaseAttr() : attr->attr),
Expand Down
20 changes: 10 additions & 10 deletions mlir/tools/mlir-tblgen/mlir-tblgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ GenNameParser::GenNameParser(llvm::cl::Option &opt)
}
}

void GenNameParser::printOptionInfo(const llvm::cl::Option &O,
size_t GlobalWidth) const {
GenNameParser *TP = const_cast<GenNameParser *>(this);
llvm::array_pod_sort(TP->Values.begin(), TP->Values.end(),
[](const GenNameParser::OptionInfo *VT1,
const GenNameParser::OptionInfo *VT2) {
return VT1->Name.compare(VT2->Name);
void GenNameParser::printOptionInfo(const llvm::cl::Option &o,
size_t globalWidth) const {
GenNameParser *tp = const_cast<GenNameParser *>(this);
llvm::array_pod_sort(tp->Values.begin(), tp->Values.end(),
[](const GenNameParser::OptionInfo *vT1,
const GenNameParser::OptionInfo *vT2) {
return vT1->Name.compare(vT2->Name);
});
using llvm::cl::parser;
parser<const GenInfo *>::printOptionInfo(O, GlobalWidth);
parser<const GenInfo *>::printOptionInfo(o, globalWidth);
}

// Generator that prints records.
Expand All @@ -64,7 +64,7 @@ const mlir::GenInfo *generator;

// TableGenMain requires a function pointer so this function is passed in which
// simply wraps the call to the generator.
static bool MlirTableGenMain(raw_ostream &os, RecordKeeper &records) {
static bool mlirTableGenMain(raw_ostream &os, RecordKeeper &records) {
if (!generator) {
os << records;
return false;
Expand All @@ -79,5 +79,5 @@ int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv);
::generator = generator.getValue();

return TableGenMain(argv[0], &MlirTableGenMain);
return TableGenMain(argv[0], &mlirTableGenMain);
}
82 changes: 41 additions & 41 deletions mlir/unittests/ExecutionEngine/Invoke.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ TEST(MLIRExecutionEngine, SubtractFloat) {
}

TEST(NativeMemRefJit, ZeroRankMemref) {
OwningMemRef<float, 0> A({});
A[{}] = 42.;
ASSERT_EQ(*A->data, 42);
A[{}] = 0;
OwningMemRef<float, 0> a({});
a[{}] = 42.;
ASSERT_EQ(*a->data, 42);
a[{}] = 0;
std::string moduleStr = R"mlir(
func @zero_ranked(%arg0 : memref<f32>) attributes { llvm.emit_c_interface } {
%cst42 = arith.constant 42.0 : f32
Expand All @@ -125,19 +125,19 @@ TEST(NativeMemRefJit, ZeroRankMemref) {
ASSERT_TRUE(!!jitOrError);
auto jit = std::move(jitOrError.get());

llvm::Error error = jit->invoke("zero_ranked", &*A);
llvm::Error error = jit->invoke("zero_ranked", &*a);
ASSERT_TRUE(!error);
EXPECT_EQ((A[{}]), 42.);
for (float &elt : *A)
EXPECT_EQ(&elt, &(A[{}]));
EXPECT_EQ((a[{}]), 42.);
for (float &elt : *a)
EXPECT_EQ(&elt, &(a[{}]));
}

TEST(NativeMemRefJit, RankOneMemref) {
int64_t shape[] = {9};
OwningMemRef<float, 1> A(shape);
OwningMemRef<float, 1> a(shape);
int count = 1;
for (float &elt : *A) {
EXPECT_EQ(&elt, &(A[{count - 1}]));
for (float &elt : *a) {
EXPECT_EQ(&elt, &(a[{count - 1}]));
elt = count++;
}

Expand All @@ -160,10 +160,10 @@ TEST(NativeMemRefJit, RankOneMemref) {
ASSERT_TRUE(!!jitOrError);
auto jit = std::move(jitOrError.get());

llvm::Error error = jit->invoke("one_ranked", &*A);
llvm::Error error = jit->invoke("one_ranked", &*a);
ASSERT_TRUE(!error);
count = 1;
for (float &elt : *A) {
for (float &elt : *a) {
if (count == 6)
EXPECT_EQ(elt, 42.);
else
Expand All @@ -173,24 +173,24 @@ TEST(NativeMemRefJit, RankOneMemref) {
}

TEST(NativeMemRefJit, BasicMemref) {
constexpr int K = 3;
constexpr int M = 7;
constexpr int k = 3;
constexpr int m = 7;
// Prepare arguments beforehand.
auto init = [=](float &elt, ArrayRef<int64_t> indices) {
assert(indices.size() == 2);
elt = M * indices[0] + indices[1];
elt = m * indices[0] + indices[1];
};
int64_t shape[] = {K, M};
int64_t shapeAlloc[] = {K + 1, M + 1};
OwningMemRef<float, 2> A(shape, shapeAlloc, init);
ASSERT_EQ(A->sizes[0], K);
ASSERT_EQ(A->sizes[1], M);
ASSERT_EQ(A->strides[0], M + 1);
ASSERT_EQ(A->strides[1], 1);
for (int i = 0; i < K; ++i) {
for (int j = 0; j < M; ++j) {
EXPECT_EQ((A[{i, j}]), i * M + j);
EXPECT_EQ(&(A[{i, j}]), &((*A)[i][j]));
int64_t shape[] = {k, m};
int64_t shapeAlloc[] = {k + 1, m + 1};
OwningMemRef<float, 2> a(shape, shapeAlloc, init);
ASSERT_EQ(a->sizes[0], k);
ASSERT_EQ(a->sizes[1], m);
ASSERT_EQ(a->strides[0], m + 1);
ASSERT_EQ(a->strides[1], 1);
for (int i = 0; i < k; ++i) {
for (int j = 0; j < m; ++j) {
EXPECT_EQ((a[{i, j}]), i * m + j);
EXPECT_EQ(&(a[{i, j}]), &((*a)[i][j]));
}
}
std::string moduleStr = R"mlir(
Expand All @@ -214,27 +214,27 @@ TEST(NativeMemRefJit, BasicMemref) {
ASSERT_TRUE(!!jitOrError);
std::unique_ptr<ExecutionEngine> jit = std::move(jitOrError.get());

llvm::Error error = jit->invoke("rank2_memref", &*A, &*A);
llvm::Error error = jit->invoke("rank2_memref", &*a, &*a);
ASSERT_TRUE(!error);
EXPECT_EQ(((*A)[1][2]), 42.);
EXPECT_EQ((A[{2, 1}]), 42.);
EXPECT_EQ(((*a)[1][2]), 42.);
EXPECT_EQ((a[{2, 1}]), 42.);
}

// A helper function that will be called from the JIT
static void memref_multiply(::StridedMemRefType<float, 2> *memref,
int32_t coefficient) {
static void memrefMultiply(::StridedMemRefType<float, 2> *memref,
int32_t coefficient) {
for (float &elt : *memref)
elt *= coefficient;
}

TEST(NativeMemRefJit, JITCallback) {
constexpr int K = 2;
constexpr int M = 2;
int64_t shape[] = {K, M};
int64_t shapeAlloc[] = {K + 1, M + 1};
OwningMemRef<float, 2> A(shape, shapeAlloc);
constexpr int k = 2;
constexpr int m = 2;
int64_t shape[] = {k, m};
int64_t shapeAlloc[] = {k + 1, m + 1};
OwningMemRef<float, 2> a(shape, shapeAlloc);
int count = 1;
for (float &elt : *A)
for (float &elt : *a)
elt = count++;

std::string moduleStr = R"mlir(
Expand All @@ -259,15 +259,15 @@ TEST(NativeMemRefJit, JITCallback) {
jit->registerSymbols([&](llvm::orc::MangleAndInterner interner) {
llvm::orc::SymbolMap symbolMap;
symbolMap[interner("_mlir_ciface_callback")] =
llvm::JITEvaluatedSymbol::fromPointer(memref_multiply);
llvm::JITEvaluatedSymbol::fromPointer(memrefMultiply);
return symbolMap;
});

int32_t coefficient = 3.;
llvm::Error error = jit->invoke("caller_for_callback", &*A, coefficient);
llvm::Error error = jit->invoke("caller_for_callback", &*a, coefficient);
ASSERT_TRUE(!error);
count = 1;
for (float elt : *A)
for (float elt : *a)
ASSERT_EQ(elt, coefficient * count++);
}

Expand Down
4 changes: 2 additions & 2 deletions mlir/unittests/IR/OperationSupportTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ TEST(NamedAttrListTest, TestAppendAssign) {
attrs.append("baz", b.getStringAttr("boo"));

{
auto it = attrs.begin();
auto *it = attrs.begin();
EXPECT_EQ(it->getName(), b.getStringAttr("foo"));
EXPECT_EQ(it->getValue(), b.getStringAttr("bar"));
++it;
Expand All @@ -260,7 +260,7 @@ TEST(NamedAttrListTest, TestAppendAssign) {
ASSERT_FALSE(dup.hasValue());

{
auto it = attrs.begin();
auto *it = attrs.begin();
EXPECT_EQ(it->getName(), b.getStringAttr("foo"));
EXPECT_EQ(it->getValue(), b.getStringAttr("f"));
++it;
Expand Down
2 changes: 1 addition & 1 deletion mlir/unittests/TableGen/StructsGenTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace mlir {

/// Pull in generated enum utility declarations and definitions.
#include "StructAttrGenTest.h.inc"
#include "StructAttrGenTest.h.inc" // NOLINT
#include "StructAttrGenTest.cpp.inc"

/// Helper that returns an example test::TestStruct for testing its
Expand Down