Skip to content

Drop elaboration emits O(N^2) cleanup for partially-initialized aggregate literals #157463

Description

@ashi009

An aggregate literal of N droppable elements whose initializers can diverge could emit O(N^2) drop terminators. Which chokes LLVM's CVP pass and cost substantial time in optimized build.

For example, the following code will take over 60s to build with -O:

pub fn build(s: u64) -> Result<Big, ()> {
    Ok(Big { f0: make_one(s ^ 0)?, /* … N fields … */ f127: make_one(s ^ 127)? })
}

See https://github.com/ashi009/cvp-llvm-repro for a runnable example.

Reproducible on 1.96.0 stable (LLVM 22.1.2) and 1.98.0-nightly e7815e5 (LLVM 22.1.6).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-codegenArea: Code generationA-mir-optArea: MIR optimizationsC-bugCategory: This is a bug.I-compiletimeIssue: Problems and improvements with respect to compile times.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions