Skip to content

Commit 07e6b5b

Browse files
committed
Clif ir comment improvements
1 parent 650835c commit 07e6b5b

File tree

3 files changed

+5
-14
lines changed

3 files changed

+5
-14
lines changed

src/abi/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,10 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
203203
let func_ref = self.module.declare_func_in_func(func_id, &mut self.bcx.func);
204204
if self.clif_comments.enabled() {
205205
self.add_comment(func_ref, format!("{:?}", name));
206+
let inst = self.bcx.func.layout.last_inst(self.bcx.current_block().unwrap()).unwrap();
207+
self.add_comment(inst, format!("lib_call {}", name));
206208
}
207209
let call_inst = self.bcx.ins().call(func_ref, args);
208-
if self.clif_comments.enabled() {
209-
self.add_comment(call_inst, format!("lib_call {}", name));
210-
}
211210
let results = self.bcx.inst_results(call_inst);
212211
assert!(results.len() <= 2, "{}", results.len());
213212
results

src/base.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -565,11 +565,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
565565
}
566566
}
567567

568-
fn codegen_stmt<'tcx>(
569-
fx: &mut FunctionCx<'_, '_, 'tcx>,
570-
#[allow(unused_variables)] cur_block: Block,
571-
stmt: &Statement<'tcx>,
572-
) {
568+
fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt: &Statement<'tcx>) {
573569
let _print_guard = crate::PrintOnPanic(|| format!("stmt {:?}", stmt));
574570

575571
fx.set_debug_loc(stmt.source_info);

src/value_and_place.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -592,13 +592,9 @@ impl<'tcx> CPlace<'tcx> {
592592
assert_eq!(self.layout().size, from.layout().size);
593593

594594
if fx.clif_comments.enabled() {
595-
use cranelift_codegen::cursor::{Cursor, CursorPosition};
596-
let cur_block = match fx.bcx.cursor().position() {
597-
CursorPosition::After(block) => block,
598-
_ => unreachable!(),
599-
};
595+
let inst = fx.bcx.func.layout.last_inst(fx.bcx.current_block().unwrap()).unwrap();
600596
fx.add_comment(
601-
fx.bcx.func.layout.last_inst(cur_block).unwrap(),
597+
inst,
602598
format!(
603599
"{}: {:?}: {:?} <- {:?}: {:?}",
604600
method,

0 commit comments

Comments
 (0)