File tree 1 file changed +10
-2
lines changed
src/librustc_mir/transform 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -39,15 +39,19 @@ struct CallSite<'tcx> {
39
39
40
40
impl < ' tcx > MirPass < ' tcx > for Inline {
41
41
fn run_pass ( & self , tcx : TyCtxt < ' tcx > , source : MirSource < ' tcx > , body : & mut BodyAndCache < ' tcx > ) {
42
- if tcx. sess . opts . debugging_opts . mir_opt_level >= 2 {
43
- Inliner { tcx, source } . run_pass ( body) ;
42
+ let mir_opt_level = tcx. sess . opts . debugging_opts . mir_opt_level ;
43
+ if mir_opt_level == 0 {
44
+ return ;
44
45
}
46
+
47
+ Inliner { tcx, source, use_simple_heuristic : mir_opt_level == 1 } . run_pass ( body) ;
45
48
}
46
49
}
47
50
48
51
struct Inliner < ' tcx > {
49
52
tcx : TyCtxt < ' tcx > ,
50
53
source : MirSource < ' tcx > ,
54
+ use_simple_heuristic : bool ,
51
55
}
52
56
53
57
impl Inliner < ' tcx > {
@@ -251,6 +255,10 @@ impl Inliner<'tcx> {
251
255
}
252
256
}
253
257
258
+ if self . use_simple_heuristic {
259
+ return callee_body. basic_blocks ( ) . len ( ) == 1 && callee_body. basic_blocks ( ) [ BasicBlock :: from_u32 ( 0 ) ] . statements . len ( ) < 10 ;
260
+ }
261
+
254
262
let mut threshold = if hinted { HINT_THRESHOLD } else { DEFAULT_THRESHOLD } ;
255
263
256
264
// Significantly lower the threshold for inlining cold functions
You can’t perform that action at this time.
0 commit comments