RFR: 8307572: AArch64: Vector registers are clobbered by some macroassemblers

Andrew Haley aph at openjdk.org
Thu May 11 08:45:42 UTC 2023


On Wed, 10 May 2023 06:36:13 GMT, Ningsheng Jian <njian at openjdk.org> wrote:

> I found that MacroAssembler::arrays_equals() would call stubcode, which may use vector registers. However, the call site in match rule does not claim the use of vector registers. Since c2 will allocate v16-v31 first [1], it's rare that using of v0-v7 will cause problem, but I did create a test case to expose the bug.
> 
> Apart from arrays_equals, I also checked other macroassemblers, and found several similar issues. Fixed by claiming those vector register being killed in match rules call sites, which should have minimal performance impact compared to always saving/restoring those vector registers, since those V0-Vx registers are rarely allocated and live cross the macroassembler call.
> 
> A jtreg test case is also added to demonstrate the failure. Test will fail without this patch, and pass with this patch.
> 
> Test: I tried to update the allocation order in [1] to allocate V0-V15 first and then V16-V31, and full jtreg tests passed with the allocation order changed. (I did found some test failures with this allocation order change without this patch). I have also eyeballed and checked other macroassembler calls, and others seemed fine.
> 
> [1] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/aarch64/aarch64.ad#L424

Great catch, thanks. Does this one need backports?

-------------

Marked as reviewed by aph (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/13895#pullrequestreview-1422072740


More information about the hotspot-dev mailing list