Skip to content

Simplify processing and remove dead code (error paths) in asmlink (port upstream PR#9943) #557

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

Merged
merged 2 commits into from
Mar 18, 2022

Conversation

gretay-js
Copy link
Contributor

An analysis of the code should convince yourself that the
[object_file_name] function is not needed and that its erroring paths
are dead code.

The reasoning is the following: all the uses of [object_file_name] in
asmlink.ml are performed on [obj_name]s which went through [read_file]
before. The latter does exactly the same file name lookup and erroring
treatement, except not in a stringly manner like [object_file_name]
does.

This new function derives the same information as [object_file_name]
except it does it on the [file] datatype returned by [read_file].
Note that all the erroring code paths of [object_file_name] have been
handled by the [read_file] which derived the [file] value.

We integrate the logic added by PR #9011 for empty cmxa here.
This commit does the following four things (it's difficult
to them in separate commits that compile).

1) It removes the [read_file] from [scan_file]. Reading the files is
   done seperately before returning an [obj_infos] list of [file]
   values. This turns [scan_file] into a function that operates on
   values of type [file].

2) In [scan_file] it removes the separate list of [obj_files]
   introduced by #9011. We can derive the same list using the function
   [object_file_name_of_file] introduced in the previous commit on the
   list of [obj_infos]. Effectively we bring back [scan_file] to the
   state before #9011 modulo the [read_file] removal.

3) We derive the list of [obj_files] directly from the
   [obj_infos] list via [object_file_name_of_file]. Note that
   the logic introduced by #9011 is preserved by virtue of
   [object_file_name_of_file]'s optional result.

