[PATCH] D111734: [HIP] Relax conditions for address space cast in builtin args

Anshil Gandhi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 13 08:42:59 PDT 2021


gandhi21299 updated this revision to Diff 379419.
gandhi21299 added a comment.

removed irrelevant lines in the test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111734

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCUDA/builtins-unsafe-atomics-gfx90a.cu


Index: clang/test/CodeGenCUDA/builtins-unsafe-atomics-gfx90a.cu
===================================================================
--- /dev/null
+++ clang/test/CodeGenCUDA/builtins-unsafe-atomics-gfx90a.cu
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -target-cpu gfx90a -x hip \
+// RUN:  -aux-triple x86_64-unknown-linux-gnu -fcuda-is-device -emit-llvm %s \
+// RUN:  -o - | FileCheck %s
+
+#define __device__ __attribute__((device))
+typedef __attribute__((address_space(3))) float *LP;
+
+// CHECK-LABEL: test_ds_atomic_add_f32
+__device__ void test_ds_atomic_add_f32(float *addr, float val) {
+  float *rtn;
+  *rtn = __builtin_amdgcn_ds_faddf((LP)addr, val, 0, 0, 0);
+}
Index: clang/lib/Sema/SemaExpr.cpp
===================================================================
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6547,7 +6547,9 @@
 
         // Only allow implicit casting from a non-default address space pointee
         // type to a default address space pointee type
-        if (ArgAS != LangAS::Default || ParamAS == LangAS::Default)
+        if (ArgAS != LangAS::Default &&
+            getASTContext().getTargetAddressSpace(ArgAS) !=
+                getASTContext().getTargetAddressSpace(ParamAS))
           continue;
 
         // First, ensure that the Arg is an RValue.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111734.379419.patch
Type: text/x-patch
Size: 1336 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211013/f21a38a1/attachment.bin>


More information about the cfe-commits mailing list