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

    <tr>
        <th>Summary</th>
        <td>
            [TypeProf][PGO]Duplicate VTableProfileInfo lead to assert hit when creating indexed profile
        </td>
    </tr>

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

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

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

<pre>
    The bug is found when trying to collect the PGO profile for chromium with the flag _-enable-vtable-value-profiling._

`llvm-profdata: chromium/src/third_party/llvm/llvm/include/llvm/ADT/IntervalMap.h:638: unsigned int llvm::IntervalMapImpl::LeafNode<unsigned long, unsigned long, 8, llvm::IntervalMapHalfOpenInfo<unsigned long>>::insertFrom(unsigned int &, unsigned int, KeyT, KeyT, ValT) [KeyT = unsigned long, ValT = unsigned long, N = 8, Traits = llvm::IntervalMapHalfOpenInfo<unsigned long>]: Assertion (i == Size || Traits::stopLess(b, start(i))) && "Overlapping insert"' failed.`

Our investigation concludes that when if there is a strong vtable and weak vtable at the same time, the respective _VTableProfileInfo_ still exist in the ___llvm_prf_vtab_ section since it is marked linker retained and cannot be garbage collected. Therefore, the duplicate info is read by the profiler and lead to the assert hit with the overlapping vtable pointer.

Our temporary hack is to add an if statement to not marked it as linker retained if the global variable is _linkonce_odr_ in https://github.com/llvm/llvm-project/blob/0ee0857363aadf9ce0f403e7e0da10f0a9d94887/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp#L1594-L1596
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVU-Po7gT_TTOpdQRMSEhhxwyk1_mN9rZ6ZY2misqoABvGxvZRWayn35V0J3ObM9lV0Ig15_nqudXBmM0rSPaq-yDyo4LHLnzYT90xpphGJ8Xpa-v-3NHUI4tmAiNH10N3ztywOFqXAvsofLWUsXAHcHTp0cYgm-M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