-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
GVN makes some post-monomorphisation errors optimisation-dependent #156836
Copy link
Copy link
Open
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-mir-optArea: MIR optimizationsArea: MIR optimizationsA-mir-opt-GVNArea: MIR opt Global Value Numbering (GVN)Area: MIR opt Global Value Numbering (GVN)C-bugCategory: This is a bug.Category: This is a bug.I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}Issue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}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.regression-untriagedUntriaged performance or correctness regression.Untriaged performance or correctness regression.
Description
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, ...)A-mir-optArea: MIR optimizationsArea: MIR optimizationsA-mir-opt-GVNArea: MIR opt Global Value Numbering (GVN)Area: MIR opt Global Value Numbering (GVN)C-bugCategory: This is a bug.Category: This is a bug.I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}Issue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}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.regression-untriagedUntriaged performance or correctness regression.Untriaged performance or correctness regression.
Type
Fields
No fields configured for issues without a type.
Code
I tried this code (https://rust.godbolt.org/z/EdW33qf15):
I expected to see this happen: I expect the panic to be a post-monomorphisation error, i. e. compilation should succeed because
fis never monomorphised. This should be independent of the optimisation level.Instead, this happened: This errors with
-C opt-level=3, but not with-C opt-level=0.This seems to be caused by a change in the
GVNMIR opt between 1.74 and 1.75; the error can be reproduced by-Z mir-enable-passes=+GVNon 1.75 (but not 1.74).I originally noticed this with an inline
constblock, which shows the same change between 1.74 and 1.75 with GVN enabled (https://rust.godbolt.org/z/xxGTjjvYn):Version it worked on
It most recently worked on: Rust 1.76 (Rust 1.74 with
-Z mir-enable-passes=+GVN)Version with regression
It regressed in Rust 1.75 with
-Z mir-enable-passes=+GVN.GVN was enabled by default for 1.77 for
opt-level != 0:a03c972#diff-6202eda9e5f3c8b8a291cf165920ea8484c372002e485eafa920b319f7cb4dd3L112-R112
rustc --version --verbose:Backtrace
Backtrace