@@ -8,7 +8,6 @@ use rustc_middle::mir::visit::*;
8
8
use rustc_middle:: mir:: * ;
9
9
use rustc_middle:: ty:: { self , Instance , InstanceDef , ParamEnv , Ty , TyCtxt } ;
10
10
use rustc_session:: config:: OptLevel ;
11
- use rustc_span:: def_id:: DefId ;
12
11
use rustc_span:: { hygiene:: ExpnKind , ExpnData , LocalExpnId , Span } ;
13
12
use rustc_target:: abi:: VariantIdx ;
14
13
use rustc_target:: spec:: abi:: Abi ;
@@ -87,13 +86,8 @@ fn inline<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) -> bool {
87
86
88
87
let param_env = tcx. param_env_reveal_all_normalized ( def_id) ;
89
88
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 } ;
97
91
let blocks = BasicBlock :: new ( 0 ) ..body. basic_blocks . next_index ( ) ;
98
92
this. process_blocks ( body, blocks) ;
99
93
this. changed
@@ -104,12 +98,6 @@ struct Inliner<'tcx> {
104
98
param_env : ParamEnv < ' tcx > ,
105
99
/// Caller codegen attributes.
106
100
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 > ,
113
101
/// Indicates that the caller body has been modified.
114
102
changed : bool ,
115
103
}
@@ -134,12 +122,12 @@ impl<'tcx> Inliner<'tcx> {
134
122
debug ! ( "not-inlined {} [{}]" , callsite. callee, reason) ;
135
123
continue ;
136
124
}
137
- Ok ( new_blocks ) => {
125
+ Ok ( _ ) => {
138
126
debug ! ( "inlined {}" , callsite. callee) ;
139
127
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.
143
131
}
144
132
}
145
133
}
@@ -313,10 +301,6 @@ impl<'tcx> Inliner<'tcx> {
313
301
return None ;
314
302
}
315
303
316
- if self . history . contains ( & callee. def_id ( ) ) {
317
- return None ;
318
- }
319
-
320
304
let fn_sig = self . tcx . bound_fn_sig ( def_id) . subst ( self . tcx , substs) ;
321
305
322
306
return Some ( CallSite {
0 commit comments