This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH 8/8] gas: xtensa: speed up find_trampoline_seg
- From: Max Filippov <jcmvbkbc at gmail dot com>
- To: binutils at sourceware dot org
- Cc: Sterling Augustine <augustine dot sterling at gmail dot com>, linux-xtensa at linux-xtensa dot org, Max Filippov <jcmvbkbc at gmail dot com>
- Date: Mon, 27 Nov 2017 11:39:34 -0800
- Subject: [PATCH 8/8] gas: xtensa: speed up find_trampoline_seg
- Authentication-results: sourceware.org; auth=none
- References: <1511811574-11128-1-git-send-email-jcmvbkbc@gmail.com>
find_trampoline_seg takes noticeable time when assembling source with
many sections. Cache the result of the most recent search and check it
first. No functional changes.
gas/
2017-11-20 Max Filippov <jcmvbkbc@gmail.com>
* config/tc-xtensa.c (find_trampoline_seg): Add static variable
that caches the result of the most recent search.
---
gas/config/tc-xtensa.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
index 1fa059c29302..b16d81c64e23 100644
--- a/gas/config/tc-xtensa.c
+++ b/gas/config/tc-xtensa.c
@@ -7463,11 +7463,18 @@ static struct trampoline_seg *
find_trampoline_seg (asection *seg)
{
struct trampoline_seg *ts = trampoline_seg_list.next;
+ static struct trampoline_seg *mr;
+
+ if (mr && mr->seg == seg)
+ return mr;
for ( ; ts; ts = ts->next)
{
if (ts->seg == seg)
- return ts;
+ {
+ mr = ts;
+ return ts;
+ }
}
return NULL;
--
2.1.4