Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mlir/include/mlir/IR/SymbolInterfaces.td
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ def Symbol : OpInterface<"SymbolOpInterface"> {
if (concreteOp.isDeclaration() && concreteOp.isPublic())
return concreteOp.emitOpError("symbol declaration cannot have public "
"visibility");
if ($_op->getNumResults() != 0)
return concreteOp.emitOpError("symbols must not have results");
auto parent = $_op->getParentOp();
if (parent && !parent->hasTrait<OpTrait::SymbolTable>() && parent->isRegistered()) {
return concreteOp.emitOpError("symbol's parent must have the SymbolTable "
Expand Down
8 changes: 8 additions & 0 deletions mlir/test/IR/invalid-ops.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,11 @@ func.func @verify_fail_3() {
%r = "arith.constant"() {value = -3 : si32} : () -> si32
return
}

// -----

// Verify that symbols with results are rejected
module {
// expected-error@+1 {{'test.symbol_with_result' op symbols must not have results}}
%0 = "test.symbol_with_result"() <{sym_name = "test_symbol"}> : () -> i32
}
7 changes: 7 additions & 0 deletions mlir/test/lib/Dialect/Test/TestOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ def SymbolOp : TEST_Op<"symbol", [NoMemoryEffect, Symbol]> {
OptionalAttr<StrAttr>:$sym_visibility);
}

def SymbolWithResultOp : TEST_Op<"symbol_with_result", [Symbol]> {
let summary = "invalid symbol operation that produces an SSA result";
let arguments = (ins StrAttr:$sym_name,
OptionalAttr<StrAttr>:$sym_visibility);
let results = (outs AnyType:$result);
}

def OverriddenSymbolVisibilityOp : TEST_Op<"overridden_symbol_visibility", [
DeclareOpInterfaceMethods<Symbol, ["getVisibility", "setVisibility"]>,
]> {
Expand Down
Loading