Skip to content

Commit 33abc59

Browse files
Fix alignment in relaxed atomics spec test (#8961)
The spec test intends to use the natural alignment for all instructions, but it's choosing an alignment based on the memory address type rather than the size of the load/store. This means that sometimes the alignment is too small (4 bytes for an 8-byte load/store in a 32-bit memory), and sometimes the alignment is too large (8 bytes for a 4-byte load/store in a 64-bit memory) both of which are a [validation error](https://github.com/stevenfontanella/threads/blob/f521d7b3c19bcc9097aad979b3b91837eab88d83/interpreter/valid/valid.ml#L206) (but are not in Binaryen today). Use the size of the load/store as the alignment instead. Spec reference: <img width="737" height="216" alt="image" src="https://github.com/user-attachments/assets/b86de03e-1316-4c2c-9a12-80773fb88119" />
1 parent b8f9160 commit 33abc59

2 files changed

Lines changed: 304 additions & 304 deletions

File tree

scripts/test/generate_atomic_spec_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def bin_statement_lines(template: Template, mem_idx: int, mem_ptr_type: ValueTyp
224224

225225
has_ordering = ordering is not None
226226
has_mem_idx = mem_idx is not None
227-
raw_alignment = int(math.log2(mem_ptr_type.value // 8))
227+
raw_alignment = int(math.log2(template.value_type.value // 8))
228228
alignment = raw_alignment | (has_ordering << 4) | (has_mem_idx << 6)
229229
comment = f"Alignment of {raw_alignment}" \
230230
f'{" with bit 4 set indicating that an ordering immediate follows" if has_ordering else ""}' \

0 commit comments

Comments
 (0)