76 lines · cpp
1// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -O1 -fclangir -emit-cir %s -o %t.cir2// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s3// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -O1 -fclangir -emit-llvm %s -o %t-cir.ll4// RUN: FileCheck --check-prefix=LLVM --input-file=%t-cir.ll %s5// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -O1 -emit-llvm %s -o %t.ll6// RUN: FileCheck --check-prefix=OGCG --input-file=%t.ll %s7 8extern int global_var;9 10__attribute__((always_inline)) inline int always_inline_function(int x) {11 return x * 2 + global_var;12}13 14inline 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 22int regular_function(int x) {23 return x + 1 + global_var;24}25 26// Force emission of all functions with function pointers27int (*always_inline_ptr)(int) = &always_inline_function;28int (*inline_hint_ptr)(int) = &inline_hint_function;29int (*noinline_ptr)(int) = &noinline_function;30int (*regular_ptr)(int) = ®ular_function;31 32// CIR-LABEL: cir.func dso_local @_Z17noinline_functioni(%arg0: !s32i {{.*}}) -> !s32i inline(never)33 34// CIR-LABEL: cir.func dso_local @_Z16regular_functioni(%arg0: !s32i {{.*}}) -> !s32i35// CIR-NOT: inline(never)36// CIR-NOT: inline(always)37// CIR-NOT: inline(hint)38// CIR-SAME: {39 40// CIR-LABEL: cir.func {{.*}}@_Z22always_inline_functioni(%arg0: !s32i {{.*}}) -> !s32i inline(always)41 42// CIR-LABEL: cir.func {{.*}}@_Z20inline_hint_functioni(%arg0: !s32i {{.*}}) -> !s32i inline(hint)43 44// LLVM: ; Function Attrs:{{.*}} noinline45// LLVM: define{{.*}} i32 @_Z17noinline_functioni46 47// LLVM: ; Function Attrs:48// LLVM-NOT: noinline49// LLVM-NOT: alwaysinline50// LLVM-NOT: inlinehint51// LLVM-SAME: {{$}}52// LLVM: define{{.*}} i32 @_Z16regular_functioni53 54// LLVM: ; Function Attrs:{{.*}} alwaysinline55// LLVM: define{{.*}} i32 @_Z22always_inline_functioni56 57// LLVM: ; Function Attrs:{{.*}} inlinehint58// LLVM: define{{.*}} i32 @_Z20inline_hint_functioni59 60// OGCG: ; Function Attrs:{{.*}} noinline61// OGCG: define{{.*}} i32 @_Z17noinline_functioni62 63// OGCG: ; Function Attrs:64// OGCG-NOT: noinline65// OGCG-NOT: alwaysinline66// OGCG-NOT: inlinehint67// OGCG-SAME: {{$}}68// OGCG: define{{.*}} i32 @_Z16regular_functioni69 70// OGCG: ; Function Attrs:{{.*}} alwaysinline71// OGCG: define{{.*}} i32 @_Z22always_inline_functioni72 73// OGCG: ; Function Attrs:{{.*}} inlinehint74// OGCG: define{{.*}} i32 @_Z20inline_hint_functioni75 76