Issue 53030
Summary MLIR loc interpreted as pdl.attribute value
Labels
Assignees
Reporter henrytwo
    Consider the following PDL pattern, where we have an attribute with a known type:
```
pdl.pattern : benefit(1)  {
  %0 = pdl.type : i32
  %1 = pdl.attribute : %0 loc("-":15:12)
  
  %2 = pdl.operation "C" {"Foo" = %1}
  pdl.rewrite {
    pdl.erase %2
  } 
}
```

As the custom PDL syntax is [currently defined](https://mlir.llvm.org/docs/Dialects/PDLOps/#pdlattribute-mlirpdlattributeop
), the location will be inadvertently interpreted as the value for the attribute.

```
operation ::= `pdl.attribute` (`:` $type^)? ($value^)? attr-dict-with-keyword
```

This results in the following error when passed through `mlir-opt` on LLVM version 14.0.0:

```
<stdin>:3:8: error: 'pdl.attribute' op expected only one of [`type`, `value`] to be set
  %1 = pdl.attribute : %0 loc("-":15:12)
       ^
<stdin>:3:8: note: see current operation: %1 = "pdl.attribute"(%0) {value = loc("-":15:12)} : (!pdl.type) -> !pdl.attribute
```

The above MLIR originated from a `mlir::Operation` in C++ and was printed using the following flags (irrelevant locations omitted for brevity):
```
mlir::OpPrintingFlags().useLocalScope().enableDebugInfo()
```

This looks like a bug (or at least an issue with the op syntax), since this MLIR does not make it through a full round trip after being printed.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to