fix(assembly): correct AMD64 AVX2 stack frame offsets#25
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes critical assembly bugs in AMD64 AVX2 implementations that caused go vet failures and test failures on Linux and Windows. The changes correct stack frame sizes and argument offsets in two assembly files.
Key Changes:
- Corrected return value offsets in
bucket_lookup_avx2_amd64.sfrom +25 to +32 - Fixed frame size and all argument offsets in
batch_avx2_amd64.sfrom incorrect values to proper 8-byte aligned offsets - However, the frame size in
bucket_lookup_avx2_amd64.sstill appears to be incorrect (should be 40, not 33)
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/lookup/bucket_lookup_avx2_amd64.s | Partially corrected frame size to 33 and return offsets to 32; however, frame size should be 40 based on argument layout |
| internal/hash/xxhash/batch_avx2_amd64.s | Correctly fixed frame size to 64 and adjusted all argument offsets (results_base, fingerprintBits, numBuckets) to proper aligned values |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| // func bucketLookupAVX2(fingerprints []byte, target byte) bool | ||
| TEXT ·bucketLookupAVX2(SB), NOSPLIT, $0-25 | ||
| TEXT ·bucketLookupAVX2(SB), NOSPLIT, $0-33 |
There was a problem hiding this comment.
The frame size should be 40, not 33. The function has:
fingerprints []byte= 24 bytes (3 × 8-byte words at offsets 0, 8, 16)target byte= 8 bytes (aligned, at offset 24)return bool= 8 bytes (aligned, at offset 32)
Total = 40 bytes (5 × 8-byte slots)
The correct declaration should be TEXT ·bucketLookupAVX2(SB), NOSPLIT, $0-40
Suggested change
| TEXT ·bucketLookupAVX2(SB), NOSPLIT, $0-33 | |
| TEXT ·bucketLookupAVX2(SB), NOSPLIT, $0-40 |
Fix critical assembly bugs that caused go vet failures and test failures on Linux and Windows. Changes: - bucket_lookup_avx2_amd64.s: Fix frame size from /bin/zsh-25 to /bin/zsh-33 - Correct return offset from ret+25(FP) to ret+32(FP) - batch_avx2_amd64.s: Fix frame size from -72 to -64 - Correct results_base offset from +32(FP) to +24(FP) - Correct fingerprintBits offset from +56(FP) to +48(FP) - Correct numBuckets offset from +64(FP) to +56(FP) The errors were due to incorrect calculation of Go function argument sizes: - []byte = 24 bytes (base + len + cap, each 8 bytes) - byte = 8 bytes (aligned) - bool = 8 bytes (aligned) All tests now pass with race detector enabled on all platforms. Fixes: go vet errors on AMD64 Fixes: TestBucketLookup* failures on Linux and Windows Fixes: XXHash batch processing on all platforms
c153d1f to
71099ca
Compare
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.
Fix critical assembly bugs that caused go vet failures and test failures on Linux and Windows.
Changes:
The errors were due to incorrect calculation of Go function argument sizes:
All tests now pass with race detector enabled on all platforms.
Fixes: go vet errors on AMD64
Fixes: TestBucketLookup* failures on Linux and Windows
Fixes: XXHash batch processing on all platforms