[clang] [cuda][[HIP] `__constant__` should imply constant (PR #110182)
Artem Belevich via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 26 19:14:37 PDT 2024
Artem-B wrote:
It has nothing to do with writing to those arrays while the kernel is running. That would indeed be UB.
> both would still work just the same even with this change,
No, they will not. Here's the demonstration of the behavior change that `const` brings to the table:
https://cuda.godbolt.org/z/h6e5Wb4PT
It shows that adding `const` allows compiler to use the initializer values as written (it does not even bother instantiating `cxxx`), while without `const` it reads the array values, assuming that they may be changed externally.
https://github.com/llvm/llvm-project/pull/110182
More information about the cfe-commits
mailing list