This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

find_basic-blocks memory leak fix



Hi,

integrate causes us to memory leak the basic block structures; when the
CFG is built before function is saved and then, at the end of compilation
the function is again proceeded by find_basic_block that attempts to reuse
the data structures already freed.

The patch solves it by removing the BASIC_BLOCK notes before saving.

Regtested/bootstrapped i686 with other today patches.

Ne čec 15 21:47:09 CEST 2001  Jan Hubicka  <jh@suse.cz>

	* integrate.c (save_for_inline): Kill all BASIC_BLOCK notes.
	(copy_insn_list): Avoid killing of BASIC_BLOCK notes.

*** /p1/jumpr2/jumpr/egcs/gcc/integrate.c	Thu Jul 12 18:03:44 2001
--- integrate.c	Sun Jul 15 19:30:27 2001
*************** save_for_inline (fndecl)
*** 426,431 ****
--- 426,438 ----
  
    argvec = initialize_for_inline (fndecl);
  
+   /* Delete basic block notes created by early run of find_basic_block.
+      The notes would be later used by find_basic_blocks to reuse the memory
+      for basic_block structures on already freed obstack.  */
+   for (insn = get_insns (); insn ; insn = NEXT_INSN (insn))
+     if (GET_CODE (insn) == NOTE && NOTE_LINE_NUMBER (insn) == NOTE_INSN_BASIC_BLOCK)
+       delete_insn (insn);
+ 
    /* If there are insns that copy parms from the stack into pseudo registers,
       those insns are not copied.  `expand_inline_function' must
       emit the correct code to handle such things.  */
*************** copy_insn_list (insns, map, static_chain
*** 1551,1567 ****
  	     discarded because it is important to have only one of
  	     each in the current function.
  
! 	     NOTE_INSN_DELETED notes aren't useful.
! 
! 	     NOTE_INSN_BASIC_BLOCK is discarded because the saved bb
! 	     pointer (which will soon be dangling) confuses flow's
! 	     attempts to preserve bb structures during the compilation
! 	     of a function.  */
  
  	  if (NOTE_LINE_NUMBER (insn) != NOTE_INSN_FUNCTION_END
  	      && NOTE_LINE_NUMBER (insn) != NOTE_INSN_FUNCTION_BEG
! 	      && NOTE_LINE_NUMBER (insn) != NOTE_INSN_DELETED
! 	      && NOTE_LINE_NUMBER (insn) != NOTE_INSN_BASIC_BLOCK)
  	    {
  	      copy = emit_note (NOTE_SOURCE_FILE (insn),
  				NOTE_LINE_NUMBER (insn));
--- 1558,1568 ----
  	     discarded because it is important to have only one of
  	     each in the current function.
  
! 	     NOTE_INSN_DELETED notes aren't useful.  */
  
  	  if (NOTE_LINE_NUMBER (insn) != NOTE_INSN_FUNCTION_END
  	      && NOTE_LINE_NUMBER (insn) != NOTE_INSN_FUNCTION_BEG
! 	      && NOTE_LINE_NUMBER (insn) != NOTE_INSN_DELETED)
  	    {
  	      copy = emit_note (NOTE_SOURCE_FILE (insn),
  				NOTE_LINE_NUMBER (insn));


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]