<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/130958>130958</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Clang] Missed case of TBAA with different derived classes with a common base class
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:codegen,
missed-optimization,
TBAA
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
frederick-vs-ja
</td>
</tr>
</table>
<pre>
When compiling this example with `-O3`, Clang currently performs one more indirection than GCC. [Godbolt link](https://godbolt.org/z/hKd7561os)
```C++
struct Base {
int x;
};
struct D1 : Base {};
struct D2 : Base {
Base y;
};
int foo2(D1& d1, D2& d2) {
d1.x = 1;
d2.x = 2;
return d1.x;
}
```
It seems that Clang's TBAA can be improved for such cases.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxsU8uO4yoQ_ZryppTILj-z8CKJldbV1dXdjDRrjMsx3RgiwJnu_voRdqZ7XlJJUM8Dh4PwXl0NcwvlCcouEUuYrGtHxwM7JV92d797Fklvh7f268QGpZ1vSitzxTApj_wq5ptm_KbChFClu_9zqFKgM561MFeUi3Nsgn7DG7vRutmjNYyzdYzKDMqxDMoaDJMw-HQ-7xHK05MdeqsDamVeoOyAmimEm4f8CHQBuly3_N66K9DlHegy_TvUZZVZD3SA9BitSjc7A52ipUcf3CIDnoRnhDpGEJUJ-Ap5dKDuHpuP0i5DyI-fHX-poF8r4szVeftzaMQarSWgpsuAKhyySFRH656ADh8jhmz_ipB3mG3diAM9IvQj4jgszqyln1g_XXwD_SegZ559ZDhsjwJUe_xyOh5RCoM9o5pvzt55wNE69IucUArPfp8MbT4c8oNIuM3qIqubsizzZGpFXhe9GLOqobqpxnqsqZA5ybQo0p4qkaiWUirTPKMszw5ZvqdDxkUhxqpo-qYXIxQpz0Lpvdb3OT5korxfuM3y9FA2iRY9a7-Kkkiuh86P0g58ZQNEQGcgmpX3POzsLahZvYuoo49cvF50yi5xbcTY9cvVQ5Fq5YP_RA0q6FX8GzNlh_-tU1cG0I4bT6u6BzWOHMWM8WtEuqQW3rPf0iJ-jdka7GPnmkoWp9vfpKvCtPR7aWegSzzFY9ndnH1mGYAuKxEe6PLg4t7S9wAAAP__tlUYSQ">