Disable inactive enum variant drop elaboration optimization #76081
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
In #74551, users of several tier 2 platforms have reported that the optimization in #68528 was causing a miscompilation. After that issue was filed, I double-checked my work and, as far as I can tell, that optimization is theoretically sound and implemented correctly. It's possible, however, that #68528 ends up triggering an LLVM or
rustc
codegen bug that results in invalid code on those platforms. It's also possible that the same codegen bug is lurking on tier 1 platforms, but does not present as a SEGFAULT.This PR disables the optimization in #68528. This should be useful for a perf run and so that affected users can apply this patch to build Firefox using the latest
rustc
. However, it's not clear whether we should actually merge it. I'm not sure what the policy should be for disabling optimizations that cause unrelated bugs (assuming I'm correct that #68528 is sound) on tier 2 platforms. Do we disable it for everyone? No one? Only affected platforms? All architectures besides x86?This PR is more complex than one might expect because there's a const-checking pass (#71824) that runs after drop elaboration and depends on the basic ideas of #68528 to allow certain functions (notably
Option::unwrap
) to beconst
. Now that drop elaboration no longer removes provably dead drop terminators in cases like these, I have to replicate some of the logic from drop elaboration in the const-checking module. If we decide to disable the optimization for all platforms, we could move these const checks back before drop elaboration to simplify the code somewhat. It was split up originally to avoid duplicating work.