summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCUDA/address-spaces.cu
diff options
context:
space:
mode:
authorJingyue Wu <jingyue@google.com>2015-03-25 20:06:28 +0000
committerJingyue Wu <jingyue@google.com>2015-03-25 20:06:28 +0000
commit4f7b9eb217f0a065acffe81189599b7db49a0792 (patch)
treebbfeca6d434823c51a752cb7a38fadd2c4469617 /clang/test/CodeGenCUDA/address-spaces.cu
parentf9dc7036d3d2f9d0de41a1be127a41d7a9728c78 (diff)
downloadbcm5719-llvm-4f7b9eb217f0a065acffe81189599b7db49a0792.tar.gz
bcm5719-llvm-4f7b9eb217f0a065acffe81189599b7db49a0792.zip
Fix addrspace when emitting constructors of static local variables
Summary: Due to CUDA's implicit address space casting, the type of a static local variable may be more specific (i.e. with address space qualifiers) than the type expected by the constructor. Emit an addrspacecast in that case. Test Plan: Clang used to crash on the added test. Reviewers: nlewycky, pcc, eliben, rsmith Reviewed By: eliben, rsmith Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D8575 llvm-svn: 233208
Diffstat (limited to 'clang/test/CodeGenCUDA/address-spaces.cu')
-rw-r--r--clang/test/CodeGenCUDA/address-spaces.cu17
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/test/CodeGenCUDA/address-spaces.cu b/clang/test/CodeGenCUDA/address-spaces.cu
index 66952c39d56..b0ef3558e2d 100644
--- a/clang/test/CodeGenCUDA/address-spaces.cu
+++ b/clang/test/CodeGenCUDA/address-spaces.cu
@@ -100,3 +100,20 @@ __device__ float *func5() {
}
// CHECK: define float* @_Z5func5v()
// CHECK: ret float* addrspacecast (float addrspace(3)* @b to float*)
+
+struct StructWithCtor {
+ __device__ StructWithCtor(): data(1) {}
+ __device__ StructWithCtor(const StructWithCtor &second): data(second.data) {}
+ __device__ int getData() { return data; }
+ int data;
+};
+
+__device__ int construct_shared_struct() {
+// CHECK-LABEL: define i32 @_Z23construct_shared_structv()
+ __shared__ StructWithCtor s;
+// CHECK: call void @_ZN14StructWithCtorC1Ev(%struct.StructWithCtor* addrspacecast (%struct.StructWithCtor addrspace(3)* @_ZZ23construct_shared_structvE1s to %struct.StructWithCtor*))
+ __shared__ StructWithCtor t(s);
+// CHECK: call void @_ZN14StructWithCtorC1ERKS_(%struct.StructWithCtor* addrspacecast (%struct.StructWithCtor addrspace(3)* @_ZZ23construct_shared_structvE1t to %struct.StructWithCtor*), %struct.StructWithCtor* dereferenceable(4) addrspacecast (%struct.StructWithCtor addrspace(3)* @_ZZ23construct_shared_structvE1s to %struct.StructWithCtor*))
+ return t.getData();
+// CHECK: call i32 @_ZN14StructWithCtor7getDataEv(%struct.StructWithCtor* addrspacecast (%struct.StructWithCtor addrspace(3)* @_ZZ23construct_shared_structvE1t to %struct.StructWithCtor*))
+}
OpenPOWER on IntegriCloud