[clang] [CUDA][HIP] Fix implicit attribute of builtin (PR #138162)
Yaxun Liu via cfe-commits
cfe-commits at lists.llvm.org
Fri May 2 09:51:27 PDT 2025
================
@@ -0,0 +1,23 @@
+// expected-no-diagnostics
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -aux-triple amdgcn-amd-amdhsa -fsyntax-only -verify -xhip %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fsyntax-only -fcuda-is-device -verify -xhip %s
+
+#include "Inputs/cuda.h"
+
+__global__ void kernel() {
+ __attribute__((address_space(0))) void *mem_ptr;
+ (void)__builtin_amdgcn_is_shared(mem_ptr);
----------------
yxsamliu wrote:
You are right. Clang actually adds implicit host or device attribute to builtin functions in `Sema::AddKnownFunctionAttributes`. Calling a device builtin in host function will cause a bad target error. I will add implicit device or host attribute to the overloaded builtin function.
https://github.com/llvm/llvm-project/pull/138162
More information about the cfe-commits
mailing list