<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/117023>117023</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[CUDA] clang calls `__cxa_guard*` on the GPU side
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Artem-B
</td>
</tr>
</table>
<pre>
Dynamic initializers are not allowed on the GPU.
CUDA allows using empty initializers, but when we actually have one, it goes through the regular codegen and ens up being guarded by `__cxa_guard_*` calls, if the empty initializer is not eliminated by the optimizations.
E.g. https://godbolt.org/z/P67j7M81c
This also exposes inconsistent behavior vs nvcc.
When initializer is not empty, clang does allow for static local variables (and that does need a guard), but NVCC rejects it, presumably because it would require guarding it.
I think we need to
a) make sure we do not emit thread guards for the static initializers
b) disallow non-empty initializers for static local variables (that would include local `__shared__` variables that are implicitly static).
There's probably some overlap with the other dynamic initializer issue #116922
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVEGP4zYP_TXKhZjAlpM4PviQnXz50EOLPXTbY0BLjM1dWXIlOdnMry8kp5jNToFeEkAmH_keH4khcG-JWrH9JLbHFc5xcL49-Ejjy6dV5_S9Pd4tjqyALUdGw2_kA6AnsC4CGuNupMFZiAPB_z9_WYMojqI4LL-vX46HJSjAHNj2QOMU709gQr5CN0e4DWThRoAqzmjMHQa8EjhLKYAj9I4CxMG7uR9yNU_9bNCDcpp6soBWA9kA8wQdpVr9jF6Thu4OYlecz-o7nvPbWciD2BWg0Jhcny8Z8UNzwCHzJMMjW4wLWAp1U-SR3zCys-GZ9P_W_RqGGKcgqoOQJyFPvdOdM3HtfC_k6U3I0-dd_bX-dV-qHzN_HzgAmuCAvk8uUAC2ytnAIZKN0NGAV3YergHsVan1j7l_Jvn-rfXEKXFUBm0POqmYJwIX5yFEjKzAOIUGrugZO0MBhNwnNeOAccmwRBpwUVTI5p-Z_fbH6yt4-koqBuCYnidPYR6xM3foSOEcKA3v5majwdNfM3taYNKEOD5x-AXiwPZbckEuGN3yjkI2MOI3gjB7Sp-1e5DjmDxBqBfQkFmlAT2YPTktg3UJTHNYRLDOvnz05H9ok3VZKLFVZtb0iMo2CwN60udzcth7Ws5Je8PjZFhxNPdHBSGb9bMLyJOQdYDJuy4rGdxI4K7kDU5w47gsgIsDedAfFxQ4hJlAyKosd42UK91WuqkaXFFb1pUs5b7aVauhLWpUJW332Fw2l7qoNrTbblR1qTuldvLSrLiVhdyUpSzK_WZXVOtL2SAVtURqtqrYlWJT0Ihs1sZcx-TvVa7dlmVdyGplsCMT8n2RMjtQSJlOjW9Twks390FsCsMhhneIyNHko5Tuh9geH97N6_rTKj82-f0AQWBNq9mb9qcV5DjM3Vq5UchTqvT4e5m8S_4V8pQ7D0KeHs1fW_l3AAAA___FKbfS">