1 // RUN: %clang_cc1 %s -triple x86_64-linux-unknown -emit-llvm -o - \
2 // RUN: | FileCheck -check-prefix=HOST %s
3 // RUN: %clang_cc1 %s -fcuda-is-device \
4 // RUN: -emit-llvm -o - -triple nvptx64 \
5 // RUN: -aux-triple x86_64-unknown-linux-gnu | FileCheck \
6 // RUN: -check-prefix=DEV %s
8 #include "Inputs/cuda.h"
10 // Check host/device-based overloding resolution in global variable initializer.
11 double pow(double, double) { return 1.0; }
13 __device__ double pow(double, int) { return 2.0; }
15 // HOST-DAG: call {{.*}}double @_Z3powdd(double noundef 1.000000e+00, double noundef 1.000000e+00)
16 double X = pow(1.0, 1);
18 constexpr double cpow(double, double) { return 11.0; }
20 constexpr __device__ double cpow(double, int) { return 12.0; }
22 // HOST-DAG: @CX = global double 1.100000e+01
23 double CX = cpow(11.0, 1);
25 // DEV-DAG: @CY = addrspace(1) externally_initialized global double 1.200000e+01
26 __device__ double CY = cpow(12.0, 1);
29 double pow(double, double) { return 3.0; }
31 __device__ double pow(double, int) { return 4.0; }
36 // HOST-DAG: call {{.*}}double @_ZN1A3powEdd(ptr {{.*}}@a, double noundef 3.000000e+00, double noundef 1.000000e+00)
37 double AX = a.pow(3.0, 1);
40 constexpr double cpow(double, double) const { return 13.0; }
42 constexpr __device__ double cpow(double, int) const { return 14.0; }
47 // HOST-DAG: @CAX = global double 1.300000e+01
48 double CAX = ca.cpow(13.0, 1);
50 // DEV-DAG: @CAY = addrspace(1) externally_initialized global double 1.400000e+01
51 __device__ double CAY = ca.cpow(14.0, 1);