Skip to content

compiler: fix data section alignment in the wasm NCG

Cheng Shao requested to merge type-dance/ghc:wasm-ncg-fix-p2align into master

Previously we tried to lower the alignment requirement as far as possible, based on the section kind inferred from the CLabel. For info tables, .p2align 1 was applied given the GC should only need the lowest bit to tag forwarding pointers. But this would lead to unaligned loads/stores, which has a performance penalty even if the wasm spec permits it. Furthermore, the test suite has shown memory corruption in a few cases when compacting gc is used.

This patch takes a more conservative approach: all data sections except C strings align to word size.

Edited by Cheng Shao

Merge request reports