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

    <tr>
        <th>Summary</th>
        <td>
            bpf target tries to emit `memcpy` and fails to compile
        </td>
    </tr>

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

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

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

<pre>
    Consider this C code:

```
#include <stdint.h>
typedef struct {
    unsigned char x[8];
} buf_t;
void f(buf_t *buf, uint64_t y, uint64_t z) {
    if (z > 8) z = 8;
 unsigned char *y_bytes = (unsigned char *)&y;
    for (int i = 0; i < z; ++i) {
        buf->x[i] = y_bytes[i];
    }
}
```

It fails to compile on clang 18:

```
$ clang -O3 -target bpf test.c
test.c:5:6: error: A call to built-in function 'memcpy' is not supported.
    5 | void f(buf_t *buf, uint64_t y, uint64_t z) {
      | ^
1 error generated.
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykU9-uuzYMfhpzY7WCBAhccNE_p9Ku9ghHhIQ2U0hQ4pzf2qefoKzV2Zm0iyEUHDv29-HP6WM0V6d1B9URqnPWJ7r50KWpd7_Mow8qk17du5N30SgdkG4m4gkHrzTwA-RnyP9e63x7n1vGjRtsUhqBnyIp42h_A_7xDNN91kqPGCmkgRDE8elHRExu5aRwuPUB_4Tq2EB1Br4dAXFGmcZPenm-vFE4AmtWNwI7yDQCO2Eyjuryk_D-bfcA1n6HNCMCax4I_AObJbqYZ2xeEP8gBexw_5R30nE9B6z5EQfWAqvv7wqIOPol1BhHaNbEHPhxNU_4WExgR2BH84Pf8sg07oB_LP0wUJ3X_I3E5vqGBeL86te_K7SuvxGOvbERyePgp9lYjd7hYHt3xaL5L5HL7eTud4476sNVE8p5RNKR9sOm9dPmhwr4oQZ-QB2CD4txwKG3dsGWyVjaGYdjcgMZ7xCYmPQ0zHdgAk1E5wljmmcfSKv9-0crBHHC_z8DuNaBapvQ4skSr9rp0L8hXy3IVMdVy9s-010hirptRV2L7Nb1ohZjqXQl21I2IytLUY11WeiBtUMuZGY6lrMyr1hbVKUoxV4Wgrda5YVoCjkKCWWup97YvbVf096Ha2ZiTLprucjzzPZS27jeWMac_oVrEBhbLnDolpydTNcIZW5NpPiuQoas7lZ9nlJRMHqVXk-GEOp863idY-_Uj8nIUrDdjWiOy1ywC7DL1dAtyf3gJ2CXBWj77Obg_9ADAbus9CKwy5P-V8f-CgAA___Ua0fH">