Debian Codegraph @

clang/test/CodeGen/AMDGPU/nullptr-in-different-address-spaces.cpp

raw
1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 6
2 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -target-cpu gfx900 -O1 -emit-llvm -o - %s | FileCheck %s
3 // REQUIRES: amdgpu-registered-target
4
5 extern __attribute__((address_space(3))) unsigned char * ptr_as3; // local address space
6 extern __attribute__((address_space(5))) unsigned char * ptr_as5; // private address space
7
8 // CHECK-LABEL: define dso_local noundef ptr @_Z11get_ptr_as3b(
9 // CHECK-SAME: i1 noundef zeroext [[V:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
10 // CHECK-NEXT: [[ENTRY:.*:]]
11 // CHECK-NEXT: [[TMP0:%.*]] = load ptr addrspace(3), ptr addrspace(1) @ptr_as3, align 4
12 // CHECK-NEXT: [[TMP1:%.*]] = select i1 [[V]], ptr addrspace(3) [[TMP0]], ptr addrspace(3) addrspacecast (ptr null to ptr addrspace(3))
13 // CHECK-NEXT: [[TMP2:%.*]] = addrspacecast ptr addrspace(3) [[TMP1]] to ptr
14 // CHECK-NEXT: ret ptr [[TMP2]]
15 //
16 unsigned char *get_ptr_as3(bool v) {
17 return v ? ptr_as3 : nullptr;
18 }
19
20 // CHECK-LABEL: define dso_local noundef ptr @_Z20get_ptr_as3_with_tmpb(
21 // CHECK-SAME: i1 noundef zeroext [[V:%.*]]) local_unnamed_addr #[[ATTR0]] {
22 // CHECK-NEXT: [[ENTRY:.*:]]
23 // CHECK-NEXT: [[TMP0:%.*]] = load ptr addrspace(3), ptr addrspace(1) @ptr_as3, align 4
24 // CHECK-NEXT: [[TMP1:%.*]] = select i1 [[V]], ptr addrspace(3) [[TMP0]], ptr addrspace(3) addrspacecast (ptr null to ptr addrspace(3))
25 // CHECK-NEXT: [[TMP2:%.*]] = addrspacecast ptr addrspace(3) [[TMP1]] to ptr
26 // CHECK-NEXT: ret ptr [[TMP2]]
27 //
28 unsigned char *get_ptr_as3_with_tmp(bool v) {
29 unsigned char *tmp = nullptr;
30 return v ? ptr_as3 : tmp;
31 }
32
33 // CHECK-LABEL: define dso_local noundef ptr @_Z11get_ptr_as5b(
34 // CHECK-SAME: i1 noundef zeroext [[V:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] {
35 // CHECK-NEXT: [[ENTRY:.*:]]
36 // CHECK-NEXT: [[TMP0:%.*]] = load ptr addrspace(5), ptr addrspace(1) @ptr_as5, align 4
37 // CHECK-NEXT: [[TMP1:%.*]] = select i1 [[V]], ptr addrspace(5) [[TMP0]], ptr addrspace(5) addrspacecast (ptr null to ptr addrspace(5))
38 // CHECK-NEXT: [[TMP2:%.*]] = addrspacecast ptr addrspace(5) [[TMP1]] to ptr
39 // CHECK-NEXT: ret ptr [[TMP2]]
40 //
41 unsigned char *get_ptr_as5(bool v) {
42 return v ? ptr_as5 : nullptr;
43 }
44
45 // CHECK-LABEL: define dso_local noundef ptr @_Z20get_ptr_as5_with_tmpb(
46 // CHECK-SAME: i1 noundef zeroext [[V:%.*]]) local_unnamed_addr #[[ATTR1]] {
47 // CHECK-NEXT: [[ENTRY:.*:]]
48 // CHECK-NEXT: [[TMP0:%.*]] = load ptr addrspace(5), ptr addrspace(1) @ptr_as5, align 4
49 // CHECK-NEXT: [[TMP1:%.*]] = select i1 [[V]], ptr addrspace(5) [[TMP0]], ptr addrspace(5) addrspacecast (ptr null to ptr addrspace(5))
50 // CHECK-NEXT: [[TMP2:%.*]] = addrspacecast ptr addrspace(5) [[TMP1]] to ptr
51 // CHECK-NEXT: ret ptr [[TMP2]]
52 //
53 unsigned char *get_ptr_as5_with_tmp(bool v) {
54 unsigned char *tmp = nullptr;
55 return v ? ptr_as5 : tmp;
56 }