You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Poor quality stencils produced with Homebrew clang version 22.1.2 on Apple Silicon #148501
While working on #148217, I found that the _fixup_constants optimizer in Tools/jit/_optimizers.py fails to convert adrp+ldr to movz when the two instructions are split by a label.
Which clang is being used to generate your stencils?
It might be different from your default clang.
Can you paste the assembly file for emit__LOAD_FAST_BORROW_r01 here?
You'll need to add delete=False to the line with tempfile.TemporaryDirectory() as tempdir: in _targets.py and then find it in your temp directory.
That should give us some hints as to why things aren't working.
changed the title [-]Fix cross-block small constant optimization on AArch64[/-][+]Poor quality stencils produced with Homebrew clang version 22.1.2 on Apple Silicon[/+]on Jun 10, 2026
I also noticed this issue in the macOS arm64 stencils. This is actually caused by LLVM’s Mach-O linker optimisation hint (Lloh) labels which split the adrp/ldr pairs into separate optimiser blocks.
The stencil for _LOAD_SMALL_INT_r01 on macOS currently looks something like this:
We can disable the linker hints with -mllvm -aarch64-enable-collect-loh=false. These hints are never used anyway since the stencils are not passed directly to the Mach-O linker, so we can safely remove them.
This would allow the current optimisations to work like they do on Linux:
A follow up to this would be to recognise the @GOTPAGE/@GOTPAGEOFF Darwin syntax similar to what's done for the :got:/:got_l12: ELF syntax so patch_aarch64_33rx can deal with it.
Activity
pythongh-148501: Fix cross-block adrp+ldr to movz optimization on AAr…
corona10 commentedon Apr 13, 2026
See the following stencil files
markshannon commentedon Apr 13, 2026
I'm not seeing the same stencils as you on main.
For
emit__LOAD_FAST_BORROW_r01, I see this:what version of Clang are you using?
I'm not seeing
__JIT_OPARG_16@GOTPAGEinemit__LOAD_FAST_r01either.corona10 commentedon Apr 13, 2026
I think this could be matter, which clang version are you using on macOS?
markshannon commentedon Apr 14, 2026
My stencil is from linux. Clang 21.1.6.
Which clang is being used to generate your stencils?
It might be different from your default clang.
Can you paste the assembly file for
emit__LOAD_FAST_BORROW_r01here?You'll need to add
delete=Falseto the linewith tempfile.TemporaryDirectory() as tempdir:in _targets.py and then find it in your temp directory.That should give us some hints as to why things aren't working.
[-]Fix cross-block small constant optimization on AArch64[/-][+]Poor quality stencils produced with Homebrew clang version 22.1.2 on Apple Silicon[/+]lgeiger commentedon Sep 6, 2026
I also noticed this issue in the macOS arm64 stencils. This is actually caused by LLVM’s Mach-O linker optimisation hint (
Lloh) labels which split theadrp/ldrpairs into separate optimiser blocks.The stencil for
_LOAD_SMALL_INT_r01on macOS currently looks something like this:We can disable the linker hints with
-mllvm -aarch64-enable-collect-loh=false. These hints are never used anyway since the stencils are not passed directly to the Mach-O linker, so we can safely remove them.This would allow the current optimisations to work like they do on Linux:
A follow up to this would be to recognise the
@GOTPAGE/@GOTPAGEOFFDarwin syntax similar to what's done for the:got:/:got_l12:ELF syntax sopatch_aarch64_33rxcan deal with it.