@@ -61,8 +61,10 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>(
61
61
fx. bcx . switch_to_block ( entry_block) ;
62
62
crate :: trap:: trap_unreachable ( & mut fx, "function has uninhabited argument" ) ;
63
63
} else {
64
- crate :: abi:: codegen_fn_prelude ( & mut fx, start_ebb) ;
65
- codegen_fn_content ( & mut fx) ;
64
+ tcx. sess . time ( "codegen clif ir" , || {
65
+ tcx. sess . time ( "codegen prelude" , || crate :: abi:: codegen_fn_prelude ( & mut fx, start_ebb) ) ;
66
+ codegen_fn_content ( & mut fx) ;
67
+ } ) ;
66
68
}
67
69
68
70
// Recover all necessary data from fx, before accessing func will prevent future access to it.
@@ -78,10 +80,13 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>(
78
80
verify_func ( tcx, & clif_comments, & context. func ) ;
79
81
80
82
// Perform rust specific optimizations
81
- crate :: optimize:: optimize_function ( cx. tcx , instance, context, & mut clif_comments) ;
83
+ tcx. sess . time ( "optimize clif ir" , || {
84
+ crate :: optimize:: optimize_function ( tcx, instance, context, & mut clif_comments) ;
85
+ } ) ;
82
86
83
87
// Define function
84
- cx. module . define_function ( func_id, context) . unwrap ( ) ;
88
+ let module = & mut cx. module ;
89
+ tcx. sess . time ( "define function" , || module. define_function ( func_id, context) . unwrap ( ) ) ;
85
90
86
91
// Write optimized function to file for debugging
87
92
#[ cfg( debug_assertions) ]
@@ -102,30 +107,34 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>(
102
107
103
108
// Define debuginfo for function
104
109
let isa = cx. module . isa ( ) ;
105
- debug_context
106
- . as_mut ( )
107
- . map ( |x| x. define ( context, isa, & source_info_set, local_map) ) ;
110
+ tcx. sess . time ( "generate debug info" , || {
111
+ debug_context
112
+ . as_mut ( )
113
+ . map ( |x| x. define ( context, isa, & source_info_set, local_map) ) ;
114
+ } ) ;
108
115
109
116
// Clear context to make it usable for the next function
110
117
context. clear ( ) ;
111
118
}
112
119
113
120
pub fn verify_func ( tcx : TyCtxt , writer : & crate :: pretty_clif:: CommentWriter , func : & Function ) {
114
- let flags = settings:: Flags :: new ( settings:: builder ( ) ) ;
115
- match :: cranelift_codegen:: verify_function ( & func, & flags) {
116
- Ok ( _) => { }
117
- Err ( err) => {
118
- tcx. sess . err ( & format ! ( "{:?}" , err) ) ;
119
- let pretty_error = :: cranelift_codegen:: print_errors:: pretty_verifier_error (
120
- & func,
121
- None ,
122
- Some ( Box :: new ( writer) ) ,
123
- err,
124
- ) ;
125
- tcx. sess
126
- . fatal ( & format ! ( "cranelift verify error:\n {}" , pretty_error) ) ;
121
+ tcx. sess . time ( "verify clif ir" , || {
122
+ let flags = settings:: Flags :: new ( settings:: builder ( ) ) ;
123
+ match :: cranelift_codegen:: verify_function ( & func, & flags) {
124
+ Ok ( _) => { }
125
+ Err ( err) => {
126
+ tcx. sess . err ( & format ! ( "{:?}" , err) ) ;
127
+ let pretty_error = :: cranelift_codegen:: print_errors:: pretty_verifier_error (
128
+ & func,
129
+ None ,
130
+ Some ( Box :: new ( writer) ) ,
131
+ err,
132
+ ) ;
133
+ tcx. sess
134
+ . fatal ( & format ! ( "cranelift verify error:\n {}" , pretty_error) ) ;
135
+ }
127
136
}
128
- }
137
+ } ) ;
129
138
}
130
139
131
140
fn codegen_fn_content ( fx : & mut FunctionCx < ' _ , ' _ , impl Backend > ) {
@@ -225,13 +234,13 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) {
225
234
cleanup : _,
226
235
from_hir_call : _,
227
236
} => {
228
- crate :: abi:: codegen_terminator_call (
237
+ fx . tcx . sess . time ( "codegen call" , || crate :: abi:: codegen_terminator_call (
229
238
fx,
230
239
func,
231
240
args,
232
241
destination,
233
242
bb_data. terminator ( ) . source_info . span ,
234
- ) ;
243
+ ) ) ;
235
244
}
236
245
TerminatorKind :: Resume | TerminatorKind :: Abort => {
237
246
trap_unreachable ( fx, "[corruption] Unwinding bb reached." ) ;
0 commit comments