From 407e1140841f7fc337e90a7ba4482fb5a10c1701 Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Mon, 20 Nov 2017 06:35:06 -0800 Subject: [PATCH] gas: xtensa: speed up find_trampoline_seg 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-27 Max Filippov * config/tc-xtensa.c (find_trampoline_seg): Add static variable that caches the result of the most recent search. --- gas/ChangeLog | 5 +++++ gas/config/tc-xtensa.c | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index 92d0c362550..81f9f8395d0 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,8 @@ +2017-11-27 Max Filippov + + * config/tc-xtensa.c (find_trampoline_seg): Add static variable + that caches the result of the most recent search. + 2017-11-27 Max Filippov * config/tc-xtensa.c (trampoline_chain_entry, trampoline_chain) diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c index 9defd739b3b..ce7eb499b84 100644 --- a/gas/config/tc-xtensa.c +++ b/gas/config/tc-xtensa.c @@ -7453,11 +7453,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.30.2