From: Bernd Schmidt Date: Wed, 28 Oct 1998 10:22:48 +0000 (+0000) Subject: regclass.c (renumber, [...]): New static variables, moved out of allocate_reg_info. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ed396e68008200351bd49b4eb8a1cbe644d3b5f3;p=platform%2Fupstream%2Fgcc.git regclass.c (renumber, [...]): New static variables, moved out of allocate_reg_info. * regclass.c (renumber, regno_allocated): New static variables, moved out of allocate_reg_info. (allocate_reg_info): Move these two variables outside the function. Move code to free memory into new function free_reg_info. (free_reg_info): New function, broken out of allocate_reg_info. * toplev.c (compile_file): Call free_reg_info, not allocate_reg_info. * rtl.h (allocate_reg_info): Don't declare. (free_reg_info): Declare. From-SVN: r23397 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f4dbd64..a84f212 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,14 @@ Wed Oct 28 03:59:29 1998 Bernd Schmidt + * regclass.c (renumber, regno_allocated): New static variables, moved + out of allocate_reg_info. + (allocate_reg_info): Move these two variables outside the function. + Move code to free memory into new function free_reg_info. + (free_reg_info): New function, broken out of allocate_reg_info. + * toplev.c (compile_file): Call free_reg_info, not allocate_reg_info. + * rtl.h (allocate_reg_info): Don't declare. + (free_reg_info): Declare. + * final.c (cleanup_subreg_operands): ASM_INPUTs need no treatment. Wed Oct 28 02:38:12 1998 Jason Merrill diff --git a/gcc/regclass.c b/gcc/regclass.c index 5c23453..d9b6db6 100644 --- a/gcc/regclass.c +++ b/gcc/regclass.c @@ -1827,6 +1827,9 @@ auto_inc_dec_reg_p (reg, mode) #endif /* REGISTER_CONSTRAINTS */ +static short *renumber = (short *)0; +static size_t regno_allocated = 0; + /* Allocate enough space to hold NUM_REGS registers for the tables used for reg_scan and flow_analysis that are indexed by the register number. If NEW_P is non zero, initialize all of the registers, otherwise only @@ -1840,38 +1843,12 @@ allocate_reg_info (num_regs, new_p, renumber_p) int new_p; int renumber_p; { - static size_t regno_allocated = 0; - static short *renumber = (short *)0; size_t size_info; size_t size_renumber; size_t min = (new_p) ? 0 : reg_n_max; struct reg_info_data *reg_data; struct reg_info_data *reg_next; - /* Free up all storage allocated */ - if (num_regs < 0) - { - if (reg_n_info) - { - VARRAY_FREE (reg_n_info); - for (reg_data = reg_info_head; reg_data; reg_data = reg_next) - { - reg_next = reg_data->next; - free ((char *)reg_data); - } - - free (prefclass_buffer); - free (altclass_buffer); - prefclass_buffer = (char *)0; - altclass_buffer = (char *)0; - reg_info_head = (struct reg_info_data *)0; - renumber = (short *)0; - } - regno_allocated = 0; - reg_n_max = 0; - return; - } - if (num_regs > regno_allocated) { size_t old_allocated = regno_allocated; @@ -1973,6 +1950,32 @@ allocate_reg_info (num_regs, new_p, renumber_p) MAX_REGNO_REG_SET (num_regs, new_p, renumber_p); } +/* Free up the space allocated by allocate_reg_info. */ +void +free_reg_info () +{ + if (reg_n_info) + { + struct reg_info_data *reg_data; + struct reg_info_data *reg_next; + + VARRAY_FREE (reg_n_info); + for (reg_data = reg_info_head; reg_data; reg_data = reg_next) + { + reg_next = reg_data->next; + free ((char *)reg_data); + } + + free (prefclass_buffer); + free (altclass_buffer); + prefclass_buffer = (char *)0; + altclass_buffer = (char *)0; + reg_info_head = (struct reg_info_data *)0; + renumber = (short *)0; + } + regno_allocated = 0; + reg_n_max = 0; +} /* This is the `regscan' pass of the compiler, run just before cse and again just before loop. diff --git a/gcc/rtl.h b/gcc/rtl.h index 0d7ffb7..0ca999e 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -1010,7 +1010,7 @@ extern rtx find_use_as_address PROTO((rtx, rtx, HOST_WIDE_INT)); extern int max_parallel; /* Free up register info memory. */ -extern void allocate_reg_info PROTO((size_t, int, int)); +extern void free_reg_info PROTO((void)); /* recog.c */ extern int asm_noperands PROTO((rtx)); diff --git a/gcc/toplev.c b/gcc/toplev.c index 64ef43e..197d280 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -3067,6 +3067,7 @@ compile_file (name) ASM_FILE_END (asm_out_file); #endif + /* Language-specific end of compilation actions. */ finish_syntax: lang_finish (); @@ -3097,6 +3098,9 @@ compile_file (name) && (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)) fatal_io_error (asm_file_name); + /* Free up memory for the benefit of leak detectors. */ + free_reg_info (); + /* Print the times. */ if (! quiet_flag)