• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -passes="function(ee-instrument),cgscc(inline),function(post-inline-ee-instrument)" -S < %s | FileCheck %s
2
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
5
6target datalayout = "E-m:e-i64:64-n32:64"
7target triple = "powerpc64-bgq-linux"
8
9define void @leaf_function() #0 {
10entry:
11  ret void
12
13; CHECK-LABEL: define void @leaf_function()
14; CHECK: entry:
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
21}
22
23
24define void @root_function() #0 {
25entry:
26  call void @leaf_function()
27  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 i8* @llvm.returnaddress(i32 0)
34; CHECK-NEXT call void @__cyg_profile_func_enter(i8* bitcast (void ()* @root_function to i8*), i8* %0)
35
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)
42
43; CHECK-NEXT call void @__cyg_profile_func_exit(i8* bitcast (void ()* @root_function to i8*), i8* %3)
44; CHECK-NEXT ret void
45}
46
47
48
49; The mcount function has many different names.
50
51define void @f1() #1 { entry: ret void }
52; CHECK-LABEL: define void @f1
53; CHECK: call void @.mcount
54
55define void @f2() #2 { entry: ret void }
56; CHECK-LABEL: define void @f2
57; CHECK: call void @"\01__gnu_mcount_nc"
58
59define void @f3() #3 { entry: ret void }
60; CHECK-LABEL: define void @f3
61; CHECK: call void @"\01_mcount"
62
63define void @f4() #4 { entry: ret void }
64; CHECK-LABEL: define void @f4
65; CHECK: call void @"\01mcount"
66
67define void @f5() #5 { entry: ret void }
68; CHECK-LABEL: define void @f5
69; CHECK: call void @__mcount
70
71define void @f6() #6 { entry: ret void }
72; CHECK-LABEL: define void @f6
73; CHECK: call void @_mcount
74
75define void @f7() #7 { entry: ret void }
76; CHECK-LABEL: define void @f7
77; CHECK: call void @__cyg_profile_func_enter_bare
78
79
80; Treat musttail calls as terminators; inserting between the musttail call and
81; ret is not allowed.
82declare i32* @tailcallee()
83define i32* @tailcaller() #8 {
84  %1 = musttail call i32* @tailcallee()
85  ret i32* %1
86; CHECK-LABEL: define i32* @tailcaller
87; CHECK: call void @__cyg_profile_func_exit
88; CHECK: musttail call i32* @tailcallee
89; CHECK: ret
90}
91define i8* @tailcaller2() #8 {
92  %1 = musttail call i32* @tailcallee()
93  %2 = bitcast i32* %1 to i8*
94  ret i8* %2
95; CHECK-LABEL: define i8* @tailcaller2
96; CHECK: call void @__cyg_profile_func_exit
97; CHECK: musttail call i32* @tailcallee
98; CHECK: bitcast
99; CHECK: ret
100}
101
102; The attributes are "consumed" when the instrumentation is inserted.
103; CHECK: attributes
104; CHECK-NOT: instrument-function
105
106attributes #0 = { "instrument-function-entry-inlined"="mcount" "instrument-function-entry"="__cyg_profile_func_enter" "instrument-function-exit"="__cyg_profile_func_exit" }
107attributes #1 = { "instrument-function-entry-inlined"=".mcount" }
108attributes #2 = { "instrument-function-entry-inlined"="\01__gnu_mcount_nc" }
109attributes #3 = { "instrument-function-entry-inlined"="\01_mcount" }
110attributes #4 = { "instrument-function-entry-inlined"="\01mcount" }
111attributes #5 = { "instrument-function-entry-inlined"="__mcount" }
112attributes #6 = { "instrument-function-entry-inlined"="_mcount" }
113attributes #7 = { "instrument-function-entry-inlined"="__cyg_profile_func_enter_bare" }
114attributes #8 = { "instrument-function-exit"="__cyg_profile_func_exit" }
115