xref: /llvm-project/clang/test/CodeGenCUDA/noinline.cu (revision afc9d674fe5a14b95c50a38d8605a159c2460427)
1 // Uses -O2 since the defalt -O0 option adds noinline to all functions.
2 
3 // RUN: %clang_cc1 -triple nvptx-nvidia-cuda -fcuda-is-device \
4 // RUN:     -O2 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
5 
6 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device \
7 // RUN:     -O2 -disable-llvm-passes -emit-llvm -o - -x hip %s | FileCheck %s
8 
9 // RUN: %clang_cc1 -triple x86_64-unknown-gnu-linux \
10 // RUN:     -O2 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
11 
12 #include "Inputs/cuda.h"
13 
fun1()14 __noinline__ __device__ __host__ void fun1() {}
15 
fun2()16 __attribute__((noinline)) __device__ __host__ void fun2() {}
17 
fun3()18 __attribute__((__noinline__)) __device__ __host__ void fun3() {}
19 
fun4()20 [[gnu::__noinline__]] __device__ __host__ void fun4() {}
21 
22 #define __noinline__ __attribute__((__noinline__))
fun5()23 __noinline__ __device__ __host__ void fun5() {}
24 
fun6()25 __device__ __host__ void fun6() {}
26 
27 // CHECK: define{{.*}}@_Z4fun1v{{.*}}#[[ATTR1:[0-9]*]]
28 // CHECK: define{{.*}}@_Z4fun2v{{.*}}#[[ATTR1:[0-9]*]]
29 // CHECK: define{{.*}}@_Z4fun3v{{.*}}#[[ATTR1:[0-9]*]]
30 // CHECK: define{{.*}}@_Z4fun4v{{.*}}#[[ATTR1:[0-9]*]]
31 // CHECK: define{{.*}}@_Z4fun5v{{.*}}#[[ATTR1:[0-9]*]]
32 // CHECK: define{{.*}}@_Z4fun6v{{.*}}#[[ATTR2:[0-9]*]]
33 // CHECK: attributes #[[ATTR1]] = {{.*}}noinline
34 // CHECK-NOT: attributes #[[ATTR2]] = {{.*}}noinline
35