@@ -159,13 +159,15 @@ impl<'tcx> MutVisitor<'tcx> for SelfArgVisitor<'tcx> {
159159 }
160160}
161161
162+ #[ tracing:: instrument( level = "trace" , skip( tcx) ) ]
162163fn replace_base < ' tcx > ( place : & mut Place < ' tcx > , new_base : Place < ' tcx > , tcx : TyCtxt < ' tcx > ) {
163164 place. local = new_base. local ;
164165
165166 let mut new_projection = new_base. projection . to_vec ( ) ;
166167 new_projection. append ( & mut place. projection . to_vec ( ) ) ;
167168
168169 place. projection = tcx. mk_place_elems ( & new_projection) ;
170+ tracing:: trace!( ?place) ;
169171}
170172
171173const SELF_ARG : Local = Local :: from_u32 ( 1 ) ;
@@ -270,6 +272,7 @@ impl<'tcx> TransformVisitor<'tcx> {
270272 // `core::ops::CoroutineState` only has single element tuple variants,
271273 // so we can just write to the downcasted first field and then set the
272274 // discriminant to the appropriate variant.
275+ #[ tracing:: instrument( level = "trace" , skip( self , statements) ) ]
273276 fn make_state (
274277 & self ,
275278 val : Operand < ' tcx > ,
@@ -348,6 +351,7 @@ impl<'tcx> TransformVisitor<'tcx> {
348351 }
349352
350353 // Create a Place referencing a coroutine struct field
354+ #[ tracing:: instrument( level = "trace" , skip( self ) , ret) ]
351355 fn make_field ( & self , variant_index : VariantIdx , idx : FieldIdx , ty : Ty < ' tcx > ) -> Place < ' tcx > {
352356 let self_place = Place :: from ( SELF_ARG ) ;
353357 let base = self . tcx . mk_place_downcast_unnamed ( self_place, variant_index) ;
@@ -358,6 +362,7 @@ impl<'tcx> TransformVisitor<'tcx> {
358362 }
359363
360364 // Create a statement which changes the discriminant
365+ #[ tracing:: instrument( level = "trace" , skip( self ) ) ]
361366 fn set_discr ( & self , state_disc : VariantIdx , source_info : SourceInfo ) -> Statement < ' tcx > {
362367 let self_place = Place :: from ( SELF_ARG ) ;
363368 Statement :: new (
@@ -370,6 +375,7 @@ impl<'tcx> TransformVisitor<'tcx> {
370375 }
371376
372377 // Create a statement which reads the discriminant into a temporary
378+ #[ tracing:: instrument( level = "trace" , skip( self , body) ) ]
373379 fn get_discr ( & self , body : & mut Body < ' tcx > ) -> ( Statement < ' tcx > , Place < ' tcx > ) {
374380 let temp_decl = LocalDecl :: new ( self . discr_ty , body. span ) ;
375381 let local_decls_len = body. local_decls . push ( temp_decl) ;
@@ -389,22 +395,20 @@ impl<'tcx> MutVisitor<'tcx> for TransformVisitor<'tcx> {
389395 self . tcx
390396 }
391397
392- fn visit_local ( & mut self , local : & mut Local , _: PlaceContext , _: Location ) {
398+ #[ tracing:: instrument( level = "trace" , skip( self ) , ret) ]
399+ fn visit_local ( & mut self , local : & mut Local , _: PlaceContext , _location : Location ) {
393400 assert ! ( !self . remap. contains( * local) ) ;
394401 }
395402
396- fn visit_place (
397- & mut self ,
398- place : & mut Place < ' tcx > ,
399- _context : PlaceContext ,
400- _location : Location ,
401- ) {
403+ #[ tracing:: instrument( level = "trace" , skip( self ) , ret) ]
404+ fn visit_place ( & mut self , place : & mut Place < ' tcx > , _: PlaceContext , _location : Location ) {
402405 // Replace an Local in the remap with a coroutine struct access
403406 if let Some ( & Some ( ( ty, variant_index, idx) ) ) = self . remap . get ( place. local ) {
404407 replace_base ( place, self . make_field ( variant_index, idx, ty) , self . tcx ) ;
405408 }
406409 }
407410
411+ #[ tracing:: instrument( level = "trace" , skip( self , data) , ret) ]
408412 fn visit_basic_block_data ( & mut self , block : BasicBlock , data : & mut BasicBlockData < ' tcx > ) {
409413 // Remove StorageLive and StorageDead statements for remapped locals
410414 for s in & mut data. statements {
@@ -483,6 +487,7 @@ fn make_aggregate_adt<'tcx>(
483487 Rvalue :: Aggregate ( Box :: new ( AggregateKind :: Adt ( def_id, variant_idx, args, None , None ) ) , operands)
484488}
485489
490+ #[ tracing:: instrument( level = "trace" , skip( tcx, body) ) ]
486491fn make_coroutine_state_argument_indirect < ' tcx > ( tcx : TyCtxt < ' tcx > , body : & mut Body < ' tcx > ) {
487492 let coroutine_ty = body. local_decls . raw [ 1 ] . ty ;
488493
@@ -495,6 +500,7 @@ fn make_coroutine_state_argument_indirect<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Bo
495500 SelfArgVisitor :: new ( tcx, ProjectionElem :: Deref ) . visit_body ( body) ;
496501}
497502
503+ #[ tracing:: instrument( level = "trace" , skip( tcx, body) ) ]
498504fn make_coroutine_state_argument_pinned < ' tcx > ( tcx : TyCtxt < ' tcx > , body : & mut Body < ' tcx > ) {
499505 let ref_coroutine_ty = body. local_decls . raw [ 1 ] . ty ;
500506
@@ -553,6 +559,7 @@ fn replace_local<'tcx>(
553559/// The async lowering step and the type / lifetime inference / checking are
554560/// still using the `ResumeTy` indirection for the time being, and that indirection
555561/// is removed here. After this transform, the coroutine body only knows about `&mut Context<'_>`.
562+ #[ tracing:: instrument( level = "trace" , skip( tcx, body) , ret) ]
556563fn transform_async_context < ' tcx > ( tcx : TyCtxt < ' tcx > , body : & mut Body < ' tcx > ) -> Ty < ' tcx > {
557564 let context_mut_ref = Ty :: new_task_context ( tcx) ;
558565
@@ -606,6 +613,7 @@ fn eliminate_get_context_call<'tcx>(bb_data: &mut BasicBlockData<'tcx>) -> Local
606613}
607614
608615#[ cfg_attr( not( debug_assertions) , allow( unused) ) ]
616+ #[ tracing:: instrument( level = "trace" , skip( tcx, body) , ret) ]
609617fn replace_resume_ty_local < ' tcx > (
610618 tcx : TyCtxt < ' tcx > ,
611619 body : & mut Body < ' tcx > ,
@@ -670,6 +678,7 @@ struct LivenessInfo {
670678/// case none exist, the local is considered to be always live.
671679/// - a local has to be stored if it is either directly used after the
672680/// the suspend point, or if it is live and has been previously borrowed.
681+ #[ tracing:: instrument( level = "trace" , skip( tcx, body) ) ]
673682fn locals_live_across_suspend_points < ' tcx > (
674683 tcx : TyCtxt < ' tcx > ,
675684 body : & Body < ' tcx > ,
@@ -945,6 +954,7 @@ impl StorageConflictVisitor<'_, '_> {
945954 }
946955}
947956
957+ #[ tracing:: instrument( level = "trace" , skip( liveness, body) ) ]
948958fn compute_layout < ' tcx > (
949959 liveness : LivenessInfo ,
950960 body : & Body < ' tcx > ,
@@ -1049,7 +1059,9 @@ fn compute_layout<'tcx>(
10491059 variant_source_info,
10501060 storage_conflicts,
10511061 } ;
1062+ debug ! ( ?remap) ;
10521063 debug ! ( ?layout) ;
1064+ debug ! ( ?storage_liveness) ;
10531065
10541066 ( remap, layout, storage_liveness)
10551067}
@@ -1221,6 +1233,7 @@ fn generate_poison_block_and_redirect_unwinds_there<'tcx>(
12211233 }
12221234}
12231235
1236+ #[ tracing:: instrument( level = "trace" , skip( tcx, transform, body) ) ]
12241237fn create_coroutine_resume_function < ' tcx > (
12251238 tcx : TyCtxt < ' tcx > ,
12261239 transform : TransformVisitor < ' tcx > ,
@@ -1299,7 +1312,7 @@ fn create_coroutine_resume_function<'tcx>(
12991312}
13001313
13011314/// An operation that can be performed on a coroutine.
1302- #[ derive( PartialEq , Copy , Clone ) ]
1315+ #[ derive( PartialEq , Copy , Clone , Debug ) ]
13031316enum Operation {
13041317 Resume ,
13051318 Drop ,
@@ -1314,6 +1327,7 @@ impl Operation {
13141327 }
13151328}
13161329
1330+ #[ tracing:: instrument( level = "trace" , skip( transform, body) ) ]
13171331fn create_cases < ' tcx > (
13181332 body : & mut Body < ' tcx > ,
13191333 transform : & TransformVisitor < ' tcx > ,
@@ -1445,6 +1459,8 @@ impl<'tcx> crate::MirPass<'tcx> for StateTransform {
14451459 // This only applies to coroutines
14461460 return ;
14471461 } ;
1462+ tracing:: trace!( def_id = ?body. source. def_id( ) ) ;
1463+
14481464 let old_ret_ty = body. return_ty ( ) ;
14491465
14501466 assert ! ( body. coroutine_drop( ) . is_none( ) && body. coroutine_drop_async( ) . is_none( ) ) ;
0 commit comments