Skip to content

Function alignment does not work on wasm #143368

Open
@RalfJung

Description

@RalfJung

For #[align], see the error here and the discussion here. I assume this also affects -Zmin-function-align.

In wasm, functions don't have an "address", it's not a von-Neumann architecture. Instead, there is a dedicated table and one can pick an integer index into the table when doing a dynamic call. So the actual address of a function cannot be observed and "aligning" it has no meaning. However, the fn ptr value can be observed by being cast to an integer, and then one will see the index into that table. One could attempt to align that but it seems not very useful...

Apart from the usefulness, I guess the question is what can we do?

  • Error when the attribute is used on wasm, since relying on fn ptr being divisible by N will just not work
  • Try to convince LLVM to implement this (is there an LLVM issue?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-alignArea: alignment control (`repr(align(N))` and so on)C-bugCategory: This is a bug.F-fn_align`#![feature(fn_align)]`O-wasmTarget: WASM (WebAssembly), http://webassembly.org/T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions