Try to hoist the conversion of diverging calls to aborts to a layer above MIR lowering #122956
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:
rust/compiler/rustc_codegen_llvm/src/base.rs
Lines 87 to 89 in d6eb0f5
We have MonoItem
s for the panic functions, and no calls to them. The key point is that we have MonoItem
s for items that we know would be invalid to call.
Is it possible to not have those MonoItem
s 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