Use record_operands_moved
more aggresively
This commit is contained in:
parent
b766abc88f
commit
7f3e8551dd
13 changed files with 128 additions and 241 deletions
|
@ -11,6 +11,8 @@ use rustc_middle::mir::*;
|
|||
use rustc_middle::ty::{self, Ty, UpvarSubsts};
|
||||
use rustc_span::Span;
|
||||
|
||||
use std::slice;
|
||||
|
||||
impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
/// Returns an rvalue suitable for use until the end of the current
|
||||
/// scope expression.
|
||||
|
@ -117,7 +119,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
block =
|
||||
this.into(this.hir.tcx().mk_place_deref(Place::from(result)), block, value)
|
||||
);
|
||||
block.and(Rvalue::Use(Operand::Move(Place::from(result))))
|
||||
let result_operand = Operand::Move(Place::from(result));
|
||||
this.record_operands_moved(slice::from_ref(&result_operand));
|
||||
block.and(Rvalue::Use(result_operand))
|
||||
}
|
||||
ExprKind::Cast { source } => {
|
||||
let source = unpack!(block = this.as_operand(block, scope, source));
|
||||
|
@ -161,6 +165,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
.map(|f| unpack!(block = this.as_operand(block, scope, f)))
|
||||
.collect();
|
||||
|
||||
this.record_operands_moved(&fields);
|
||||
block.and(Rvalue::Aggregate(box AggregateKind::Array(el_ty), fields))
|
||||
}
|
||||
ExprKind::Tuple { fields } => {
|
||||
|
@ -171,6 +176,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
.map(|f| unpack!(block = this.as_operand(block, scope, f)))
|
||||
.collect();
|
||||
|
||||
this.record_operands_moved(&fields);
|
||||
block.and(Rvalue::Aggregate(box AggregateKind::Tuple, fields))
|
||||
}
|
||||
ExprKind::Closure { closure_id, substs, upvars, movability } => {
|
||||
|
@ -222,6 +228,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
UpvarSubsts::Closure(substs) => box AggregateKind::Closure(closure_id, substs),
|
||||
};
|
||||
this.record_operands_moved(&operands);
|
||||
block.and(Rvalue::Aggregate(result, operands))
|
||||
}
|
||||
ExprKind::Assign { .. } | ExprKind::AssignOp { .. } => {
|
||||
|
|
|
@ -10,9 +10,10 @@ use rustc_hir as hir;
|
|||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::{self, CanonicalUserTypeAnnotation};
|
||||
use rustc_span::symbol::sym;
|
||||
|
||||
use rustc_target::spec::abi::Abi;
|
||||
|
||||
use std::slice;
|
||||
|
||||
impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
/// Compile `expr`, storing the result into `destination`, which
|
||||
/// is assumed to be uninitialized.
|
||||
|
@ -271,7 +272,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
|
||||
let field_names = this.hir.all_fields(adt_def, variant_index);
|
||||
|
||||
let fields = if let Some(FruInfo { base, field_types }) = base {
|
||||
let fields: Vec<_> = if let Some(FruInfo { base, field_types }) = base {
|
||||
let base = unpack!(block = this.as_place(block, base));
|
||||
|
||||
// MIR does not natively support FRU, so for each
|
||||
|
@ -306,6 +307,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
user_ty,
|
||||
active_field_index,
|
||||
);
|
||||
this.record_operands_moved(&fields);
|
||||
this.cfg.push_assign(
|
||||
block,
|
||||
source_info,
|
||||
|
@ -432,6 +434,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
let scope = this.local_scope();
|
||||
let value = unpack!(block = this.as_operand(block, scope, value));
|
||||
let resume = this.cfg.start_new_block();
|
||||
this.record_operands_moved(slice::from_ref(&value));
|
||||
this.cfg.terminate(
|
||||
block,
|
||||
source_info,
|
||||
|
|
|
@ -3,6 +3,7 @@ use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
|
|||
use crate::thir::*;
|
||||
use rustc_middle::middle::region;
|
||||
use rustc_middle::mir::*;
|
||||
use std::slice;
|
||||
|
||||
impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
/// Builds a block of MIR statements to evaluate the THIR `expr`.
|
||||
|
@ -46,6 +47,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
if this.hir.needs_drop(lhs.ty) {
|
||||
let rhs = unpack!(block = this.as_local_operand(block, rhs));
|
||||
let lhs = unpack!(block = this.as_place(block, lhs));
|
||||
this.record_operands_moved(slice::from_ref(&rhs));
|
||||
unpack!(block = this.build_drop_and_replace(block, lhs_span, lhs, rhs));
|
||||
} else {
|
||||
let rhs = unpack!(block = this.as_local_rvalue(block, rhs));
|
||||
|
|
|
@ -83,7 +83,7 @@ that contains only loops and breakable blocks. It tracks where a `break`,
|
|||
|
||||
use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder, CFG};
|
||||
use crate::thir::{Expr, ExprRef, LintLevel};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_hir as hir;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_middle::middle::region;
|
||||
|
@ -1379,7 +1379,7 @@ impl<'tcx> DropTreeBuilder<'tcx> for Unwind {
|
|||
| TerminatorKind::Yield { .. }
|
||||
| TerminatorKind::GeneratorDrop
|
||||
| TerminatorKind::FalseEdge { .. }
|
||||
| TerminatorKind::InlineAsm {.. } => {
|
||||
| TerminatorKind::InlineAsm { .. } => {
|
||||
span_bug!(term.source_info.span, "cannot unwind from {:?}", term.kind)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue