<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=http://email.email.llvm.org/c/eJzVVV-PozYQ_zTkZRRkTEjIAw_Zjfa50qY6qS-VMSa4NRhhs9vcp-_YhoRt9tJWp5NaiUDsmfnN_5lSV5fiJIzlzIgoPUTkGJH5vSXh4RF9co-_NXYYuYUvA-sh2k2X4M8RzXnDBvgjontAMEDBPByQcXecYGkq60rU8HJ4PS3FIaJb3YuBWT1E6dGh6c7YG21CAo7gR9Axj9InGIQdhw7pB9tI426WmkRXyXpWMoODsxLhHV5Q4VAnIP4BAjyvv5wwkXL9799vWlZQI9xkJ6o99LPTEwiAV-fvo-yJRNnR-xDRHcPfFfGOM1lwlg856YKTP-RMF5zVkvMWuDnzSz-fddtLJSp4l7bRIwZtS9ZHn0RkpM_wLuAsOhdiAbUeBzCiZ_5kMOjCOJ5BKM0q2Z2hFDVegpdFy7YEBONNDF8Q_SE0A4PyKuhYl5cZP14ae2oE9IMulWhBGrANsx7HgTPA6mOjsugL1_0FmDHy3LWis9cSuVPaOZuUemvjVrS8vziD3xttJg8SWzIWh95wpFZYVjGLquQguFUX9LwWg-i4cNYIOD0dDiC7WqMbg7-ppVAV2Es_RYrhpaOg6lnWxS3oWPdIDiBXVR-ADOjameb7ckticBFZhhVcx18ddEZhnGYIH1Cw2h_8BECBYGA1Ds4MR7jF7VuTwwVsrsKAKXMsuyx3HkpXk-60dyemEAsS93cKp_vmnxfkPT7yZlNRJ67x8E2pbjvZa-sSG1qeTvBbr3-7AbIYFsn2DuBVtj1W2nMYgD7eDmQhk3-U2U8Ksk8V7O8U_PrL6XUTZid9IPpZP8ZxjBWIdcHMnKb1zw-S-09yxJlS4AdatFlWe9wTmYcXWobTJORuypnLYZLcUrq8prM3gZ5AzRRuGrpfJHrqG3fc_dfzvVvIBMClf75iv10d2b9M8U84NceWlTg-cBhxPWL_4VSrRo4tqrHxG9eKSv4uQvtK3GWCVX-f6f9l9H5wb62qIq326Z6t2IgLbii-Xs5aYS-sxkEVjbW9byH6gs8Z98hYxly3ePBhDZ81Zuc3nPd4lMaMbpK_ZCnJ6aopNoynXGxIUtVsuyNbURKe12me7-qcV2W9UqwUyhS4odHgTryDh3DGZ8fV91sgC0ooJQnJCSG7lMR1vkl4td9k-x2hGS2x5UXLpIp94-vhvBoKD1mOZ-PmgTTW3Ihh-gvhDUYLrbRKFFMrf7KeOm1hNLhzZffXxndlrqyrZaSVrMI1bGUrvzIrdecWmR3km2QqrGv0CFr9JqZljSxm5X0tvKN_AumT9ts>53082</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            struct path TBAA metadata not used in !tbaa.struct resulting in bad optimization of trivial copy / move operations
        </td>
    </tr>

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

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

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

<pre>
    Testcase:

```c++
struct Wrap {
  Wrap(char x) : c(x) {}
#ifdef FAST
  Wrap &operator=(const Wrap &o) { c = o.c; return *this; }
#endif
  operator char() const { return c; }
  char c;
};

void f(Wrap **p) {
    (*p)[0] = 'a';
    (*p)[1] = 'b';
    (*p)[2] = 'c';
    (*p)[3] = 'd';
}
```

Compiled without `-DFAST`, we generate four separate stores, reloading before `*p` each. With `-DFAST`, we generate a single four-byte store.

The problem is that, with a defaulted copy assignment operator, we generate an `llvm.memcpy` whose `!tbaa.struct` metadata directly references the TBAA info for the field types, rather than referencing struct-path TBAA metadata for the fields of `Wrap`. The `-DFAST` case generates this for the store to the `c` field during the assignment:

```llvm
  store i8 %8, i8* %9, align 1, !tbaa !8
```
```llvm
!5 = !{!"omnipotent char", !6, i64 0}
!6 = !{!"Simple C++ TBAA"}
!8 = !{!9, !5, i64 0}
!9 = !{!"_ZTS4Wrap", !5, i64 0}
```

... whereas the `-UFAST` case generates this:

```llvm
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %11, i8* align 1 %12, i64 1, i1 false), !tbaa.struct !7
```
```llvm
!5 = !{!"omnipotent char", !6, i64 0}
!6 = !{!"Simple C++ TBAA"}
!7 = !{i64 0, i64 1, !8}
!8 = !{!5, !5, i64 0}
```

Presumably we could produce something like this instead:

```llvm
!5 = !{!"omnipotent char", !6, i64 0}
!6 = !{!"Simple C++ TBAA"}
!7 = !{i64 0, i64 1, !8}
!8 = !{!9, !5, i64 0}
!9 = !{!"_ZTS4Wrap", !5, i64 0}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzVVl-PozYQ_zTkZRQEJhB44CG70T5X2lQn9aUy2AS3BiNsdpv79B3bkLCXvbR9qHQnERJ7Zn7zfyaVYpfyxLWpqeZBcgiiYxAt7yzyTx2QJ_u4W23GqTbwZaQDBPv5Etw5IHnd0hH-CkgBCAYomPsDMu6PMyxJRMN4Ay-H19NaHAKSqYGP1KgxSI4WTfXa3GgzEtQIfgQV1kHyBCM309gj_WBaoe3NWhPvmWgWJQs4WCsR3uJ5FRZ1Bqo_QIDjdZczJlKuv937TQkGDcLNdqLaw7A4PYMAOHXuPkifoiA9Oh8Csqf4uSLeccYrzuohJ1lx1g85kxUnW3PeArdkfu3ns-oGITmDd2FaNWHQsmh7dElERvIM7xzOvLch5tCoaQTNB-pOGoPOteUZuVSUif4MFW_wEpwsWpZFwGndhvAF0R9CU9AoL72ObXVZ8MO1saeWwzCqSvIOhAbTUuNwLDgFrD46SYO-1Gq4ANVanPuO9-ZaIndKe2uTlG9d2PGuHi7W4PdW6dmD2FSUhr43LKnjhjJqUJUYeW3kBT1v-Mj7mltrOJyeDgcQfaPQjdHdNIJLBuYyzJGieGkpqHqRtXHzOrYDkj3IVdUHIA2qsaa5vsyiEGxE1mEF2_FXB61RGKcFwgUUjHIHNwFQwBvIptGaYQm3uH1vctiALVXoMUWOZZfm1kNha9KeCnuiErEgtj_ncNrv_POCvMdH3nQu6tg2Hr4JUV0vBmVsYn3Lkxk-c_q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