[PATCH] D118153: [CUDA][HIP] Do not treat host var address as constant in device compilation

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 27 10:03:03 PST 2022


yaxunl updated this revision to Diff 403706.
yaxunl added a comment.

Fix the regression in lit tests.

Basically in device compilation we still evaluate constant expression for host functions or host template instantiation. If we just disallow host variable in any constant expressions we will get errors in template class instantiation which use host variables as non-type template arguments.

Therefore we should only disallow host variables in constant expressions in situations when we are sure that allowing them will lead to issues, e.g. when promoting const variables.

A CUDAConstantEvaluationContext is introduced in ASTContext to control this.


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

https://reviews.llvm.org/D118153

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Sema/SemaCUDA.cpp
  clang/test/CodeGenCUDA/const-var.cu
  clang/test/SemaCUDA/const-var.cu

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118153.403706.patch
Type: text/x-patch
Size: 6467 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220127/3a45f1b8/attachment.bin>


More information about the cfe-commits mailing list