<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/65829>65829</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            MLIR: Modifying Variadics in AttrSizedOperandSegments ops crashes
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue,
            mlir
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          roytu
      </td>
    </tr>
</table>

<pre>
    Given the following op:

```
def MyOp : _Op<"...",[
 AttrSizedOperandSegments
]> {
    let arguments = (ins
 Variadic<AnyType>: $fooOperands,
        Variadic<AnyType>: $barOperands,
    );
}
```

Running `getBarOperandsMutable.clear()` throws the following error:

```
error: ... op operand count (2) does not match with the total size (17) specified in attribute 'operand_segment_sizes'
```

due to the [verifyTrait](https://github.com/llvm/llvm-project/blob/523c471250a49b5603bd907ff05535f18ef61c91/mlir/include/mlir/IR/OpDefinition.h#L1347-L1357). The workaround is to update the "operandSegmentSizes" manually, but probably better would be to add helper functions to `AttrSizedOperandSegments`. Thoughts?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVN1u4zgPfRrmhhhDpmI7vvBF24w_DNCiQFt8t4Vs07F2FcvQT4PM0y_kJFvsYqbAGoYMSyTP4SEp5b0-zMwNFPdQ7Dcqhsm6xtlziJvODufmf_qDZwwT42iNsSc9H9AuIO9A7EHc1lJc3_V34BGfzs8LgrzD9-cF5AMQZVkGREAPCWu1w7sQ3Kv-ycPzwk7NwysfjjwHf41a7EF-R6hu5ohoOKByh7iaIcg9Au30fPXA_yun1aB7kA938_ntvDDI74kF0Ha09grjE4m_Q6bnK79OuV_6AdUgr9Sg2v9Sicv6Euc56QalOHC4_4z3FIPqDGe9YeWAdilkKTBMzp78v0Rn56z7WvebCWZZhnZBe4HB3sY5JKEIqMbBssfZBjyq0E940mFaoYINyqDXPzmZ5lWy9Qv3etQ8oJ5RheB0F0M6r66x3_2lZO_JzwNVX8gwxASyYkFx_8FOj-c3p3RIhabdFMLiU4LUArUHHabYZb09ArXGfNw-3xZn_-A-ALWdsR1QW5Dst1VOhVDbuitKIbuhFtU4iqKQxZjveCzzvs6B2qPRDqjVc2_iwJ8bP16A2udlz6OeddB2ziYg-ZjLbfXtMZdF0iLDt4nxZN2fytk4D6h9yiYugwp8SYrI_qOPXy-aEB7VHJUxZ6AH7GLAxdlOdeaMHYfADk82mgG7VR41DDixWdjhGOc-sVmBoBS_HZdSJHY2HqbgQbaboZFDLWu14SYv6y1RJfPdZmryUnQ1lXJUxbgbK1EWougGVv1W1rKq-o1uSJAUtagFbfNilynui5qor4pc5DnnsBV8VNpkqRaZdYeN9j5yUxY7qjdGdWz8epkQzXzC9fA69UQXtSldNK5Zi9nFg4etMNoH_xky6GC4eXr88ZKa-ckOejynEbhNqU_d-Dsx0C4ee6f8xH4TnWn-c1-tpD1Quyb1VwAAAP__cHKWCg">