-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix code generation with nested let rec of functions #8712
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8de4f81
regression test for pr8681.ml
gasche 495434a
Add more tests for #8681, #8699
stedolan d946686
Code generation and runtime fix for #8699, #8681
stedolan 3607562
Code review fixes
stedolan 13deb30
Bugfix for letrec infix compilation
stedolan c49273b
More assertions in caml_update_dummy
stedolan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,5 +14,6 @@ mixing_value_closures_2.ml | |
mutual_functions.ml | ||
nested.ml | ||
pr4989.ml | ||
pr8681.ml | ||
record_with.ml | ||
ref.ml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
(* TEST *) | ||
let rec h = | ||
let rec f n = if n >= 0 then g (n - 1) | ||
and g n = h n; f n in | ||
f | ||
|
||
let () = Gc.minor () | ||
let () = ignore (h 10) | ||
|
||
let mooo x = | ||
let rec h = | ||
ignore (Sys.opaque_identity x); | ||
let rec g n = h n; f n | ||
and f n = if n >= 0 then g (n - 1) in | ||
f | ||
in | ||
h | ||
|
||
let h = mooo 3 | ||
let () = Gc.minor () | ||
let () = ignore (h 10) | ||
|
||
|
||
let rec foo = | ||
let rec f = function | ||
| 0 -> 100 | ||
| n -> foo (n-1) | ||
and g = function | ||
| 0 -> 200 | ||
| n -> f (n-1) in | ||
g | ||
|
||
let () = print_int (foo 2); print_newline () | ||
let () = print_int (foo 7); print_newline () | ||
|
||
|
||
let with_free_vars a b c = | ||
let rec foo = | ||
let rec f = function | ||
| 0 -> 100 + a + b + c | ||
| n -> foo (n-1) | ||
and g = function | ||
| 0 -> 200 + a + b + c | ||
| n -> f (n-1) in | ||
g in | ||
foo | ||
|
||
let () = print_int (with_free_vars 1 2 3 2); print_newline () | ||
let () = print_int (with_free_vars 1 2 3 7); print_newline () | ||
|
||
let bar = | ||
let rec f = function | ||
| 0 -> 3 | ||
| n -> g (n - 1) | ||
and g = function | ||
| 0 -> 10 + f 10 | ||
| n -> f (n - 1) | ||
in | ||
let rec foof = f | ||
and goof = g | ||
in (foof, goof) | ||
|
||
let () = print_int (snd bar 42); print_newline () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
200 | ||
100 | ||
206 | ||
106 | ||
13 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also handle
RHS_infix { blocksize; offset = offset' } -> RHS_infix { blocksize; offset = offset + offset' }
I'm not certain that I can produce an example where Uoffsets are chained, but in theory, flambda could produce it through convoluted sequence of unrolling.