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

    <tr>
        <th>Summary</th>
        <td>
            [CUDA] __constant__ aggregate initializer values return undef in host compilation
        </td>
    </tr>

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

    <tr>
      <th>Assignees</th>
      <td>
            Artem-B
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Artem-B
      </td>
    </tr>
</table>

<pre>
    `__constant__` aggregate initializer values return undef in host compilation, but things work when we access individual field values or make a local copy.

Reproducer: https://godbolt.org/z/7ahK78end

```
struct S { int s; };
const __constant__ S const_s = { 77 };

__host__ S works () {
    S s = const_s;
    return s;  // returns {77}
}

__host__ S broken () {
 return const_s;  // returns undef
}
```


</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykUk1vozAQ_TXDZdTIsSGEAwfSKJe9bbVnZOwJeOvYkT9Stb9-BWGVtntcCfFh5r2Z9-bJGM3oiFqoDsB5FxJdnuY3qI6FzGnyoV0Pi8Hr9xZ2rO-VdzFJl_oedgzlOAYaZSI0ziQjrfmggDdpM0UMlHJwmJ2mMxqHk48Jlb9cjZXJeAf8GYecME3GjRHffHjFt4kcvhFKpShGNE6bm9FZWjwbsvovtQ94ka-EEq1X0qLy1_cNsA5Y95OuweusKIDocErpGkF0wE_AT6PXg7dp48MI_PQB_FTL6Ue9J6fvYNix9WJdTCGrhC8I9QGNSxhBHBDqI4gDsG4xAj8bgi-4fPQRQRwXWF0_AMC6vp89WCpntRGB74E3cymwDhHxBe_gleiOnH-sZi4z4F3NehZneF3PfVi33r-0GoJ_Jfet18r36PMP67K3B-UnZ4B1hW6FbkQjC2q3dblvWM25KKZWV3yoB0G7gVesGc5i2xAvK7WXO2JNXRam5YxXbMc4F0KUfHM-N9W2FNUwqC0rtYCS0UUau7H2dplXVZgYM7XbklesLKwcyMY1tCpruSY2tHP905DHCCWzJqb4YEgm2SXoz7-OHVTHr3v7rxQXOdj2W8xMmvKwUf4C_DTPsD6ersH_JpWAnxZJEfhpVXVr-Z8AAAD__4l8HQs">