From 7c0b5cf99fc8c0f575d6e6304d4b3fc247beb298 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 4 May 2024 15:41:52 -0700 Subject: [PATCH] compiler: Add FramePointer::ratchet --- compiler/rustc_target/src/spec/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 62ccc57f421..81ada30a594 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1413,6 +1413,20 @@ pub enum FramePointer { MayOmit, } +impl FramePointer { + /// It is intended that the "force frame pointer" transition is "one way" + /// so this convenience assures such if used + #[inline] + pub fn ratchet(&mut self, rhs: FramePointer) -> FramePointer { + *self = match (*self, rhs) { + (FramePointer::Always, _) | (_, FramePointer::Always) => FramePointer::Always, + (FramePointer::NonLeaf, _) | (_, FramePointer::NonLeaf) => FramePointer::NonLeaf, + _ => FramePointer::MayOmit, + }; + *self + } +} + impl FromStr for FramePointer { type Err = (); fn from_str(s: &str) -> Result {