Skip to content

Try to hoist the conversion of diverging calls to aborts to a layer above MIR lowering #122956

Open
@saethlin

Description

In #122580 I added some code that prevents the magic compiler_builtins crate from linking against core. The replacement of calls happens as late as possible, so we end up with some odd behavior, where the LLVM IR and LLVM bitcode contain declarations of panic functions from core that are never called. We have those declarations because of this loop:

for &(mono_item, data) in &mono_items {
mono_item.predefine::<Builder<'_, '_, '_>>(&cx, data.linkage, data.visibility);
}

We have MonoItems for the panic functions, and no calls to them. The key point is that we have MonoItems for items that we know would be invalid to call.

Is it possible to not have those MonoItems in builds of compiler_builtins?

One possible implementation of this would be to hoist this "error or abort on upstream call" to a MIR transform that's only run when building compiler_builtins. Then maybe we could drop the logic from cg_ssa?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlE-help-wantedCall for participation: Help is requested to fix this issue.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