Skip to content

Commit e80cf79

Browse files
Address remaining issues raised by @ftynse.
1 parent e7bd104 commit e80cf79

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

mlir/lib/Dialect/Transform/Transforms/TransformInterpreterPassBase.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,10 @@ static void performOptionalDebugActions(
304304
transform->removeAttr(kTransformDialectTagAttrName);
305305
}
306306

307-
/// Return whether `func1` can be merged into `func2`.
307+
/// Return whether `func1` can be merged into `func2`. For that to work `func1`
308+
/// has to be a declaration (aka has to be external) and `func2` either has to
309+
/// be a declaration as well, or it has to be public (otherwise, it wouldn't
310+
/// be visible by `func1`).
308311
bool canMergeInto(FunctionOpInterface func1, FunctionOpInterface func2) {
309312
return func1.isExternal() && (func2.isPublic() || func2.isExternal());
310313
}
@@ -381,9 +384,10 @@ static LogicalResult mergeSymbolsInto(Operation *target,
381384
// Rename private symbols in both ops in order to resolve conflicts that can
382385
// be resolved that way.
383386
LLVM_DEBUG(DBGS() << "renaming private symbols to resolve conflicts:\n");
384-
for (auto [symbolTable, otherSymbolTable] : llvm::zip(
385-
SmallVector<SymbolTable *>{&targetSymbolTable, &otherSymbolTable},
386-
SmallVector<SymbolTable *>{&otherSymbolTable, &targetSymbolTable})) {
387+
for (auto &&[symbolTable, otherSymbolTable] : llvm::zip(
388+
SmallVector<SymbolTable *, 2>{&targetSymbolTable, &otherSymbolTable},
389+
SmallVector<SymbolTable *, 2>{&otherSymbolTable,
390+
&targetSymbolTable})) {
387391
Operation *symbolTableOp = symbolTable->getOp();
388392
for (Operation &op : symbolTableOp->getRegion(0).front()) {
389393
auto symbolOp = dyn_cast<SymbolOpInterface>(op);
@@ -449,18 +453,16 @@ static LogicalResult mergeSymbolsInto(Operation *target,
449453
}
450454

451455
LLVM_DEBUG(llvm::dbgs() << ", emitting error\n");
452-
InFlightDiagnostic diag =
453-
emitError(symbolOp->getLoc(),
454-
Twine("doubly defined symbol @") + name.getValue());
456+
InFlightDiagnostic diag = symbolOp.emitError()
457+
<< "doubly defined symbol @" << name.getValue();
455458
diag.attachNote(collidingOp->getLoc()) << "previously defined here";
456459
return diag;
457460
}
458461
}
459462

460463
for (auto *op : SmallVector<Operation *>{target, *other}) {
461464
if (failed(mlir::verify(op)))
462-
return emitError(op->getLoc(),
463-
"failed to verify input op after renaming");
465+
return op->emitError() << "failed to verify input op after renaming";
464466
}
465467

466468
// Step 2:
@@ -520,8 +522,8 @@ static LogicalResult mergeSymbolsInto(Operation *target,
520522
}
521523

522524
if (failed(mlir::verify(target)))
523-
return emitError(target->getLoc(),
524-
"failed to verify target op after merging symbols");
525+
return target->emitError()
526+
<< "failed to verify target op after merging symbols";
525527

526528
LLVM_DEBUG(DBGS() << "done merging ops\n");
527529
return success();

0 commit comments

Comments
 (0)