4) Deletes [object_file_name] which is no longer used.
@gretay-js gretay-js merged commit 6093947 into ocaml-flambda:main Mar 18, 2022
lpw25 added a commit that referenced this pull request May 19, 2022
fe8a98b flambda-backend: Save Mach as Cfg after Selection (#624)
2b205d8 flambda-backend: Clean up algorithms (#611)
524f0b4 flambda-backend: Initial refactoring of To_cmm (#619)
0bf75de flambda-backend: Refactor and correct the "is pure" and "can raise" (port upstream PR#10354 and PR#10387) (#555)
d234bfd flambda-backend: Cpp mangling is now a configuration option (#614)
20fc614 flambda-backend: Check that stack frames are not too large (#10085) (#561)
5fc2e95 flambda-backend: Allow CSE of immutable loads across stores (port upstream PR#9562) (#562)
2a650de flambda-backend: Backport commit fc95347 from trunk (#584)
31651b8 flambda-backend: Improved ARM64 code generation (port upstream PR#9937) (#556)
f0b6d68 flambda-backend: Simplify processing and remove dead code (error paths) in asmlink (port upstream PR#9943) (#557)
90c6746 flambda-backend: Improve code-generation for inlined comparisons (port upstream PR#10228) (#563)

git-subtree-dir: ocaml
git-subtree-split: fe8a98b
mshinwell pushed a commit that referenced this pull request May 20, 2022
…rt upstream PR#9943) (#557)

* Asmlink.object_file_name removal: add object_file_name_of_file

An analysis of the code should convince yourself that the
[object_file_name] function is not needed and that its erroring paths
are dead code.

The reasoning is the following: all the uses of [object_file_name] in
asmlink.ml are performed on [obj_name]s which went through [read_file]
before. The latter does exactly the same file name lookup and erroring
treatement, except not in a stringly manner like [object_file_name]
does.

This new function derives the same information as [object_file_name]
except it does it on the [file] datatype returned by [read_file].
Note that all the erroring code paths of [object_file_name] have been
handled by the [read_file] which derived the [file] value.

We integrate the logic added by PR #9011 for empty cmxa here.

* Asmlink.object_file_name removal: remove.

This commit does the following four things (it's difficult
to them in separate commits that compile).

1) It removes the [read_file] from [scan_file]. Reading the files is
   done seperately before returning an [obj_infos] list of [file]
   values. This turns [scan_file] into a function that operates on
   values of type [file].

2) In [scan_file] it removes the separate list of [obj_files]
   introduced by #9011. We can derive the same list using the function
   [object_file_name_of_file] introduced in the previous commit on the
   list of [obj_infos]. Effectively we bring back [scan_file] to the
   state before #9011 modulo the [read_file] removal.

3) We derive the list of [obj_files] directly from the
   [obj_infos] list via [object_file_name_of_file]. Note that
   the logic introduced by #9011 is preserved by virtue of
   [object_file_name_of_file]'s optional result.

4) Deletes [object_file_name] which is no longer used.

Co-authored-by: Daniel Bünzli <[email protected]>
lpw25 added a commit to lpw25/flambda-backend that referenced this pull request May 20, 2022
fe8a98b flambda-backend: Save Mach as Cfg after Selection (ocaml-flambda#624)
2b205d8 flambda-backend: Clean up algorithms (ocaml-flambda#611)
524f0b4 flambda-backend: Initial refactoring of To_cmm (ocaml-flambda#619)
0bf75de flambda-backend: Refactor and correct the "is pure" and "can raise" (port upstream PR#10354 and PR#10387) (ocaml-flambda#555)
d234bfd flambda-backend: Cpp mangling is now a configuration option (ocaml-flambda#614)
20fc614 flambda-backend: Check that stack frames are not too large (#10085) (ocaml-flambda#561)
5fc2e95 flambda-backend: Allow CSE of immutable loads across stores (port upstream PR#9562) (ocaml-flambda#562)
2a650de flambda-backend: Backport commit fc95347 from trunk (ocaml-flambda#584)
31651b8 flambda-backend: Improved ARM64 code generation (port upstream PR#9937) (ocaml-flambda#556)
f0b6d68 flambda-backend: Simplify processing and remove dead code (error paths) in asmlink (port upstream PR#9943) (ocaml-flambda#557)
90c6746 flambda-backend: Improve code-generation for inlined comparisons (port upstream PR#10228) (ocaml-flambda#563)

git-subtree-dir: ocaml
git-subtree-split: fe8a98b
mshinwell added a commit that referenced this pull request May 24, 2022
454150b flambda-backend: Speed up testsuite (#658)
8362f9e flambda-backend: Speed up builds (#585)
a527cab flambda-backend: Update backends for changes from ocaml-jst
ce88833 Merge flambda-backend changes
b7506bb Revert "Cherry-pick of ocaml/ocaml 1eeb0e7fe595f5f9e1ea1edbdf785ff3b49feeeb (#12)"
183f688 Add config option to enable/disable stack allocation (#22)
ee7c849 If both the type and mode of an ident are wrong, complain about the type. (#19)
44bade0 Allow submoding during module inclusion checks (#21)
de3bec9 Add subtyping between arrows of related modes (#20)
fe8a98b flambda-backend: Save Mach as Cfg after Selection (#624)
2b205d8 flambda-backend: Clean up algorithms (#611)
93d8615 Enable the local keywords even when the local extension is off (#18)
524f0b4 flambda-backend: Initial refactoring of To_cmm (#619)
81dd85e Documentation for local allocations
b05519f Fix a GC bug in local stack scanning (#17)
9f879de Fix __FUNCTION__ (#15)
0bf75de flambda-backend: Refactor and correct the "is pure" and "can raise" (port upstream PR#10354 and PR#10387) (#555)
d234bfd flambda-backend: Cpp mangling is now a configuration option (#614)
20fc614 flambda-backend: Check that stack frames are not too large (#10085) (#561)
5fc2e95 flambda-backend: Allow CSE of immutable loads across stores (port upstream PR#9562) (#562)
2a650de flambda-backend: Backport commit fc95347 from trunk (#584)
a78975e Optimise "include struct ... end" in more cases (ocaml/ocaml#11134)
b819c66 Cherry-pick of ocaml/ocaml 1eeb0e7fe595f5f9e1ea1edbdf785ff3b49feeeb (#12)
bb363d4 Optimise the allocation of optional arguments (#11)
31651b8 flambda-backend: Improved ARM64 code generation (port upstream PR#9937) (#556)
f0b6d68 flambda-backend: Simplify processing and remove dead code (error paths) in asmlink (port upstream PR#9943) (#557)
90c6746 flambda-backend: Improve code-generation for inlined comparisons (port upstream PR#10228) (#563)

git-subtree-dir: ocaml
git-subtree-split: 454150b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants