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]

Make cfun_push and cfun_pop also change current_function_decl


Hi,

this is my second attempt to make push_cfun and pop_cfun save and
restore current_function_decl, so that code that wants to change the
function context does not have to do the latter manually.

This of course enforces that cfun and current_function_decl match at
push_cfun points which is asserted and the patch checking_asserts that
they match at cfun_pop times too, except when cfun is NULL and
current_function_decl has been changed in order to interact with code
shared with front-ends (and in some other cases, e.g. in dwarf2out.c).
However, this code does not make pushing and popping NULL cfun cheaper
because the patch is already quite big as it is.  I will try doing
that as a followup.

The patch is very similar to what I have posted to the mailing list in
August but without the two ugly spots (tricks in Ada front end and
dwarf2out.c) which I have meanwhile sorted out differently.  I have
bootstrapped and tested the patch on x86_64-linux and have also
LTO-built Firefox with it.  OK for trunk?

Thanks,

Martin


2012-09-12  Martin Jambor  <mjambor@suse.cz>

	* function.c (push_cfun): Check old current_function_decl matches
	old cfun, set new current_function_decl to the decl of the new
	cfun.
	(push_struct_function): Likewise.
	(pop_cfun): Likewise.
	(allocate_struct_function): Move call to
	invoke_set_current_function_hook to the end of the function.
	* cfgexpand.c (estimated_stack_frame_size): Do not set and restore
	current_function_decl.
	* cgraph.c (cgraph_release_function_body): Likewise.
	* cgraphunit.c (cgraph_process_new_functions): Likewise.
	(cgraph_add_new_function): Likewise.
	(cgraph_analyze_function): Likewise.
	(assemble_thunk): Set cfun to NULL at the end.
	(expand_function): Move call to set_cfun downwards.
	* gimple-low.c (record_vars_into): Only check current_function_decl
	before possibly doing push_cfun.
	* gimplify.c (gimplify_function_tree): Do not set and restore
	current_function_decl.
	* ipa-inline-analysis.c (compute_inline_parameters): Likewise.
	(inline_analyze_function): Likewise.
	* ipa-prop.c (ipa_analyze_node): Likewise.
	* ipa-pure-const.c (analyze_function): Likewise.
	* lto-streamer-in.c (lto_input_function_body): Do not set
	current_function_decl.
	* lto-streamer-out.c (output_function): Do not set and restore
	current_function_decl.
	* omp-low.c (finalize_task_copyfn): Likewise.
	(expand_omp_taskreg): Likewise.
	(create_task_copyfn): Likewise, move push_cfun up quite a bit.
	* passes.c (dump_passes): Do not set and restore current_function_decl.
	(do_per_function): Likewise.
	(do_per_function_toporder): Likewise.
	* trans-mem.c (ipa_tm_scan_irr_function): Likewise.
	(ipa_tm_transform_transaction): Likewise.
	(ipa_tm_transform_clone): Likewise.
	(ipa_tm_execute): Likewise.
	* tree-emutls.c (lower_emutls_function_body): Likewise.
	* tree-inline.c (initialize_cfun): Do not call pop_cfun.
	(tree_function_versioning): Do not call push_cfun, do not set and
	restore current_function_decl.  Remove assert checking consistency of
	cfun and current_function_decl.
	* tree-profile.c (tree_profiling): Do not set and restore
	current_function_decl.
	* tree-sra.c (convert_callers_for_node): Do not set
	current_function_decl.
	(convert_callers): Do not restore current_function_decl.
	(modify_function): Do not set current_function_decl.
	* tree-ssa-structalias.c (ipa_pta_execute): Do not set and restore
	current_function_decl.

fortran/
	* trans-decl.c (gfc_get_extern_function_decl): Push NULL cfun.  Do not
	set and restore current_function_decl.
	(gfc_init_coarray_decl): Do not set and restore current_function_decl.

go/
	* gofrontend/gogo-tree.cc (Gogo::write_initialization_function): Do
	not set and restore current_function_decl.
	(Gogo::write_globals): Likewise.
	(Named_object::get_tree): Likewise.

lto/
	* lto.c (lto_materialize_function): Call push_struct_function and
	pop_cfun.


