MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / log_value_labels_ranges

Method log_value_labels_ranges

cranelift/codegen/src/machinst/vcode.rs:1307–1507  ·  view source on GitHub ↗
(&self, regalloc: &regalloc2::Output, inst_offsets: &[CodeOffset])

Source from the content-addressed store, hash-verified

1305 }
1306
1307 fn log_value_labels_ranges(&self, regalloc: &regalloc2::Output, inst_offsets: &[CodeOffset]) {
1308 debug_assert!(trace_log_enabled!());
1309
1310 // What debug labels do we have? Note we'll skip those that have not been
1311 // allocated any location at all. They will show up as numeric gaps in the table.
1312 let mut labels = vec![];
1313 for &(label, _, _, _) in &regalloc.debug_locations {
1314 if Some(&label) == labels.last() {
1315 continue;
1316 }
1317 labels.push(label);
1318 }
1319
1320 // Reformat the data on what VRegs were the VLs assigned to by lowering, since
1321 // the array we have is sorted by VReg, and we want it sorted by VL for easy
1322 // access in the loop below.
1323 let mut vregs = vec![];
1324 for &(vreg, start, end, label) in &self.debug_value_labels {
1325 if matches!(labels.binary_search(&label), Ok(_)) {
1326 vregs.push((label, start, end, vreg));
1327 }
1328 }
1329 vregs.sort_unstable_by(
1330 |(l_label, l_start, _, _), (r_label, r_start, _, _)| match l_label.cmp(r_label) {
1331 Ordering::Equal => l_start.cmp(r_start),
1332 cmp => cmp,
1333 },
1334 );
1335
1336 #[derive(PartialEq)]
1337 enum Mode {
1338 Measure,
1339 Emit,
1340 }
1341 #[derive(PartialEq)]
1342 enum Row {
1343 Head,
1344 Line,
1345 Inst(usize, usize),
1346 }
1347
1348 let mut widths = vec![0; 3 + 2 * labels.len()];
1349 let mut row = String::new();
1350 let mut output_row = |row_kind: Row, mode: Mode| {
1351 let mut column_index = 0;
1352 row.clear();
1353
1354 macro_rules! output_cell_impl {
1355 ($fill:literal, $span:literal, $($cell_fmt:tt)*) => {
1356 let column_start = row.len();
1357 {
1358 row.push('|');
1359 write!(row, $($cell_fmt)*).unwrap();
1360 }
1361
1362 let next_column_index = column_index + $span;
1363 let expected_width: usize = widths[column_index..next_column_index].iter().sum();
1364 if mode == Mode::Measure {

Callers 1

Calls 11

sort_unstable_byMethod · 0.80
binary_search_byMethod · 0.80
newFunction · 0.50
InstClass · 0.50
lastMethod · 0.45
pushMethod · 0.45
cmpMethod · 0.45
clearMethod · 0.45
getMethod · 0.45
indexMethod · 0.45
num_blocksMethod · 0.45

Tested by

no test coverage detected