@@ -8,7 +8,6 @@ use rustc_middle::mir::visit::*;
88use rustc_middle:: mir:: * ;
99use rustc_middle:: ty:: { self , Instance , InstanceDef , ParamEnv , Ty , TyCtxt } ;
1010use rustc_session:: config:: OptLevel ;
11- use rustc_span:: def_id:: DefId ;
1211use rustc_span:: { hygiene:: ExpnKind , ExpnData , LocalExpnId , Span } ;
1312use rustc_target:: abi:: VariantIdx ;
1413use rustc_target:: spec:: abi:: Abi ;
@@ -87,13 +86,8 @@ fn inline<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) -> bool {
8786
8887 let param_env = tcx. param_env_reveal_all_normalized ( def_id) ;
8988
90- let mut this = Inliner {
91- tcx,
92- param_env,
93- codegen_fn_attrs : tcx. codegen_fn_attrs ( def_id) ,
94- history : Vec :: new ( ) ,
95- changed : false ,
96- } ;
89+ let mut this =
90+ Inliner { tcx, param_env, codegen_fn_attrs : tcx. codegen_fn_attrs ( def_id) , changed : false } ;
9791 let blocks = BasicBlock :: new ( 0 ) ..body. basic_blocks . next_index ( ) ;
9892 this. process_blocks ( body, blocks) ;
9993 this. changed
@@ -104,12 +98,6 @@ struct Inliner<'tcx> {
10498 param_env : ParamEnv < ' tcx > ,
10599 /// Caller codegen attributes.
106100 codegen_fn_attrs : & ' tcx CodegenFnAttrs ,
107- /// Stack of inlined instances.
108- /// We only check the `DefId` and not the substs because we want to
109- /// avoid inlining cases of polymorphic recursion.
110- /// The number of `DefId`s is finite, so checking history is enough
111- /// to ensure that we do not loop endlessly while inlining.
112- history : Vec < DefId > ,
113101 /// Indicates that the caller body has been modified.
114102 changed : bool ,
115103}
@@ -134,12 +122,12 @@ impl<'tcx> Inliner<'tcx> {
134122 debug ! ( "not-inlined {} [{}]" , callsite. callee, reason) ;
135123 continue ;
136124 }
137- Ok ( new_blocks ) => {
125+ Ok ( _ ) => {
138126 debug ! ( "inlined {}" , callsite. callee) ;
139127 self . changed = true ;
140- self . history . push ( callsite . callee . def_id ( ) ) ;
141- self . process_blocks ( caller_body , new_blocks ) ;
142- self . history . pop ( ) ;
128+ // We could process the blocks returned by `try_inlining` here. However, that
129+ // leads to exponential compile times due to the top-down nature of this kind
130+ // of inlining.
143131 }
144132 }
145133 }
@@ -313,10 +301,6 @@ impl<'tcx> Inliner<'tcx> {
313301 return None ;
314302 }
315303
316- if self . history . contains ( & callee. def_id ( ) ) {
317- return None ;
318- }
319-
320304 let fn_sig = self . tcx . bound_fn_sig ( def_id) . subst ( self . tcx , substs) ;
321305
322306 return Some ( CallSite {
0 commit comments