[PATCH] D103108: [CUDA][HIP] Promote const variables to constant

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 26 18:49:07 PDT 2021


yaxunl marked an inline comment as done.
yaxunl added inline comments.


================
Comment at: clang/test/SemaCUDA/device-use-host-var.cu:90
+  const int &ref_const_var = global_const_var;
   const int &ref_constexpr_var = global_constexpr_var;
   *out = ref_host_var;
----------------
tra wrote:
> What happens if we have  `const int &ref_foo = something_we_cant_emit_on_device;`?
> Both if ref_foo is and isn't used from device code.
> 
> 
If we have `const int &ref_foo = something_we_cant_emit_on_device`, `__constant__` attribute will not be added. If `ref_foo` is used in device code, it will be diagnosed. If `ref_foo` is not used in device code, no diagnostics is emitted.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103108/new/

https://reviews.llvm.org/D103108



More information about the cfe-commits mailing list