1 // REQUIRES: x86-registered-target
2 // REQUIRES: nvptx-registered-target
4 // Make sure we handle target overloads correctly. Most of this is checked in
5 // sema, but special functions like constructors and destructors are here.
7 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s \
8 // RUN: | FileCheck -check-prefix=CHECK-BOTH -check-prefix=CHECK-HOST %s
9 // RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -emit-llvm -o - %s \
10 // RUN: | FileCheck -check-prefix=CHECK-BOTH -check-prefix=CHECK-DEVICE %s
12 #include "Inputs/cuda.h"
14 // Check constructors/destructors for D/H functions
20 __host__ s_cd_dh() { x = 11; }
21 __device__ s_cd_dh() { x = 12; }
25 __host__ __device__ s_cd_hd() { x = 31; }
26 __host__ __device__ ~s_cd_hd() { x = 32; }
29 // CHECK-BOTH: define{{.*}} void @_Z7wrapperv
30 #if defined(__CUDA_ARCH__)
37 // CHECK-BOTH: call void @_ZN7s_cd_dhC1Ev(
39 // CHECK-BOTH: call void @_ZN7s_cd_hdC1Ev
41 // CHECK-BOTH: call void @_ZN7s_cd_hdD1Ev(
43 // CHECK-BOTH: ret void
45 // Now it's time to check what's been generated for the methods we used.
47 // CHECK-BOTH: define linkonce_odr void @_ZN7s_cd_dhC2Ev(
48 // CHECK-HOST: store i32 11,
49 // CHECK-DEVICE: store i32 12,
50 // CHECK-BOTH: ret void
52 // CHECK-BOTH: define linkonce_odr void @_ZN7s_cd_hdC2Ev(
53 // CHECK-BOTH: store i32 31,
54 // CHECK-BOTH: ret void
56 // CHECK-BOTH: define linkonce_odr void @_ZN7s_cd_hdD2Ev(
57 // CHECK-BOTH: store i32 32,
58 // CHECK-BOTH: ret void