@@ -177,8 +177,8 @@ LogicalResult transform::detail::assembleTransformLibraryFromPaths(
177
177
for (OwningOpRef<ModuleOp> &parsedLibrary : parsedLibraries) {
178
178
if (failed (transform::detail::mergeSymbolsInto (
179
179
mergedParsedLibraries.get (), std::move (parsedLibrary))))
180
- return mergedParsedLibraries ->emitError ()
181
- << " failed to verify merged transform module" ;
180
+ return parsedLibrary ->emitError ()
181
+ << " failed to merge symbols into shared library module" ;
182
182
}
183
183
}
184
184
@@ -197,8 +197,8 @@ static bool canMergeInto(FunctionOpInterface func1, FunctionOpInterface func2) {
197
197
// / Merge `func1` into `func2`. The two ops must be inside the same parent op
198
198
// / and mergable according to `canMergeInto`. The function erases `func1` such
199
199
// / that only `func2` exists when the function returns.
200
- static LogicalResult mergeInto (FunctionOpInterface func1,
201
- FunctionOpInterface func2) {
200
+ static InFlightDiagnostic mergeInto (FunctionOpInterface func1,
201
+ FunctionOpInterface func2) {
202
202
assert (canMergeInto (func1, func2));
203
203
assert (func1->getParentOp () == func2->getParentOp () &&
204
204
" expected func1 and func2 to be in the same parent op" );
@@ -241,10 +241,10 @@ static LogicalResult mergeInto(FunctionOpInterface func1,
241
241
assert (func1.isExternal ());
242
242
func1->erase ();
243
243
244
- return success ();
244
+ return InFlightDiagnostic ();
245
245
}
246
246
247
- LogicalResult
247
+ InFlightDiagnostic
248
248
transform::detail::mergeSymbolsInto (Operation *target,
249
249
OwningOpRef<Operation *> other) {
250
250
assert (target->hasTrait <OpTrait::SymbolTable>() &&
@@ -301,7 +301,7 @@ transform::detail::mergeSymbolsInto(Operation *target,
301
301
auto renameToUnique =
302
302
[&](SymbolOpInterface op, SymbolOpInterface otherOp,
303
303
SymbolTable &symbolTable,
304
- SymbolTable &otherSymbolTable) -> LogicalResult {
304
+ SymbolTable &otherSymbolTable) -> InFlightDiagnostic {
305
305
LLVM_DEBUG (llvm::dbgs () << " , renaming\n " );
306
306
FailureOr<StringAttr> maybeNewName =
307
307
symbolTable.renameToUnique (op, {&otherSymbolTable});
@@ -313,19 +313,21 @@ transform::detail::mergeSymbolsInto(Operation *target,
313
313
}
314
314
LLVM_DEBUG (DBGS () << " renamed to @" << maybeNewName->getValue ()
315
315
<< " \n " );
316
- return success ();
316
+ return InFlightDiagnostic ();
317
317
};
318
318
319
319
if (symbolOp.isPrivate ()) {
320
- if (failed (renameToUnique (symbolOp, collidingOp, *symbolTable,
321
- *otherSymbolTable)))
322
- return failure ();
320
+ InFlightDiagnostic diag = renameToUnique (
321
+ symbolOp, collidingOp, *symbolTable, *otherSymbolTable);
322
+ if (failed (diag))
323
+ return diag;
323
324
continue ;
324
325
}
325
326
if (collidingOp.isPrivate ()) {
326
- if (failed (renameToUnique (collidingOp, symbolOp, *otherSymbolTable,
327
- *symbolTable)))
328
- return failure ();
327
+ InFlightDiagnostic diag = renameToUnique (
328
+ collidingOp, symbolOp, *otherSymbolTable, *symbolTable);
329
+ if (failed (diag))
330
+ return diag;
329
331
continue ;
330
332
}
331
333
LLVM_DEBUG (llvm::dbgs () << " , emitting error\n " );
@@ -394,8 +396,10 @@ transform::detail::mergeSymbolsInto(Operation *target,
394
396
assert (targetSymbolTable.lookup (funcOp.getName ()) == collidingFuncOp);
395
397
396
398
// Do the actual merging.
397
- if (failed (mergeInto (funcOp, collidingFuncOp))) {
398
- return failure ();
399
+ {
400
+ InFlightDiagnostic diag = mergeInto (funcOp, collidingFuncOp);
401
+ if (failed (diag))
402
+ return diag;
399
403
}
400
404
}
401
405
}
@@ -405,7 +409,7 @@ transform::detail::mergeSymbolsInto(Operation *target,
405
409
<< " failed to verify target op after merging symbols" ;
406
410
407
411
LLVM_DEBUG (DBGS () << " done merging ops\n " );
408
- return success ();
412
+ return InFlightDiagnostic ();
409
413
}
410
414
411
415
LogicalResult transform::applyTransformNamedSequence (
0 commit comments