Skip to content

Commit 680692f

Browse files
Apply suggestions from code review
Co-authored-by: Markus Böck <[email protected]>
1 parent d63b6ed commit 680692f

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

mlir/lib/Transforms/Utils/DialectConversion.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ struct ConversionValueMapping {
187187
}
188188

189189
/// Drop the last mapping for the given values.
190-
void erase(ValueVector value) { mapping.erase(value); }
190+
void erase(const ValueVector &value) { mapping.erase(value); }
191191

192192
private:
193193
/// Current value mappings.
@@ -221,7 +221,7 @@ ConversionValueMapping::lookupOrDefault(ValueVector from,
221221
}
222222
if (next != from) {
223223
// If at least one value was replaced, continue the lookup from there.
224-
from = next;
224+
from = std::move(next);
225225
continue;
226226
}
227227

@@ -1175,7 +1175,7 @@ UnresolvedMaterializationRewrite::UnresolvedMaterializationRewrite(
11751175
ValueVector mappedValues)
11761176
: OperationRewrite(Kind::UnresolvedMaterialization, rewriterImpl, op),
11771177
converterAndKind(converter, kind), originalType(originalType),
1178-
mappedValues(mappedValues) {
1178+
mappedValues(std::move(mappedValues)) {
11791179
assert((!originalType || kind == MaterializationKind::Target) &&
11801180
"original type is valid only for target materializations");
11811181
rewriterImpl.unresolvedMaterializations[op] = this;
@@ -1265,9 +1265,9 @@ LogicalResult ConversionPatternRewriterImpl::remapValues(
12651265
ValueVector repl = mapping.lookupOrDefault({operand}, legalTypes);
12661266
if (!repl.empty() && TypeRange(repl) == legalTypes) {
12671267
// Mapped values have the correct type or there is an existing
1268-
// materialization. Or the opreand is not mapped at all and has the
1268+
// materialization. Or the operand is not mapped at all and has the
12691269
// correct type.
1270-
remapped.push_back(repl);
1270+
remapped.push_back(std::move(repl));
12711271
continue;
12721272
}
12731273

@@ -1416,8 +1416,7 @@ Block *ConversionPatternRewriterImpl::applySignatureConversion(
14161416
// used as a replacement.
14171417
auto replArgs =
14181418
newBlock->getArguments().slice(inputMap->inputNo, inputMap->size);
1419-
ValueVector replArgVals = llvm::map_to_vector<1>(
1420-
replArgs, [](BlockArgument arg) -> Value { return arg; });
1419+
ValueVector replArgVals = llvm::to_vector_of<Value, 1>(replArgs);
14211420
mapping.map({origArg}, replArgVals);
14221421
appendRewrite<ReplaceBlockArgRewrite>(block, origArg, converter);
14231422
}
@@ -1462,8 +1461,8 @@ ValueRange ConversionPatternRewriterImpl::buildUnresolvedMaterialization(
14621461
mapping.map(valuesToMap, convertOp.getResults());
14631462
if (castOp)
14641463
*castOp = convertOp;
1465-
appendRewrite<UnresolvedMaterializationRewrite>(convertOp, converter, kind,
1466-
originalType, valuesToMap);
1464+
appendRewrite<UnresolvedMaterializationRewrite>(
1465+
convertOp, converter, kind, originalType, std::move(valuesToMap));
14671466
return convertOp.getResults();
14681467
}
14691468

@@ -1495,10 +1494,13 @@ Value ConversionPatternRewriterImpl::findOrBuildReplacementValue(
14951494
// `applySignatureConversion`.)
14961495
return Value();
14971496
}
1498-
Value castValue = buildUnresolvedMaterialization(
1499-
MaterializationKind::Source, computeInsertPoint(repl), value.getLoc(),
1500-
/*valuesToMap=*/{value}, /*inputs=*/repl, /*outputType=*/value.getType(),
1501-
/*originalType=*/Type(), converter)[0];
1497+
Value castValue =
1498+
buildUnresolvedMaterialization(MaterializationKind::Source,
1499+
computeInsertPoint(repl), value.getLoc(),
1500+
/*valuesToMap=*/{value}, /*inputs=*/repl,
1501+
/*outputType=*/value.getType(),
1502+
/*originalType=*/Type(), converter)
1503+
.front();
15021504
mapping.map({value}, {castValue});
15031505
return castValue;
15041506
}

0 commit comments

Comments
 (0)