[PATCH] Fix PR58723

Richard Biener rguenther@suse.de
Wed Nov 27 17:17:00 GMT 2013


This fixes the cgraph machinery wrt internal calls and makes LTO
and the recent OMP work regarding vectorization work (to some extent).

LTO bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2013-11-27  Richard Biener  <rguenther@suse.de>

	PR middle-end/58723
	* cgraphbuild.c (build_cgraph_edges): Do not build edges
	for internal calls.
	(rebuild_cgraph_edges): Likewise.
	* ipa-inline-analysis.c (estimate_function_body_sizes):
	Skip internal calls.
	* tree-inline.c (estimate_num_insns): Estimate size of internal
	calls as 0.
	(gimple_expand_calls_inline): Do not try inline-expanding
	internal calls.
	* lto-streamer-in.c (input_cfg): Stream loop safelen,
	force_vect and simduid.
	(input_struct_function_base): Stream has_force_vect_loops
	and has_simduid_loops.
	(input_function): Adjust.
	* lto-streamer-out.c (output_cfg): Stream loop safelen,
	force_vect and simduid.
	(output_struct_function_base): Stream has_force_vect_loops
	and has_simduid_loops.

Index: gcc/cgraphbuild.c
===================================================================
*** gcc/cgraphbuild.c.orig	2013-11-27 11:01:21.000000000 +0100
--- gcc/cgraphbuild.c	2013-11-27 11:01:33.767324692 +0100
*************** build_cgraph_edges (void)
*** 335,340 ****
--- 335,342 ----
  	      if (decl)
  		cgraph_create_edge (node, cgraph_get_create_node (decl),
  				    stmt, bb->count, freq);
