Repository navigation
fix(arm64): a homogeneous float aggregate takes one SIMD register per element - #627
Merged
Merged
Conversation
…er element AAPCS64 passes a struct whose instance fields are all float (or all double), one to four of them, in consecutive SIMD registers. IL2CPP follows the platform ABI for managed methods: Vector3 occupies V0..V2, so the float argument after it goes in V3, and the null MethodInfo slot sits in X0. The resolver counted every parameter as one slot, taking the struct's integer register. Every argument after such a struct was then read from the wrong register - typically X0, the nil MethodInfo - which is why call arguments showed up as a literal 0 and C# reported int -> Vector3 conversion errors. Adds HomogeneousFloatAggregate.Count, which flattens nested aggregates, bounds both the element count (4) and the nesting depth, refuses mixed float/double, and returns 0 when the layout is unknown so such a parameter keeps the previous behaviour. AddParameterSlots expands such a parameter into one slot per element while still contributing exactly one call operand, so the operand-to-parameter mapping stays 1:1. Verified on Assembly-CSharp::AutoRotation::Update, whose native body passes rot in V0..V2 and deltaTime in V3: before: Call Vector3.op_Multiply, dest, 0, this.rot after : Call Vector3.op_Multiply, dest, this.rot, v68 @ V0_v1 (Single) Measured over a 46,727-method IL2CPP game (ARM64, metadata 24.5) by compiling the decompiled output assembly by assembly: total C# compile errors 9,395 -> 7,965, of which "cannot convert" (CS0030) 3,229 -> 1,913. 7 assemblies improved, none regressed.
XHuoHuaX
force-pushed
the
pr/arm64-hfa
branch
from
November 3, 2026 03:12
1064940 to
b7aa138
Compare
SamboyCoding
approved these changes
Nov 28, 2026
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.
What this fixes
AAPCS64 passes a homogeneous floating-point aggregate — a struct whose instance fields are all
float, or alldouble, one to four of them — in consecutive SIMD registers. IL2CPP follows the platform ABI for managed methods, so aVector3argument occupiesV0..V2, thefloatargument after it goes inV3, and the nullMethodInfoslot sits inX0.The ARM64 resolver counted every parameter as exactly one register slot, so an HFA took the struct's integer register. Every argument after such a struct was then read from the wrong register — typically
X0, the nilMethodInfo— which is where literal0s in call arguments come from, and why the decompiled output reportsint -> Vector3conversion errors (CS0030).Evidence
Assembly-CSharp::AutoRotation::Update, whose native body passesrotinV0..V2anddeltaTimeinV3:Measured effect
Over a 46,727-method IL2CPP game (ARM64, metadata 24.5), compiling the decompiled output assembly by assembly:
7 assemblies improved, none regressed.
How it is scoped
HomogeneousFloatAggregate.Countflattens nested aggregates, bounds the element count (4) and the nesting depth, refuses mixedfloat/double, and returns 0 when the layout is unknown so such a parameter keeps the previous behaviour rather than guessing.AddParameterSlotsexpands such a parameter into one slot per element while still contributing exactly one call operand, so the operand↔parameter mapping stays 1:1 and nothing downstream has to change.Notes for review
protected virtual AddParameterSlotswith the previous one-slot behaviour as its default, so other architectures are untouched.