xref: /llvm-project/clang/test/CodeGenCUDA/lambda-noinline.cu (revision 0419465fa4358af1ec808e376e3881377bfac76b)
1 // RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
2 // RUN:   -triple x86_64-linux-gnu \
3 // RUN:   | FileCheck -check-prefix=HOST %s
4 // RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
5 // RUN:   -triple amdgcn-amd-amdhsa -fcuda-is-device \
6 // RUN:   | FileCheck -check-prefix=DEV %s
7 
8 #include "Inputs/cuda.h"
9 
10 // Checks noinline is correctly added to the lambda function.
11 
12 // HOST: define{{.*}}@_ZZ4HostvENKUlvE_clEv({{.*}}) #[[ATTR:[0-9]+]]
13 // HOST: attributes #[[ATTR]]{{.*}}noinline
14 
15 // DEV: define{{.*}}@_ZZ6DevicevENKUlvE_clEv({{.*}}) #[[ATTR:[0-9]+]]
16 // DEV: attributes #[[ATTR]]{{.*}}noinline
17 
18 __device__ int a;
19 int b;
20 
Device()21 __device__ int Device() { return ([&] __device__ __noinline__ (){ return a; })(); }
22 
Host()23 __host__ int Host() { return ([&] __host__ __noinline__ (){ return b; })(); }
24