1 ; RUN: opt -passes="function(ee-instrument),cgscc(inline),function(post-inline-ee-instrument)" -S < %s | FileCheck %s
3 ; Running the passes twice should not result in more instrumentation.
4 ; RUN: opt -passes="function(ee-instrument),function(ee-instrument),cgscc(inline),function(post-inline-ee-instrument),function(post-inline-ee-instrument)" -S < %s | FileCheck %s
6 target datalayout = "E-m:e-i64:64-n32:64"
7 target triple = "powerpc64-bgq-linux"
9 define void @leaf_function() #0 {
13 ; CHECK-LABEL: define void @leaf_function()
15 ; CHECK-NEXT: call void @mcount()
16 ; CHECK-NEXT: %0 = call i8* @llvm.returnaddress(i32 0)
17 ; CHECK-NEXT: call void @__cyg_profile_func_enter(i8* bitcast (void ()* @leaf_function to i8*), i8* %0)
18 ; CHECK-NEXT: %1 = call i8* @llvm.returnaddress(i32 0)
19 ; CHECK-NEXT: call void @__cyg_profile_func_exit(i8* bitcast (void ()* @leaf_function to i8*), i8* %1)
20 ; CHECK-NEXT: ret void
24 define void @root_function() #0 {
26 call void @leaf_function()
29 ; CHECK-LABEL: define void @root_function()
31 ; CHECK-NEXT: call void @mcount()
33 ; CHECK-NEXT %0 = call i8* @llvm.returnaddress(i32 0)
34 ; CHECK-NEXT call void @__cyg_profile_func_enter(i8* bitcast (void ()* @root_function to i8*), i8* %0)
36 ; Entry and exit calls, inlined from @leaf_function()
37 ; CHECK-NEXT %1 = call i8* @llvm.returnaddress(i32 0)
38 ; CHECK-NEXT call void @__cyg_profile_func_enter(i8* bitcast (void ()* @leaf_function to i8*), i8* %1)
39 ; CHECK-NEXT %2 = call i8* @llvm.returnaddress(i32 0)
40 ; CHECK-NEXT call void @__cyg_profile_func_exit(i8* bitcast (void ()* @leaf_function to i8*), i8* %2)
41 ; CHECK-NEXT %3 = call i8* @llvm.returnaddress(i32 0)
43 ; CHECK-NEXT call void @__cyg_profile_func_exit(i8* bitcast (void ()* @root_function to i8*), i8* %3)
49 ; The mcount function has many different names.
51 define void @f1() #1 { entry: ret void }
52 ; CHECK-LABEL: define void @f1
53 ; CHECK: call void @.mcount
55 define void @f2() #2 { entry: ret void }
56 ; CHECK-LABEL: define void @f2
57 ; CHECK: call void @llvm.arm.gnu.eabi.mcount
59 define void @f3() #3 { entry: ret void }
60 ; CHECK-LABEL: define void @f3
61 ; CHECK: call void @"\01_mcount"
63 define void @f4() #4 { entry: ret void }
64 ; CHECK-LABEL: define void @f4
65 ; CHECK: call void @"\01mcount"
67 define void @f5() #5 { entry: ret void }
68 ; CHECK-LABEL: define void @f5
69 ; CHECK: call void @__mcount
71 define void @f6() #6 { entry: ret void }
72 ; CHECK-LABEL: define void @f6
73 ; CHECK: call void @_mcount
75 define void @f7() #7 { entry: ret void }
76 ; CHECK-LABEL: define void @f7
77 ; CHECK: call void @__cyg_profile_func_enter_bare
80 ; Treat musttail calls as terminators; inserting between the musttail call and
82 declare i32* @tailcallee()
83 define i32* @tailcaller() #8 {
84 %1 = musttail call i32* @tailcallee()
86 ; CHECK-LABEL: define i32* @tailcaller
87 ; CHECK: call void @__cyg_profile_func_exit
88 ; CHECK: musttail call i32* @tailcallee
91 define i8* @tailcaller2() #8 {
92 %1 = musttail call i32* @tailcallee()
93 %2 = bitcast i32* %1 to i8*
95 ; CHECK-LABEL: define i8* @tailcaller2
96 ; CHECK: call void @__cyg_profile_func_exit
97 ; CHECK: musttail call i32* @tailcallee
102 ; The attributes are "consumed" when the instrumentation is inserted.
104 ; CHECK-NOT: instrument-function
106 attributes #0 = { "instrument-function-entry-inlined"="mcount" "instrument-function-entry"="__cyg_profile_func_enter" "instrument-function-exit"="__cyg_profile_func_exit" }
107 attributes #1 = { "instrument-function-entry-inlined"=".mcount" }
108 attributes #2 = { "instrument-function-entry-inlined"="llvm.arm.gnu.eabi.mcount" }
109 attributes #3 = { "instrument-function-entry-inlined"="\01_mcount" }
110 attributes #4 = { "instrument-function-entry-inlined"="\01mcount" }
111 attributes #5 = { "instrument-function-entry-inlined"="__mcount" }
112 attributes #6 = { "instrument-function-entry-inlined"="_mcount" }
113 attributes #7 = { "instrument-function-entry-inlined"="__cyg_profile_func_enter_bare" }
114 attributes #8 = { "instrument-function-exit"="__cyg_profile_func_exit" }