-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
flambda-backend: Refactor and correct the "is pure" and "can raise" (…
…port upstream PR#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 15e6354 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>
- Loading branch information
1 parent
d234bfd
commit 0bf75de
Showing
21 changed files
with
126 additions
and
103 deletions.
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
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
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
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
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,12 @@ | ||
(* TEST *) | ||
|
||
(* See PR#10339 *) | ||
|
||
let access (a: string array) n = | ||
try | ||
ignore (a.(n)); -1 | ||
with _ -> | ||
n | ||
|
||
let _ = | ||
assert (access [||] 1 = 1) |