-
Notifications
You must be signed in to change notification settings - Fork 76
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
Refactor and correct the "is pure" and "can raise" (port upstream PR#10354 and PR#10387) #555
Merged
Conversation
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
xclerc
reviewed
Mar 2, 2022
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.
I am slightly worried about various catch-all patterns
in predicate definitions under backend/
, since there
is a decent chance we will add new constructors.
gretay-js
added
4.12.0-7
Bug fix patches for 4.12.0-7 release
4.12.0-8
and removed
4.12.0-7
Bug fix patches for 4.12.0-7 release
labels
Mar 3, 2022
xclerc
approved these changes
Mar 4, 2022
8 tasks
mshinwell
approved these changes
Apr 14, 2022
@gretay-js Please could you resolve the conflicts, then this should be ready to merge. |
These two predicates test properties of Mach operations. For the standard operations, the results are independent of the target platform. For the platform-specific operations, results vary. The "is pure" predicate was implemented in a platform-specific file, $ARCH/proc.ml. The treatment of standard operations was duplicated. The "can raise" predicate was implemented in a platform-independent file, mach.ml. All specific operations were assumed not to raise, which is incorrect for ARM and ARM64 and their "shiftcheckbound" specific operation. (See #10339.) This commit refactors the two predicates as follows: - `Arch.operation_is_pure` and `Arch.operation_can_raise` predicates are added to each platform description file. They deal with specific operations only. - `Mach.operation_is_pure` was added and `Mach.operation_can_raise` was fixed to implement the test for standard operations and delegate to the Arch functions for specific operations.
The ARM and ARM64 architectures have `Ishiftcheckbound` specific instructions that can raise an Invalid_argument exception. This exception can, in turn, be handled in the same function (see PR#10339 for an example). However, these specific instructions were not taken into account during insertion of spill code in asmcomp/spill.ml. The consequence is a variable that is reloaded from stack in the exception handler, yet has not been spilled to stack before. This commit fixes the issue by using the recently-fixed `Mach.operation_can_raise` predicate to handle operations during spill code insertion, instead of an ad-hoc pattern-matching. Fixes: PR#10339
… analysis (#10387) This is a follow-up to 15e635462 and #10354. Use the `Mach.operation_can_raise` predicate instead of an ad-hoc pattern matching to spot operations where the variables live at entry to the enclosing exception handler must also be live. The ad-hoc pattern matching was missing the `Ishiftcheckbound` specific operations of ARM and ARM64.
lpw25
added a commit
that referenced
this pull request
May 19, 2022
fe8a98b0c flambda-backend: Save Mach as Cfg after Selection (#624) 2b205d886 flambda-backend: Clean up algorithms (#611) 524f0b435 flambda-backend: Initial refactoring of To_cmm (#619) 0bf75de86 flambda-backend: Refactor and correct the "is pure" and "can raise" (port upstream PR#10354 and PR#10387) (#555) d234bfdbe flambda-backend: Cpp mangling is now a configuration option (#614) 20fc614bf flambda-backend: Check that stack frames are not too large (#10085) (#561) 5fc2e9503 flambda-backend: Allow CSE of immutable loads across stores (port upstream PR#9562) (#562) 2a650deec flambda-backend: Backport commit fc9534746bf5d08a4c109f22e344cf49d5d46d54 from trunk (#584) 31651b87e flambda-backend: Improved ARM64 code generation (port upstream PR#9937) (#556) f0b6d68e8 flambda-backend: Simplify processing and remove dead code (error paths) in asmlink (port upstream PR#9943) (#557) 90c674687 flambda-backend: Improve code-generation for inlined comparisons (port upstream PR#10228) (#563) git-subtree-dir: ocaml git-subtree-split: fe8a98b0cd38bf1872b8faf3b93542caebabad18
mshinwell
pushed a commit
that referenced
this pull request
May 20, 2022
…10354 and PR#10387) (#555) * Refactor Proc.op_is_pure and fix Mach.operation_can_raise These two predicates test properties of Mach operations. For the standard operations, the results are independent of the target platform. For the platform-specific operations, results vary. The "is pure" predicate was implemented in a platform-specific file, $ARCH/proc.ml. The treatment of standard operations was duplicated. The "can raise" predicate was implemented in a platform-independent file, mach.ml. All specific operations were assumed not to raise, which is incorrect for ARM and ARM64 and their "shiftcheckbound" specific operation. (See #10339.) This commit refactors the two predicates as follows: - `Arch.operation_is_pure` and `Arch.operation_can_raise` predicates are added to each platform description file. They deal with specific operations only. - `Mach.operation_is_pure` was added and `Mach.operation_can_raise` was fixed to implement the test for standard operations and delegate to the Arch functions for specific operations. * Fix handling of exception-raising specific operations during spilling The ARM and ARM64 architectures have `Ishiftcheckbound` specific instructions that can raise an Invalid_argument exception. This exception can, in turn, be handled in the same function (see PR#10339 for an example). However, these specific instructions were not taken into account during insertion of spill code in asmcomp/spill.ml. The consequence is a variable that is reloaded from stack in the exception handler, yet has not been spilled to stack before. This commit fixes the issue by using the recently-fixed `Mach.operation_can_raise` predicate to handle operations during spill code insertion, instead of an ad-hoc pattern-matching. Fixes: PR#10339 * Fix handling of exception-raising specific operations during liveness analysis (#10387) This is a follow-up to 15e635462 and #10354. Use the `Mach.operation_can_raise` predicate instead of an ad-hoc pattern matching to spot operations where the variables live at entry to the enclosing exception handler must also be live. The ad-hoc pattern matching was missing the `Ishiftcheckbound` specific operations of ARM and ARM64. * Handle flambda-backend operations * Update cfg * Iprobe_is_enabled is pure * Exhaustive match * Fix after rebase * Fix arm64 after rebase and cleanup Co-authored-by: Xavier Leroy <xavier.leroy@college-de-france.fr> Co-authored-by: Xavier Leroy <xavierleroy@users.noreply.github.com>
lpw25
added a commit
to lpw25/flambda-backend
that referenced
this pull request
May 20, 2022
fe8a98b0c flambda-backend: Save Mach as Cfg after Selection (ocaml-flambda#624) 2b205d886 flambda-backend: Clean up algorithms (ocaml-flambda#611) 524f0b435 flambda-backend: Initial refactoring of To_cmm (ocaml-flambda#619) 0bf75de86 flambda-backend: Refactor and correct the "is pure" and "can raise" (port upstream PR#10354 and PR#10387) (ocaml-flambda#555) d234bfdbe flambda-backend: Cpp mangling is now a configuration option (ocaml-flambda#614) 20fc614bf flambda-backend: Check that stack frames are not too large (#10085) (ocaml-flambda#561) 5fc2e9503 flambda-backend: Allow CSE of immutable loads across stores (port upstream PR#9562) (ocaml-flambda#562) 2a650deec flambda-backend: Backport commit fc9534746bf5d08a4c109f22e344cf49d5d46d54 from trunk (ocaml-flambda#584) 31651b87e flambda-backend: Improved ARM64 code generation (port upstream PR#9937) (ocaml-flambda#556) f0b6d68e8 flambda-backend: Simplify processing and remove dead code (error paths) in asmlink (port upstream PR#9943) (ocaml-flambda#557) 90c674687 flambda-backend: Improve code-generation for inlined comparisons (port upstream PR#10228) (ocaml-flambda#563) git-subtree-dir: ocaml git-subtree-split: fe8a98b0cd38bf1872b8faf3b93542caebabad18
mshinwell
added a commit
that referenced
this pull request
May 24, 2022
454150b1a7 flambda-backend: Speed up testsuite (#658) 8362f9e90c flambda-backend: Speed up builds (#585) a527cabbb2 flambda-backend: Update backends for changes from ocaml-jst ce8883357f Merge flambda-backend changes b7506bbc69 Revert "Cherry-pick of ocaml/ocaml 1eeb0e7fe595f5f9e1ea1edbdf785ff3b49feeeb (#12)" 183f688179 Add config option to enable/disable stack allocation (#22) ee7c849eb8 If both the type and mode of an ident are wrong, complain about the type. (#19) 44bade06c7 Allow submoding during module inclusion checks (#21) de3bec9aea Add subtyping between arrows of related modes (#20) fe8a98b0cd flambda-backend: Save Mach as Cfg after Selection (#624) 2b205d8861 flambda-backend: Clean up algorithms (#611) 93d861556b Enable the local keywords even when the local extension is off (#18) 524f0b435e flambda-backend: Initial refactoring of To_cmm (#619) 81dd85ee19 Documentation for local allocations b05519f16c Fix a GC bug in local stack scanning (#17) 9f879dea8c Fix __FUNCTION__ (#15) 0bf75de86a flambda-backend: Refactor and correct the "is pure" and "can raise" (port upstream PR#10354 and PR#10387) (#555) d234bfdbe4 flambda-backend: Cpp mangling is now a configuration option (#614) 20fc614bff flambda-backend: Check that stack frames are not too large (#10085) (#561) 5fc2e95038 flambda-backend: Allow CSE of immutable loads across stores (port upstream PR#9562) (#562) 2a650deeca flambda-backend: Backport commit fc9534746bf5d08a4c109f22e344cf49d5d46d54 from trunk (#584) a78975eb57 Optimise "include struct ... end" in more cases (ocaml/ocaml#11134) b819c66154 Cherry-pick of ocaml/ocaml 1eeb0e7fe595f5f9e1ea1edbdf785ff3b49feeeb (#12) bb363d4e70 Optimise the allocation of optional arguments (#11) 31651b87ef flambda-backend: Improved ARM64 code generation (port upstream PR#9937) (#556) f0b6d68e86 flambda-backend: Simplify processing and remove dead code (error paths) in asmlink (port upstream PR#9943) (#557) 90c6746877 flambda-backend: Improve code-generation for inlined comparisons (port upstream PR#10228) (#563) git-subtree-dir: ocaml git-subtree-split: 454150b1a78ad6b30cd6892f07f56db2f0b63aa8
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Port ocaml/ocaml#10354 and ocaml/ocaml#10387