Skip to content

Commit a146874

Browse files
committed
Couple of clif ir printing improvements around abi handling
1 parent 0ba0845 commit a146874

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

src/abi/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,11 @@ pub(crate) fn codegen_terminator_call<'tcx>(
562562
adjust_call_for_c_variadic(fx, &fn_abi, source_info, func_ref, &mut call_args);
563563
}
564564

565+
if fx.clif_comments.enabled() {
566+
let nop_inst = fx.bcx.ins().nop();
567+
with_no_trimmed_paths!(fx.add_comment(nop_inst, format!("abi: {:?}", fn_abi)));
568+
}
569+
565570
match func_ref {
566571
CallTarget::Direct(func_ref) => fx.bcx.ins().call(func_ref, &call_args),
567572
CallTarget::Indirect(sig, func_ptr) => {

src/base.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ pub(crate) fn codegen_fn<'tcx>(
101101
let block_map: IndexVec<BasicBlock, Block> =
102102
(0..mir.basic_blocks.len()).map(|_| bcx.create_block()).collect();
103103

104+
let fn_abi = RevealAllLayoutCx(tcx).fn_abi_of_instance(instance, ty::List::empty());
105+
104106
// Make FunctionCx
105107
let target_config = module.target_config();
106108
let pointer_type = target_config.pointer_type();
107-
let clif_comments = crate::pretty_clif::CommentWriter::new(tcx, instance);
108-
109-
let fn_abi = RevealAllLayoutCx(tcx).fn_abi_of_instance(instance, ty::List::empty());
109+
let clif_comments = crate::pretty_clif::CommentWriter::new(tcx, instance, fn_abi);
110110

111111
let func_debug_cx = if let Some(debug_context) = &mut cx.debug_context {
112112
Some(debug_context.define_function(tcx, type_dbg, instance, fn_abi, &symbol_name, mir.span))

src/pretty_clif.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ use cranelift_codegen::entity::SecondaryMap;
6262
use cranelift_codegen::ir::Fact;
6363
use cranelift_codegen::ir::entities::AnyEntity;
6464
use cranelift_codegen::write::{FuncWriter, PlainWriter};
65-
use rustc_middle::ty::layout::FnAbiOf;
6665
use rustc_middle::ty::print::with_no_trimmed_paths;
6766
use rustc_session::config::{OutputFilenames, OutputType};
67+
use rustc_target::abi::call::FnAbi;
6868

6969
use crate::prelude::*;
7070

@@ -76,17 +76,18 @@ pub(crate) struct CommentWriter {
7676
}
7777

7878
impl CommentWriter {
79-
pub(crate) fn new<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> Self {
79+
pub(crate) fn new<'tcx>(
80+
tcx: TyCtxt<'tcx>,
81+
instance: Instance<'tcx>,
82+
fn_abi: &'tcx FnAbi<'tcx, Ty<'tcx>>,
83+
) -> Self {
8084
let enabled = should_write_ir(tcx);
8185
let global_comments = if enabled {
8286
with_no_trimmed_paths!({
8387
vec![
8488
format!("symbol {}", tcx.symbol_name(instance).name),
8589
format!("instance {:?}", instance),
86-
format!(
87-
"abi {:?}",
88-
RevealAllLayoutCx(tcx).fn_abi_of_instance(instance, ty::List::empty())
89-
),
90+
format!("abi {:?}", fn_abi),
9091
String::new(),
9192
]
9293
})

0 commit comments

Comments
 (0)