Add a debug value label to a register.
(&mut self, reg: Reg, label: ValueLabel)
| 375 | |
| 376 | /// Add a debug value label to a register. |
| 377 | pub fn add_value_label(&mut self, reg: Reg, label: ValueLabel) { |
| 378 | // 1) In the reversed order, we consider the instructions |
| 379 | // that define ranges in the "debug_info" array to refer |
| 380 | // to the IP **after** them (when reversed): |
| 381 | // IP[2]__| Inst 3 | |
| 382 | // IP[1]__| Inst 2 | |
| 383 | // IP[0]__| Inst 1 | |
| 384 | // | Inst 0 | |
| 385 | // This is so that we can represent IP[<function start>], |
| 386 | // done at the cost of not being to represent IP[<function end>], |
| 387 | // which is OK since no values will be live at that point. |
| 388 | // 2) The live range for "reg" begins at the current IP |
| 389 | // and continues until the next, in execution order, |
| 390 | // VReg that defines "label". Since the ranges are open |
| 391 | // at the end, the subtraction of 1 cancels out: |
| 392 | // [last..current IP] <=> |
| 393 | // [last..last emitted inst index] <=> |
| 394 | // [last..next_inst_index - 1] <=> |
| 395 | // [last..next_inst_index) |
| 396 | // |
| 397 | let next_inst_index = self.vcode.insts.len(); |
| 398 | if next_inst_index == 0 { |
| 399 | // This would produce a defective [0..0) range. |
| 400 | return; |
| 401 | } |
| 402 | let next_inst = InsnIndex::new(next_inst_index); |
| 403 | let labels = self.debug_info.entry(label).or_insert_with(|| vec![]); |
| 404 | let last = labels |
| 405 | .last() |
| 406 | .map(|(_start, end, _vreg)| *end) |
| 407 | .unwrap_or(InsnIndex::new(0)); |
| 408 | labels.push((last, next_inst, reg.into())); |
| 409 | } |
| 410 | |
| 411 | /// Access the constants. |
| 412 | pub fn constants(&mut self) -> &mut VCodeConstants { |
no test coverage detected