Skip to content

Commit 2b9aa76

Browse files
Auto merge of #147886 - dianqk:gvn-new-deref-arg, r=<try>
GVN: Use the borrows only if they are always live
2 parents 377656d + d6f8232 commit 2b9aa76

30 files changed

+596
-366
lines changed

‎compiler/rustc_middle/src/mir/statement.rs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,12 @@ impl<'tcx> Place<'tcx> {
374374
self.projection.iter().any(|elem| elem.is_indirect())
375375
}
376376

377+
/// Returns `true` if all projection of this `Place` always refers to the same memory region
378+
/// whatever the state of the program.
379+
pub fn is_stable_offset(&self) -> bool {
380+
self.projection.iter().all(|elem| elem.is_stable_offset())
381+
}
382+
377383
/// Returns `true` if this `Place`'s first projection is `Deref`.
378384
///
379385
/// This is useful because for MIR phases `AnalysisPhase::PostCleanup` and later,

‎compiler/rustc_middle/src/mir/terminator.rs‎

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -695,28 +695,6 @@ impl<'tcx> TerminatorKind<'tcx> {
695695
_ => None,
696696
}
697697
}
698-
699-
/// Returns true if the terminator can write to memory.
700-
pub fn can_write_to_memory(&self) -> bool {
701-
match self {
702-
TerminatorKind::Goto { .. }
703-
| TerminatorKind::SwitchInt { .. }
704-
| TerminatorKind::UnwindResume
705-
| TerminatorKind::UnwindTerminate(_)
706-
| TerminatorKind::Return
707-
| TerminatorKind::Assert { .. }
708-
| TerminatorKind::CoroutineDrop
709-
| TerminatorKind::FalseEdge { .. }
710-
| TerminatorKind::FalseUnwind { .. }
711-
| TerminatorKind::Unreachable => false,
712-
TerminatorKind::Call { .. }
713-
| TerminatorKind::Drop { .. }
714-
| TerminatorKind::TailCall { .. }
715-
// Yield writes to the resume_arg place.
716-
| TerminatorKind::Yield { .. }
717-
| TerminatorKind::InlineAsm { .. } => true,
718-
}
719-
}
720698
}
721699

722700
#[derive(Copy, Clone, Debug)]

0 commit comments

Comments
 (0)