<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/89940>89940</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Generic Operation builder does not set up properties
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jschj
</td>
</tr>
</table>
<pre>
We use some of the auto-generated “generic” builders with return type inference for some our operations in our code base. They roughly look like this:
```
void MyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
assert(operands.size() >= 1u && "mismatched number of parameters");
odsState.addOperands(operands);
odsState.addAttributes(attributes);
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
if (::mlir::succeeded(MyOp::inferReturnTypes(odsBuilder.getContext(),
odsState.location, operands,
odsState.attributes.getDictionary(odsState.getContext()),
odsState.getRawProperties(),
odsState.regions, inferredReturnTypes))) {
assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
odsState.addTypes(inferredReturnTypes);
} else {
::llvm::report_fatal_error("Failed to infer result type(s).");
}
}
```
The problem is that at no point the properties are set up. The other builders (the ones where the individual operands are provided) do eventually call `odsState.getOrAddProperties<Properties>();`. This poses a problem in our case since we rely on operandSegmentSizes (which is a property) to be correctly set up. This issue is happening with the release version of LLVM18.
To reproduce someone might simply look at the generated "generic" builders of any operation with properties.
[Discourse link](https://discourse.llvm.org/t/generic-operation-builder-does-not-set-up-properties/78552)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVk9zo7gT_TTypcsuEMbAwYckjn-XmV-2kqnZ45RAbdCMkChJJMt8-i0JMHiS2d1UypFI_3n9-tFtZq2oFeKRpPckPW1Y7xptjt9t1XzflJoPxz8ReotgdYugL-AaBNY7va1RoWEOOZBHSvKIFA_hkajm-wnKXkiOxsKbc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