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

Juan Manuel Martinez CaamaƱo via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 20 08:59:15 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()) {
----------------
jmmartinez wrote:

We would be adding implicit casts on the host side, while I'd expect the host side to remain the same.

At the same time, I guess it doesn't really matter since the host side is not as address-space-rich as the device.

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


More information about the cfe-commits mailing list