@@ -106,7 +106,7 @@ pub(crate) fn codegen_fn<'tcx>(
106
106
next_ssa_var : 0 ,
107
107
} ;
108
108
109
- tcx . prof . generic_activity ( "codegen clif ir" ) . run ( || codegen_fn_body ( & mut fx, start_block) ) ;
109
+ codegen_fn_body ( & mut fx, start_block) ;
110
110
fx. bcx . seal_all_blocks ( ) ;
111
111
fx. bcx . finalize ( ) ;
112
112
@@ -136,14 +136,11 @@ pub(crate) fn codegen_fn<'tcx>(
136
136
137
137
pub ( crate ) fn compile_fn (
138
138
cx : & mut crate :: CodegenCx ,
139
- profiler : & SelfProfilerRef ,
139
+ _profiler : & SelfProfilerRef ,
140
140
cached_context : & mut Context ,
141
141
module : & mut dyn Module ,
142
142
codegened_func : CodegenedFunction ,
143
143
) {
144
- let _timer =
145
- profiler. generic_activity_with_arg ( "compile function" , & * codegened_func. symbol_name ) ;
146
-
147
144
let clif_comments = codegened_func. clif_comments ;
148
145
149
146
// Store function in context
@@ -180,36 +177,34 @@ pub(crate) fn compile_fn(
180
177
} ;
181
178
182
179
// Define function
183
- profiler. generic_activity ( "define function" ) . run ( || {
184
- context. want_disasm = cx. should_write_ir ;
185
- match module. define_function ( codegened_func. func_id , context) {
186
- Ok ( ( ) ) => { }
187
- Err ( ModuleError :: Compilation ( CodegenError :: ImplLimitExceeded ) ) => {
188
- let early_dcx = rustc_session:: EarlyDiagCtxt :: new (
189
- rustc_session:: config:: ErrorOutputType :: default ( ) ,
190
- ) ;
191
- early_dcx. early_fatal ( format ! (
192
- "backend implementation limit exceeded while compiling {name}" ,
193
- name = codegened_func. symbol_name
194
- ) ) ;
195
- }
196
- Err ( ModuleError :: Compilation ( CodegenError :: Verifier ( err) ) ) => {
197
- let early_dcx = rustc_session:: EarlyDiagCtxt :: new (
198
- rustc_session:: config:: ErrorOutputType :: default ( ) ,
199
- ) ;
200
- let _ = early_dcx. early_err ( format ! ( "{:?}" , err) ) ;
201
- let pretty_error = cranelift_codegen:: print_errors:: pretty_verifier_error (
202
- & context. func ,
203
- Some ( Box :: new ( & clif_comments) ) ,
204
- err,
205
- ) ;
206
- early_dcx. early_fatal ( format ! ( "cranelift verify error:\n {}" , pretty_error) ) ;
207
- }
208
- Err ( err) => {
209
- panic ! ( "Error while defining {name}: {err:?}" , name = codegened_func. symbol_name) ;
210
- }
180
+ context. want_disasm = cx. should_write_ir ;
181
+ match module. define_function ( codegened_func. func_id , context) {
182
+ Ok ( ( ) ) => { }
183
+ Err ( ModuleError :: Compilation ( CodegenError :: ImplLimitExceeded ) ) => {
184
+ let early_dcx = rustc_session:: EarlyDiagCtxt :: new (
185
+ rustc_session:: config:: ErrorOutputType :: default ( ) ,
186
+ ) ;
187
+ early_dcx. early_fatal ( format ! (
188
+ "backend implementation limit exceeded while compiling {name}" ,
189
+ name = codegened_func. symbol_name
190
+ ) ) ;
211
191
}
212
- } ) ;
192
+ Err ( ModuleError :: Compilation ( CodegenError :: Verifier ( err) ) ) => {
193
+ let early_dcx = rustc_session:: EarlyDiagCtxt :: new (
194
+ rustc_session:: config:: ErrorOutputType :: default ( ) ,
195
+ ) ;
196
+ let _ = early_dcx. early_err ( format ! ( "{:?}" , err) ) ;
197
+ let pretty_error = cranelift_codegen:: print_errors:: pretty_verifier_error (
198
+ & context. func ,
199
+ Some ( Box :: new ( & clif_comments) ) ,
200
+ err,
201
+ ) ;
202
+ early_dcx. early_fatal ( format ! ( "cranelift verify error:\n {}" , pretty_error) ) ;
203
+ }
204
+ Err ( err) => {
205
+ panic ! ( "Error while defining {name}: {err:?}" , name = codegened_func. symbol_name) ;
206
+ }
207
+ }
213
208
214
209
if cx. should_write_ir {
215
210
// Write optimized function to file for debugging
@@ -233,37 +228,33 @@ pub(crate) fn compile_fn(
233
228
234
229
// Define debuginfo for function
235
230
let debug_context = & mut cx. debug_context ;
236
- profiler. generic_activity ( "generate debug info" ) . run ( || {
237
- if let Some ( debug_context) = debug_context {
238
- codegened_func. func_debug_cx . unwrap ( ) . finalize (
239
- debug_context,
240
- codegened_func. func_id ,
241
- context,
242
- ) ;
243
- }
244
- } ) ;
231
+ if let Some ( debug_context) = debug_context {
232
+ codegened_func. func_debug_cx . unwrap ( ) . finalize (
233
+ debug_context,
234
+ codegened_func. func_id ,
235
+ context,
236
+ ) ;
237
+ }
245
238
}
246
239
247
240
fn verify_func ( tcx : TyCtxt < ' _ > , writer : & crate :: pretty_clif:: CommentWriter , func : & Function ) {
248
241
if !enable_verifier ( tcx. sess ) {
249
242
return ;
250
243
}
251
244
252
- tcx. prof . generic_activity ( "verify clif ir" ) . run ( || {
253
- let flags = cranelift_codegen:: settings:: Flags :: new ( cranelift_codegen:: settings:: builder ( ) ) ;
254
- match cranelift_codegen:: verify_function ( & func, & flags) {
255
- Ok ( _) => { }
256
- Err ( err) => {
257
- tcx. dcx ( ) . err ( format ! ( "{:?}" , err) ) ;
258
- let pretty_error = cranelift_codegen:: print_errors:: pretty_verifier_error (
259
- & func,
260
- Some ( Box :: new ( writer) ) ,
261
- err,
262
- ) ;
263
- tcx. dcx ( ) . fatal ( format ! ( "cranelift verify error:\n {}" , pretty_error) ) ;
264
- }
245
+ let flags = cranelift_codegen:: settings:: Flags :: new ( cranelift_codegen:: settings:: builder ( ) ) ;
246
+ match cranelift_codegen:: verify_function ( & func, & flags) {
247
+ Ok ( _) => { }
248
+ Err ( err) => {
249
+ tcx. dcx ( ) . err ( format ! ( "{:?}" , err) ) ;
250
+ let pretty_error = cranelift_codegen:: print_errors:: pretty_verifier_error (
251
+ & func,
252
+ Some ( Box :: new ( writer) ) ,
253
+ err,
254
+ ) ;
255
+ tcx. dcx ( ) . fatal ( format ! ( "cranelift verify error:\n {}" , pretty_error) ) ;
265
256
}
266
- } ) ;
257
+ }
267
258
}
268
259
269
260
fn codegen_fn_body ( fx : & mut FunctionCx < ' _ , ' _ , ' _ > , start_block : Block ) {
@@ -277,10 +268,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
277
268
fx. bcx . ins ( ) . trap ( TrapCode :: user ( 1 /* unreachable */ ) . unwrap ( ) ) ;
278
269
return ;
279
270
}
280
- fx. tcx
281
- . prof
282
- . generic_activity ( "codegen prelude" )
283
- . run ( || crate :: abi:: codegen_fn_prelude ( fx, start_block) ) ;
271
+ crate :: abi:: codegen_fn_prelude ( fx, start_block) ;
284
272
285
273
let reachable_blocks = traversal:: mono_reachable_as_bitset ( fx. mir , fx. tcx , fx. instance ) ;
286
274
@@ -475,19 +463,15 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
475
463
fn_span,
476
464
unwind,
477
465
call_source : _,
478
- } => {
479
- fx. tcx . prof . generic_activity ( "codegen call" ) . run ( || {
480
- crate :: abi:: codegen_terminator_call (
481
- fx,
482
- mir:: SourceInfo { span : * fn_span, ..source_info } ,
483
- func,
484
- args,
485
- * destination,
486
- * target,
487
- * unwind,
488
- )
489
- } ) ;
490
- }
466
+ } => crate :: abi:: codegen_terminator_call (
467
+ fx,
468
+ mir:: SourceInfo { span : * fn_span, ..source_info } ,
469
+ func,
470
+ args,
471
+ * destination,
472
+ * target,
473
+ * unwind,
474
+ ) ,
491
475
// FIXME(explicit_tail_calls): add support for tail calls to the cranelift backend, once cranelift supports tail calls
492
476
TerminatorKind :: TailCall { fn_span, .. } => span_bug ! (
493
477
* fn_span,
0 commit comments