From 9c025d7e0439e97fcec7a3977e39c152fd88d1df Mon Sep 17 00:00:00 2001 From: Jan Niehusmann Date: Tue, 15 Apr 2025 14:57:50 +0000 Subject: [PATCH] Remove lr::write() function, and add comment to lr::read() function. Fixes #570 --- cortex-m/src/register/lr.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/cortex-m/src/register/lr.rs b/cortex-m/src/register/lr.rs index 02708ae4..5752ff72 100644 --- a/cortex-m/src/register/lr.rs +++ b/cortex-m/src/register/lr.rs @@ -4,6 +4,9 @@ use core::arch::asm; /// Reads the CPU register +/// +/// Note that this function can't be used reliably: The value returned at least depends +/// on whether the compiler chooses to inline the function or not. #[cfg(cortex_m)] #[inline] pub fn read() -> u32 { @@ -12,9 +15,4 @@ pub fn read() -> u32 { r } -/// Writes `bits` to the CPU register -#[cfg(cortex_m)] -#[inline] -pub unsafe fn write(bits: u32) { - asm!("mov lr, {}", in(reg) bits, options(nomem, nostack, preserves_flags)); -} +// No `write` function for the LR register, as it can't be used soundly.