Skip to content

Commit f08ae58

Browse files
authored
flambda-backend: Implemented inlining history and use it inside inlining reports (#365)
* Implemented inlining history * Add links between apply node and there respective function declaration * Fix formatting for inlining arguments * Inlining reports are now showing all decisions taken for any paths, making them work both with simplify and closure conversion
1 parent ac496bf commit f08ae58

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

lambda/debuginfo.ml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module Scoped_location = struct
2929

3030
type scopes =
3131
| Empty
32-
| Cons of {item: scope_item; str: string; str_fun: string}
32+
| Cons of {item: scope_item; str: string; str_fun: string; name : string; prev: scopes}
3333

3434
let str = function
3535
| Empty -> ""
@@ -39,8 +39,8 @@ module Scoped_location = struct
3939
| Empty -> "(fun)"
4040
| Cons r -> r.str_fun
4141

42-
let cons item str =
43-
Cons {item; str; str_fun = str ^ ".(fun)"}
42+
let cons scopes item str name =
43+
Cons {item; str; str_fun = str ^ ".(fun)"; name; prev = scopes}
4444

4545
let empty_scopes = Empty
4646

@@ -63,29 +63,29 @@ module Scoped_location = struct
6363

6464
let enter_anonymous_function ~scopes =
6565
let str = str_fun scopes in
66-
Cons {item = Sc_anonymous_function; str; str_fun = str}
66+
Cons {item = Sc_anonymous_function; str; str_fun = str; name = ""; prev = scopes}
6767

6868
let enter_value_definition ~scopes id =
69-
cons Sc_value_definition (dot scopes (Ident.name id))
69+
cons scopes Sc_value_definition (dot scopes (Ident.name id)) (Ident.name id)
7070

7171
let enter_module_definition ~scopes id =
72-
cons Sc_module_definition (dot scopes (Ident.name id))
72+
cons scopes Sc_module_definition (dot scopes (Ident.name id)) (Ident.name id)
7373

7474
let enter_class_definition ~scopes id =
75-
cons Sc_class_definition (dot scopes (Ident.name id))
75+
cons scopes Sc_class_definition (dot scopes (Ident.name id)) (Ident.name id)
7676

7777
let enter_method_definition ~scopes (s : Asttypes.label) =
7878
let str =
7979
match scopes with
8080
| Cons {item = Sc_class_definition; _} -> dot ~sep:"#" scopes s
8181
| _ -> dot scopes s
8282
in
83-
cons Sc_method_definition str
84-
85-
let enter_lazy ~scopes = cons Sc_lazy (str scopes)
83+
cons scopes Sc_method_definition str s
8684

85+
let enter_lazy ~scopes = cons scopes Sc_lazy (str scopes) ""
86+
8787
let enter_partial_or_eta_wrapper ~scopes =
88-
cons Sc_partial_or_eta_wrapper (dot ~no_parens:() scopes "(partial)")
88+
cons scopes Sc_partial_or_eta_wrapper (dot ~no_parens:() scopes "(partial)") ""
8989

9090
let string_of_scopes = function
9191
| Empty -> "<unknown>"

lambda/debuginfo.mli

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,19 @@
1414
(**************************************************************************)
1515

1616
module Scoped_location : sig
17-
type scopes
17+
type scope_item = private
18+
| Sc_anonymous_function
19+
| Sc_value_definition
20+
| Sc_module_definition
21+
| Sc_class_definition
22+
| Sc_method_definition
23+
| Sc_partial_or_eta_wrapper
24+
| Sc_lazy
25+
26+
type scopes = private
27+
| Empty
28+
| Cons of {item: scope_item; str: string; str_fun: string; name : string; prev: scopes}
29+
1830
val string_of_scopes : scopes -> string
1931

2032
val empty_scopes : scopes

0 commit comments

Comments
 (0)