xref: /llvm-project/llvm/test/Transforms/EntryExitInstrumenter/pre-inliner-instrumentation.ll (revision cab81dd03813ac6333ad7fc031d72b84341fe2b9)
1; RUN: opt -passes="default<O0>" -S < %s | FileCheck -check-prefix=INSTRUMENT %s
2; RUN: opt -passes="default<O1>" -S < %s | FileCheck -check-prefix=INSTRUMENT %s
3; RUN: opt -passes="thinlto-pre-link<O0>" -S < %s | FileCheck -check-prefix=INSTRUMENT %s
4; RUN: opt -passes="thinlto-pre-link<O2>" -S < %s | FileCheck -check-prefix=INSTRUMENT %s
5; RUN: opt -passes="thinlto<O0>" -S < %s | FileCheck -check-prefix=NOINSTRUMENT %s
6; RUN: opt -passes="thinlto<O2>" -S < %s | FileCheck -check-prefix=NOINSTRUMENT %s
7; RUN: opt -passes="lto<O0>" -S < %s | FileCheck -check-prefix=NOINSTRUMENT %s
8; RUN: opt -passes="lto<O2>" -S < %s | FileCheck -check-prefix=NOINSTRUMENT %s
9
10; Pre-inline instrumentation should be inserted, but not by LTO/ThinLTO passes.
11
12target triple = "x86_64-unknown-linux"
13
14define void @leaf_function() #0 {
15entry:
16  ret void
17; INSTRUMENT-LABEL:   entry:
18; INSTRUMENT-NEXT:    %0 ={{.*}} call ptr @llvm.returnaddress(i32 0)
19; INSTRUMENT-NEXT:    {{.* call void @__cyg_profile_func_enter\(ptr( nonnull)? @leaf_function, ptr %0\)}}
20; NOINSTRUMENT-NOT:   {{.*}} call void @__cyg_profile_func_enter
21; INSTRUMENT:         {{.*}} call void @__cyg_profile_func_exit
22; INSTRUMENT-NEXT:    ret void
23; NOINSTRUMENT-NOT:   {{.*}} call void @__cyg_profile_func_exit
24; NOINSTRUMENT-LABEL: entry:
25; NOINSTRUMENT-NEXT:  ret void
26}
27
28
29define void @root_function() #1 {
30entry:
31  call void @leaf_function()
32  ret void
33; INSTRUMENT-LABEL:   entry:
34; INSTRUMENT-NEXT:    %0 ={{.*}} call ptr @llvm.returnaddress(i32 0)
35; INSTRUMENT-NEXT:    {{.*}} call void @__cyg_profile_func_enter(ptr{{( nonnull)?}} @root_function, ptr %0)
36; INSTRUMENT:         {{.*}} call void @__cyg_profile_func_enter
37; INSTRUMENT:         {{.*}} call void @__cyg_profile_func_exit
38; INSTRUMENT:         {{.*}} call void @__cyg_profile_func_exit
39; INSTRUMENT-NEXT:    ret void
40; NOINSTRUMENT-LABEL: entry:
41; NOINSTRUMENT:       ret void
42; NOINSTRUMENT-NOT:   {{.*}} call void @__cyg_profile_func_exit
43}
44
45attributes #0 = { alwaysinline "instrument-function-entry"="__cyg_profile_func_enter" "instrument-function-exit"="__cyg_profile_func_exit" }
46attributes #1 = { "instrument-function-entry"="__cyg_profile_func_enter" "instrument-function-exit"="__cyg_profile_func_exit" }
47