|
| 1 | +use std::ops::Deref; |
| 2 | + |
1 | 3 | use rustc_middle::mir::{self, NonDivergingIntrinsic};
|
2 |
| -use rustc_middle::span_bug; |
| 4 | +use rustc_middle::ty::layout::HasTyCtxt; |
| 5 | +use rustc_middle::ty::{Ty, TyCtxt}; |
| 6 | +use rustc_middle::{bug, span_bug}; |
3 | 7 | use tracing::instrument;
|
4 | 8 |
|
5 | 9 | use super::{FunctionCx, LocalRef};
|
| 10 | +use crate::mir::operand::{OperandRef, OperandValue}; |
| 11 | +use crate::mir::place::PlaceRef; |
6 | 12 | use crate::traits::*;
|
7 | 13 |
|
8 | 14 | impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
@@ -94,8 +100,65 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
94 | 100 | | mir::StatementKind::PlaceMention(..)
|
95 | 101 | | mir::StatementKind::BackwardIncompatibleDropHint { .. } => {}
|
96 | 102 | mir::StatementKind::Nop(ref stmt) => {
|
97 |
| - if stmt.is_some() { |
98 |
| - todo!("add debugging information") |
| 103 | + if let Some(box stmt_kind) = stmt { |
| 104 | + match stmt_kind { |
| 105 | + mir::StatementKind::Assign(box (dest, rvalue)) => { |
| 106 | + if let Some(index) = dest.as_local() |
| 107 | + && let mir::Rvalue::Ref(_, _, place) = *rvalue |
| 108 | + { |
| 109 | + let place_ref = match self.locals[place.local] { |
| 110 | + LocalRef::Place(place_ref) |
| 111 | + | LocalRef::UnsizedPlace(place_ref) => Some(place_ref), |
| 112 | + LocalRef::Operand(operand_ref) => match operand_ref.val { |
| 113 | + OperandValue::Ref(_place_value) => { |
| 114 | + todo!("OperandValue::Ref") |
| 115 | + } |
| 116 | + OperandValue::Immediate(v) => { |
| 117 | + Some(PlaceRef::new_sized(v, operand_ref.layout)) |
| 118 | + } |
| 119 | + OperandValue::Pair(_, _) => None, |
| 120 | + OperandValue::ZeroSized => None, |
| 121 | + }, |
| 122 | + LocalRef::PendingOperand => None, |
| 123 | + }; |
| 124 | + let (val, layout, projection) = |
| 125 | + match (place_ref, place.is_indirect_first_projection()) { |
| 126 | + (Some(place_ref), false) => ( |
| 127 | + place_ref.val, |
| 128 | + place_ref.layout, |
| 129 | + place.projection.as_slice(), |
| 130 | + ), |
| 131 | + (Some(place_ref), true) => { |
| 132 | + let projected_ty = place_ref |
| 133 | + .layout |
| 134 | + .ty |
| 135 | + .builtin_deref(true) |
| 136 | + .unwrap_or_else(|| { |
| 137 | + bug!("deref of non-pointer {:?}", place_ref) |
| 138 | + }); |
| 139 | + let layout = bx.cx().layout_of(projected_ty); |
| 140 | + (place_ref.val, layout, &place.projection[1..]) |
| 141 | + } |
| 142 | + _ => { |
| 143 | + let ty = |
| 144 | + self.monomorphize(self.mir.local_decls[index].ty); |
| 145 | + let layout = bx.cx().layout_of(ty); |
| 146 | + let to_backend_ty = |
| 147 | + bx.cx().immediate_backend_type(layout); |
| 148 | + let place_ref = PlaceRef::new_sized( |
| 149 | + bx.cx().const_poison(to_backend_ty), |
| 150 | + layout, |
| 151 | + ); |
| 152 | + (place_ref.val, layout, [].as_slice()) |
| 153 | + } |
| 154 | + }; |
| 155 | + self.debug_new_value_to_local(bx, index, val, layout, projection); |
| 156 | + } else { |
| 157 | + todo!("add debugging information") |
| 158 | + } |
| 159 | + } |
| 160 | + _ => {} |
| 161 | + } |
99 | 162 | }
|
100 | 163 | }
|
101 | 164 | }
|
|
0 commit comments