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bcBERViBschwbcmzXMRRwagOU6Up0fToRRiATCSuE6pBF4Kemb2R2cWs3uT1Ol-rmerDwboNatZdwtnOemc271voHpj6clHZIwbcSsfXvHP2H9QWhhE899AiT_N0dtiss8cmVamipljm62W1lquVLCoq61SWTV7MjCrJ-A0XYrGd_XeXeiNTKdMsfUgLmaGf1JnKakmNfKyrUi6rZJnSUWkzfQxmbhNNIh0ei0b74G-LaF963xJdEQYdDG0i9VDbx87-vivE0ptFgJuI7l95O4Yh>53030</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
MLIR loc interpreted as pdl.attribute value
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
henrytwo
</td>
</tr>
</table>
<pre>
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.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVU1v2zgQ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