+ 	      else if (gimple_call_internal_p (stmt))
+ 		;
  	      else
  		cgraph_create_indirect_edge (node, stmt,
  					     gimple_call_flags (stmt),
*************** rebuild_cgraph_edges (void)
*** 464,469 ****
--- 466,473 ----
  	      if (decl)
  		cgraph_create_edge (node, cgraph_get_create_node (decl), stmt,
  				    bb->count, freq);
+ 	      else if (gimple_call_internal_p (stmt))
+ 		;
  	      else
  		cgraph_create_indirect_edge (node, stmt,
  					     gimple_call_flags (stmt),
Index: gcc/ipa-inline-analysis.c
===================================================================
*** gcc/ipa-inline-analysis.c.orig	2013-11-27 11:01:21.000000000 +0100
--- gcc/ipa-inline-analysis.c	2013-11-27 11:01:33.771324737 +0100
*************** estimate_function_body_sizes (struct cgr
*** 2502,2508 ****
  	    }
  
  
! 	  if (is_gimple_call (stmt))
  	    {
  	      struct cgraph_edge *edge = cgraph_edge (node, stmt);
  	      struct inline_edge_summary *es = inline_edge_summary (edge);
--- 2502,2509 ----
  	    }
  
  
! 	  if (is_gimple_call (stmt)
! 	      && !gimple_call_internal_p (stmt))
  	    {
  	      struct cgraph_edge *edge = cgraph_edge (node, stmt);
  	      struct inline_edge_summary *es = inline_edge_summary (edge);
Index: gcc/tree-inline.c
===================================================================
*** gcc/tree-inline.c.orig	2013-11-27 11:01:21.000000000 +0100
--- gcc/tree-inline.c	2013-11-27 11:01:53.957557118 +0100
*************** estimate_num_insns (gimple stmt, eni_wei
*** 3801,3812 ****
  
      case GIMPLE_CALL:
        {
! 	tree decl = gimple_call_fndecl (stmt);
  	struct cgraph_node *node = NULL;
  
  	/* Do not special case builtins where we see the body.
  	   This just confuse inliner.  */
! 	if (!decl || !(node = cgraph_get_node (decl)) || node->definition)
  	  ;
  	/* For buitins that are likely expanded to nothing or
  	   inlined do not account operand costs.  */
--- 3801,3816 ----
  
      case GIMPLE_CALL:
        {
! 	tree decl;
  	struct cgraph_node *node = NULL;
  
  	/* Do not special case builtins where we see the body.
  	   This just confuse inliner.  */
! 	if (gimple_call_internal_p (stmt))
! 	  return 0;
! 	else if (!(decl = gimple_call_fndecl (stmt))
! 		 || !(node = cgraph_get_node (decl))
! 		 || node->definition)
  	  ;
  	/* For buitins that are likely expanded to nothing or
  	   inlined do not account operand costs.  */
*************** gimple_expand_calls_inline (basic_block
*** 4427,4432 ****
--- 4431,4437 ----
        gimple stmt = gsi_stmt (gsi);
  
        if (is_gimple_call (stmt)
+ 	  && !gimple_call_internal_p (stmt)
  	  && expand_call_inline (bb, stmt, id))
  	return true;
      }
Index: gcc/lto-streamer-in.c
===================================================================
*** gcc/lto-streamer-in.c.orig	2013-11-25 10:44:28.000000000 +0100
--- gcc/lto-streamer-in.c	2013-11-27 11:28:13.006784679 +0100
*************** make_new_block (struct function *fn, uns
*** 598,604 ****
  /* Read the CFG for function FN from input block IB.  */
  
  static void
! input_cfg (struct lto_input_block *ib, struct function *fn,
  	   int count_materialization_scale)
  {
    unsigned int bb_count;
--- 598,605 ----
  /* Read the CFG for function FN from input block IB.  */
  
  static void
! input_cfg (struct lto_input_block *ib, struct data_in *data_in,
! 	   struct function *fn,
  	   int count_materialization_scale)
  {
    unsigned int bb_count;
*************** input_cfg (struct lto_input_block *ib, s
*** 714,719 ****
--- 715,725 ----
  	  loop->nb_iterations_estimate.high = streamer_read_hwi (ib);
  	}
  
+       /* Read OMP SIMD related info.  */
+       loop->safelen = streamer_read_hwi (ib);
+       loop->force_vect = streamer_read_hwi (ib);
+       loop->simduid = stream_read_tree (ib, data_in);
+ 
        place_new_loop (fn, loop);
  
        /* flow_loops_find doesn't like loops not in the tree, hook them
*************** input_struct_function_base (struct funct
*** 877,882 ****
--- 883,890 ----
    fn->has_nonlocal_label = bp_unpack_value (&bp, 1);
    fn->calls_alloca = bp_unpack_value (&bp, 1);
    fn->calls_setjmp = bp_unpack_value (&bp, 1);
+   fn->has_force_vect_loops = bp_unpack_value (&bp, 1);
+   fn->has_simduid_loops = bp_unpack_value (&bp, 1);
    fn->va_list_fpr_size = bp_unpack_value (&bp, 8);
    fn->va_list_gpr_size = bp_unpack_value (&bp, 8);
  
*************** input_function (tree fn_decl, struct dat
*** 923,929 ****
    if (!node)
      node = cgraph_create_node (fn_decl);
    input_struct_function_base (fn, data_in, ib);
!   input_cfg (ib_cfg, fn, node->count_materialization_scale);
  
    /* Read all the SSA names.  */
    input_ssa_names (ib, data_in, fn);
--- 931,937 ----
    if (!node)
      node = cgraph_create_node (fn_decl);
    input_struct_function_base (fn, data_in, ib);
!   input_cfg (ib_cfg, data_in, fn, node->count_materialization_scale);
  
    /* Read all the SSA names.  */
    input_ssa_names (ib, data_in, fn);
Index: gcc/lto-streamer-out.c
===================================================================
*** gcc/lto-streamer-out.c.orig	2013-11-25 10:44:27.000000000 +0100
--- gcc/lto-streamer-out.c	2013-11-27 11:26:04.365300457 +0100
*************** output_cfg (struct output_block *ob, str
*** 1642,1647 ****
--- 1642,1652 ----
  	  streamer_write_uhwi (ob, loop->nb_iterations_estimate.low);
  	  streamer_write_hwi (ob, loop->nb_iterations_estimate.high);
  	}
+ 
+       /* Write OMP SIMD related info.  */
+       streamer_write_hwi (ob, loop->safelen);
+       streamer_write_hwi (ob, loop->force_vect);
+       stream_write_tree (ob, loop->simduid, true);
      }
  
    ob->main_stream = tmp_stream;
*************** output_struct_function_base (struct outp
*** 1735,1740 ****
--- 1740,1747 ----
    bp_pack_value (&bp, fn->has_nonlocal_label, 1);
    bp_pack_value (&bp, fn->calls_alloca, 1);
    bp_pack_value (&bp, fn->calls_setjmp, 1);
+   bp_pack_value (&bp, fn->has_force_vect_loops, 1);
+   bp_pack_value (&bp, fn->has_simduid_loops, 1);
    bp_pack_value (&bp, fn->va_list_fpr_size, 8);
    bp_pack_value (&bp, fn->va_list_gpr_size, 8);
  



More information about the Gcc-patches mailing list