gas: xtensa: speed up find_trampoline_seg
authorMax Filippov <jcmvbkbc@gmail.com>
Mon, 20 Nov 2017 14:35:06 +0000 (06:35 -0800)
committerMax Filippov <jcmvbkbc@gmail.com>
Mon, 27 Nov 2017 23:16:22 +0000 (15:16 -0800)
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  <jcmvbkbc@gmail.com>

* config/tc-xtensa.c (find_trampoline_seg): Add static variable
that caches the result of the most recent search.

gas/ChangeLog
gas/config/tc-xtensa.c

index 92d0c36255051cb925c8760ec6d6137f238c6328..81f9f8395d0eefe8f537a8f153984b83a93bf5e0 100644 (file)
@@ -1,3 +1,8 @@
+2017-11-27  Max Filippov  <jcmvbkbc@gmail.com>
+
+       * config/tc-xtensa.c (find_trampoline_seg): Add static variable
+       that caches the result of the most recent search.
+
 2017-11-27  Max Filippov  <jcmvbkbc@gmail.com>
 
        * config/tc-xtensa.c (trampoline_chain_entry, trampoline_chain)
index 9defd739b3b7b908cb94fc26f648483f59346969..ce7eb499b844f7640a22fbcaead58cb0fcf91438 100644 (file)
@@ -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;