Skip to content

Commit 95d788c

Browse files
Revert "[mlir][Pass] Fix crash when applying a pass to an optional interface" (#168847)
Reverts #168499
1 parent 3396b46 commit 95d788c

File tree

5 files changed

+5
-23
lines changed

5 files changed

+5
-23
lines changed

mlir/include/mlir/Pass/Pass.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,6 @@ class Pass {
193193
/// This is useful for generic operation passes to add restrictions on the
194194
/// operations they operate on.
195195
virtual bool canScheduleOn(RegisteredOperationName opName) const = 0;
196-
virtual bool canScheduleOn(Operation *op) const {
197-
std::optional<RegisteredOperationName> registeredInfo =
198-
op->getName().getRegisteredInfo();
199-
if (!registeredInfo)
200-
return false;
201-
return canScheduleOn(*registeredInfo);
202-
}
203196

204197
/// Schedule an arbitrary pass pipeline on the provided operation.
205198
/// This can be invoke any time in a pass to dynamic schedule more passes.
@@ -443,7 +436,6 @@ class InterfacePass : public OperationPass<> {
443436
/// Indicate if the current pass can be scheduled on the given operation type.
444437
/// For an InterfacePass, this checks if the operation implements the given
445438
/// interface.
446-
bool canScheduleOn(Operation *op) const final { return isa<InterfaceT>(op); }
447439
bool canScheduleOn(RegisteredOperationName opName) const final {
448440
return opName.hasInterface<InterfaceT>();
449441
}

mlir/lib/Pass/Pass.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,9 +559,9 @@ LogicalResult OpToOpPassAdaptor::run(Pass *pass, Operation *op,
559559
return op->emitOpError() << "trying to schedule a pass on an operation not "
560560
"marked as 'IsolatedFromAbove'";
561561
}
562-
if (!pass->canScheduleOn(op)) {
563-
return op->emitOpError() << "trying to schedule pass '" << pass->getName()
564-
<< "' on an unsupported operation";
562+
if (!pass->canScheduleOn(*op->getName().getRegisteredInfo())) {
563+
return op->emitOpError()
564+
<< "trying to schedule a pass on an unsupported operation";
565565
}
566566

567567
// Initialize the pass state with a callback for the pass to dynamically

mlir/test/Dialect/Transform/test-pass-application.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ module attributes {transform.with_named_sequence} {
386386
// -----
387387

388388
module attributes {transform.with_named_sequence} {
389-
// expected-error @below {{trying to schedule pass 'DuplicateFunctionEliminationPass' on an unsupported operation}}
389+
// expected-error @below {{trying to schedule a pass on an unsupported operation}}
390390
// expected-note @below {{target op}}
391391
func.func @invalid_target_op_type() {
392392
return

mlir/test/Pass/invalid-unsupported-operation.mlir

Lines changed: 0 additions & 10 deletions
This file was deleted.

mlir/test/Pass/pipeline-invalid.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ arith.constant 0
1515

1616
// -----
1717

18-
// expected-error@below {{trying to schedule pass '(anonymous namespace)::TestFunctionPass' on an unsupported operation}}
18+
// expected-error@below {{trying to schedule a pass on an unsupported operation}}
1919
module {}

0 commit comments

Comments
 (0)