Skip to content

Commit e124355

Browse files
committed
Auto merge of rust-lang#147735 - yotamofek:pr/ssa/initialize_locals_opt, r=JonathanBrouwer
Micro-optimization in `FunctionCx::initialize_locals` This showed up in a profile I was looking at, hoping this might improve perf by a little bit.
2 parents 377a931 + 9361d64 commit e124355

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

compiler/rustc_codegen_ssa/src/mir/locals.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ impl<'tcx, V> Locals<'tcx, V> {
4040
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
4141
pub(super) fn initialize_locals(&mut self, values: Vec<LocalRef<'tcx, Bx::Value>>) {
4242
assert!(self.locals.values.is_empty());
43+
self.locals.values = IndexVec::from_raw(values);
4344
// FIXME(#115215): After #115025 get's merged this might not be necessary
44-
for (local, value) in values.into_iter().enumerate() {
45+
for (local, value) in self.locals.values.iter_enumerated() {
4546
match value {
4647
LocalRef::Place(_) | LocalRef::UnsizedPlace(_) | LocalRef::PendingOperand => (),
4748
LocalRef::Operand(op) => {
48-
let local = mir::Local::from_usize(local);
4949
let expected_ty = self.monomorphize(self.mir.local_decls[local].ty);
5050
if expected_ty != op.layout.ty {
5151
warn!(
@@ -56,7 +56,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
5656
}
5757
}
5858
}
59-
self.locals.values.push(value);
6059
}
6160
}
6261

0 commit comments

Comments
 (0)