*** /tmp/WDLEAb_cfgexpand.c	Wed Sep 19 14:29:03 2012
--- gcc/cfgexpand.c	Mon Sep 17 14:48:19 2012
*************** estimated_stack_frame_size (struct cgrap
*** 1423,1432 ****
    HOST_WIDE_INT size = 0;
    size_t i;
    tree var;
-   tree old_cur_fun_decl = current_function_decl;
    struct function *fn = DECL_STRUCT_FUNCTION (node->symbol.decl);
  
-   current_function_decl = node->symbol.decl;
    push_cfun (fn);
  
    init_vars_expansion ();
--- 1423,1430 ----
*************** estimated_stack_frame_size (struct cgrap
*** 1446,1452 ****
  
    fini_vars_expansion ();
    pop_cfun ();
-   current_function_decl = old_cur_fun_decl;
    return size;
  }
  
--- 1444,1449 ----
*** /tmp/2KxwId_cgraph.c	Wed Sep 19 14:29:03 2012
--- gcc/cgraph.c	Mon Sep 17 14:48:19 2012
*************** cgraph_release_function_body (struct cgr
*** 1127,1133 ****
  {
    if (DECL_STRUCT_FUNCTION (node->symbol.decl))
      {
-       tree old_decl = current_function_decl;
        push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
        if (cfun->cfg
  	  && current_loops)
--- 1127,1132 ----
*************** cgraph_release_function_body (struct cgr
*** 1137,1147 ****
  	}
        if (cfun->gimple_df)
  	{
- 	  current_function_decl = node->symbol.decl;
  	  delete_tree_ssa ();
  	  delete_tree_cfg_annotations ();
  	  cfun->eh = NULL;
- 	  current_function_decl = old_decl;
  	}
        if (cfun->cfg)
  	{
--- 1136,1144 ----
*** /tmp/OtqJnd_cgraphunit.c	Wed Sep 19 14:29:03 2012
--- gcc/cgraphunit.c	Mon Sep 17 14:48:19 2012
*************** cgraph_process_new_functions (void)
*** 313,319 ****
  	  if (!node->analyzed)
  	    cgraph_analyze_function (node);
  	  push_cfun (DECL_STRUCT_FUNCTION (fndecl));
- 	  current_function_decl = fndecl;
  	  if ((cgraph_state == CGRAPH_STATE_IPA_SSA
  	      && !gimple_in_ssa_p (DECL_STRUCT_FUNCTION (fndecl)))
  	      /* When not optimizing, be sure we run early local passes anyway
--- 313,318 ----
*************** cgraph_process_new_functions (void)
*** 325,331 ****
  	  free_dominance_info (CDI_POST_DOMINATORS);
  	  free_dominance_info (CDI_DOMINATORS);
  	  pop_cfun ();
- 	  current_function_decl = NULL;
            cgraph_call_function_insertion_hooks (node);
  	  break;
  
--- 324,329 ----
*************** cgraph_add_new_function (tree fndecl, bo
*** 495,508 ****
  	if (!lowered && cgraph_state == CGRAPH_STATE_EXPANSION)
  	  {
  	    push_cfun (DECL_STRUCT_FUNCTION (fndecl));
- 	    current_function_decl = fndecl;
  	    gimple_register_cfg_hooks ();
  	    bitmap_obstack_initialize (NULL);
  	    execute_pass_list (all_lowering_passes);
  	    execute_pass_list (pass_early_local_passes.pass.sub);
  	    bitmap_obstack_release (NULL);
  	    pop_cfun ();
- 	    current_function_decl = NULL;
  
  	    lowered = true;
  	  }
--- 493,504 ----
*************** cgraph_add_new_function (tree fndecl, bo
*** 521,527 ****
  	  node->lowered = true;
  	cgraph_analyze_function (node);
  	push_cfun (DECL_STRUCT_FUNCTION (fndecl));
- 	current_function_decl = fndecl;
  	gimple_register_cfg_hooks ();
  	bitmap_obstack_initialize (NULL);
  	if (!gimple_in_ssa_p (DECL_STRUCT_FUNCTION (fndecl)))
--- 517,522 ----
*************** cgraph_add_new_function (tree fndecl, bo
*** 529,535 ****
  	bitmap_obstack_release (NULL);
  	pop_cfun ();
  	expand_function (node);
- 	current_function_decl = NULL;
  	break;
  
        default:
--- 524,529 ----
*************** fixup_same_cpp_alias_visibility (symtab_
*** 597,603 ****
  static void
  cgraph_analyze_function (struct cgraph_node *node)
  {
-   tree save = current_function_decl;
    tree decl = node->symbol.decl;
    location_t saved_loc = input_location;
    input_location = DECL_SOURCE_LOCATION (decl);
--- 591,596 ----
*************** cgraph_analyze_function (struct cgraph_n
*** 638,644 ****
      }
    else
      {
-       current_function_decl = decl;
        push_cfun (DECL_STRUCT_FUNCTION (decl));
  
        assign_assembler_name_if_neeeded (node->symbol.decl);
--- 631,636 ----
*************** cgraph_analyze_function (struct cgraph_n
*** 672,678 ****
      }
    node->analyzed = true;
  
-   current_function_decl = save;
    input_location = saved_loc;
  }
  
--- 664,669 ----
*************** assemble_thunk (struct cgraph_node *node
*** 1524,1529 ****
--- 1515,1521 ----
        bitmap_obstack_release (NULL);
      }
    current_function_decl = NULL;
+   set_cfun (NULL);
  }
  
  
*************** expand_function (struct cgraph_node *nod
*** 1616,1623 ****
    /* Release the default bitmap obstack.  */
    bitmap_obstack_release (NULL);
  
-   set_cfun (NULL);
- 
    /* If requested, warn about function definitions where the function will
       return a value (usually of some struct or union type) which itself will
       take up a lot of stack space.  */
--- 1608,1613 ----
*************** expand_function (struct cgraph_node *nod
*** 1662,1667 ****
--- 1652,1658 ----
  
    /* Make sure that BE didn't give up on compiling.  */
    gcc_assert (TREE_ASM_WRITTEN (decl));
+   set_cfun (NULL);
    current_function_decl = NULL;
  
    /* It would make a lot more sense to output thunks before function body to get more
*** /tmp/GBgLSa_trans-decl.c	Wed Sep 19 14:29:03 2012
--- gcc/fortran/trans-decl.c	Mon Sep 17 14:48:42 2012
*************** gfc_get_extern_function_decl (gfc_symbol
*** 1630,1646 ****
  	  /* By construction, the external function cannot be
  	     a contained procedure.  */
  	  locus old_loc;
- 	  tree save_fn_decl = current_function_decl;
  
- 	  current_function_decl = NULL_TREE;
  	  gfc_save_backend_locus (&old_loc);
! 	  push_cfun (cfun);
  
  	  gfc_create_function_decl (gsym->ns, true);
  
  	  pop_cfun ();
  	  gfc_restore_backend_locus (&old_loc);
- 	  current_function_decl = save_fn_decl;
  	}
  
        /* If the namespace has entries, the proc_name is the
--- 1630,1643 ----
  	  /* By construction, the external function cannot be
  	     a contained procedure.  */
  	  locus old_loc;
  
  	  gfc_save_backend_locus (&old_loc);
! 	  push_cfun (NULL);
  
  	  gfc_create_function_decl (gsym->ns, true);
  
  	  pop_cfun ();
  	  gfc_restore_backend_locus (&old_loc);
  	}
  
        /* If the namespace has entries, the proc_name is the
*************** add_argument_checking (stmtblock_t *bloc
*** 4861,4876 ****
  void
  gfc_init_coarray_decl (bool main_tu)
  {
-   tree save_fn_decl;
- 
    if (gfc_option.coarray != GFC_FCOARRAY_LIB)
      return;
  
    if (gfort_gvar_caf_this_image || gfort_gvar_caf_num_images)
      return;
  
-   save_fn_decl = current_function_decl;
-   current_function_decl = NULL_TREE;
    push_cfun (cfun);
  
    gfort_gvar_caf_this_image
--- 4858,4869 ----
*************** gfc_init_coarray_decl (bool main_tu)
*** 4906,4912 ****
    pushdecl_top_level (gfort_gvar_caf_num_images);
  
    pop_cfun ();
-   current_function_decl = save_fn_decl;
  }
  
  
--- 4899,4904 ----
*** /tmp/mJHkad_function.c	Wed Sep 19 14:29:03 2012
--- gcc/function.c	Mon Sep 17 14:48:42 2012
*************** set_cfun (struct function *new_cfun)
*** 4413,4434 ****
  
  static VEC(function_p,heap) *cfun_stack;
  
! /* Push the current cfun onto the stack, and set cfun to new_cfun.  */
  
  void
  push_cfun (struct function *new_cfun)
  {
    VEC_safe_push (function_p, heap, cfun_stack, cfun);
    set_cfun (new_cfun);
  }
  
! /* Pop cfun from the stack.  */
  
  void
  pop_cfun (void)
  {
    struct function *new_cfun = VEC_pop (function_p, cfun_stack);
    set_cfun (new_cfun);
  }
  
  /* Return value of funcdef and increase it.  */
--- 4413,4446 ----
  
  static VEC(function_p,heap) *cfun_stack;
  
! /* Push the current cfun onto the stack, and set cfun to new_cfun.  Also set
!    current_function_decl accordingly.  */
  
  void
  push_cfun (struct function *new_cfun)
  {
+   gcc_assert ((!cfun && !current_function_decl)
+ 	      || (cfun && current_function_decl == cfun->decl));
    VEC_safe_push (function_p, heap, cfun_stack, cfun);
+   current_function_decl = new_cfun ? new_cfun->decl : NULL_TREE;
    set_cfun (new_cfun);
  }
  
! /* Pop cfun from the stack.  Also set current_function_decl accordingly.  */
  
  void
  pop_cfun (void)
  {
    struct function *new_cfun = VEC_pop (function_p, cfun_stack);
+   /* When in_dummy_function, we do have a cfun but current_function_decl is
+      NULL.  We also allow pushing NULL cfun and subsequently changing
+      current_function_decl to something else and have both restored by
+      pop_cfun.  */
+   gcc_checking_assert (in_dummy_function
+ 		       || !cfun
+ 		       || current_function_decl == cfun->decl);
    set_cfun (new_cfun);
+   current_function_decl = new_cfun ? new_cfun->decl : NULL_TREE;
  }
  
  /* Return value of funcdef and increase it.  */
*************** allocate_struct_function (tree fndecl, b
*** 4475,4482 ****
    OVERRIDE_ABI_FORMAT (fndecl);
  #endif
  
-   invoke_set_current_function_hook (fndecl);
- 
    if (fndecl != NULL_TREE)
      {
        DECL_STRUCT_FUNCTION (fndecl) = cfun;
--- 4487,4492 ----
*************** allocate_struct_function (tree fndecl, b
*** 4502,4507 ****
--- 4512,4519 ----
           but is this worth the hassle?  */
        cfun->can_throw_non_call_exceptions = flag_non_call_exceptions;
      }
+ 
+   invoke_set_current_function_hook (fndecl);
  }
  
  /* This is like allocate_struct_function, but pushes a new cfun for FNDECL
*************** allocate_struct_function (tree fndecl, b
*** 4510,4516 ****
--- 4522,4534 ----
  void
  push_struct_function (tree fndecl)
  {
+   /* When in_dummy_function we might be in the middle of a pop_cfun and
+      current_function_decl and cfun may not match.  */
+   gcc_assert (in_dummy_function
+ 	      || (!cfun && !current_function_decl)
+ 	      || (cfun && current_function_decl == cfun->decl));
    VEC_safe_push (function_p, heap, cfun_stack, cfun);
+   current_function_decl = fndecl;
    allocate_struct_function (fndecl, false);
  }
  
*** /tmp/2osN7a_gimple-low.c	Wed Sep 19 14:29:03 2012
--- gcc/gimple-low.c	Mon Sep 17 14:48:42 2012
*************** lower_builtin_setjmp (gimple_stmt_iterat
*** 991,997 ****
  void
  record_vars_into (tree vars, tree fn)
  {
!   if (fn != current_function_decl)
      push_cfun (DECL_STRUCT_FUNCTION (fn));
  
    for (; vars; vars = DECL_CHAIN (vars))
--- 991,999 ----
  void
  record_vars_into (tree vars, tree fn)
  {
!   bool change_cfun = fn != current_function_decl;
! 
!   if (change_cfun)
      push_cfun (DECL_STRUCT_FUNCTION (fn));
  
    for (; vars; vars = DECL_CHAIN (vars))
*************** record_vars_into (tree vars, tree fn)
*** 1011,1017 ****
        add_local_decl (cfun, var);
      }
  
!   if (fn != current_function_decl)
      pop_cfun ();
  }
  
--- 1013,1019 ----
        add_local_decl (cfun, var);
      }
  
!   if (change_cfun)
      pop_cfun ();
  }
  
*** /tmp/ihOsDc_gimplify.c	Wed Sep 19 14:29:03 2012
--- gcc/gimplify.c	Mon Sep 17 14:48:42 2012
*************** flag_instrument_functions_exclude_p (tre
*** 8288,8301 ****
  void
  gimplify_function_tree (tree fndecl)
  {
!   tree oldfn, parm, ret;
    gimple_seq seq;
    gimple bind;
  
    gcc_assert (!gimple_body (fndecl));
  
-   oldfn = current_function_decl;
-   current_function_decl = fndecl;
    if (DECL_STRUCT_FUNCTION (fndecl))
      push_cfun (DECL_STRUCT_FUNCTION (fndecl));
    else
--- 8288,8299 ----
  void
  gimplify_function_tree (tree fndecl)
  {
!   tree parm, ret;
    gimple_seq seq;
    gimple bind;
  
    gcc_assert (!gimple_body (fndecl));
  
    if (DECL_STRUCT_FUNCTION (fndecl))
      push_cfun (DECL_STRUCT_FUNCTION (fndecl));
    else
*************** gimplify_function_tree (tree fndecl)
*** 8380,8386 ****
    DECL_SAVED_TREE (fndecl) = NULL_TREE;
    cfun->curr_properties = PROP_gimple_any;
  
-   current_function_decl = oldfn;
    pop_cfun ();
  }
  
--- 8378,8383 ----
*** /tmp/koXFIa_gogo-tree.cc	Wed Sep 19 14:29:03 2012
--- gcc/go/gofrontend/gogo-tree.cc	Mon Sep 17 14:48:42 2012
*************** Gogo::write_initialization_function(tree
*** 476,482 ****
  
    DECL_SAVED_TREE(fndecl) = init_stmt_list;
  
-   current_function_decl = fndecl;
    if (DECL_STRUCT_FUNCTION(fndecl) == NULL)
      push_struct_function(fndecl);
    else
--- 476,481 ----
*************** Gogo::write_initialization_function(tree
*** 487,493 ****
  
    cgraph_add_new_function(fndecl, false);
  
-   current_function_decl = NULL_TREE;
    pop_cfun();
  }
  
--- 486,491 ----
*************** Gogo::write_globals()
*** 864,870 ****
  	      // means that we need an fndecl.
  	      if (init_fndecl == NULL_TREE)
  		init_fndecl = this->initialization_function_decl();
- 	      current_function_decl = init_fndecl;
  	      if (DECL_STRUCT_FUNCTION(init_fndecl) == NULL)
  		push_struct_function(init_fndecl);
  	      else
--- 862,867 ----
*************** Gogo::write_globals()
*** 874,880 ****
  	      var_init_tree = no->var_value()->get_init_block(this, NULL,
  							      var_decl);
  
- 	      current_function_decl = NULL_TREE;
  	      pop_cfun();
  	    }
  
--- 871,876 ----
*************** Named_object::get_tree(Gogo* gogo, Named
*** 1116,1130 ****
  		cfun->function_end_locus =
                    func->block()->end_location().gcc_location();
  
- 		current_function_decl = decl;
- 
  		func->build_tree(gogo, this);
  
  		gimplify_function_tree(decl);
  
  		cgraph_finalize_function(decl, true);
  
- 		current_function_decl = NULL_TREE;
  		pop_cfun();
  	      }
  	  }
--- 1112,1123 ----
*** /tmp/22CARc_ipa-inline-analysis.c	Wed Sep 19 14:29:03 2012
--- gcc/ipa-inline-analysis.c	Mon Sep 17 14:48:42 2012
*************** compute_inline_parameters (struct cgraph
*** 2554,2560 ****
    HOST_WIDE_INT self_stack_size;
    struct cgraph_edge *e;
    struct inline_summary *info;
-   tree old_decl = current_function_decl;
  
    gcc_assert (!node->global.inlined_to);
  
--- 2554,2559 ----
*************** compute_inline_parameters (struct cgraph
*** 2581,2587 ****
      }
  
    /* Even is_gimple_min_invariant rely on current_function_decl.  */
-   current_function_decl = node->symbol.decl;
    push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
  
    /* Estimate the stack size for the function if we're optimizing.  */
--- 2580,2585 ----
*************** compute_inline_parameters (struct cgraph
*** 2623,2629 ****
    info->size = info->self_size;
    info->stack_frame_offset = 0;
    info->estimated_stack_size = info->estimated_self_stack_size;
-   current_function_decl = old_decl;
    pop_cfun ();
  }
  
--- 2621,2626 ----
*************** static void
*** 3554,3560 ****
  inline_analyze_function (struct cgraph_node *node)
  {
    push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
-   current_function_decl = node->symbol.decl;
  
    if (dump_file)
      fprintf (dump_file, "\nAnalyzing function: %s/%u\n",
--- 3551,3556 ----
*************** inline_analyze_function (struct cgraph_n
*** 3563,3569 ****
      inline_indirect_intraprocedural_analysis (node);
    compute_inline_parameters (node, false);
  
-   current_function_decl = NULL;
    pop_cfun ();
  }
  
--- 3559,3564 ----
*** /tmp/OZMC0b_ipa-prop.c	Wed Sep 19 14:29:03 2012
--- gcc/ipa-prop.c	Mon Sep 17 14:48:42 2012
*************** ipa_analyze_node (struct cgraph_node *no
*** 1913,1919 ****
    ipa_check_create_edge_args ();
    info = IPA_NODE_REF (node);
    push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
-   current_function_decl = node->symbol.decl;
    ipa_initialize_node_params (node);
  
    param_count = ipa_get_param_count (info);
--- 1913,1918 ----
*************** ipa_analyze_node (struct cgraph_node *no
*** 1931,1937 ****
  	BITMAP_FREE (parms_ainfo[i].pt_visited_statements);
      }
  
-   current_function_decl = NULL;
    pop_cfun ();
  }
  
--- 1930,1935 ----
*** /tmp/Gn7fDe_ipa-pure-const.c	Wed Sep 19 14:29:03 2012
--- gcc/ipa-pure-const.c	Mon Sep 17 14:48:42 2012
*************** static funct_state
*** 725,731 ****
  analyze_function (struct cgraph_node *fn, bool ipa)
  {
    tree decl = fn->symbol.decl;
-   tree old_decl = current_function_decl;
    funct_state l;
    basic_block this_block;
  
--- 725,730 ----
*************** analyze_function (struct cgraph_node *fn
*** 753,759 ****
      }
  
    push_cfun (DECL_STRUCT_FUNCTION (decl));
-   current_function_decl = decl;
  
    FOR_EACH_BB (this_block)
      {
--- 752,757 ----
*************** end:
*** 821,827 ****
      l->can_throw = false;
  
    pop_cfun ();
-   current_function_decl = old_decl;
    if (dump_file)
      {
        if (l->looping)
--- 819,824 ----
*** /tmp/cOQYlb_lto-streamer-in.c	Wed Sep 19 14:29:03 2012
--- gcc/lto-streamer-in.c	Mon Sep 17 14:48:20 2012
*************** void
*** 1036,1042 ****
  lto_input_function_body (struct lto_file_decl_data *file_data,
  			 tree fn_decl, const char *data)
  {
-   current_function_decl = fn_decl;
    lto_read_body (file_data, fn_decl, data, LTO_section_function_body);
  }
  
--- 1036,1041 ----
*** /tmp/sgBZWa_lto-streamer-out.c	Wed Sep 19 14:29:03 2012
--- gcc/lto-streamer-out.c	Mon Sep 17 14:48:20 2012
*************** output_function (struct cgraph_node *nod
*** 796,802 ****
    gcc_assert (current_function_decl == NULL_TREE && cfun == NULL);
  
    /* Set current_function_decl and cfun.  */
-   current_function_decl = function;
    push_cfun (fn);
  
    /* Make string 0 be a NULL string.  */
--- 796,801 ----
*************** output_function (struct cgraph_node *nod
*** 850,856 ****
  
    destroy_output_block (ob);
  
-   current_function_decl = NULL;
    pop_cfun ();
  }
  
--- 849,854 ----
*** /tmp/QMBsyd_lto.c	Wed Sep 19 14:29:03 2012
--- gcc/lto/lto.c	Mon Sep 17 14:48:42 2012
*************** lto_materialize_function (struct cgraph_
*** 221,227 ****
  
  	  gcc_assert (DECL_STRUCT_FUNCTION (decl) == NULL);
  
! 	  allocate_struct_function (decl, false);
  	  announce_function (decl);
  	  lto_input_function_body (file_data, decl, data);
  	  if (DECL_FUNCTION_PERSONALITY (decl) && !first_personality_decl)
--- 221,227 ----
  
  	  gcc_assert (DECL_STRUCT_FUNCTION (decl) == NULL);
  
! 	  push_struct_function (decl);
  	  announce_function (decl);
  	  lto_input_function_body (file_data, decl, data);
  	  if (DECL_FUNCTION_PERSONALITY (decl) && !first_personality_decl)
*************** lto_materialize_function (struct cgraph_
*** 229,234 ****
--- 229,235 ----
  	  lto_stats.num_function_bodies++;
  	  lto_free_section_data (file_data, LTO_section_function_body, name,
  				 data, len);
+ 	  pop_cfun ();
  	  ggc_collect ();
  	}
      }
*** /tmp/W9Tkqa_omp-low.c	Wed Sep 19 14:29:03 2012
--- gcc/omp-low.c	Tue Sep 18 14:36:26 2012
*************** static void
*** 1243,1249 ****
  finalize_task_copyfn (gimple task_stmt)
  {
    struct function *child_cfun;
!   tree child_fn, old_fn;
    gimple_seq seq = NULL, new_seq;
    gimple bind;
  
--- 1243,1249 ----
  finalize_task_copyfn (gimple task_stmt)
  {
    struct function *child_cfun;
!   tree child_fn;
    gimple_seq seq = NULL, new_seq;
    gimple bind;
  
*************** finalize_task_copyfn (gimple task_stmt)
*** 1257,1265 ****
    DECL_STRUCT_FUNCTION (child_fn)->curr_properties
      = cfun->curr_properties & ~PROP_loops;
  
-   old_fn = current_function_decl;
    push_cfun (child_cfun);
-   current_function_decl = child_fn;
    bind = gimplify_body (child_fn, false);
    gimple_seq_add_stmt (&seq, bind);
    new_seq = maybe_catch_exception (seq);
--- 1257,1263 ----
*************** finalize_task_copyfn (gimple task_stmt)
*** 1271,1277 ****
      }
    gimple_set_body (child_fn, seq);
    pop_cfun ();
-   current_function_decl = old_fn;
  
    cgraph_add_new_function (child_fn, false);
  }
--- 1269,1274 ----
*************** expand_omp_taskreg (struct omp_region *r
*** 3388,3394 ****
    basic_block entry_bb, exit_bb, new_bb;
    struct function *child_cfun;
    tree child_fn, block, t;
-   tree save_current;
    gimple_stmt_iterator gsi;
    gimple entry_stmt, stmt;
    edge e;
--- 3385,3390 ----
*************** expand_omp_taskreg (struct omp_region *r
*** 3588,3595 ****
        /* Fix the callgraph edges for child_cfun.  Those for cfun will be
  	 fixed in a following pass.  */
        push_cfun (child_cfun);
-       save_current = current_function_decl;
-       current_function_decl = child_fn;
        if (optimize)
  	optimize_omp_library_calls (entry_stmt);
        rebuild_cgraph_edges ();
--- 3584,3589 ----
*************** expand_omp_taskreg (struct omp_region *r
*** 3610,3616 ****
  	}
        if (gimple_in_ssa_p (cfun))
  	update_ssa (TODO_update_ssa);
-       current_function_decl = save_current;
        pop_cfun ();
      }
  
--- 3604,3609 ----
*************** create_task_copyfn (gimple task_stmt, om
*** 6456,6462 ****
  
    /* Populate the function.  */
    push_gimplify_context (&gctx);
!   current_function_decl = child_fn;
  
    bind = build3 (BIND_EXPR, void_type_node, NULL, NULL, NULL);
    TREE_SIDE_EFFECTS (bind) = 1;
--- 6449,6455 ----
  
    /* Populate the function.  */
    push_gimplify_context (&gctx);
!   push_cfun (child_cfun);
  
    bind = build3 (BIND_EXPR, void_type_node, NULL, NULL, NULL);
    TREE_SIDE_EFFECTS (bind) = 1;
*************** create_task_copyfn (gimple task_stmt, om
*** 6503,6510 ****
    else
      tcctx.cb.decl_map = NULL;
  
-   push_cfun (child_cfun);
- 
    arg = DECL_ARGUMENTS (child_fn);
    TREE_TYPE (arg) = build_pointer_type (record_type);
    sarg = DECL_CHAIN (arg);
--- 6496,6501 ----
*************** create_task_copyfn (gimple task_stmt, om
*** 6662,6668 ****
    pop_gimplify_context (NULL);
    BIND_EXPR_BODY (bind) = list;
    pop_cfun ();
-   current_function_decl = ctx->cb.src_fn;
  }
  
  /* Lower the OpenMP parallel or task directive in the current statement
--- 6653,6658 ----
*** /tmp/udHfNc_passes.c	Wed Sep 19 14:29:03 2012
--- gcc/passes.c	Mon Sep 17 14:48:42 2012
*************** void
*** 679,685 ****
  dump_passes (void)
  {
    struct cgraph_node *n, *node = NULL;
-   tree save_fndecl = current_function_decl;
  
    create_pass_tab();
  
--- 679,684 ----
*************** dump_passes (void)
*** 694,700 ****
      return;
  
    push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
-   current_function_decl = node->symbol.decl;
  
    dump_pass_list (all_lowering_passes, 1);
    dump_pass_list (all_small_ipa_passes, 1);
--- 693,698 ----
*************** dump_passes (void)
*** 704,710 ****
    dump_pass_list (all_passes, 1);
  
    pop_cfun ();
-   current_function_decl = save_fndecl;
  }
  
  
--- 702,707 ----
*************** do_per_function (void (*callback) (void
*** 1652,1665 ****
  	    && (!node->clone_of || node->symbol.decl != node->clone_of->symbol.decl))
  	  {
  	    push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
- 	    current_function_decl = node->symbol.decl;
  	    callback (data);
  	    if (!flag_wpa)
  	      {
  	        free_dominance_info (CDI_DOMINATORS);
  	        free_dominance_info (CDI_POST_DOMINATORS);
  	      }
- 	    current_function_decl = NULL;
  	    pop_cfun ();
  	    ggc_collect ();
  	  }
--- 1649,1660 ----
*************** do_per_function_toporder (void (*callbac
*** 1700,1710 ****
  	  if (cgraph_function_with_gimple_body_p (node))
  	    {
  	      push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
- 	      current_function_decl = node->symbol.decl;
  	      callback (data);
  	      free_dominance_info (CDI_DOMINATORS);
  	      free_dominance_info (CDI_POST_DOMINATORS);
- 	      current_function_decl = NULL;
  	      pop_cfun ();
  	      ggc_collect ();
  	    }
--- 1695,1703 ----
*** /tmp/YWgCfa_trans-mem.c	Wed Sep 19 14:29:03 2012
--- gcc/trans-mem.c	Mon Sep 17 14:48:42 2012
*************** ipa_tm_scan_irr_function (struct cgraph_
*** 3988,3994 ****
        || DECL_STRUCT_FUNCTION (node->symbol.decl)->cfg == NULL)
      return false;
  
-   current_function_decl = node->symbol.decl;
    push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
    calculate_dominance_info (CDI_DOMINATORS);
  
--- 3988,3993 ----
*************** ipa_tm_scan_irr_function (struct cgraph_
*** 4060,4066 ****
  
    VEC_free (basic_block, heap, queue);
    pop_cfun ();
-   current_function_decl = NULL;
  
    return ret;
  }
--- 4059,4064 ----
*************** ipa_tm_transform_transaction (struct cgr
*** 4698,4704 ****
  
    d = get_cg_data (&node, true);
  
-   current_function_decl = node->symbol.decl;
    push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
    calculate_dominance_info (CDI_DOMINATORS);
  
--- 4696,4701 ----
*************** ipa_tm_transform_transaction (struct cgr
*** 4723,4729 ****
      update_ssa (TODO_update_ssa_only_virtuals);
  
    pop_cfun ();
-   current_function_decl = NULL;
  }
  
  /* Transform the calls within the transactional clone of NODE.  */
--- 4720,4725 ----
*************** ipa_tm_transform_clone (struct cgraph_no
*** 4742,4749 ****
    if (!node->callees && !node->indirect_calls && !d->irrevocable_blocks_clone)
      return;
  
!   current_function_decl = d->clone->symbol.decl;
!   push_cfun (DECL_STRUCT_FUNCTION (current_function_decl));
    calculate_dominance_info (CDI_DOMINATORS);
  
    need_ssa_rename =
--- 4738,4744 ----
    if (!node->callees && !node->indirect_calls && !d->irrevocable_blocks_clone)
      return;
  
!   push_cfun (DECL_STRUCT_FUNCTION (d->clone->symbol.decl));
    calculate_dominance_info (CDI_DOMINATORS);
  
    need_ssa_rename =
*************** ipa_tm_transform_clone (struct cgraph_no
*** 4754,4760 ****
      update_ssa (TODO_update_ssa_only_virtuals);
  
    pop_cfun ();
-   current_function_decl = NULL;
  }
  
  /* Main entry point for the transactional memory IPA pass.  */
--- 4749,4754 ----
*************** ipa_tm_execute (void)
*** 4801,4807 ****
  	    continue;
  	  }
  
- 	current_function_decl = node->symbol.decl;
  	push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
  	calculate_dominance_info (CDI_DOMINATORS);
  
--- 4795,4800 ----
*************** ipa_tm_execute (void)
*** 4821,4827 ****
  	  }
  
  	pop_cfun ();
- 	current_function_decl = NULL;
        }
  
    /* For every local function on the callee list, scan as if we will be
--- 4814,4819 ----
*** /tmp/u3XoUc_tree-emutls.c	Wed Sep 19 14:29:03 2012
--- gcc/tree-emutls.c	Mon Sep 17 14:48:42 2012
*************** lower_emutls_function_body (struct cgrap
*** 618,624 ****
    struct lower_emutls_data d;
    bool any_edge_inserts = false;
  
-   current_function_decl = node->symbol.decl;
    push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
  
    d.cfun_node = node;
--- 618,623 ----
*************** lower_emutls_function_body (struct cgrap
*** 689,695 ****
      gsi_commit_edge_inserts ();
  
    pop_cfun ();
-   current_function_decl = NULL;
  }
  
  /* Create emutls variable for VAR, DATA is pointer to static
--- 688,693 ----
*** /tmp/KxXQ1b_tree-inline.c	Wed Sep 19 14:29:03 2012
--- gcc/tree-inline.c	Mon Sep 17 14:48:20 2012
*************** remap_decl_1 (tree decl, void *data)
*** 2030,2036 ****
  }
  
  /* Build struct function and associated datastructures for the new clone
!    NEW_FNDECL to be build.  CALLEE_FNDECL is the original */
  
  static void
  initialize_cfun (tree new_fndecl, tree callee_fndecl, gcov_type count)
--- 2030,2037 ----
  }
  
  /* Build struct function and associated datastructures for the new clone
!    NEW_FNDECL to be build.  CALLEE_FNDECL is the original.  Function changes
!    the cfun to the function of new_fndecl (and current_function_decl too).  */
  
  static void
  initialize_cfun (tree new_fndecl, tree callee_fndecl, gcov_type count)
*************** initialize_cfun (tree new_fndecl, tree c
*** 2095,2101 ****
        cfun->gimple_df->in_ssa_p = true;
        init_ssa_operands (cfun);
      }
-   pop_cfun ();
  }
  
  /* Helper function for copy_cfg_body.  Move debug stmts from the end
--- 2096,2101 ----
*************** tree_function_versioning (tree old_decl,
*** 5028,5035 ****
    struct ipa_replace_map *replace_info;
    basic_block old_entry_block, bb;
    VEC (gimple, heap) *init_stmts = VEC_alloc (gimple, heap, 10);
- 
-   tree old_current_function_decl = current_function_decl;
    tree vars = NULL_TREE;
  
    gcc_assert (TREE_CODE (old_decl) == FUNCTION_DECL
--- 5028,5033 ----
*************** tree_function_versioning (tree old_decl,
*** 5100,5113 ****
    id.transform_return_to_modify = false;
    id.transform_lang_insert_block = NULL;
  
-   current_function_decl = new_decl;
    old_entry_block = ENTRY_BLOCK_PTR_FOR_FUNCTION
      (DECL_STRUCT_FUNCTION (old_decl));
    initialize_cfun (new_decl, old_decl,
  		   old_entry_block->count);
    DECL_STRUCT_FUNCTION (new_decl)->gimple_df->ipa_pta
      = id.src_cfun->gimple_df->ipa_pta;
-   push_cfun (DECL_STRUCT_FUNCTION (new_decl));
  
    /* Copy the function's static chain.  */
    p = DECL_STRUCT_FUNCTION (old_decl)->static_chain_decl;
--- 5098,5109 ----
*************** tree_function_versioning (tree old_decl,
*** 5261,5269 ****
    gcc_assert (!id.debug_stmts);
    VEC_free (gimple, heap, init_stmts);
    pop_cfun ();
-   current_function_decl = old_current_function_decl;
-   gcc_assert (!current_function_decl
- 	      || DECL_STRUCT_FUNCTION (current_function_decl) == cfun);
    return;
  }
  
--- 5257,5262 ----
*** /tmp/qHfxNe_tree-profile.c	Wed Sep 19 14:29:03 2012
--- gcc/tree-profile.c	Mon Sep 17 14:48:20 2012
*************** tree_profiling (void)
*** 475,481 ****
  	continue;
  
        push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
-       current_function_decl = node->symbol.decl;
  
        /* Local pure-const may imply need to fixup the cfg.  */
        if (execute_fixup_cfg () & TODO_cleanup_cfg)
--- 475,480 ----
*************** tree_profiling (void)
*** 497,504 ****
  	 easy to adjust it, if and when there is some.  */
        free_dominance_info (CDI_DOMINATORS);
        free_dominance_info (CDI_POST_DOMINATORS);
- 
-       current_function_decl = NULL;
        pop_cfun ();
      }
  
--- 496,501 ----
*************** tree_profiling (void)
*** 533,539 ****
  	continue;
  
        push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
-       current_function_decl = node->symbol.decl;
  
        FOR_EACH_BB (bb)
  	{
--- 530,535 ----
*************** tree_profiling (void)
*** 550,556 ****
  
        rebuild_cgraph_edges ();
  
-       current_function_decl = NULL;
        pop_cfun ();
      }
  
--- 546,551 ----
*** /tmp/G9pNzb_tree-sra.c	Wed Sep 19 14:29:03 2012
--- gcc/tree-sra.c	Mon Sep 17 14:48:42 2012
*************** convert_callers_for_node (struct cgraph_
*** 4616,4622 ****
  
    for (cs = node->callers; cs; cs = cs->next_caller)
      {
-       current_function_decl = cs->caller->symbol.decl;
        push_cfun (DECL_STRUCT_FUNCTION (cs->caller->symbol.decl));
  
        if (dump_file)
--- 4616,4621 ----
*************** static void
*** 4645,4658 ****
  convert_callers (struct cgraph_node *node, tree old_decl,
  		 ipa_parm_adjustment_vec adjustments)
  {
-   tree old_cur_fndecl = current_function_decl;
    basic_block this_block;
  
    cgraph_for_node_and_aliases (node, convert_callers_for_node,
  			       adjustments, false);
  
-   current_function_decl = old_cur_fndecl;
- 
    if (!encountered_recursive_call)
      return;
  
--- 4644,4654 ----
*************** modify_function (struct cgraph_node *nod
*** 4693,4707 ****
    rebuild_cgraph_edges ();
    free_dominance_info (CDI_DOMINATORS);
    pop_cfun ();
-   current_function_decl = NULL_TREE;
  
    new_node = cgraph_function_versioning (node, redirect_callers, NULL, NULL,
  					 false, NULL, NULL, "isra");
    VEC_free (cgraph_edge_p, heap, redirect_callers);
  
-   current_function_decl = new_node->symbol.decl;
    push_cfun (DECL_STRUCT_FUNCTION (new_node->symbol.decl));
- 
    ipa_modify_formal_parameters (current_function_decl, adjustments, "ISRA");
    cfg_changed = ipa_sra_modify_function_body (adjustments);
    sra_ipa_reset_debug_stmts (adjustments);
--- 4689,4700 ----
*** /tmp/8FhSKd_tree-ssa-structalias.c	Wed Sep 19 14:29:03 2012
--- gcc/tree-ssa-structalias.c	Mon Sep 17 14:48:42 2012
*************** ipa_pta_execute (void)
*** 6925,6931 ****
      {
        struct function *func;
        basic_block bb;
-       tree old_func_decl;
  
        /* Nodes without a body are not interesting.  */
        if (!cgraph_function_with_gimple_body_p (node))
--- 6925,6930 ----
*************** ipa_pta_execute (void)
*** 6943,6951 ****
  	}
  
        func = DECL_STRUCT_FUNCTION (node->symbol.decl);
-       old_func_decl = current_function_decl;
        push_cfun (func);
-       current_function_decl = node->symbol.decl;
  
        /* For externally visible or attribute used annotated functions use
  	 local constraints for their arguments.
--- 6942,6948 ----
*************** ipa_pta_execute (void)
*** 7002,7008 ****
  	    }
  	}
  
-       current_function_decl = old_func_decl;
        pop_cfun ();
  
        if (dump_file)
--- 6999,7004 ----


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