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]
Other format: [Raw text]

[tree-profiling] Better error recovery


Hi,
as Richard suggested, instead of giving up compilation when error is
reached, I modified the CFG builder to emit the missing labels.  This
fixes bunch of testsuite failures..

Honza

2004-03-07  Jan Hubicka  <jh@suse.cz>
	* tree-cfg.c (label_to_block): Emit missing langes
	* tree-optimize.c (tree_rest_of_compilation): Revert patch disabling
	compilation with errorcount/sorrycount.
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.267.2.5
diff -c -3 -p -r1.1.4.267.2.5 tree-cfg.c
*** tree-cfg.c	3 Mar 2004 14:18:17 -0000	1.1.4.267.2.5
--- tree-cfg.c	7 Mar 2004 10:08:14 -0000
*************** make_switch_expr_edges (basic_block bb)
*** 635,641 ****
  basic_block
  label_to_block (tree dest)
  {
!   return VARRAY_BB (label_to_block_map, LABEL_DECL_UID (dest));
  }
  
  /* Create edges for a goto statement at block BB.  */
--- 635,655 ----
  basic_block
  label_to_block (tree dest)
  {
!   int uid = LABEL_DECL_UID (dest);
! 
!   /* We would die hard when faced by undefined label.  Emit label to
!      very first basic block.  This will hopefully make even the dataflow
!      and undefined variable warnings quite right.  */
!   if ((errorcount || sorrycount) && uid < 0)
!     {
!       block_stmt_iterator bsi = bsi_start (ENTRY_BLOCK_PTR->succ->dest);
!       tree stmt;
! 
!       stmt = build1 (LABEL_EXPR, void_type_node, dest);
!       bsi_insert_before (&bsi, stmt, BSI_NEW_STMT);
!       uid = LABEL_DECL_UID (dest);
!     }
!   return VARRAY_BB (label_to_block_map, uid);
  }
  
  /* Create edges for a goto statement at block BB.  */
Index: tree-optimize.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-optimize.c,v
retrieving revision 1.1.4.122.2.6
diff -c -3 -p -r1.1.4.122.2.6 tree-optimize.c
*** tree-optimize.c	3 Mar 2004 14:18:18 -0000	1.1.4.122.2.6
--- tree-optimize.c	7 Mar 2004 10:08:14 -0000
*************** tree_rest_of_compilation (tree fndecl, b
*** 544,598 ****
        cfun->saved_tree = save_body (current_function_decl, &cfun->saved_args);
      }
  
!   /* Do not confuse backend by incorrect instruction chain.  */
!   if (!errorcount && !sorrycount)
!     {
!       /* Perform all tree transforms and optimizations.  */
!       execute_pass_list (all_passes);
! 
!       /* If the function has a variably modified type, there may be
! 	 SAVE_EXPRs in the parameter types.  Their context must be set to
! 	 refer to this function; they cannot be expanded in the containing
! 	 function.  */
!       if (decl_function_context (fndecl) == current_function_decl
! 	  && variably_modified_type_p (TREE_TYPE (fndecl)))
! 	walk_tree (&TREE_TYPE (fndecl), set_save_expr_context, fndecl,
! 		   NULL);
! 
!       /* Set up parameters and prepare for return, for the function.  */
!       expand_function_start (fndecl, 0);
! 
!       /* Expand the variables recorded during gimple lowering.  */
!       expand_used_vars ();
! 
!       /* Allow language dialects to perform special processing.  */
!       (*lang_hooks.rtl_expand.start) ();
! 
!       /* If this function is `main', emit a call to `__main'
! 	 to run global initializers, etc.  */
!       if (DECL_NAME (fndecl)
! 	  && MAIN_NAME_P (DECL_NAME (fndecl))
! 	  && DECL_FILE_SCOPE_P (fndecl))
! 	expand_main_function ();
! 
!       /* Generate the RTL for this function.  */
!       tree_expand_cfg ();
! 
!       /* If this is a nested function, protect the local variables in the stack
! 	 above us from being collected while we're compiling this function.  */
!       if (nested_p)
! 	ggc_push_context ();
! 
!       /* There's no need to defer outputting this function any more; we
! 	 know we want to output it.  */
!       DECL_DEFER_OUTPUT (fndecl) = 0;
! 
!       /* Run the optimizers and output the assembler code for this function.  */
!       rest_of_compilation (fndecl);
!     }
!   else
!     /* Pretend that we compiled the function.  */
!     TREE_ASM_WRITTEN (fndecl) = 1;
  
    /* Restore original body if still needed.  */
    if (cfun->saved_tree)
--- 544,591 ----
        cfun->saved_tree = save_body (current_function_decl, &cfun->saved_args);
      }
  
!   /* Perform all tree transforms and optimizations.  */
!   execute_pass_list (all_passes);
! 
!   /* If the function has a variably modified type, there may be
!      SAVE_EXPRs in the parameter types.  Their context must be set to
!      refer to this function; they cannot be expanded in the containing
!      function.  */
!   if (decl_function_context (fndecl) == current_function_decl
!       && variably_modified_type_p (TREE_TYPE (fndecl)))
!     walk_tree (&TREE_TYPE (fndecl), set_save_expr_context, fndecl,
! 	       NULL);
! 
!   /* Set up parameters and prepare for return, for the function.  */
!   expand_function_start (fndecl, 0);
! 
!   /* Expand the variables recorded during gimple lowering.  */
!   expand_used_vars ();
! 
!   /* Allow language dialects to perform special processing.  */
!   (*lang_hooks.rtl_expand.start) ();
! 
!   /* If this function is `main', emit a call to `__main'
!      to run global initializers, etc.  */
!   if (DECL_NAME (fndecl)
!       && MAIN_NAME_P (DECL_NAME (fndecl))
!       && DECL_FILE_SCOPE_P (fndecl))
!     expand_main_function ();
! 
!   /* Generate the RTL for this function.  */
!   tree_expand_cfg ();
! 
!   /* If this is a nested function, protect the local variables in the stack
!      above us from being collected while we're compiling this function.  */
!   if (nested_p)
!     ggc_push_context ();
! 
!   /* There's no need to defer outputting this function any more; we
!      know we want to output it.  */
!   DECL_DEFER_OUTPUT (fndecl) = 0;
! 
!   /* Run the optimizers and output the assembler code for this function.  */
!   rest_of_compilation (fndecl);
  
    /* Restore original body if still needed.  */
    if (cfun->saved_tree)


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