Skip to content

trans: discrepancies between (MIR-based) collector and non-MIR translation. #34151

Closed
@michaelwoerister

Description

@michaelwoerister

The translation item collector in trans::collector is supposed to find all monomorphizations and instantiations of local and extern functions and drop-glue that need to go into the binary currently being compiled. It does so by analyzing the MIR of every function, following calls, references, drops, etc.
In theory this is a sound strategy.

However, in combination with legacy-trans, which is not based on MIR, we are running into problems: Since the MIR is heavily optimized before being passed into the collector, it might not contain references to what really is dead code. HIR-based trans, however, does not have this knowledge and will have to translate everything. This leads to situations where HIR-based trans will insert references to what only MIR-based analysis knows to be dead code. Thus we end up with "dangling references" and, subsequently, linker errors.

In order to still support HIR-based trans for the time being, there's some code in trans that will instantiate functions and drop-glue on demand if the collector "missed" it. This code should be removed once HIR-based trans has been removed from the compiler.
Specifically, this concerns trans::monomorphize::monomorphic_fn() and trans::glue::get_drop_glue_core().

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-incr-compArea: Incremental compilationC-cleanupCategory: PRs that clean code up or issues documenting cleanup.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions