public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jens Remus <jremus@linux.ibm.com>
To: binutils@sourceware.org, Indu Bhagat <indu.bhagat@oracle.com>
Cc: Jens Remus <jremus@linux.ibm.com>
Subject: [PATCH 1/3] libsframe: simplify SFrame FRE range check
Date: Wed, 21 May 2025 10:30:57 +0200	[thread overview]
Message-ID: <20250521083059.55048-2-jremus@linux.ibm.com> (raw)
In-Reply-To: <20250521083059.55048-1-jremus@linux.ibm.com>

For regular SFrame FDEs the PC offset from function start address must
be within a SFrame FRE's start IP offset and end IP offset.  For type
PC mask FDEs the masked PC offset must be within that range.

libsframe/
	* sframe.c (sframe_fre_check_range_p): Simplify.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
---

Notes (jremus):
    @Indu: This could be squashed into your "libsframe: fix issue in
    finding FRE in SFRAME_FDE_TYPE_PCMASK type SFrame FDEs" or kept
    separately.

 libsframe/sframe.c | 32 ++++++++------------------------
 1 file changed, 8 insertions(+), 24 deletions(-)

diff --git a/libsframe/sframe.c b/libsframe/sframe.c
index 85457e4d6602..c1bc692829a9 100644
--- a/libsframe/sframe.c
+++ b/libsframe/sframe.c
@@ -372,43 +372,27 @@ sframe_fre_check_range_p (sframe_func_desc_entry *fdep,
 			  int32_t start_ip_offset, int32_t end_ip_offset,
 			  int32_t pc)
 {
-  int32_t start_ip, end_ip;
   int32_t func_start_addr;
   uint8_t rep_block_size;
   uint32_t fde_type;
-  int32_t masked_pc;
+  int32_t pc_offset;
   bool mask_p;
-  bool ret;
-
-  ret = false;
 
   if (!fdep)
-    return ret;
+    return false;
 
   func_start_addr = fdep->sfde_func_start_address;
   fde_type = sframe_get_fde_type (fdep);
   mask_p = (fde_type == SFRAME_FDE_TYPE_PCMASK);
   rep_block_size = fdep->sfde_func_rep_size;
 
-  if (!mask_p)
-    {
-      start_ip = start_ip_offset + func_start_addr;
-      end_ip = end_ip_offset + func_start_addr;
-      ret = ((start_ip <= pc) && (end_ip >= pc));
-    }
-  else
-    {
-      /* For SFrame FDEs encoding information for repetitive pattern of insns,
-	 masking with the rep_block_size is necessary to find the matching FRE.
-	 start_ip_offset and end_ip_offset are _unsigned_values_ identifying
-	 the SFrame FRE.  So, perform a calculation to first get the distance
-	 between the pc and func_start_addr, followed by modulo to find the
-	 fitting range.  */
-      masked_pc = (pc - func_start_addr) % rep_block_size;
-      ret = ((start_ip_offset <= masked_pc) && (end_ip_offset >= masked_pc));
-    }
+  pc_offset = pc - func_start_addr;
+  /* For SFrame FDEs encoding information for repetitive pattern of insns,
+     masking with the rep_block_size is necessary to find the matching FRE.  */
+  if (mask_p)
+    pc_offset = pc_offset % rep_block_size;
 
-  return ret;
+  return (start_ip_offset <= pc_offset) && (end_ip_offset >= pc_offset);
 }
 
 static int
-- 
2.45.2


  reply	other threads:[~2025-05-21  8:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-21  8:30 [PATCH 0/3] libsframe: Further enhancements and fixes Jens Remus
2025-05-21  8:30 ` Jens Remus [this message]
2025-05-21  8:30 ` [PATCH 2/3] libsframe: stop search for SFrame FRE if its start IP is greater than PC Jens Remus
2025-05-21  8:30 ` [PATCH 3/3] libsframe: correct binary search for SFrame FDE Jens Remus
2025-05-22  6:02 ` [PATCH 0/3] libsframe: Further enhancements and fixes Indu Bhagat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250521083059.55048-2-jremus@linux.ibm.com \
    --to=jremus@linux.ibm.com \
    --cc=binutils@sourceware.org \
    --cc=indu.bhagat@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).