Skip to content

Commit ba1a622

Browse files
committed
WIP
1 parent 4104497 commit ba1a622

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

compiler/lib/inline.ml

+8-4
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,15 @@ and should_inline
315315
&& (functor_like ~env p info
316316
|| (live_vars.(Var.idx info.f) = 1
317317
&&
318-
(* Avoid inlining in loop since, if the loop is not hot, the
319-
code might not be optimized *)
320318
match Config.target () with
321-
| `Wasm when in_loop -> body_size info ~env p < 30 && not (contains_loop info p)
322-
| _ -> body_size info ~env p < 150)
319+
| `Wasm when in_loop ->
320+
(* Avoid inlining in loop since, if the loop is not hot, the
321+
code might not be optimized *)
322+
body_size info ~env p < 30 && not (contains_loop info p)
323+
| _ ->
324+
body_size info ~env p < 150
325+
(* Avoid inlining loops at toplevel *)
326+
&& ((not (contains_loop info p)) || Option.is_some current_function))
323327
|| (body_size info ~env p <= 1 && closure_count info ~env p = 0)
324328
|| small_function
325329
~live_vars

0 commit comments

Comments
 (0)