[clang] [HIP] Perform implicit pointer cast when compiling device code, not when -fcuda-is-device (PR #165387)

Yaxun Liu via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 19 10:48:41 PST 2025


================
@@ -6734,8 +6734,10 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc,
     // If Arg is declared in the default address space and Param is declared
     // in a non-default address space, perform an implicit address space cast to
     // the parameter type.
-    if (getLangOpts().HIP && getLangOpts().CUDAIsDevice && FD &&
-        FD->getBuiltinID()) {
+    FunctionDecl *Caller = getCurFunctionDecl(/*AllowLambda =*/true);
+    bool CallerIsDevice = Caller && (Caller->hasAttr<CUDAGlobalAttr>() ||
+                                     Caller->hasAttr<CUDADeviceAttr>());
+    if (getLangOpts().HIP && CallerIsDevice && FD && FD->getBuiltinID()) {
----------------
yxsamliu wrote:

maybe we should allow this always in HIP, not limited by device caller functions. my understanding is that the addr space in builtin arg is intended for addr-space-aware languages like OpenCL only.

the comments need update.

https://github.com/llvm/llvm-project/pull/165387


More information about the cfe-commits mailing list