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

    <tr>
        <th>Summary</th>
        <td>
            opt -passes="function-simplification<O1>" leaves debug info that the LLParser complains about
        </td>
    </tr>

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

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

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

<pre>
    llvm commit: 7e6b1504c7cf
Reproduce with:
```
opt -passes="function-simplification<O1>" bbi-98372.ll -S -o - | opt -o /dev/null
```
Result:
```
opt: <stdin>:8:20: error: base element of getelementptr must be sized
    #dbg_value(ptr getelementptr inbounds ([1 x %union.anon], ptr @d, i32 0, i32 3), !7, !DIExpression(), !14)
```
The problem is that the output from function-simplification contains
```
#dbg_value(ptr getelementptr inbounds ([1 x %union.anon], ptr @d, i32 0, i32 3), !7, !DIExpression(), !14)
```
but there is no definition left of the type %union.anon. That type exists in the bbi-98372.ll input but I suppose it was removed in the output since there is no non-debug info use left. But this then makes other users of the output (e.g. opt or llc) error out.

[bbi-98372.ll.gz](https://github.com/user-attachments/files/16744959/bbi-98372.ll.gz)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUVE2P2zYQ_TX0ZSBBGkoWddDBu46BAAFapLkXlDSS2FCkwA_vJr--oOxtssV2D70FMMyhOJyZ9x5npPdqNkQdqx9YfT7IGBbrulV9laQXq1cyh96O3zqtrysMdl1VYPwEDR37si6qoRkmVpxZcfpMm7NjHAieVFgYP90-s2Nx_-1buwXINuk9ecbPDHGKZgjKmsyrddNqUoNMW8YffysZ_8AQoe9V1greYK41ZH9AZiED1jzCHswCw8tIV4YXE7V-M-tn8lGHd2pKkBh_9GFUJmXlJ8H4CYv0nZyzLhm99ASkaSUTwE4wU7jvtuBgjT5AT-DVdxpvgQEAGPKxn_-8Sh2JoUier-8p09toRg8MBasfSngGhnU0yppcGmtYfWb4CMmVVcWYbMURiheDM2yTzbBs7uv544fnzZH3iUgUPxzKKtlvcfBlIdic7TWtoDyERQYIC4GNYYsBJmdX-A-pYLAmSGX8m4F_Efx93PE6SuiNhZEmZdQOT9O0y53oCN82el1eDl92rtIBPSsfPCiz-756tsokGlOWj-DjtllPoAI8SQ-OVnul8eXanXGvzECvSjLWZCP1cQZlJgvR015aDg977btqZGCVX8mDTTeTj_Mvtd8DMxSUz_nePNaB1gPD9vbIk0t-p-f2Xz_8jCKfv-9qiCWEzad2wgvDy6zCEvt8sCvDS0qZyRDksCSFPcPLpDSltTw2VdXWLcPLv6O-qHIYOz62vJUH6soGq2Nd8aI5LN04ibZsxcRFU_HjJARhO_ZEvB2aspXVQXVYYFUIPBZHLrDJ5SCOFQop6qoshUBWFbRKpfM0yXLr5oPyPlJXFseiwoOWPWm_j0FEQ0-wnzLENBXdPv6yPs6eVYVOKv8IE1TQ1P2fwaZJXsnDT6L-03efPv0unSeXRu6mU3eB7G0Mh-h09w79qar7km3O_kVDYHjZsewS3MBeO_w7AAD__2SO1q4">