1+ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
12; RUN: opt -passes="function(ee-instrument),cgscc(inline),function(ee-instrument<post-inline>)" -S < %s | FileCheck %s
23
34; Running the passes twice should not result in more instrumentation.
@@ -7,104 +8,126 @@ target datalayout = "E-m:e-i64:64-n32:64"
78target triple = "powerpc64le-unknown-linux"
89
910define void @leaf_function () #0 {
10- entry:
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
18+ ;
1119 ret void
12-
13- ; CHECK-LABEL: define void @leaf_function()
14- ; CHECK: entry:
15- ; CHECK-NEXT: call void @mcount()
16- ; CHECK-NEXT: %0 = call ptr @llvm.returnaddress(i32 0)
17- ; CHECK-NEXT: call void @__cyg_profile_func_enter(ptr @leaf_function, ptr %0)
18- ; CHECK-NEXT: %1 = call ptr @llvm.returnaddress(i32 0)
19- ; CHECK-NEXT: call void @__cyg_profile_func_exit(ptr @leaf_function, ptr %1)
20- ; CHECK-NEXT: ret void
2120}
2221
2322
2423define void @root_function () #0 {
25- entry:
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
35+ ;
2636 call void @leaf_function ()
2737 ret void
28-
29- ; CHECK-LABEL: define void @root_function()
30- ; CHECK: entry:
31- ; CHECK-NEXT: call void @mcount()
32-
33- ; CHECK-NEXT: %0 = call ptr @llvm.returnaddress(i32 0)
34- ; CHECK-NEXT: call void @__cyg_profile_func_enter(ptr @root_function, ptr %0)
35-
36- ; Entry and exit calls, inlined from @leaf_function()
37- ; CHECK-NEXT: %1 = call ptr @llvm.returnaddress(i32 0)
38- ; CHECK-NEXT: call void @__cyg_profile_func_enter(ptr @leaf_function, ptr %1)
39- ; CHECK-NEXT: %2 = call ptr @llvm.returnaddress(i32 0)
40- ; CHECK-NEXT: call void @__cyg_profile_func_exit(ptr @leaf_function, ptr %2)
41- ; CHECK-NEXT: %3 = call ptr @llvm.returnaddress(i32 0)
42-
43- ; CHECK-NEXT: call void @__cyg_profile_func_exit(ptr @root_function, ptr %3)
44- ; CHECK-NEXT: ret void
4538}
4639
47-
48-
4940; The mcount function has many different names.
5041
51- define void @f1 () #1 { entry: ret void }
52- ; CHECK-LABEL: define void @f1
53- ; CHECK: call void @.mcount
54-
55- define void @f2 () # 2 { entry: ret void }
56- ; CHECK-LABEL: define void @f2
57- ; CHECK: call void @llvm.arm.gnu.eabi.mcount
42+ define void @f1 () #1 {
43+ ; CHECK-LABEL: define void @f1() {
44+ ; CHECK-NEXT: call void @.mcount()
45+ ; CHECK-NEXT: ret void
46+ ;
47+ ret void
48+ }
5849
59- define void @f3 () #3 { entry: ret void }
60- ; CHECK-LABEL: define void @f3
61- ; CHECK: call void @"\01_mcount"
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
54+ ;
55+ ret void
56+ }
6257
63- define void @f4 () #4 { entry: ret void }
64- ; CHECK-LABEL: define void @f4
65- ; CHECK: call void @"\01mcount"
58+ define void @f3 () #3 {
59+ ; CHECK-LABEL: define void @f3() {
60+ ; CHECK-NEXT: call void @"\01_mcount"()
61+ ; CHECK-NEXT: ret void
62+ ;
63+ ret void
64+ }
6665
67- define void @f5 () #5 { entry: ret void }
68- ; CHECK-LABEL: define void @f5
69- ; CHECK: call void @__mcount
66+ define void @f4 () #4 {
67+ ; CHECK-LABEL: define void @f4() {
68+ ; CHECK-NEXT: call void @"\01mcount"()
69+ ; CHECK-NEXT: ret void
70+ ;
71+ ret void
72+ }
7073
71- define void @f6 () #6 { entry: ret void }
72- ; CHECK-LABEL: define void @f6
73- ; CHECK: call void @_mcount
74+ define void @f5 () #5 {
75+ ; CHECK-LABEL: define void @f5() {
76+ ; CHECK-NEXT: call void @__mcount()
77+ ; CHECK-NEXT: ret void
78+ ;
79+ ret void
80+ }
7481
75- define void @f7 () #7 { entry: ret void }
76- ; CHECK-LABEL: define void @f7
77- ; CHECK: call void @__cyg_profile_func_enter_bare
82+ define void @f6 () #6 {
83+ ; CHECK-LABEL: define void @f6() {
84+ ; CHECK-NEXT: call void @_mcount()
85+ ; CHECK-NEXT: ret void
86+ ;
87+ ret void
88+ }
7889
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
94+ ;
95+ ret void
96+ }
7997
8098; Treat musttail calls as terminators; inserting between the musttail call and
8199; ret is not allowed.
82100declare ptr @tailcallee ()
83101define 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]]
107+ ;
84108 %1 = musttail call ptr @tailcallee ()
85109 ret ptr %1
86- ; CHECK-LABEL: define ptr @tailcaller
87- ; CHECK: call void @__cyg_profile_func_exit
88- ; CHECK: musttail call ptr @tailcallee
89- ; CHECK: ret
90110}
91111define 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]]
117+ ;
92118 %1 = musttail call ptr @tailcallee ()
93- %2 = bitcast ptr %1 to ptr
94- ret ptr %2
95- ; CHECK-LABEL: define ptr @tailcaller2
96- ; CHECK: call void @__cyg_profile_func_exit
97- ; CHECK: musttail call ptr @tailcallee
98- ; CHECK: bitcast
99- ; CHECK: ret
119+ ret ptr %1
100120}
101121
102122;; naked functions are not instrumented, otherwise the argument registers
103123;; and the return address register (if present) would be clobbered.
104- define void @naked () naked { entry: ret void }
105- ; CHECK-LABEL: define void @naked(
106- ; CHECK-LABEL-NEXT: entry:
107- ; CHECK-LABEL-NEXT: ret void
124+ define void @naked () naked {
125+ ; CHECK-LABEL: define void @naked(
126+ ; CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
127+ ; CHECK-NEXT: ret void
128+ ;
129+ ret void
130+ }
108131
109132; The attributes are "consumed" when the instrumentation is inserted.
110133; CHECK: attributes
0 commit comments