Skip to content

Commit e221b24

Browse files
committed
Shrink StatementKind::InlineAsm.
This shrinks StatementKind from 64 bytes to 48 bytes on 64-bit.
1 parent a577f90 commit e221b24

File tree

6 files changed

+21
-9
lines changed

6 files changed

+21
-9
lines changed

src/librustc/mir/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1633,8 +1633,8 @@ pub enum StatementKind<'tcx> {
16331633
/// Execute a piece of inline Assembly.
16341634
InlineAsm {
16351635
asm: Box<InlineAsm>,
1636-
outputs: Vec<Place<'tcx>>,
1637-
inputs: Vec<Operand<'tcx>>,
1636+
outputs: Box<[Place<'tcx>]>,
1637+
inputs: Box<[Operand<'tcx>]>,
16381638
},
16391639

16401640
/// Assert the given places to be valid inhabitants of their type. These statements are

src/librustc/ty/structural_impls.rs

+10
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,16 @@ impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Vec<T> {
720720
}
721721
}
722722

723+
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Box<[T]> {
724+
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
725+
self.iter().map(|t| t.fold_with(folder)).collect::<Vec<_>>().into_boxed_slice()
726+
}
727+
728+
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
729+
self.iter().any(|t| t.visit_with(visitor))
730+
}
731+
}
732+
723733
impl<'tcx, T:TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<T> {
724734
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
725735
self.map_bound_ref(|ty| ty.fold_with(folder))

src/librustc_mir/borrow_check/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ impl<'cx, 'gcx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx
528528
ref inputs,
529529
} => {
530530
let context = ContextKind::InlineAsm.new(location);
531-
for (o, output) in asm.outputs.iter().zip(outputs) {
531+
for (o, output) in asm.outputs.iter().zip(outputs.iter()) {
532532
if o.is_indirect {
533533
// FIXME(eddyb) indirect inline asm outputs should
534534
// be encoeded through MIR place derefs instead.
@@ -555,7 +555,7 @@ impl<'cx, 'gcx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx
555555
);
556556
}
557557
}
558-
for input in inputs {
558+
for input in inputs.iter() {
559559
self.consume_operand(context, (input, span), flow_state);
560560
}
561561
}

src/librustc_mir/borrow_check/nll/invalidation.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl<'cg, 'cx, 'tcx, 'gcx> Visitor<'tcx> for InvalidationGenerator<'cg, 'cx, 'tc
118118
ref inputs,
119119
} => {
120120
let context = ContextKind::InlineAsm.new(location);
121-
for (o, output) in asm.outputs.iter().zip(outputs) {
121+
for (o, output) in asm.outputs.iter().zip(outputs.iter()) {
122122
if o.is_indirect {
123123
// FIXME(eddyb) indirect inline asm outputs should
124124
// be encoeded through MIR place derefs instead.
@@ -137,7 +137,7 @@ impl<'cg, 'cx, 'tcx, 'gcx> Visitor<'tcx> for InvalidationGenerator<'cg, 'cx, 'tc
137137
);
138138
}
139139
}
140-
for input in inputs {
140+
for input in inputs.iter() {
141141
self.consume_operand(context, input);
142142
}
143143
}

src/librustc_mir/build/expr/stmt.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,13 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
143143
let outputs = outputs
144144
.into_iter()
145145
.map(|output| unpack!(block = this.as_place(block, output)))
146-
.collect();
146+
.collect::<Vec<_>>()
147+
.into_boxed_slice();
147148
let inputs = inputs
148149
.into_iter()
149150
.map(|input| unpack!(block = this.as_local_operand(block, input)))
150-
.collect();
151+
.collect::<Vec<_>>()
152+
.into_boxed_slice();
151153
this.cfg.push(
152154
block,
153155
Statement {

src/librustc_mir/dataflow/move_paths/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> {
290290
self.gather_init(output, InitKind::Deep);
291291
}
292292
}
293-
for input in inputs {
293+
for input in inputs.iter() {
294294
self.gather_operand(input);
295295
}
296296
}

0 commit comments

Comments
 (0)