-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
size_of_val(p) == 0 doesn't optimize out for clearly-not-ZST values #152788
Copy link
Copy link
Open
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-codegenArea: Code generationArea: Code generationC-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchCategory: An issue highlighting optimization opportunities or PRs implementing suchT-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.
Metadata
Metadata
Assignees
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-codegenArea: Code generationArea: Code generationC-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchCategory: An issue highlighting optimization opportunities or PRs implementing suchT-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.
Type
Fields
Give feedbackNo fields configured for issues without a type.
The following rust
currently https://rust.godbolt.org/z/r1d5n6Phe optimizes to
but clearly that type has to be at least 12 bytes no matter what.
Why does that matter? Well, whenever you drop a
Boxit needs to check for ZSTs before calling the allocator. So that check should optimize out in these cases, but it doesn't today.Filed here because we're probably not telling LLVM enough to be able to do that itself. #152786 will give it a bit more information, but probably not enough to solve this.
For some DSTs it does optimize, notably
optimizes to
false.However, this one
doesn't today https://rust.godbolt.org/z/nnhGKz767
(That last one might get fixed with #152786, though, because the icmp can only be true if it wraps, which definitely can't happen.)