Handle calls to upstream monomorphizations in compiler_builtins

This commit is contained in:
Ben Kimock 2024-03-15 14:13:11 -04:00
parent 1ca424ca43
commit 5f4f2526b8
12 changed files with 95 additions and 9 deletions

View file

@ -8,6 +8,7 @@ use rustc_index::IndexVec;
use rustc_middle::ty::adjustment::PointerCoercion;
use rustc_middle::ty::layout::FnAbiOf;
use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_monomorphize::is_call_from_compiler_builtins_to_upstream_monomorphization;
use crate::constant::ConstantCx;
use crate::debuginfo::FunctionDebugContext;
@ -999,6 +1000,12 @@ fn codegen_panic_inner<'tcx>(
let def_id = fx.tcx.require_lang_item(lang_item, span);
let instance = Instance::mono(fx.tcx, def_id).polymorphize(fx.tcx);
if is_call_from_compiler_builtins_to_upstream_monomorphization(fx.tcx, instance) {
fx.bcx.ins().trap(TrapCode::User(0));
return;
}
let symbol_name = fx.tcx.symbol_name(instance).name;
fx.lib_call(