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

    <tr>
        <th>Summary</th>
        <td>
            [BOLT] merge-fdata produces corrupted profile
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    After merging several thousand fdata profiles with `merge-fdata` llvm-bolt fails because of malformed strings. These strings are different each time and look like this (here I am trying to optimize clang-15):
```
1 _ZN4llvm15ScalarEvolution21forgetMemoizedResultsENS_8Arra1 _ZN5clang9ASTVectorIPNS_4StmtEE6insertERKNS_10ASTContextEPS2_mRKS2_/1 3a 1 _ZN5clang9ASTVectorIPNS_4StmtEE6appendERKNS_10ASTContextEmRKS2_/1 0 0 535
```
You can see a line
```
1 _ZN4llvm15ScalarEvolution21forgetMemoizedResultsENS_8Arra
```
suddenly overwritten with another line
```
1 _ZN5clang9ASTVectorIPNS_4StmtEE6insertERKNS_10ASTContextEPS2_mRKS2_/1 3a 1 _ZN5clang9ASTVectorIPNS_4StmtEE6appendERKNS_10ASTContextEmRKS2_/1 0 0 535
```

Can it be because I interrupted profile gathering (build with bolted clang) before finishing? I needed to delete several fdatas afterwards because merge-fdata failed on them but after that it did not complain.
If not, I don't know how to debug it further, maybe try to find bad raw fdata's by running `merge-fdata` one by one on them?

Used version `llvmorg-15.0.5`
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzVVE2P2zYQ_TXSZbCGPix_HHRwNl5gkTYN1psC6WVBiSOJXYo0SGpd99f3UXaTTbtALr0UliVRnBm-efNmGivP9a4L7Ghk1yvTk-cXdkJTGOzkhZHUSREEHZ3tlGZPJxUGSlZZtOebeRMr0vplvGmsDtQJpT013IrJM9mORqE760aW5IPDEX5BjwNj77ok4Zik6jp2bAKxaAcKamSKp2trn0mrZwYg5SkpNgPM6J7ESMGdI-JgyR7hoP5karUw_U1eJcU2KXdJ9j7JdoB3veZlTk-_fVxGvHl1aIUWbv9i9RSUNUUOoD2Hn3m0iCYf2E86-P3Hw9Nm55yYXav5jO3u8Pgrt8G6-0_YXh7CGPb7lTKeXdg_fMC3PIPNrTWB_wj7T4fiaXz4gHtS3OVUCvpxMHE8spFvBHsVKMOvKqs3M_1iJ2qFQUnBJUg0_F8T8mY8P0nJRp_JQkknp0Jgc5GNMDagfD-A8v8h-HK_BcUqQPFfRX9PCnGcm44Bqr-2DvUiJh8VCxU3k9LywkrsGpjNQKFbRAHpTJ0yyg8wT8o7RDTMElYQu2TNgb826tyCaKLYxSfh5Lfee9Wic1fC3Rr0EY_UTOHigaUIEb5UklAeau141EKZxSW5-y5-TYpbQJDWJMU60LOxJxrwn8E0Ux_9u8nF9KLlKM4gA90ZDZCGpEZIcuJ0wYoYwHgmNxkzs_GvYWINR4P4uAIGB68p_-yRC9L30Gj0j-KFUNH4i2xR4UPKdb5abdabbbnMU1mXcltuRRpU0Fwn1bt3v_z0mFTvv6MIdZJTixHX2n-ULp2crocQjj4OleIOV4_KTc0CbGERj78-buDyO5SGpfJ-Yo-Xaput1ulQr8V2WTJzUW3XWccsVryRvMza5VquGi5SLRrWPuIDtlTVRVYUeZ5v8lVZLfPFliVsi2rTxDibLllmPKKui3jwAvmnrr7M4an32NTKB_9tU3ivesjo7_hiwox39YvC1E1nsPWM9C-Yev1F">