From: John David Anglin Date: Thu, 11 Jun 2015 22:50:39 +0000 (-0400) Subject: tc-hppa.c: Speed up search for last label X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=18c208b2292f3c61097dee99053ecab78b393e46;p=binutils-gdb.git tc-hppa.c: Speed up search for last label --- diff --git a/gas/ChangeLog b/gas/ChangeLog index 4b78a5134e3..d9c525d097c 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,11 @@ +2015-06-11 John David Anglin + + PR gas/18427 + * gas/config/tc-hppa.c (last_label_symbol): Declare. + (pa_get_label): Return last label in current space/segment or NULL. + (pa_define_label): Record last label and add to root. + (pa_undefine_label): Remove last label from root. + 2015-06-08 Nick Clifton * config/tc-rx.c (rx_op): Correct handling of integer bignums. diff --git a/gas/config/tc-hppa.c b/gas/config/tc-hppa.c index 57d7e96be72..06e222db0a9 100644 --- a/gas/config/tc-hppa.c +++ b/gas/config/tc-hppa.c @@ -606,6 +606,9 @@ static int within_procedure; seen in each subspace. */ static label_symbol_struct *label_symbols_rootp = NULL; +/* Last label symbol */ +static label_symbol_struct last_label_symbol; + /* Nonzero when strict matching is enabled. Zero otherwise. Each opcode in the table has a flag which indicates whether or @@ -1114,19 +1117,17 @@ pa_check_eof (void) static label_symbol_struct * pa_get_label (void) { - label_symbol_struct *label_chain; + label_symbol_struct *label_chain = label_symbols_rootp; - for (label_chain = label_symbols_rootp; - label_chain; - label_chain = label_chain->lss_next) + if (label_chain) { #ifdef OBJ_SOM - if (current_space == label_chain->lss_space && label_chain->lss_label) - return label_chain; + if (current_space == label_chain->lss_space && label_chain->lss_label) + return label_chain; #endif #ifdef OBJ_ELF - if (now_seg == label_chain->lss_segment && label_chain->lss_label) - return label_chain; + if (now_seg == label_chain->lss_segment && label_chain->lss_label) + return label_chain; #endif } @@ -1139,28 +1140,23 @@ pa_get_label (void) void pa_define_label (symbolS *symbol) { - label_symbol_struct *label_chain = pa_get_label (); + label_symbol_struct *label_chain = label_symbols_rootp; - if (label_chain) - label_chain->lss_label = symbol; - else - { - /* Create a new label entry and add it to the head of the chain. */ - label_chain = xmalloc (sizeof (label_symbol_struct)); - label_chain->lss_label = symbol; + if (!label_chain) + label_chain = &last_label_symbol; + + label_chain->lss_label = symbol; #ifdef OBJ_SOM - label_chain->lss_space = current_space; + label_chain->lss_space = current_space; #endif #ifdef OBJ_ELF - label_chain->lss_segment = now_seg; + label_chain->lss_segment = now_seg; #endif - label_chain->lss_next = NULL; - if (label_symbols_rootp) - label_chain->lss_next = label_symbols_rootp; + /* Not used. */ + label_chain->lss_next = NULL; - label_symbols_rootp = label_chain; - } + label_symbols_rootp = label_chain; #ifdef OBJ_ELF dwarf2_emit_label (symbol); @@ -1173,33 +1169,7 @@ pa_define_label (symbolS *symbol) static void pa_undefine_label (void) { - label_symbol_struct *label_chain; - label_symbol_struct *prev_label_chain = NULL; - - for (label_chain = label_symbols_rootp; - label_chain; - label_chain = label_chain->lss_next) - { - if (1 -#ifdef OBJ_SOM - && current_space == label_chain->lss_space && label_chain->lss_label -#endif -#ifdef OBJ_ELF - && now_seg == label_chain->lss_segment && label_chain->lss_label -#endif - ) - { - /* Remove the label from the chain and free its memory. */ - if (prev_label_chain) - prev_label_chain->lss_next = label_chain->lss_next; - else - label_symbols_rootp = label_chain->lss_next; - - free (label_chain); - break; - } - prev_label_chain = label_chain; - } + label_symbols_rootp = NULL; } /* An HPPA-specific version of fix_new. This is required because the HPPA