summaryrefslogtreecommitdiff
path: root/test/CodeGen/x86_64-instrument-functions.c
blob: 686d9aa14ca72b6e88b97d55ec1ad40bb5f146f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// REQUIRES: x86-registered-target
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -finstrument-functions -O2 -o - %s | FileCheck %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -finstrument-functions-after-inlining -O2 -o - %s | FileCheck -check-prefix=NOINLINE %s

// It's not so nice having asm tests in Clang, but we need to check that we set
// up the pipeline correctly in order to have the instrumentation inserted.

int leaf(int x) {
  return x;
// CHECK-LABEL: leaf:
// CHECK: callq __cyg_profile_func_enter
// CHECK-NOT: cyg_profile
// CHECK: callq __cyg_profile_func_exit
// CHECK-NOT: cyg_profile
// CHECK: ret
}

int root(int x) {
  return leaf(x);
// CHECK-LABEL: root:
// CHECK: callq __cyg_profile_func_enter
// CHECK-NOT: cyg_profile

// Inlined from leaf():
// CHECK: callq __cyg_profile_func_enter
// CHECK-NOT: cyg_profile
// CHECK: callq __cyg_profile_func_exit

// CHECK-NOT: cyg_profile
// CHECK: callq __cyg_profile_func_exit
// CHECK: ret

// NOINLINE-LABEL: root:
// NOINLINE: callq __cyg_profile_func_enter
// NOINLINE-NOT: cyg_profile
// NOINLINE: callq __cyg_profile_func_exit
// NOINLINE: ret
}