[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
Fri Nov 21 01:15:37 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:
I've updated the condition and dropped the `CallerIsDevice` side of it.
https://github.com/llvm/llvm-project/pull/165387
More information about the cfe-commits
mailing list