IRC: Fix interf graph for exceptional path.#804
Merged
xclerc merged 3 commits intooxcaml:mainfrom Sep 7, 2022
Merged
Conversation
gretay-js
approved these changes
Sep 1, 2022
xclerc
approved these changes
Sep 6, 2022
This file contains hidden or 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
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.
To create interf graph edges for exceptional branch there were edges add from every temporary variable to every physical register from
Proc.destroyed_at_raise.That is correct thing to do but the set of all live variables computed incorrectly.
The expected value is
first_instr.beforebut withoutProc.loc_exn_bucket, because that is "generated" by the exception.But the value
first_instr.acrossis currently taken.If the
first_instristemporary/X = Proc.loc_exn_bucketthenfirst_instr.acrosswill be what we want because thetemporary/Xwill be removed andProc.loc_exn_bucketwon't be added yet.But in case where the first instruction isn't that (which can happen if the exception value is ignored and deadcode removes this move) then we would want exactly
first_instr.beforebecause we expect that it doesn't containtProc.loc_exn_bucketas that's a preassigned register.But
first_instr.acrosscompared tofirst_instr.beforeis missing all arguments of the instruction.For that reason IRC doesn't mark those temporaries as colliding with
Proc.loc_exn_bucket.Then the registers can be left unspilled over an exception which isn't an allowed behaviour.
An example of this is
Upstream:
IRC:
The region pointer for IRC is stored in
rsiwhile for Upstream it's spilled on stack.In the handler the code generated by IRC reads the pointer from
rsibut it could have been destroyed by the exception.The Upstream code properly handles it by reload from stack slot which is persistent.