Skip to content

Commit fe059c1

Browse files
committed
Clif ir comment improvements
1 parent dfe7636 commit fe059c1

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
@@ -187,11 +187,10 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
187187
let func_ref = self.module.declare_func_in_func(func_id, &mut self.bcx.func);
188188
if self.clif_comments.enabled() {
189189
self.add_comment(func_ref, format!("{:?}", name));
190+
let inst = self.bcx.func.layout.last_inst(self.bcx.current_block().unwrap()).unwrap();
191+
self.add_comment(inst, format!("lib_call {}", name));
190192
}
191193
let call_inst = self.bcx.ins().call(func_ref, args);
192-
if self.clif_comments.enabled() {
193-
self.add_comment(call_inst, format!("lib_call {}", name));
194-
}
195194
let results = self.bcx.inst_results(call_inst);
196195
assert!(results.len() <= 2, "{}", results.len());
197196
results

src/base.rs

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

562-
fn codegen_stmt<'tcx>(
563-
fx: &mut FunctionCx<'_, '_, 'tcx>,
564-
#[allow(unused_variables)] cur_block: Block,
565-
stmt: &Statement<'tcx>,
566-
) {
562+
fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt: &Statement<'tcx>) {
567563
let _print_guard = crate::PrintOnPanic(|| format!("stmt {:?}", stmt));
568564

569565
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)