[arm64] Constant rematerialization fix for loads clobbering a constant register#479
Closed
siddhesh wants to merge 2 commits intoLuaJIT:v2.1from
Closed
[arm64] Constant rematerialization fix for loads clobbering a constant register#479siddhesh wants to merge 2 commits intoLuaJIT:v2.1from
siddhesh wants to merge 2 commits intoLuaJIT:v2.1from
Conversation
PR LuaJIT#438 describes an issue with constant rematerialization where a rematerializaed constant could use a register it thought was constant but was in fact clobbered in the same instruction that it was defined in. Fix the problem by adding a mask and a safe entry point for the allocator that marks constant holding registers that are unsafe for rematerialization due to them being the same as the destination register for an instruction it is used in. While this is only implemented in asm_fusexref, it should ideally be implemented for all instructions where the destination is likely to clobber one of the source registers and if one or more of the source registers hold constants.
Even if the offset is a constant, it is not 32-bit since it failed that check earlier before it came here. The code is thus useless and hence removed.
Author
|
I'm dropping this in favour of the earlier fix. |
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.
During rematerialization, the register allocator is unable to see when the write to a destination register from a register holding a constant overwrites the register and incorrectly uses it for rematerialization, thus causing a crash.
The first patch in this PR creates a new rset that keeps track of such constant regs and adds a new register allocator entry point ra_alloc_rematsafe() that marks the register as unsafe if it holds a constant and is reused for the destination. The arm64 backend uses this entry point and the new rset (rematset) to make sure that it does not use an unsafe constant register for rematerialization either during an ra_allock or in emit_kdelta.