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

    <tr>
        <th>Summary</th>
        <td>
            [MIR] MIR file generated that cannot be parsed due to concatenated debug information
        </td>
    </tr>

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

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

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

<pre>
    The issue is that clang can generate a `.mir` file that `llc` cannot parse. It looks like the MIR printer concatenated the debug-info-variable, debug-info-expression and debug-info-location, but the MIR parser does not expect that.

Here is a reduced input file:
```
// reduced.c
typedef enum { a } b;
void c();
void d() {
  int e;
  {
    b f;
    c(&f);
  }
 c(&e);
}
```

Then to generate a MIR file:
```
clang -target riscv64-unknown-elf -g -mlittle-endian -fstack-protector-strong -O2 -c reduced.c -mllvm -stop-before=machine-scheduler -o reduced.mir`
```

Then to error out trying to parse that file:
```
llc -mtriple=riscv64 reduced.mir
```

The error I get is
```
error: reduced.mir:150:51: expected end of string after the metadata node
      local-offset: -12, debug-info-variable: '!20!22', debug-info-expression: '!DIExpression()!DIExpression()',
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVN2OozgTfRrnpuQIDITkgov0ly_aXIxWGs0LGLsAbxsb2UXP9NuvDGySbs22VoocXH-uKp1zZIymd4gNq15YddnJmQYfmtGoQaIdpSErnd61Xr83PwYEE-OcTqBBEigrXQ9KOujRYZCEIIEdsv1oAjtk0BmLayQ7ZNaqZFPSOU8wyRBxDzcC6_1rBGteUyjCt9t3mIJxhAGUd0oSOkmoF6fGdu65cZ3nbzIY2Vpk4n_PZvw1BYzReAfS6WeP9UqS8S4ltDM9HkudBNAeI6TO8NeEipa29yy7sOy8nn9gWCaXEFDPCjUYN820DMmKLYgdsu23XsWVies_CXu1Wul9Qo0doJtHYPVLWlp9gZYVL2vAmzcaFBNHJk4fjXo1pqzVCmAcAd6j4NkF0EL35IKt6KF7LpxSLtvn5sdn_937ebjl_DGgA_LPCEhb_WorK2w4ydAjQTBRvR1KPrtX5386jrYD3gMfrSGyyNFpIx3wLpJUr3wKnlCRDzxS8KnOnwK4euw4Zdq3EXgkP_EWOx-QFZdRqsE45FENqGeLAbi_J614_Q9TYgg-gE_wCe_G9cm2AGiF-VdTW5tao2CmFHPZxv7Qwpfvb2_fIC3NxN8GLyGsOH-oWpzzKmPFucqTZ4U3akCnwXcQKaQ5ZJcIlzgxIkktSYLzGh_IAUgEstx3XURKlXguPpHvzsniDEzUTOQiS4dYLv_C00fw5fb_h3UF_--Nqdin-Xe6KfSpOMkdNnmdi6IUVV3uhqZAUWV4KFt5UEVdZ6dCyCzPj5gfuky1x51pRCbKrMyq_FiKqtx36qS17nKpdVvkVcvKDEdp7D7Bau9Dv1tUsDnWx7zeWdmijYt-CuHw5yqRTIgkp6FJObyd-8jKzJpI8VGFDNlFeL_dvrPqcqfNnUp6U9lVMVtckaZBz5hw90Edl9VCWm0YF5nbzcE2A9EUEyAXHeoNDXO7V35k4pra2P4Sp_5CRUxcl-YjE9dluL8DAAD__7uO3Ug">