Skip to content

Conversation

@alexrp
Copy link
Member

@alexrp alexrp commented Oct 15, 2024

No description provided.

@alexrp alexrp requested a review from mlugg October 15, 2024 21:37
…r more targets.

defaultFunctionAlignment() can be made more sophisticated over time based on the
CPU model and/or features. For now, I've picked some reasonable values for the
CPUs that are most commonly used in practice. (Values are sourced from LLVM.)
minFunctionAlignment() is something we can know ahead of time for any given
target because it's a matter of ABI. However, defaultFunctionAlignment() is a
matter of optimization and every backend can do it differently depending on any
number of factors. For example, LLVM will base the choice on the CPU model in
its aarch64 backend. So just don't use this value in the frontend.
…cified.

max(user_align, minFunctionAlignment()) is only appropriate when the user has
actually given an explicit, non-zero alignment value.
…he linker.

In particular, for user-specified alignment values, we need to do
max(user_align, minFunctionAlignment()) to respect the ABI minimum.
@alexrp alexrp force-pushed the function-alignment branch from b4cfd4b to 6c1e306 Compare October 20, 2024 07:27
@alexrp alexrp requested review from kubkon and mlugg October 20, 2024 07:27
@alexrp alexrp merged commit 03d0e29 into ziglang:master Oct 25, 2024
10 checks passed
@alexrp alexrp deleted the function-alignment branch October 26, 2024 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants