Skip to content

Commit 4644612

Browse files
committed
Auto merge of #42197 - arielb1:box-mir-beta, r=nikomatsakis
[beta] box large variants in MIR Beta backport of #41926. Operand: 72 -> 24 B Statement: 192 -> 96 B Terminator: 256 -> 112 B librustc translation memory usage: 1795 -> 1669 MB next step would be interning lvalues, I suppose?
2 parents 2df18ed + ea239f2 commit 4644612

File tree

24 files changed

+48
-44
lines changed

24 files changed

+48
-44
lines changed

Diff for: src/ci/docker/dist-i686-linux/build-openssl.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
set -ex
1313
source shared.sh
1414

15-
VERSION=1.0.2j
15+
VERSION=1.0.2k
16+
URL=https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/openssl-$VERSION.tar.gz
1617

17-
curl https://www.openssl.org/source/openssl-$VERSION.tar.gz | tar xzf -
18+
curl $URL | tar xzf -
1819

1920
cd openssl-$VERSION
2021
hide_output ./config --prefix=/rustroot shared -fPIC

Diff for: src/ci/docker/dist-x86_64-linux/build-openssl.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
set -ex
1313
source shared.sh
1414

15-
VERSION=1.0.2j
15+
VERSION=1.0.2k
16+
URL=https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/openssl-$VERSION.tar.gz
1617

17-
curl https://www.openssl.org/source/openssl-$VERSION.tar.gz | tar xzf -
18+
curl $URL | tar xzf -
1819

1920
cd openssl-$VERSION
2021
hide_output ./config --prefix=/rustroot shared -fPIC

Diff for: src/librustc/mir/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ pub enum StatementKind<'tcx> {
797797
StorageDead(Lvalue<'tcx>),
798798

799799
InlineAsm {
800-
asm: InlineAsm,
800+
asm: Box<InlineAsm>,
801801
outputs: Vec<Lvalue<'tcx>>,
802802
inputs: Vec<Operand<'tcx>>
803803
},
@@ -993,7 +993,7 @@ pub struct VisibilityScopeData {
993993
#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable)]
994994
pub enum Operand<'tcx> {
995995
Consume(Lvalue<'tcx>),
996-
Constant(Constant<'tcx>),
996+
Constant(Box<Constant<'tcx>>),
997997
}
998998

999999
impl<'tcx> Debug for Operand<'tcx> {
@@ -1013,7 +1013,7 @@ impl<'tcx> Operand<'tcx> {
10131013
substs: &'tcx Substs<'tcx>,
10141014
span: Span,
10151015
) -> Self {
1016-
Operand::Constant(Constant {
1016+
Operand::Constant(box Constant {
10171017
span: span,
10181018
ty: tcx.item_type(def_id).subst(tcx, substs),
10191019
literal: Literal::Value { value: ConstVal::Function(def_id, substs) },
@@ -1060,7 +1060,7 @@ pub enum Rvalue<'tcx> {
10601060
/// ..., y: ... }` from `dest.x = ...; dest.y = ...;` in the case
10611061
/// that `Foo` has a destructor. These rvalues can be optimized
10621062
/// away after type-checking and before lowering.
1063-
Aggregate(AggregateKind<'tcx>, Vec<Operand<'tcx>>),
1063+
Aggregate(Box<AggregateKind<'tcx>>, Vec<Operand<'tcx>>),
10641064
}
10651065

10661066
#[derive(Clone, Copy, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)]
@@ -1183,7 +1183,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
11831183
tuple_fmt.finish()
11841184
}
11851185

1186-
match *kind {
1186+
match **kind {
11871187
AggregateKind::Array(_) => write!(fmt, "{:?}", lvs),
11881188

11891189
AggregateKind::Tuple => {
@@ -1601,7 +1601,7 @@ impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> {
16011601
Discriminant(ref lval) => Discriminant(lval.fold_with(folder)),
16021602
Box(ty) => Box(ty.fold_with(folder)),
16031603
Aggregate(ref kind, ref fields) => {
1604-
let kind = match *kind {
1604+
let kind = box match **kind {
16051605
AggregateKind::Array(ty) => AggregateKind::Array(ty.fold_with(folder)),
16061606
AggregateKind::Tuple => AggregateKind::Tuple,
16071607
AggregateKind::Adt(def, v, substs, n) =>
@@ -1629,7 +1629,7 @@ impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> {
16291629
Discriminant(ref lval) => lval.visit_with(visitor),
16301630
Box(ty) => ty.visit_with(visitor),
16311631
Aggregate(ref kind, ref fields) => {
1632-
(match *kind {
1632+
(match **kind {
16331633
AggregateKind::Array(ty) => ty.visit_with(visitor),
16341634
AggregateKind::Tuple => false,
16351635
AggregateKind::Adt(_, _, substs, _) => substs.visit_with(visitor),

Diff for: src/librustc/mir/tcx.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl<'tcx> Rvalue<'tcx> {
183183
tcx.mk_box(t)
184184
}
185185
Rvalue::Aggregate(ref ak, ref ops) => {
186-
match *ak {
186+
match **ak {
187187
AggregateKind::Array(ty) => {
188188
tcx.mk_array(ty, ops.len())
189189
}

Diff for: src/librustc/mir/visit.rs

+1
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ macro_rules! make_mir_visitor {
515515

516516
Rvalue::Aggregate(ref $($mutability)* kind,
517517
ref $($mutability)* operands) => {
518+
let kind = &$($mutability)* **kind;
518519
match *kind {
519520
AggregateKind::Array(ref $($mutability)* ty) => {
520521
self.visit_ty(ty);

Diff for: src/librustc_borrowck/borrowck/mir/elaborate_drops.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -517,11 +517,11 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
517517
}
518518

519519
fn constant_bool(&self, span: Span, val: bool) -> Rvalue<'tcx> {
520-
Rvalue::Use(Operand::Constant(Constant {
520+
Rvalue::Use(Operand::Constant(Box::new(Constant {
521521
span: span,
522522
ty: self.tcx.types.bool,
523523
literal: Literal::Value { value: ConstVal::Bool(val) }
524-
}))
524+
})))
525525
}
526526

527527
fn set_drop_flag(&mut self, loc: Location, path: MovePathIndex, val: DropFlagState) {

Diff for: src/librustc_mir/build/cfg.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ impl<'tcx> CFG<'tcx> {
6060
temp: &Lvalue<'tcx>,
6161
constant: Constant<'tcx>) {
6262
self.push_assign(block, source_info, temp,
63-
Rvalue::Use(Operand::Constant(constant)));
63+
Rvalue::Use(Operand::Constant(box constant)));
6464
}
6565

6666
pub fn push_assign_unit(&mut self,
6767
block: BasicBlock,
6868
source_info: SourceInfo,
6969
lvalue: &Lvalue<'tcx>) {
7070
self.push_assign(block, source_info, lvalue, Rvalue::Aggregate(
71-
AggregateKind::Tuple, vec![]
71+
box AggregateKind::Tuple, vec![]
7272
));
7373
}
7474

Diff for: src/librustc_mir/build/expr/as_operand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
6666
match category {
6767
Category::Constant => {
6868
let constant = this.as_constant(expr);
69-
block.and(Operand::Constant(constant))
69+
block.and(Operand::Constant(box constant))
7070
}
7171
Category::Lvalue |
7272
Category::Rvalue(..) => {

Diff for: src/librustc_mir/build/expr/as_rvalue.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
166166
.map(|f| unpack!(block = this.as_operand(block, scope, f)))
167167
.collect();
168168

169-
block.and(Rvalue::Aggregate(AggregateKind::Array(el_ty), fields))
169+
block.and(Rvalue::Aggregate(box AggregateKind::Array(el_ty), fields))
170170
}
171171
ExprKind::Tuple { fields } => { // see (*) above
172172
// first process the set of fields
@@ -175,14 +175,14 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
175175
.map(|f| unpack!(block = this.as_operand(block, scope, f)))
176176
.collect();
177177

178-
block.and(Rvalue::Aggregate(AggregateKind::Tuple, fields))
178+
block.and(Rvalue::Aggregate(box AggregateKind::Tuple, fields))
179179
}
180180
ExprKind::Closure { closure_id, substs, upvars } => { // see (*) above
181181
let upvars =
182182
upvars.into_iter()
183183
.map(|upvar| unpack!(block = this.as_operand(block, scope, upvar)))
184184
.collect();
185-
block.and(Rvalue::Aggregate(AggregateKind::Closure(closure_id, substs), upvars))
185+
block.and(Rvalue::Aggregate(box AggregateKind::Closure(closure_id, substs), upvars))
186186
}
187187
ExprKind::Adt {
188188
adt_def, variant_index, substs, fields, base
@@ -215,7 +215,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
215215
field_names.iter().filter_map(|n| fields_map.get(n).cloned()).collect()
216216
};
217217

218-
let adt = AggregateKind::Adt(adt_def, variant_index, substs, active_field_index);
218+
let adt =
219+
box AggregateKind::Adt(adt_def, variant_index, substs, active_field_index);
219220
block.and(Rvalue::Aggregate(adt, fields))
220221
}
221222
ExprKind::Assign { .. } |

Diff for: src/librustc_mir/build/expr/stmt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
129129
this.cfg.push(block, Statement {
130130
source_info: source_info,
131131
kind: StatementKind::InlineAsm {
132-
asm: asm.clone(),
132+
asm: box asm.clone(),
133133
outputs: outputs,
134134
inputs: inputs
135135
},

Diff for: src/librustc_mir/build/matches/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
308308
let eq_block = self.cfg.start_new_block();
309309
let cleanup = self.diverge_cleanup();
310310
self.cfg.terminate(block, source_info, TerminatorKind::Call {
311-
func: Operand::Constant(Constant {
311+
func: Operand::Constant(box Constant {
312312
span: test.span,
313313
ty: mty,
314314
literal: method

Diff for: src/librustc_mir/build/misc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
4040
ty: Ty<'tcx>,
4141
literal: Literal<'tcx>)
4242
-> Operand<'tcx> {
43-
let constant = Constant {
43+
let constant = box Constant {
4444
span: span,
4545
ty: ty,
4646
literal: literal,
@@ -49,7 +49,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
4949
}
5050

5151
pub fn unit_rvalue(&mut self) -> Rvalue<'tcx> {
52-
Rvalue::Aggregate(AggregateKind::Tuple, vec![])
52+
Rvalue::Aggregate(box AggregateKind::Tuple, vec![])
5353
}
5454

5555
// Returns a zero literal operand for the appropriate type, works for

Diff for: src/librustc_mir/build/scope.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ fn build_free<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
782782
let free_func = tcx.require_lang_item(lang_items::BoxFreeFnLangItem);
783783
let substs = tcx.intern_substs(&[Kind::from(data.item_ty)]);
784784
TerminatorKind::Call {
785-
func: Operand::Constant(Constant {
785+
func: Operand::Constant(box Constant {
786786
span: data.span,
787787
ty: tcx.item_type(free_func).subst(tcx, substs),
788788
literal: Literal::Value {

Diff for: src/librustc_mir/shim.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ fn build_call_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
330330
let (callee, mut args) = match call_kind {
331331
CallKind::Indirect => (rcvr, vec![]),
332332
CallKind::Direct(def_id) => (
333-
Operand::Constant(Constant {
333+
Operand::Constant(box Constant {
334334
span: span,
335335
ty: tcx.item_type(def_id).subst(tcx, param_env.free_substs),
336336
literal: Literal::Value {
@@ -456,7 +456,7 @@ pub fn build_adt_ctor<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a, 'gcx, 'tcx>,
456456
kind: StatementKind::Assign(
457457
Lvalue::Local(RETURN_POINTER),
458458
Rvalue::Aggregate(
459-
AggregateKind::Adt(adt_def, variant_no, substs, None),
459+
box AggregateKind::Adt(adt_def, variant_no, substs, None),
460460
(1..sig.inputs().len()+1).map(|i| {
461461
Operand::Consume(Lvalue::Local(Local::new(i)))
462462
}).collect()

Diff for: src/librustc_mir/transform/copy_prop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ impl<'tcx> MutVisitor<'tcx> for ConstantPropagationVisitor<'tcx> {
318318
_ => return,
319319
}
320320

321-
*operand = Operand::Constant(self.constant.clone());
321+
*operand = Operand::Constant(box self.constant.clone());
322322
self.uses_replaced += 1
323323
}
324324
}

Diff for: src/librustc_mir/transform/deaggregator.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ impl<'tcx> MirPass<'tcx> for Deaggregator {
4949
&Rvalue::Aggregate(ref agg_kind, ref operands) => (agg_kind, operands),
5050
_ => span_bug!(src_info.span, "expected aggregate, not {:?}", rhs),
5151
};
52-
let (adt_def, variant, substs) = match agg_kind {
53-
&AggregateKind::Adt(adt_def, variant, substs, None)
52+
let (adt_def, variant, substs) = match **agg_kind {
53+
AggregateKind::Adt(adt_def, variant, substs, None)
5454
=> (adt_def, variant, substs),
5555
_ => span_bug!(src_info.span, "expected struct, not {:?}", rhs),
5656
};
@@ -114,8 +114,8 @@ fn get_aggregate_statement_index<'a, 'tcx, 'b>(start: usize,
114114
&Rvalue::Aggregate(ref kind, ref operands) => (kind, operands),
115115
_ => continue,
116116
};
117-
let (adt_def, variant) = match kind {
118-
&AggregateKind::Adt(adt_def, variant, _, None) => (adt_def, variant),
117+
let (adt_def, variant) = match **kind {
118+
AggregateKind::Adt(adt_def, variant, _, None) => (adt_def, variant),
119119
_ => continue,
120120
};
121121
if operands.len() == 0 {

Diff for: src/librustc_mir/transform/promote_consts.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
230230
(if self.keep_original {
231231
rhs.clone()
232232
} else {
233-
let unit = Rvalue::Aggregate(AggregateKind::Tuple, vec![]);
233+
let unit = Rvalue::Aggregate(box AggregateKind::Tuple, vec![]);
234234
mem::replace(rhs, unit)
235235
}, statement.source_info)
236236
};
@@ -288,7 +288,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
288288

289289
fn promote_candidate(mut self, candidate: Candidate) {
290290
let span = self.promoted.span;
291-
let new_operand = Operand::Constant(Constant {
291+
let new_operand = Operand::Constant(box Constant {
292292
span: span,
293293
ty: self.promoted.return_ty,
294294
literal: Literal::Promoted {

Diff for: src/librustc_mir/transform/qualify_consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
733733
}
734734

735735
Rvalue::Aggregate(ref kind, _) => {
736-
if let AggregateKind::Adt(def, ..) = *kind {
736+
if let AggregateKind::Adt(def, ..) = **kind {
737737
if def.has_dtor(self.tcx) {
738738
self.add(Qualif::NEEDS_DROP);
739739
self.deny_drop();

Diff for: src/librustc_mir/transform/simplify_branches.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl<'l, 'tcx> MirPass<'tcx> for SimplifyBranches<'l> {
3030
for block in mir.basic_blocks_mut() {
3131
let terminator = block.terminator_mut();
3232
terminator.kind = match terminator.kind {
33-
TerminatorKind::SwitchInt { discr: Operand::Constant(Constant {
33+
TerminatorKind::SwitchInt { discr: Operand::Constant(box Constant {
3434
literal: Literal::Value { ref value }, ..
3535
}), ref values, ref targets, .. } => {
3636
if let Some(ref constint) = value.to_const_int() {
@@ -47,7 +47,7 @@ impl<'l, 'tcx> MirPass<'tcx> for SimplifyBranches<'l> {
4747
continue
4848
}
4949
},
50-
TerminatorKind::Assert { target, cond: Operand::Constant(Constant {
50+
TerminatorKind::Assert { target, cond: Operand::Constant(box Constant {
5151
literal: Literal::Value {
5252
value: ConstVal::Bool(cond)
5353
}, ..
@@ -67,4 +67,4 @@ impl<'l> Pass for SimplifyBranches<'l> {
6767

6868
// avoid calling `type_name` - it contains `<'static>`
6969
fn name(&self) -> ::std::borrow::Cow<'static, str> { "SimplifyBranches".into() }
70-
}
70+
}

Diff for: src/librustc_mir/transform/type_check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
534534

535535
fn is_box_free(&self, operand: &Operand<'tcx>) -> bool {
536536
match operand {
537-
&Operand::Constant(Constant {
537+
&Operand::Constant(box Constant {
538538
literal: Literal::Value {
539539
value: ConstVal::Function(def_id, _), ..
540540
}, ..

Diff for: src/librustc_passes/mir_stats.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl<'a, 'tcx> mir_visit::Visitor<'tcx> for StatCollector<'a, 'tcx> {
190190
Rvalue::Aggregate(ref kind, ref _operands) => {
191191
// AggregateKind is not distinguished by visit API, so
192192
// record it. (`super_rvalue` handles `_operands`.)
193-
self.record(match *kind {
193+
self.record(match **kind {
194194
AggregateKind::Array(_) => "AggregateKind::Array",
195195
AggregateKind::Tuple => "AggregateKind::Tuple",
196196
AggregateKind::Adt(..) => "AggregateKind::Adt",

Diff for: src/librustc_trans/mir/analyze.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl<'mir, 'a, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'tcx> {
108108
location: Location) {
109109
match *kind {
110110
mir::TerminatorKind::Call {
111-
func: mir::Operand::Constant(mir::Constant {
111+
func: mir::Operand::Constant(box mir::Constant {
112112
literal: Literal::Value {
113113
value: ConstVal::Function(def_id, _), ..
114114
}, ..

Diff for: src/librustc_trans/mir/constant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> {
537537
}
538538
failure?;
539539

540-
match *kind {
540+
match **kind {
541541
mir::AggregateKind::Array(_) => {
542542
self.const_array(dest_ty, &fields)
543543
}

Diff for: src/librustc_trans/mir/rvalue.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
104104
}
105105

106106
mir::Rvalue::Aggregate(ref kind, ref operands) => {
107-
match *kind {
107+
match **kind {
108108
mir::AggregateKind::Adt(adt_def, variant_index, substs, active_field_index) => {
109109
let discr = adt_def.discriminant_for_variant(bcx.tcx(), variant_index)
110110
.to_u128_unchecked() as u64;

0 commit comments

Comments
 (0)