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

    <tr>
        <th>Summary</th>
        <td>
            Assertion failure in operator delete of llvm::User
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            llvm:ir
      </td>
    </tr>

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

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

<pre>
    Commit https://github.com/llvm/llvm-project/commit/e3f936eb755d9ae37019ffcc7f53d71d2d58d188 introduces a functional regression. If operator new fails, and then operator delete is called, we run into the following assertion. This was caught by malfunction tests:

https://github.com/llvm/llvm-project/blob/main/llvm/lib/IR/User.cpp#L190

Reverting the removal of:

```cpp
Obj->NumUserOperands = Us;
Obj->HasHungOffUses = false;
Obj->HasDescriptor = DescBytes != 0;
```
respecively
```cpp
Obj->NumUserOperands = 0;
Obj->HasHungOffUses = true;
Obj->HasDescriptor = false;
```

I will prepare a patch for that.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUk91q-zgQxZ9GvhkaZCmu4wtfuO2aFpYtlO0DyNLIVpEto4-EvP0ip2nD_i9KQWAsnaP5-XhGhGDGBbEl1QNhbBZeijSgR08YI9VTIVKcnG9vDorBqXP76ObZRJhiXAPhHWE9Yf1o4pSGnXQzYb21x-vjbvXuA2UkrJebj7AeuW74PQ51ValGIK9p2WgtZa0rrupSMVUdVHk4gFmidypJDCBAp0VG4xZhwePoMQTjlh28aHArehGdhwVPoIWxgbBHEIuCOOHyfazQYkQwAaSwFlVWnRB8WnIll9WgnbXuZJYRRAjo41bj38kEOInsS-MUYTjDLOwVCCKGuCVB8_p1LoN1A2H9LMxyozF57-WNsP49oN_JdSWM_1029FLlDY-Zbhk3ao-zOwoLTn9hkHt6WdlJu9fh447wv_5Jc77uNUeyqACEP8F7IPzhW_IswnNaxlet3wNeFFrYgP8XPWGQ3qw52KzJrw_nmB2szBv0YvjiILTzGFaU5oj2_CtC-hNg9OknvptvuEUitHuBk7EWVo-r8AgCVhHlBNp5iJOIu0K1XDW8EQW2Zb0vy2a_r6piahWtKedK76tqqBt24BXlslY1E1xpXR0K0zLKKsppVda05nzXoNT6HmvFhRI4MLKnOAtjd_mv75wfCxNCwrZkTUNpYcWANnwO6NYYvDPX8fTt1kdDGgPZU2tCDN_XRBMttt21hbepSB7B_DkOTsPn1YR3Ofoiedv-uos38EBY_8l-bNl_AQAA__8-CGad">