Debian Codegraph @

clang/test/CIR/CodeGen/inline-attributes.cpp

raw
1 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -O1 -fclangir -emit-cir %s -o %t.cir
2 // RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
3 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -O1 -fclangir -emit-llvm %s -o %t-cir.ll
4 // RUN: FileCheck --check-prefix=LLVM --input-file=%t-cir.ll %s
5 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -O1 -emit-llvm %s -o %t.ll
6 // RUN: FileCheck --check-prefix=OGCG --input-file=%t.ll %s
7
8 extern int global_var;
9
10 __attribute__((always_inline)) inline int always_inline_function(int x) {
11 return x * 2 + global_var;
12 }
13
14 inline int inline_hint_function(int x) {
15 return x - 1 + global_var;
16 }
17
18 __attribute__((noinline)) int noinline_function(int x) {
19 return x / 2 + global_var;
20 }
21
22 int regular_function(int x) {
23 return x + 1 + global_var;
24 }
25
26 // Force emission of all functions with function pointers
27 int (*always_inline_ptr)(int) = &always_inline_function;
28 int (*inline_hint_ptr)(int) = &inline_hint_function;
29 int (*noinline_ptr)(int) = &noinline_function;
30 int (*regular_ptr)(int) = &regular_function;
31
32 // CIR-LABEL: cir.func no_inline dso_local @_Z17noinline_functioni(%arg0: !s32i {{.*}}) -> !s32i
33
34 // CIR-LABEL: cir.func dso_local @_Z16regular_functioni(%arg0: !s32i {{.*}}) -> !s32i
35 // CIR-NOT: no_inline
36 // CIR-NOT: always_inline
37 // CIR-NOT: inline_hint
38 // CIR-SAME: {
39
40 // CIR-LABEL: cir.func{{.*}} always_inline {{.*}}@_Z22always_inline_functioni(%arg0: !s32i {{.*}}) -> !s32i
41
42 // CIR-LABEL: cir.func{{.*}} inline_hint {{.*}}@_Z20inline_hint_functioni(%arg0: !s32i {{.*}}) -> !s32i
43
44 // LLVM: ; Function Attrs:{{.*}} noinline
45 // LLVM: define{{.*}} i32 @_Z17noinline_functioni
46
47 // LLVM: ; Function Attrs:
48 // LLVM-NOT: noinline
49 // LLVM-NOT: alwaysinline
50 // LLVM-NOT: inlinehint
51 // LLVM-SAME: {{$}}
52 // LLVM: define{{.*}} i32 @_Z16regular_functioni
53
54 // LLVM: ; Function Attrs:{{.*}} alwaysinline
55 // LLVM: define{{.*}} i32 @_Z22always_inline_functioni
56
57 // LLVM: ; Function Attrs:{{.*}} inlinehint
58 // LLVM: define{{.*}} i32 @_Z20inline_hint_functioni
59
60 // OGCG: ; Function Attrs:{{.*}} noinline
61 // OGCG: define{{.*}} i32 @_Z17noinline_functioni
62
63 // OGCG: ; Function Attrs:
64 // OGCG-NOT: noinline
65 // OGCG-NOT: alwaysinline
66 // OGCG-NOT: inlinehint
67 // OGCG-SAME: {{$}}
68 // OGCG: define{{.*}} i32 @_Z16regular_functioni
69
70 // OGCG: ; Function Attrs:{{.*}} alwaysinline
71 // OGCG: define{{.*}} i32 @_Z22always_inline_functioni
72
73 // OGCG: ; Function Attrs:{{.*}} inlinehint
74 // OGCG: define{{.*}} i32 @_Z20inline_hint_functioni
75