1 // REQUIRES: amdgpu-registered-target
2 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -x hip %s \
3 // RUN: -std=c++11 -O3 -mllvm -amdgpu-internalize-symbols -emit-llvm -o - \
4 // RUN: -target-cpu gfx906 | FileCheck %s
5 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -x hip %s \
6 // RUN: -std=c++11 -O3 -mllvm -amdgpu-internalize-symbols -emit-llvm -o - \
7 // RUN: -target-cpu gfx906 | FileCheck -check-prefix=NEGCHK %s
9 #include "Inputs/cuda.h"
11 // AMDGPU internalize unused global variables for whole-program compilation
12 // (-fno-gpu-rdc for each TU, or -fgpu-rdc for LTO), which are then
13 // eliminated by global DCE. If there are invisible unused address space casts
14 // for global variables, these dead users need to be eliminated by global
15 // DCE before internalization. This test makes sure unused global variables
24 // Check unused device/constant variables are eliminated.
26 // NEGCHK-NOT: @_ZL2v3
29 // Check managed variables are always kept.
34 // Check used device/constant variables are not eliminated.
41 // Check u3 is kept because its address is taken.
45 // Check u4 is not kept because it is not ODR-use.
46 // NEGCHK-NOT: @_ZL2u4
49 __device__ int fun1(const int& x);
51 __global__ void kern1(int *x) {
52 *x = u1 + u2 + fun1(u3) + u4;