brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · 6103edb Raw
47 lines · plain
1// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --functions "bar" --version 52// REQUIRES: amdgpu-registered-target3// 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 %s5 6struct 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 ptr21// AMDGCN-NEXT:    [[SRC_PTR_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[SRC_PTR_ADDR]] to ptr22// AMDGCN-NEXT:    [[AGG_RESULT_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[AGG_RESULT]] to ptr23// AMDGCN-NEXT:    [[DST_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[DST]] to ptr24// AMDGCN-NEXT:    store ptr addrspace(5) [[AGG_RESULT]], ptr [[RESULT_PTR_ASCAST]], align 425// AMDGCN-NEXT:    store ptr [[SRC_PTR]], ptr [[SRC_PTR_ADDR_ASCAST]], align 826// 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 828// AMDGCN-NEXT:    [[TMP0:%.*]] = load ptr, ptr [[SRC_PTR_ADDR_ASCAST]], align 829// AMDGCN-NEXT:    [[VAL:%.*]] = getelementptr inbounds nuw [[STRUCT_FOO]], ptr [[TMP0]], i32 0, i32 030// AMDGCN-NEXT:    [[TMP1:%.*]] = load i64, ptr [[VAL]], align 831// AMDGCN-NEXT:    [[TMP2:%.*]] = load ptr, ptr [[DST_ASCAST]], align 832// AMDGCN-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds i64, ptr [[TMP2]], i64 033// AMDGCN-NEXT:    store i64 [[TMP1]], ptr [[ARRAYIDX]], align 834// AMDGCN-NEXT:    ret void35//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}47