Clang Project

clang_source_code/test/CodeGen/x86_64-instrument-functions.c
1// REQUIRES: x86-registered-target
2// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -finstrument-functions -O2 -o - %s | FileCheck %s
3// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -finstrument-functions-after-inlining -O2 -o - %s | FileCheck -check-prefix=NOINLINE %s
4
5// It's not so nice having asm tests in Clang, but we need to check that we set
6// up the pipeline correctly in order to have the instrumentation inserted.
7
8int leaf(int x) {
9  return x;
10// CHECK-LABEL: leaf:
11// CHECK: callq __cyg_profile_func_enter
12// CHECK-NOT: cyg_profile
13// CHECK: callq __cyg_profile_func_exit
14// CHECK-NOT: cyg_profile
15// CHECK: ret
16}
17
18int root(int x) {
19  return leaf(x);
20// CHECK-LABEL: root:
21// CHECK: callq __cyg_profile_func_enter
22// CHECK-NOT: cyg_profile
23
24// Inlined from leaf():
25// CHECK: callq __cyg_profile_func_enter
26// CHECK-NOT: cyg_profile
27// CHECK: callq __cyg_profile_func_exit
28
29// CHECK-NOT: cyg_profile
30// CHECK: callq __cyg_profile_func_exit
31// CHECK: ret
32
33// NOINLINE-LABEL: root:
34// NOINLINE: callq __cyg_profile_func_enter
35// NOINLINE-NOT: cyg_profile
36// NOINLINE: callq __cyg_profile_func_exit
37// NOINLINE: ret
38}
39