[PATCH] D54947: [OpenCL][CodeGen] Fix replacing memcpy with addrspacecast

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 28 03:35:29 PST 2018


Anastasia added inline comments.


================
Comment at: lib/CodeGen/CGCall.cpp:3972
+          // we don't want to perform address space cast for it, since that
+          // leads to casting __private * (default addr space in OpenCL) to
+          // __global * which is not valid. Create memcpy call instead.
----------------
This statement is incorrect. Private is only default AS in CL versions before 2.0.

I feel this can be expressed simpler. I guess the observation here is that if addr space mismatches it has to generate a copy because even if it would be a generic we can't get what the original specific addr space was? So it's safe to generate a copy.


================
Comment at: test/CodeGenOpenCL/addr-space-struct-arg.cl:4
 // RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL2.0 -O0 -finclude-default-header -triple amdgcn | FileCheck -enable-var-scope -check-prefixes=COM,AMDGCN,AMDGCN20 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL1.2 -O0 -finclude-default-header -triple spir-unknown-unknown-unknown | FileCheck -enable-var-scope -check-prefixes=SPIR %s
 
----------------
Do you know why we need `-finclude-default-header` here? If it's just for vector types perhaps we should just declare them here... headers parsing is expensive in terms of time.


Repository:
  rC Clang

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

https://reviews.llvm.org/D54947





More information about the cfe-commits mailing list