Debian Codegraph @

clang/test/CodeGenHIP/store-addr-space.hip

raw
1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --functions "bar" --version 5
2 // REQUIRES: amdgpu-registered-target
3 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -x hip -emit-llvm -fcuda-is-device \
4 // RUN: -o - %s | FileCheck --check-prefix=AMDGCN --enable-var-scope %s
5
6 struct Foo {
7 unsigned long long val;
8 //
9 __attribute__((device)) inline Foo() { val = 0; }
10 __attribute__((device)) inline Foo(const Foo &src) { val = src.val; }
11 __attribute__((device)) inline Foo(const volatile Foo &src) { val = src.val; }
12 };
13
14 // AMDGCN-LABEL: define dso_local void @_Z3barPK3Foo(
15 // AMDGCN-SAME: ptr addrspace(5) dead_on_unwind noalias writable sret([[STRUCT_FOO:%.*]]) align 8 [[AGG_RESULT:%.*]], ptr noundef [[SRC_PTR:%.*]]) #[[ATTR0:[0-9]+]] {
16 // AMDGCN-NEXT: [[ENTRY:.*:]]
17 // AMDGCN-NEXT: [[RESULT_PTR:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
18 // AMDGCN-NEXT: [[SRC_PTR_ADDR:%.*]] = alloca ptr, align 8, addrspace(5)
19 // AMDGCN-NEXT: [[DST:%.*]] = alloca [[UNION_ANON:%.*]], align 8, addrspace(5)
20 // AMDGCN-NEXT: [[RESULT_PTR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RESULT_PTR]] to ptr
21 // AMDGCN-NEXT: [[SRC_PTR_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[SRC_PTR_ADDR]] to ptr
22 // AMDGCN-NEXT: [[AGG_RESULT_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[AGG_RESULT]] to ptr
23 // AMDGCN-NEXT: [[DST_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[DST]] to ptr
24 // AMDGCN-NEXT: store ptr addrspace(5) [[AGG_RESULT]], ptr [[RESULT_PTR_ASCAST]], align 4
25 // AMDGCN-NEXT: store ptr [[SRC_PTR]], ptr [[SRC_PTR_ADDR_ASCAST]], align 8
26 // AMDGCN-NEXT: call void @_ZN3FooC1Ev(ptr noundef nonnull align 8 dereferenceable(8) [[AGG_RESULT_ASCAST]]) #[[ATTR1:[0-9]+]]
27 // AMDGCN-NEXT: store ptr [[AGG_RESULT_ASCAST]], ptr [[DST_ASCAST]], align 8
28 // AMDGCN-NEXT: [[TMP0:%.*]] = load ptr, ptr [[SRC_PTR_ADDR_ASCAST]], align 8
29 // AMDGCN-NEXT: [[VAL:%.*]] = getelementptr inbounds nuw [[STRUCT_FOO]], ptr [[TMP0]], i32 0, i32 0
30 // AMDGCN-NEXT: [[TMP1:%.*]] = load i64, ptr [[VAL]], align 8
31 // AMDGCN-NEXT: [[TMP2:%.*]] = load ptr, ptr [[DST_ASCAST]], align 8
32 // AMDGCN-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i64, ptr [[TMP2]], i64 0
33 // AMDGCN-NEXT: store i64 [[TMP1]], ptr [[ARRAYIDX]], align 8
34 // AMDGCN-NEXT: ret void
35 //
36 __attribute__((device)) Foo bar(const Foo *const src_ptr) {
37 Foo result;
38
39 union {
40 Foo* const ptr;
41 unsigned long long * const ptr64;
42 } dst = {&result};
43
44 dst.ptr64[0] = src_ptr->val;
45 return result;
46 }