bjorn3 opened issue #6716:
Feature
See title.
Benefit
Correct alignment are necessary to avoid crashes on some architectures and code may depend on correct alignment. In addition rustc checks that the right alignment is used when dereferencing a raw pointer in debug mode. This breaks rayon which allocates a stack value with cacheline alignment and then takes a raw pointer which it later dereferences. See https://github.com/bjorn3/rustc_codegen_cranelift/issues/1381.
Implementation
Sort stackslots by alignment for better packing and then add padding as necessary and if the alignment of a stack slot exceeds the ABI stack alignment realign the stack at runtime.
Alternatives
Doing dynamic alignment at runtime in the cranelift ir producer. This is slower and has higher stack usage overhead.
bjorn3 commented on issue #6716:
Also necessary to fix https://github.com/bjorn3/rustc_codegen_cranelift/issues/1258.
cfallin closed issue #6716:
Feature
See title.
Benefit
Correct alignment are necessary to avoid crashes on some architectures and code may depend on correct alignment. In addition rustc checks that the right alignment is used when dereferencing a raw pointer in debug mode. This breaks rayon which allocates a stack value with cacheline alignment and then takes a raw pointer which it later dereferences. See https://github.com/bjorn3/rustc_codegen_cranelift/issues/1381.
Implementation
Sort stackslots by alignment for better packing and then add padding as necessary and if the alignment of a stack slot exceeds the ABI stack alignment realign the stack at runtime.
Alternatives
Doing dynamic alignment at runtime in the cranelift ir producer. This is slower and has higher stack usage overhead.
bjorn3 commented on issue #6716:
Would you mind reopening this? It hasn't been fully resolved yet: https://github.com/bytecodealliance/wasmtime/pull/8635/files#r1603954465
cfallin reopened issue #6716:
Feature
See title.
Benefit
Correct alignment are necessary to avoid crashes on some architectures and code may depend on correct alignment. In addition rustc checks that the right alignment is used when dereferencing a raw pointer in debug mode. This breaks rayon which allocates a stack value with cacheline alignment and then takes a raw pointer which it later dereferences. See https://github.com/bjorn3/rustc_codegen_cranelift/issues/1381.
Implementation
Sort stackslots by alignment for better packing and then add padding as necessary and if the alignment of a stack slot exceeds the ABI stack alignment realign the stack at runtime.
Alternatives
Doing dynamic alignment at runtime in the cranelift ir producer. This is slower and has higher stack usage overhead.
cfallin commented on issue #6716:
Sure; to summarize here, the issue is that alignment is now correct with respect to the start of stack frame, but start of stack frame is only aligned as per ABI (e.g. 16 bytes on x86-64 and aarch64) so we need to dynamically align SP (it must be dynamic).
cfallin edited a comment on issue #6716:
Sure; to summarize here, the issue is that alignment is now correct with respect to the start of stack frame, but start of stack frame is only aligned as per ABI (e.g. 16 bytes on x86-64 and aarch64) so we need to dynamically align SP (it must be dynamic, we can't know statically anything more than the ABI guarantee).
Last updated: Nov 22 2024 at 16:03 UTC