GH-125498: Update JIT builds to use LLVM 19 and preserve_none (GH-125499)

This commit is contained in:
Savannah Ostrowski 2024-10-30 12:03:31 -07:00 committed by GitHub
parent 597d814334
commit c29bbe2101
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 69 additions and 78 deletions

View file

@ -2,6 +2,7 @@
import dataclasses
import enum
import sys
import typing
import _schema
@ -132,8 +133,18 @@ class Hole:
def __post_init__(self) -> None:
self.func = _PATCH_FUNCS[self.kind]
def fold(self, other: typing.Self) -> typing.Self | None:
def fold(self, other: typing.Self, body: bytes) -> typing.Self | None:
"""Combine two holes into a single hole, if possible."""
instruction_a = int.from_bytes(
body[self.offset : self.offset + 4], byteorder=sys.byteorder
)
instruction_b = int.from_bytes(
body[other.offset : other.offset + 4], byteorder=sys.byteorder
)
reg_a = instruction_a & 0b11111
reg_b1 = instruction_b & 0b11111
reg_b2 = (instruction_b >> 5) & 0b11111
if (
self.offset + 4 == other.offset
and self.value == other.value
@ -141,6 +152,7 @@ class Hole:
and self.addend == other.addend
and self.func == "patch_aarch64_21rx"
and other.func == "patch_aarch64_12x"
and reg_a == reg_b1 == reg_b2
):
# These can *only* be properly relaxed when they appear together and
# patch the same value: