@@ -50,8 +50,6 @@ constexpr static llvm::StringLiteral kTransformDialectTagPayloadRootValue =
50
50
constexpr static llvm::StringLiteral
51
51
kTransformDialectTagTransformContainerValue = " transform_container" ;
52
52
53
- namespace {
54
-
55
53
// / Utility to parse the content of a `transformFileName` MLIR file containing
56
54
// / a transform dialect specification.
57
55
static LogicalResult
@@ -180,8 +178,9 @@ printReproCall(llvm::raw_ostream &os, StringRef rootOpName, StringRef passName,
180
178
181
179
// / Prints the module rooted at `root` to `os` and appends
182
180
// / `transformContainer` if it is not nested in `root`.
183
- llvm::raw_ostream &printModuleForRepro (llvm::raw_ostream &os, Operation *root,
184
- Operation *transform) {
181
+ static llvm::raw_ostream &printModuleForRepro (llvm::raw_ostream &os,
182
+ Operation *root,
183
+ Operation *transform) {
185
184
root->print (os);
186
185
if (!root->isAncestor (transform))
187
186
transform->print (os);
@@ -190,12 +189,13 @@ llvm::raw_ostream &printModuleForRepro(llvm::raw_ostream &os, Operation *root,
190
189
191
190
// / Saves the payload and the transform IR into a temporary file and reports
192
191
// / the file name to `os`.
193
- void saveReproToTempFile (
194
- llvm::raw_ostream &os, Operation *target, Operation *transform,
195
- StringRef passName, const Pass::Option<std::string> &debugPayloadRootTag,
196
- const Pass::Option<std::string> &debugTransformRootTag,
197
- const Pass::Option<std::string> &transformLibraryFileName,
198
- StringRef binaryName) {
192
+ static void
193
+ saveReproToTempFile (llvm::raw_ostream &os, Operation *target,
194
+ Operation *transform, StringRef passName,
195
+ const Pass::Option<std::string> &debugPayloadRootTag,
196
+ const Pass::Option<std::string> &debugTransformRootTag,
197
+ const Pass::Option<std::string> &transformLibraryFileName,
198
+ StringRef binaryName) {
199
199
using llvm::sys::fs::TempFile;
200
200
Operation *root = getRootOperation (target);
201
201
@@ -298,14 +298,15 @@ static void performOptionalDebugActions(
298
298
// / has to be a declaration (aka has to be external) and `func2` either has to
299
299
// / be a declaration as well, or it has to be public (otherwise, it wouldn't
300
300
// / be visible by `func1`).
301
- bool canMergeInto (FunctionOpInterface func1, FunctionOpInterface func2) {
301
+ static bool canMergeInto (FunctionOpInterface func1, FunctionOpInterface func2) {
302
302
return func1.isExternal () && (func2.isPublic () || func2.isExternal ());
303
303
}
304
304
305
305
// / Merge `func1` into `func2`. The two ops must be inside the same parent op
306
306
// / and mergable according to `canMergeInto`. The function erases `func1` such
307
307
// / that only `func2` exists when the function returns.
308
- LogicalResult mergeInto (FunctionOpInterface func1, FunctionOpInterface func2) {
308
+ static LogicalResult mergeInto (FunctionOpInterface func1,
309
+ FunctionOpInterface func2) {
309
310
assert (canMergeInto (func1, func2));
310
311
assert (func1->getParentOp () == func2->getParentOp () &&
311
312
" expected func1 and func2 to be in the same parent op" );
@@ -319,7 +320,7 @@ LogicalResult mergeInto(FunctionOpInterface func1, FunctionOpInterface func2) {
319
320
320
321
// Check and merge argument attributes.
321
322
MLIRContext *context = func1->getContext ();
322
- auto td = context->getLoadedDialect <transform::TransformDialect>();
323
+ auto * td = context->getLoadedDialect <transform::TransformDialect>();
323
324
StringAttr consumedName = td->getConsumedAttrName ();
324
325
StringAttr readOnlyName = td->getReadOnlyAttrName ();
325
326
for (unsigned i = 0 , e = func1.getNumArguments (); i < e; ++i) {
@@ -359,6 +360,10 @@ LogicalResult mergeInto(FunctionOpInterface func1, FunctionOpInterface func2) {
359
360
// / instances of `SymbolOpInterface`, where collisions are allowed if at least
360
361
// / one of the two is external, in which case the other op preserved (or any one
361
362
// / of the two if both are external).
363
+ // TODO: Reconsider cloning individual ops rather than forcing users of the
364
+ // function to clone (or move) `other` in order to improve efficiency.
365
+ // This might primarily make sense if we can also prune the symbols that
366
+ // are merged to a subset (such as those that are actually used).
362
367
static LogicalResult mergeSymbolsInto (Operation *target,
363
368
OwningOpRef<Operation *> other) {
364
369
assert (target->hasTrait <OpTrait::SymbolTable>() &&
@@ -374,6 +379,7 @@ static LogicalResult mergeSymbolsInto(Operation *target,
374
379
// Rename private symbols in both ops in order to resolve conflicts that can
375
380
// be resolved that way.
376
381
LLVM_DEBUG (DBGS () << " renaming private symbols to resolve conflicts:\n " );
382
+ // TODO: Do we *actually* need to test in both directions?
377
383
for (auto &&[symbolTable, otherSymbolTable] : llvm::zip (
378
384
SmallVector<SymbolTable *, 2 >{&targetSymbolTable, &otherSymbolTable},
379
385
SmallVector<SymbolTable *, 2 >{&otherSymbolTable,
@@ -519,8 +525,6 @@ static LogicalResult mergeSymbolsInto(Operation *target,
519
525
return success ();
520
526
}
521
527
522
- } // namespace
523
-
524
528
LogicalResult transform::detail::interpreterBaseRunOnOperationImpl (
525
529
Operation *target, StringRef passName,
526
530
const std::shared_ptr<OwningOpRef<ModuleOp>> &sharedTransformModule,
0 commit comments