-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Const eval does alignment checks #61952
Copy link
Copy link
Closed
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
The const eval engine takes quite a few steps to ensure that it bails out of evaluation if any steps would cause unaligned reads. E.g.
will fail to compile with
The question is, do we need to be this restrictive during const eval. The checks are everywhere, so we may even see perf gains from removing them, but the main gain would be that we can remove the additional code that just exists to ensure we fiddle the right alignment through the pattern-matching-on-constants logic (
ConstValue::ByRef'sAlignfield is unused for anything else).I think there's little use in keeping this restriction in const eval, since it only exists in miri because some hardware platforms actually do UB on unaligned reads, while other platforms are simply slower on unaligned reads.
cc @RalfJung