Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 51cb2bc

Browse files
committed
Add a workaround for the TailDuplicator compile time overhead
1 parent 34f2672 commit 51cb2bc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

compiler/rustc_mir_transform/src/uninhabited_enum_branching.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,13 @@ impl<'tcx> MirPass<'tcx> for UninhabitedEnumBranching {
130130
let mut targets = targets.clone();
131131
if replace_otherwise_to_unreachable {
132132
let otherwise_is_last_variant = !allowed_variants.is_empty();
133-
if otherwise_is_last_variant {
133+
// After resolving https://github.com/llvm/llvm-project/issues/78578, we can remove the limit on the number of successors.
134+
if otherwise_is_last_variant
135+
&& !body.basic_blocks[targets.otherwise()]
136+
.terminator()
137+
.successors()
138+
.any(|bb| body.basic_blocks[bb].terminator().successors().count() >= 8)
139+
{
134140
#[allow(rustc::potential_query_instability)]
135141
let last_variant = *allowed_variants.iter().next().unwrap();
136142
targets.add_target(last_variant, targets.otherwise());

0 commit comments

Comments
 (0)