Skip to content

Commit d1c090c

Browse files
lukemaurerlthls
andauthored
flambda-backend: Implement -no-approx and -no-code in flambda-backend ocamlobjinfo (#2737)
* Implement `-no-approx` and `-no-code` in flambda-backend `ocamlobjinfo` The old `-no-approx` and `-no-code` options are currently parsed but ignored. This is inconvenient, since the output for an flambda2 .cmx can be screenfuls long even for relatively small modules. This PR implements `-no-approx` by just suppressing .cmx export information altogether (roughly equivalent to what the old one did). Also implements `-no-code` by doing exactly the same thing as `-no-approx`. (Which does indeed mean there's no code.) * Also suppress zero-alloc info It's not as noisy as the full export info but it does make tests more sensitive. * Add conditional printing to Flambda_cmx_format * Better condition * Add a test case with `-no-code` but not `-no-approx` This exercises the separate `-no-approx` implementation from lukemaurer#2. --------- Co-authored-by: Vincent Laviron <[email protected]>
1 parent 1dc5b60 commit d1c090c

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

testsuite/tests/tool-ocamlobjinfo/question.ml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,18 @@
88
check-ocamlopt.byte-output;
99
{
1010
ocamlobjinfo;
11+
12+
program = "-no-code -no-approx question.cmx";
13+
ocamlobjinfo;
14+
15+
program = "-no-code question.cmx";
16+
ocamlobjinfo;
17+
1118
check-program-output;
1219
}{
1320
program = "question.cmx";
1421
ocamlobjinfo;
15-
(* The cmx output varies too much to check. We're just happy it didn't
22+
(* The full cmx output varies too much to check. We're just happy it didn't
1623
segfault on us. *)
1724
}
1825
*)

testsuite/tests/tool-ocamlobjinfo/question.reference

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,64 @@ Interfaces imported:
88
00000000000000000000000000000000 Question
99
00000000000000000000000000000000 CamlinternalFormatBasics
1010
Implementations imported:
11+
File question.cmx
12+
Name: Question
13+
CRC of implementation: 00000000000000000000000000000000
14+
Globals defined:
15+
Question
16+
Interfaces imported:
17+
00000000000000000000000000000000 Stdlib
18+
00000000000000000000000000000000 Question
19+
00000000000000000000000000000000 CamlinternalFormatBasics
20+
Implementations imported:
21+
Flambda 2 unit with export information
22+
Currying functions:
23+
Apply functions:
24+
Send functions:
25+
Force link: no
26+
File question.cmx
27+
Name: Question
28+
CRC of implementation: 00000000000000000000000000000000
29+
Globals defined:
30+
Question
31+
Interfaces imported:
32+
00000000000000000000000000000000 Stdlib
33+
00000000000000000000000000000000 Question
34+
00000000000000000000000000000000 CamlinternalFormatBasics
35+
Implementations imported:
36+
Flambda 2 export information:
37+
Original unit: Question
38+
Typing env:
39+
((defined_symbols_without_equations ())
40+
(code_age_relation
41+
{(camlQuestion__answer_0_1_code camlQuestion__answer_0_0_code)})
42+
(type_equations
43+
{(Question.camlQuestion
44+
(Val
45+
(Variant
46+
(blocks
47+
((alloc_mode Heap) (known
48+
{(tag_0 => (Known 1), ((Val (= Question.camlQuestion__answer_1))))})
49+
(other Bottom))) (tagged_imms (Naked_immediate ⊥)))))
50+
(Question.camlQuestion__answer_1
51+
(Val
52+
((alloc_mode Heap) (known
53+
{((answer/0 ∷ 𝕍)
54+
=> (Known ((closures { (answer/0 ∷ 𝕍) }) (value_slots { }))),
55+
((function_types
56+
{((answer/0 ∷ 𝕍)
57+
(Ok (function_type (code_id camlQuestion__answer_0_1_code)
58+
(rec_info (Rec_info 0)))))})
59+
(closure_types
60+
((function_slot_components_by_index
61+
{((answer/0 ∷ 𝕍) (Val (= Question.camlQuestion__answer_1)))})))
62+
(value_slot_types ((value_slot_components_by_index {})))))})
63+
(other Bottom))))})
64+
(aliases
65+
((canonical_elements {}) (aliases_of_canonical_names {})
66+
(aliases_of_consts {}))))
67+
68+
Currying functions:
69+
Apply functions:
70+
Send functions:
71+
Force link: no

0 commit comments

Comments
 (0)