1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2 ; RUN: opt -passes="function(ee-instrument),cgscc(inline),function(ee-instrument<post-inline>)" -S < %s | FileCheck %s
4 ; Running the passes twice should not result in more instrumentation.
5 ; RUN: opt -passes="function(ee-instrument),function(ee-instrument),cgscc(inline),function(ee-instrument<post-inline>),function(ee-instrument<post-inline>)" -S < %s | FileCheck %s
7 target datalayout = "E-m:e-i64:64-n32:64"
8 target triple = "powerpc64le-unknown-linux"
10 define void @leaf_function() #0 {
11 ; CHECK-LABEL: define void @leaf_function() {
12 ; CHECK-NEXT: call void @mcount()
13 ; CHECK-NEXT: [[TMP1:%.*]] = call ptr @llvm.returnaddress(i32 0)
14 ; CHECK-NEXT: call void @__cyg_profile_func_enter(ptr @leaf_function, ptr [[TMP1]])
15 ; CHECK-NEXT: [[TMP2:%.*]] = call ptr @llvm.returnaddress(i32 0)
16 ; CHECK-NEXT: call void @__cyg_profile_func_exit(ptr @leaf_function, ptr [[TMP2]])
17 ; CHECK-NEXT: ret void
23 define void @root_function() #0 {
24 ; CHECK-LABEL: define void @root_function() {
25 ; CHECK-NEXT: call void @mcount()
26 ; CHECK-NEXT: [[TMP1:%.*]] = call ptr @llvm.returnaddress(i32 0)
27 ; CHECK-NEXT: call void @__cyg_profile_func_enter(ptr @root_function, ptr [[TMP1]])
28 ; CHECK-NEXT: [[TMP2:%.*]] = call ptr @llvm.returnaddress(i32 0)
29 ; CHECK-NEXT: call void @__cyg_profile_func_enter(ptr @leaf_function, ptr [[TMP2]])
30 ; CHECK-NEXT: [[TMP3:%.*]] = call ptr @llvm.returnaddress(i32 0)
31 ; CHECK-NEXT: call void @__cyg_profile_func_exit(ptr @leaf_function, ptr [[TMP3]])
32 ; CHECK-NEXT: [[TMP4:%.*]] = call ptr @llvm.returnaddress(i32 0)
33 ; CHECK-NEXT: call void @__cyg_profile_func_exit(ptr @root_function, ptr [[TMP4]])
34 ; CHECK-NEXT: ret void
36 call void @leaf_function()
40 ; The mcount function has many different names.
42 define void @f1() #1 {
43 ; CHECK-LABEL: define void @f1() {
44 ; CHECK-NEXT: call void @.mcount()
45 ; CHECK-NEXT: ret void
50 define void @f2() #2 {
51 ; CHECK-LABEL: define void @f2() {
52 ; CHECK-NEXT: call void @llvm.arm.gnu.eabi.mcount()
53 ; CHECK-NEXT: ret void
58 define void @f3() #3 {
59 ; CHECK-LABEL: define void @f3() {
60 ; CHECK-NEXT: call void @"\01_mcount"()
61 ; CHECK-NEXT: ret void
66 define void @f4() #4 {
67 ; CHECK-LABEL: define void @f4() {
68 ; CHECK-NEXT: call void @"\01mcount"()
69 ; CHECK-NEXT: ret void
74 define void @f5() #5 {
75 ; CHECK-LABEL: define void @f5() {
76 ; CHECK-NEXT: call void @__mcount()
77 ; CHECK-NEXT: ret void
82 define void @f6() #6 {
83 ; CHECK-LABEL: define void @f6() {
84 ; CHECK-NEXT: call void @_mcount()
85 ; CHECK-NEXT: ret void
90 define void @f7() #7 {
91 ; CHECK-LABEL: define void @f7() {
92 ; CHECK-NEXT: call void @__cyg_profile_func_enter_bare()
93 ; CHECK-NEXT: ret void
98 ; Treat musttail calls as terminators; inserting between the musttail call and
100 declare ptr @tailcallee()
101 define ptr @tailcaller() #8 {
102 ; CHECK-LABEL: define ptr @tailcaller() {
103 ; CHECK-NEXT: [[TMP1:%.*]] = call ptr @llvm.returnaddress(i32 0)
104 ; CHECK-NEXT: call void @__cyg_profile_func_exit(ptr @tailcaller, ptr [[TMP1]])
105 ; CHECK-NEXT: [[TMP2:%.*]] = musttail call ptr @tailcallee()
106 ; CHECK-NEXT: ret ptr [[TMP2]]
108 %1 = musttail call ptr @tailcallee()
111 define ptr @tailcaller2() #8 {
112 ; CHECK-LABEL: define ptr @tailcaller2() {
113 ; CHECK-NEXT: [[TMP1:%.*]] = call ptr @llvm.returnaddress(i32 0)
114 ; CHECK-NEXT: call void @__cyg_profile_func_exit(ptr @tailcaller2, ptr [[TMP1]])
115 ; CHECK-NEXT: [[TMP2:%.*]] = musttail call ptr @tailcallee()
116 ; CHECK-NEXT: ret ptr [[TMP2]]
118 %1 = musttail call ptr @tailcallee()
122 ;; naked functions are not instrumented, otherwise the argument registers
123 ;; and the return address register (if present) would be clobbered.
124 define void @naked() naked {
125 ; CHECK-LABEL: define void @naked(
126 ; CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
127 ; CHECK-NEXT: ret void
132 ; The attributes are "consumed" when the instrumentation is inserted.
134 ; CHECK-NOT: instrument-function
136 attributes #0 = { "instrument-function-entry-inlined"="mcount" "instrument-function-entry"="__cyg_profile_func_enter" "instrument-function-exit"="__cyg_profile_func_exit" }
137 attributes #1 = { "instrument-function-entry-inlined"=".mcount" }
138 attributes #2 = { "instrument-function-entry-inlined"="llvm.arm.gnu.eabi.mcount" }
139 attributes #3 = { "instrument-function-entry-inlined"="\01_mcount" }
140 attributes #4 = { "instrument-function-entry-inlined"="\01mcount" }
141 attributes #5 = { "instrument-function-entry-inlined"="__mcount" }
142 attributes #6 = { "instrument-function-entry-inlined"="_mcount" }
143 attributes #7 = { "instrument-function-entry-inlined"="__cyg_profile_func_enter_bare" }
144 attributes #8 = { "instrument-function-exit"="__cyg_profile_func_exit" }