[clang] [cuda][[HIP] `__constant__` should imply constant (PR #110182)
Artem Belevich via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 26 17:02:24 PDT 2024
Artem-B wrote:
I'm not 100% sure that `externally_initialized` is sufficient to deal with this use pattern.
IR manual says: https://llvm.org/docs/LangRef.html#global-variables
> By default, global initializers are optimized by assuming that global variables defined within the module are not modified from their initial values before the start of the global initializer. This is true even for variables potentially accessible from outside the module, including those with external linkage or appearing in @llvm.used or dllexported variables. This assumption may be suppressed by marking the variable with externally_initialized.
It appears that `externally_initialized` is meant to suppress the assumption about the values only up to the point of the global initializer start. However, CUDA & NVIDIA GPUs do not have any global initializers, so it's either constant values or uninitialized. Considering that the values in the array may be changed by the host between kernel invocations, LLVM should never use the 'known' values in the global arrays, unless they explicitly made `const` by the user.
https://github.com/llvm/llvm-project/pull/110182
More information about the cfe-commits
mailing list