diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2024-06-26 09:44:03 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2024-07-31 00:59:12 +0000 |
| commit | 70ee6e4b23f455b62554c3ee9365657f9e700abd (patch) | |
| tree | 33f4306835a07b1b31c32ea2c6b7202fc3b8f294 /compiler/rustc_mir_transform/src | |
| parent | 95986dd279d0bd7b292d0b0907fcb5e8d4b64c9c (diff) | |
| download | rust-70ee6e4b23f455b62554c3ee9365657f9e700abd.tar.gz rust-70ee6e4b23f455b62554c3ee9365657f9e700abd.zip | |
Amortize growing rev_locals.
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/gvn.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index d9bfe44633a..8eab9890d63 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -293,9 +293,15 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { let (index, new) = self.values.insert_full(value); let index = VnIndex::from_usize(index); if new { + // Grow `evaluated` and `rev_locals` here to amortize the allocations. let evaluated = self.eval_to_const(index); let _index = self.evaluated.push(evaluated); debug_assert_eq!(index, _index); + // No need to push to `rev_locals` if we finished listing assignments. + if self.next_opaque.is_some() { + let _index = self.rev_locals.push(SmallVec::new()); + debug_assert_eq!(index, _index); + } } index } @@ -332,7 +338,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { let is_sized = !self.feature_unsized_locals || self.local_decls[local].ty.is_sized(self.tcx, self.param_env); if is_sized { - self.rev_locals.ensure_contains_elem(value, SmallVec::new).push(local); + self.rev_locals[value].push(local); } } |
