detached 5e114e1

fix: handle arm64 float arrays in HFA detection

commit
5e114e1bf8ccae01abd55a03b1e1737f1fe68223
author
brice · · 2026-04-13 10:13 UTC
parent
b883928
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +22 -1
M struct_arm64.go +15 -1
@@ -230,7 +230,7 @@ func placeStack(v reflect.Value, keepAlive []any, addInt func(uintptr)) []any {
230230 // [Arm64 Calling Convention]: https://github.com/ARM-software/abi-aa/blob/main/sysvabi64/sysvabi64.rst
231231 func isHFA(t reflect.Type) bool {
232232 structSize := roundUpTo8(t.Size())
233- if structSize == 0 || t.NumField() > 4 {
233+ if structSize == 0 {
234234 return false
235235 }
236236 var kind reflect.Kind
@@ -254,6 +254,20 @@ func isHFA(t reflect.Type) bool {
254254 if !walk(ft) {
255255 return false
256256 }
257+ case reflect.Array:
258+ elemKind := ft.Elem().Kind()
259+ if elemKind != reflect.Float32 && elemKind != reflect.Float64 {
260+ return false
261+ }
262+ if kind == 0 {
263+ kind = elemKind
264+ } else if elemKind != kind {
265+ return false
266+ }
267+ members += ft.Len()
268+ if members > 4 {
269+ return false
270+ }
257271 default:
258272 return false
259273 }
@@ -230,7 +230,7 @@ func placeStack(v reflect.Value, keepAlive []any, addInt func(uintptr)) []any {
230 // [Arm64 Calling Convention]: https://github.com/ARM-software/abi-aa/blob/main/sysvabi64/sysvabi64.rst230 // [Arm64 Calling Convention]: https://github.com/ARM-software/abi-aa/blob/main/sysvabi64/sysvabi64.rst
231 func isHFA(t reflect.Type) bool {231 func isHFA(t reflect.Type) bool {
232 structSize := roundUpTo8(t.Size())232 structSize := roundUpTo8(t.Size())
233- if structSize == 0 || t.NumField() > 4 {233+ if structSize == 0 {
234 return false234 return false
235 }235 }
236 var kind reflect.Kind236 var kind reflect.Kind
@@ -254,6 +254,20 @@ func isHFA(t reflect.Type) bool {
254 if !walk(ft) {254 if !walk(ft) {
255 return false255 return false
256 }256 }
257+ case reflect.Array:
258+ elemKind := ft.Elem().Kind()
259+ if elemKind != reflect.Float32 && elemKind != reflect.Float64 {
260+ return false
261+ }
262+ if kind == 0 {
263+ kind = elemKind
264+ } else if elemKind != kind {
265+ return false
266+ }
267+ members += ft.Len()
268+ if members > 4 {
269+ return false
270+ }
257 default:271 default:
258 return false272 return false
259 }273 }
M struct_arm64_regression_test.go +7 -0
@@ -28,3 +28,10 @@ func TestIsHFAAcceptsNestedFloatStructs(t *testing.T) {
2828 t.Fatal("expected nested float-only struct to be HFA")
2929 }
3030 }
31+
32+func TestIsHFAAcceptsFloatArrayStruct(t *testing.T) {
33+ type arrayed struct{ A [2]float64 }
34+ if !isHFA(reflect.TypeOf(arrayed{})) {
35+ t.Fatal("expected float array struct to be HFA")
36+ }
37+}
@@ -28,3 +28,10 @@ func TestIsHFAAcceptsNestedFloatStructs(t *testing.T) {
28 t.Fatal("expected nested float-only struct to be HFA")28 t.Fatal("expected nested float-only struct to be HFA")
29 }29 }
30 }30 }
31+
32+func TestIsHFAAcceptsFloatArrayStruct(t *testing.T) {
33+ type arrayed struct{ A [2]float64 }
34+ if !isHFA(reflect.TypeOf(arrayed{})) {
35+ t.Fatal("expected float array struct to be HFA")
36+ }
37+}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close