Move some things from codegen_mono_item to trans_fn
This commit is contained in:
parent
db8fa0edfa
commit
4e547b942d
2 changed files with 8 additions and 9 deletions
|
@ -12,6 +12,10 @@ pub(crate) fn codegen_fn<'tcx>(
|
||||||
) {
|
) {
|
||||||
let tcx = cx.tcx;
|
let tcx = cx.tcx;
|
||||||
|
|
||||||
|
let _inst_guard =
|
||||||
|
crate::PrintOnPanic(|| format!("{:?} {}", instance, tcx.symbol_name(instance).name));
|
||||||
|
debug_assert!(!instance.substs.needs_infer());
|
||||||
|
|
||||||
let mir = tcx.instance_mir(instance.def);
|
let mir = tcx.instance_mir(instance.def);
|
||||||
|
|
||||||
// Declare function
|
// Declare function
|
||||||
|
|
|
@ -68,20 +68,15 @@ fn codegen_mono_item<'tcx, M: Module>(
|
||||||
mono_item: MonoItem<'tcx>,
|
mono_item: MonoItem<'tcx>,
|
||||||
linkage: Linkage,
|
linkage: Linkage,
|
||||||
) {
|
) {
|
||||||
let tcx = cx.tcx;
|
|
||||||
match mono_item {
|
match mono_item {
|
||||||
MonoItem::Fn(inst) => {
|
MonoItem::Fn(inst) => {
|
||||||
let _inst_guard =
|
cx.tcx
|
||||||
crate::PrintOnPanic(|| format!("{:?} {}", inst, tcx.symbol_name(inst).name));
|
.sess
|
||||||
debug_assert!(!inst.substs.needs_infer());
|
|
||||||
tcx.sess
|
|
||||||
.time("codegen fn", || crate::base::codegen_fn(cx, inst, linkage));
|
.time("codegen fn", || crate::base::codegen_fn(cx, inst, linkage));
|
||||||
}
|
}
|
||||||
MonoItem::Static(def_id) => {
|
MonoItem::Static(def_id) => crate::constant::codegen_static(&mut cx.constants_cx, def_id),
|
||||||
crate::constant::codegen_static(&mut cx.constants_cx, def_id);
|
|
||||||
}
|
|
||||||
MonoItem::GlobalAsm(hir_id) => {
|
MonoItem::GlobalAsm(hir_id) => {
|
||||||
let item = tcx.hir().expect_item(hir_id);
|
let item = cx.tcx.hir().expect_item(hir_id);
|
||||||
if let rustc_hir::ItemKind::GlobalAsm(rustc_hir::GlobalAsm { asm }) = item.kind {
|
if let rustc_hir::ItemKind::GlobalAsm(rustc_hir::GlobalAsm { asm }) = item.kind {
|
||||||
cx.global_asm.push_str(&*asm.as_str());
|
cx.global_asm.push_str(&*asm.as_str());
|
||||||
cx.global_asm.push_str("\n\n");
|
cx.global_asm.push_str("\n\n");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue