Re: [x32] PATCH: PR middle-end/47725: [x32] error: unable to find a register to spill in class DIREG

2011-03-23 Thread Eric Botcazou
> It is:
>
>   op0 = parmreg;
>   op1 = validated_mem;
>   if (icode != CODE_FOR_nothing
>   && insn_data[icode].operand[0].predicate (op0,
> promoted_nominal_mode) && insn_data[icode].operand[1].predicate (op1,
> data->passed_mode)) {
>   enum rtx_code code = unsignedp ? ZERO_EXTEND : SIGN_EXTEND;
>   rtx insn, insns;
>   HARD_REG_SET hardregs;
>
>   start_sequence ();
>   insn = gen_extend_insn (op0, op1, promoted_nominal_mode,
>   data->passed_mode, unsignedp);
>   emit_insn (insn);
>   insns = get_insns ();

Sure, but why is need_conversion set to true?

-- 
Eric Botcazou


Re: [PATCH 0/4] Remove (lots of) lazy call graph node construction

2011-03-23 Thread Jan Hubicka
> Hi,
> 
> I believe the general consensus is that lazy call graph node creation
> is no longer a good idea and a few of us have seen bugs caused by a
> creation of a node when we did not expect it.  Therefore I embarked on
> getting rid of it.  In the process I quickly realized it would be
> difficult to do that completely but it is certainly possible to weed
> it out of most places where it is not necessary.  We can then tackle
> the remaining places separately.
> 
> These patches are meant to be applied on top of
> http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01170.html
> 
> The first patch in the series removes the cgraph_node function.  Most
> of its callers should use already existing cgraph_get_node instead,
> for the others there are new functions:
> 
> - craph_create_node will create a node but fail on assert if there
>   already is a node for the declaration
> 
> - cgraph_get_create_node is the new lazy node creation.  I did not
>   want to continue using cgraph_node name because I really thought the
>   it was unfortunate and the new name will also help us to discourage
>   potential new uses and isolate those that we might want to convert
>   to a non-lazy way of creating nodes later.
> 
> - cgraph_do_get_node is a simple wrapper around cgraph_get_node which
>   checking_asserts that the return value is not NULL.  I found it very
>   useful while developing the patch and think it can be sometimes
>   useful even in the longer term, for example when the result is
>   stored in some data structure which is to be used later.  If the
>   general consensus is that we don't want it, it is easy to remove it
>   from the patch.

Well, I didn't quite expected we will get 3 new accesstors to the cgraph,
but I see it can be useful.  I would perhaps go with cgraph_maybe_create_node
that seems more consistent with names elsewhere, but cgraph_get_create_node
seems OK to me, too.

Thanks!
Honza


Re: [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412)

2011-03-23 Thread Rainer Orth
Hi Paolo,

> On Mon, Mar 21, 2011 at 19:27, Mike Stump  wrote:
>> On Mar 21, 2011, at 5:59 AM, Rainer Orth wrote:
>>> I've applied those changes, and also managed to fix the problems I had
>>> in Tru64 UNIX testing.  Here's the patch I'd like to commit to 4.7.
>>
>>> +# Build shared library from LIB.
>>> +proc boehm-gc-build-shlib { lib flags extra-flags } {
>>
>>> +    # FIXME: Explain options.
>>> +    set shopt "-version-info 1:2:0 -no-undefined -rpath /nowhere"
>>
>> So, this still seems unportable to me?
>
> These are libtool options.

do you see any issues with the build portion of the patch?  It certainly
needs build maintainer approval before the whole thing can go in.

Thanks.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [PATCH 1/4] Remove cgraph_node function and fixup all callers

2011-03-23 Thread Jan Hubicka
> 2011-03-18  Martin Jambor  
> 
>   * cgraph.h (cgraph_node): Remove function declaration.
>   (cgraph_create_node): Declare.
>   (cgraph_get_create_node): Likewise.
>   (cgraph_do_get_node): New function.
> 
>   * cgraph.c (cgraph_create_node): Renamed to cgraph_create_node_1.
>   Updated all callers.
>   (cgraph_node): Renamed to cgraph_create_node, assert that a node for
>   the decl does not already exist.  Call cgraph_get_create_node instead
>   of cgraph_node.
>   (cgraph_get_create_node): New function.
>   (cgraph_same_body_alias): Update comment.
>   (cgraph_set_call_stmt): Call cgraph_do_get_node instead of cgraph_node.
>   (cgraph_update_edges_for_call_stmt): Likewise.
>   (cgraph_clone_edge): Likewise.
>   (cgraph_create_virtual_clone): Likewise.
>   (cgraph_set_call_stmt): Call cgraph_get_create_node instead of
>   cgraph_node.
>   (cgraph_local_info): Call cgraph_get_node instead of cgraph_node,
>   handle NULL return value.
>   (cgraph_global_info): Likewise.
>   (cgraph_rtl_info): Likewise.
>   (cgraph_add_new_function): Call cgraph_create_node or
>   cgraph_get_create_node instead of cgraph_node.
> 
>   * cgraphbuild.c (record_reference): Call cgraph_get_create_node
>   instead of cgraph_node.
>   (record_eh_tables): Likewise.
>   (mark_address): Likewise.
>   (mark_load): Likewise.
>   (build_cgraph_edges): Call cgraph_get_node and cgraph_get_create_node
>   instead of cgraph_node.
>   (rebuild_cgraph_edges): Likewise.
>   (cgraph_rebuild_references): Call cgraph_get_node instead of
>   cgraph_node.
>   (remove_cgraph_callee_edges): Likewise.
> 
>   * cgraphunit.c (cgraph_finalize_function): Call cgraph_get_create_node
>   instead of cgraph_node.
>   (cgraph_mark_if_needed): Call cgraph_get_node instead of cgraph_node.
>   (verify_cgraph_node): Likewise.
>   (cgraph_analyze_functions): Likewise.
>   (cgraph_preserve_function_body_p): Likewise.
>   (save_inline_function_body): Likewise.
>   (save_inline_function_body): Likewise.
>   (cgraph_copy_node_for_versioning): Call cgraph_create_node instead of
>   cgraph_node.
> 
>   * tree-inline.c (copy_bb): Call cgraph_get_node instead of cgraph_node.
>   (estimate_num_insns): Likewise and handle returned NULL.
>   (optimize_inline_calls): Call cgraph_get_node instead of cgraph_node.
>   (tree_function_versioning): Call cgraph_do_get_node instead of
>   cgraph_node.
> 
>   * lto-symtab.c (lto_symtab_merge_cgraph_nodes_1): Call
>   cgraph_create_node instead of cgraph_node.
> 
>   * c-decl.c (finish_function): Call cgraph_get_create_node instead
>   of cgraph_node.
>   * c-family/c-gimplify.c (c_genericize): Likewise.
>   * lto-cgraph.c (input_node): Likewise.
>   * lto-streamer-in.c (input_function): Likewise.
> 
>   * except.c (set_nothrow_function_flags): Call cgraph_get_node instead
>   of cgraph_node.
>   * final.c (rest_of_clean_state): Likewise.
>   * gimple-iterator.c (update_call_edge_frequencies): Likewise.
>   * passes.c (pass_init_dump_file): Likewise.
>   (execute_all_ipa_transforms): Likewise.
>   (function_called_by_processed_nodes_p): Likewise.
>   * predict.c (maybe_hot_frequency_p): Likewise.
>   (probably_never_executed_bb_p): Likewise.
>   (compute_function_frequency): Likewise.
>   * tree-nested.c (check_for_nested_with_variably_modified): Likewise.
>   (unnest_nesting_tree_1): Likewise.
>   (lower_nested_functions): Likewise.
>   * tree-optimize.c (execute_fixup_cfg): Likewise.
>   (tree_rest_of_compilation): Likewise.
>   * tree-optimize.c (execute_fixup_cfg): Likewise.
>   (tree_rest_of_compilation): Likewise.
>   * tree-profile.c (gimple_gen_ic_func_profiler): Likewise.
>   * tree-sra.c (ipa_early_sra): Likewise.
>   * tree-ssa-loop-ivopts.c (computation_cost): Likewise.
>   * config/i386/i386.c (ix86_compute_frame_layout): Likewise.
>   * ipa.c (record_cdtor_fn): Likewise.
>   * ipa-inline.c (cgraph_early_inlining): Likewise.
>   (compute_inline_parameters_for_current): Likewise.
>   * ipa-prop.c (ipa_make_edge_direct_to_target): Likewise.
>   * ipa-pure-const.c (local_pure_const): Likewise.
>   * ipa-split.c (split_function): Likewise.
>   (split_function): Likewise.
>   (execute_split_functions): Likewise.
> 
>   * lto-streamer-in.c (lto_read_body): Call cgraph_do_get_node instead
>   of cgraph_node.
>   * omp-low.c (new_omp_context): Likewise.
>   (create_task_copyfn): Likewise.
>   * tree-emutls.c (lower_emutls_function_body): Likewise.
>   * ipa-struct-reorg.c (update_cgraph_with_malloc_call): Likewise.
>   * ipa-type-escape.c (check_call): Likewise.
>   * matrix-reorg.c (transform_allocation_sites): Likewise.
> 
>   * gimplify.c (unshare_body): C

Re: [doc patch] fix PRs 48179, 48221 and 48234

2011-03-23 Thread Richard Guenther
On Tue, Mar 22, 2011 at 11:28 PM, Jonathan Wakely  wrote:
> This fixes three bugs reported against the docs generated from the 4.6.0 RC.
>
> 48179 and 48234 are caused by a @section appearing in a different
> order compared to the order they apepar in the @menu, so the order of
> sections in the TOC and the Next/Previous navigation links do not
> match the section numbering.  This is problem is present on all active
> release branches.
> 48221 simply replaces -Wcpp with -Wno-cpp in the options summary and
> removes a stray backslash which prevents the option appearing in the
> HTML docs. This is only relevant for 4.6 and trunk.

Ok everywhere relevant.

Richard.

> 2011-03-22  Jonathan Wakely  
>
>        PR other/48179
>        PR other/48221
>        PR other/48234
>        * doc/extend.texi (Alignment): Move section to match order in TOC.
>        * doc/invoke.texi (i386 and x86-64 Windows Options): Likewise.
>        (Warning Options): Adjust -Wno-cpp summary and remove stray backslash.
>
> Tested on x86_64-linux with "make html"
>
> OK for trunk?
> OK for other active branches?
> (the -Wno-cpp bit isn't relevant before 4.6 and I will wait for the
> 4.6 branch to reopen)
>


[Ada] Fix ICE on twin pair of dynamically-sized arrays

2011-03-23 Thread Eric Botcazou
The ICE occurs during RTL expansion but the problem is an incorrect sharing of 
a tree node between two types.  Classical issue with dynamically-sized types.

Tested on i586-suse-linux, applied on the mainline.


2011-03-23  Eric Botcazou  

* gcc-interface/decl.c (gnat_to_gnu_entity) : Create TYPE_DECL
for the padded type built in order to support a specified alignment.
Fix incorrect formatting.


2011-03-23  Eric Botcazou  

* gnat.dg/array14.ad[sb]: New test.
* gnat.dg/array14_pkg.ads: New helper.


-- 
Eric Botcazou
Index: gcc-interface/decl.c
===
--- gcc-interface/decl.c	(revision 171254)
+++ gcc-interface/decl.c	(working copy)
@@ -687,6 +687,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 	if (kind != E_Exception && Known_Alignment (gnat_entity))
 	  {
 	gcc_assert (Present (Alignment (gnat_entity)));
+
 	align = validate_alignment (Alignment (gnat_entity), gnat_entity,
 	TYPE_ALIGN (gnu_type));
 
@@ -695,9 +696,20 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 	if (Present (Address_Clause (gnat_entity)))
 	  align = 0;
 	else
-	  gnu_type
-		= maybe_pad_type (gnu_type, NULL_TREE, align, gnat_entity,
-  false, false, definition, true);
+	  {
+		tree orig_type = gnu_type;
+
+		gnu_type
+		  = maybe_pad_type (gnu_type, NULL_TREE, align, gnat_entity,
+false, false, definition, true);
+
+		/* If a padding record was made, declare it now since it will
+		   never be declared otherwise.  This is necessary to ensure
+		   that its subtrees are properly marked.  */
+		if (gnu_type != orig_type && !DECL_P (TYPE_NAME (gnu_type)))
+		  create_type_decl (TYPE_NAME (gnu_type), gnu_type, NULL, true,
+debug_info_p, gnat_entity);
+	  }
 	  }
 
 	/* If we are defining the object, see if it has a Size and validate it
@@ -865,16 +877,15 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 	if (Is_Constr_Subt_For_UN_Aliased (Etype (gnat_entity))
 	&& Is_Array_Type (Etype (gnat_entity))
 	&& !type_annotate_only)
-	{
-	  tree gnu_fat
-	= TREE_TYPE (gnat_to_gnu_type (Base_Type (Etype (gnat_entity;
-
-	  gnu_type
-	= build_unc_object_type_from_ptr (gnu_fat, gnu_type,
-	  concat_name (gnu_entity_name,
-			   "UNC"),
-	  debug_info_p);
-	}
+	  {
+	tree gnu_fat
+	  = TREE_TYPE (gnat_to_gnu_type (Base_Type (Etype (gnat_entity;
+	gnu_type
+	  = build_unc_object_type_from_ptr (gnu_fat, gnu_type,
+		concat_name (gnu_entity_name,
+			 "UNC"),
+		debug_info_p);
+	  }
 
 #ifdef MINIMUM_ATOMIC_ALIGNMENT
 	/* If the size is a constant and no alignment is specified, force
-- { dg-do compile }
-- { dg-options "-gnatws" }

with Array14_Pkg; use Array14_Pkg;

package body Array14 is

  package Nested is

Length : constant SSE.Storage_Count := Length2;

subtype Encoded_Index_Type is SSE.Storage_Count range 1 .. Length;
subtype Encoded_Type is SSE.Storage_Array (Encoded_Index_Type'Range);

procedure Encode (Input : in Integer; Output : out Encoded_Type);

  end;

  package body Nested is

procedure Encode (Input : in Integer; Output : out Encoded_Type) is
begin
  Encode2 (Input, Output);
end;

  end;

  procedure Init is
O : Nested.Encoded_Type;
for O'Alignment use 4;
  begin
null;
  end;

end Array14;
package Array14 is

  procedure Init;

end Array14;
with System.Storage_Elements;

package Array14_Pkg is

  package SSE renames System.Storage_Elements;

  function Parity_Byte_Count return SSE.Storage_Count;

  Length2 : constant SSE.Storage_Count := Parity_Byte_Count;

  subtype Encoded_Index_Type2 is SSE.Storage_Count range 1 .. Length2;
  subtype Encoded_Type2 is SSE.Storage_Array (Encoded_Index_Type2'Range);

  procedure Encode2 (Input : in Integer; Output : out Encoded_Type2);

end Array14_Pkg;


[Ada] Small gigi tweaks

2011-03-23 Thread Eric Botcazou
In preparation for a larger change.

Tested on i586-suse-linux, applied on the mainline.


2011-03-23  Eric Botcazou  

* gcc-interface/decl.c (validate_size): Improve comments and tweak
error message.
(set_rm_size): Likewise.


-- 
Eric Botcazou
Index: gcc-interface/decl.c
===
--- gcc-interface/decl.c	(revision 171342)
+++ gcc-interface/decl.c	(working copy)
@@ -7799,14 +7799,14 @@ build_variant_list (tree qual_union_type
 }
 
 /* UINT_SIZE is a Uint giving the specified size for an object of GNU_TYPE
-   corresponding to GNAT_OBJECT.  If size is valid, return a tree corresponding
-   to its value.  Otherwise return 0.  KIND is VAR_DECL is we are specifying
-   the size for an object, TYPE_DECL for the size of a type, and FIELD_DECL
-   for the size of a field.  COMPONENT_P is true if we are being called
-   to process the Component_Size of GNAT_OBJECT.  This is used for error
-   message handling and to indicate to use the object size of GNU_TYPE.
-   ZERO_OK is true if a size of zero is permitted; if ZERO_OK is false,
-   it means that a size of zero should be treated as an unspecified size.  */
+   corresponding to GNAT_OBJECT.  If the size is valid, return an INTEGER_CST
+   corresponding to its value.  Otherwise, return NULL_TREE.  KIND is set to
+   VAR_DECL if we are specifying the size of an object, TYPE_DECL for the
+   size of a type, and FIELD_DECL for the size of a field.  COMPONENT_P is
+   true if we are being called to process the Component_Size of GNAT_OBJECT;
+   this is used only for error messages.  ZERO_OK is true if a size of zero
+   is permitted; if ZERO_OK is false, it means that a size of zero should be
+   treated as an unspecified size.  */
 
 static tree
 validate_size (Uint uint_size, tree gnu_type, Entity_Id gnat_object,
@@ -7823,7 +7823,7 @@ validate_size (Uint uint_size, tree gnu_
   if (UI_Lt (uint_size, Uint_0))
 return NULL_TREE;
 
-  /* Find the node to use for errors.  */
+  /* Find the node to use for error messages.  */
   if ((Ekind (gnat_object) == E_Component
|| Ekind (gnat_object) == E_Discriminant)
   && Present (Component_Clause (gnat_object)))
@@ -7833,16 +7833,16 @@ validate_size (Uint uint_size, tree gnu_
   else
 gnat_error_node = gnat_object;
 
-  /* Get the size as a tree.  Issue an error if a size was specified but
- cannot be represented in sizetype.  */
+  /* Get the size as an INTEGER_CST.  Issue an error if a size was specified
+ but cannot be represented in bitsizetype.  */
   size = UI_To_gnu (uint_size, bitsizetype);
   if (TREE_OVERFLOW (size))
 {
   if (component_p)
-	post_error_ne ("component size of & is too large", gnat_error_node,
+	post_error_ne ("component size for& is too large", gnat_error_node,
 		   gnat_object);
   else
-	post_error_ne ("size of & is too large", gnat_error_node,
+	post_error_ne ("size for& is too large", gnat_error_node,
 		   gnat_object);
   return NULL_TREE;
 }
@@ -7865,15 +7865,15 @@ validate_size (Uint uint_size, tree gnu_
 }
 
   /* If this is an integral type or a packed array type, the front-end has
- verified the size, so we need not do it here (which would entail
+ already verified the size, so we need not do it here (which would mean
  checking against the bounds).  However, if this is an aliased object,
  it may not be smaller than the type of the object.  */
   if ((INTEGRAL_TYPE_P (gnu_type) || TYPE_IS_PACKED_ARRAY_TYPE_P (gnu_type))
   && !(kind == VAR_DECL && Is_Aliased (gnat_object)))
 return size;
 
-  /* If the object is a record that contains a template, add the size of
- the template to the specified size.  */
+  /* If the object is a record that contains a template, add the size of the
+ template to the specified size.  */
   if (TREE_CODE (gnu_type) == RECORD_TYPE
   && TYPE_CONTAINS_TEMPLATE_P (gnu_type))
 size = size_binop (PLUS_EXPR, DECL_SIZE (TYPE_FIELDS (gnu_type)), size);
@@ -7886,8 +7886,7 @@ validate_size (Uint uint_size, tree gnu_
   else
 type_size = rm_size (gnu_type);
 
-  /* Modify the size of the type to be that of the maximum size if it has a
- discriminant.  */
+  /* Modify the size of a discriminated type to be the maximum size.  */
   if (type_size && CONTAINS_PLACEHOLDER_P (type_size))
 type_size = max_size (type_size, true);
 
@@ -7901,8 +7900,8 @@ validate_size (Uint uint_size, tree gnu_
   type_size = bitsize_int (GET_MODE_BITSIZE (p_mode));
 }
 
-  /* If the size of the object is a constant, the new size must not be
- smaller.  */
+  /* Issue an error either if the default size of the object isn't a constant
+ or if the new size is smaller than it.  */
   if (TREE_CODE (type_size) != INTEGER_CST
   || TREE_OVERFLOW (type_size)
   || tree_int_cst_lt (size, type_size))
@@ -7915,15 +7914,14 @@ validate_size (Uint uint_size, tree gnu_
 	post_error_ne_tree

[Ada] Fix ICE on call returning variable-sized record type

2011-03-23 Thread Eric Botcazou
The gimplifier doesn't know how to create variable-sized temporaries so this 
needs to be done in gigi.  This case was missed by the machinery.  The patch 
is more than a mere fix as it overhauls the entire machinery.

Tested on i586-suse-linux, applied on the mainline.


2011-03-23  Eric Botcazou  

* gcc-interface/trans.c (create_temporary): New function taken from...
(create_init_temporary): ...here.  Call it.
(call_to_gnu): Create the temporary for the return value early, if any.
Create it for a function with copy-in/copy-out parameters if there is
no target; in other cases of copy-in/copy-out, use another temporary.
Push the new binding level lazily.  Add and rename local variables.


2011-03-23  Eric Botcazou  

* gnat.dg/discr26.ad[sb]: New test.
* gnat.dg/discr26_pkg.ads: New helper.


-- 
Eric Botcazou
Index: gcc-interface/trans.c
===
--- gcc-interface/trans.c	(revision 171210)
+++ gcc-interface/trans.c	(working copy)
@@ -2701,6 +2701,19 @@ Subprogram_Body_to_gnu (Node_Id gnat_nod
   mark_out_of_scope (Defining_Unit_Name (Specification (gnat_node)));
 }
 
+/* Create a temporary variable with PREFIX and TYPE, and return it.  */
+
+static tree
+create_temporary (const char *prefix, tree type)
+{
+  tree gnu_temp = create_var_decl (create_tmp_var_name (prefix), NULL_TREE,
+   type, NULL_TREE, false, false, false, false,
+   NULL, Empty);
+  DECL_ARTIFICIAL (gnu_temp) = 1;
+  DECL_IGNORED_P (gnu_temp) = 1;
+
+  return gnu_temp;
+}
 
 /* Create a temporary variable with PREFIX and initialize it with GNU_INIT.
Put the initialization statement into GNU_INIT_STMT and annotate it with
@@ -2710,11 +2723,7 @@ static tree
 create_init_temporary (const char *prefix, tree gnu_init, tree *gnu_init_stmt,
 		   Node_Id gnat_node)
 {
-  tree gnu_temp = create_var_decl (create_tmp_var_name (prefix), NULL_TREE,
-   TREE_TYPE (gnu_init), NULL_TREE, false,
-   false, false, false, NULL, Empty);
-  DECL_ARTIFICIAL (gnu_temp) = 1;
-  DECL_IGNORED_P (gnu_temp) = 1;
+  tree gnu_temp = create_temporary (prefix, TREE_TYPE (gnu_init));
 
   *gnu_init_stmt = build_binary_op (INIT_EXPR, NULL_TREE, gnu_temp, gnu_init);
   set_expr_location_from_node (*gnu_init_stmt, gnat_node);
@@ -2731,6 +2740,8 @@ create_init_temporary (const char *prefi
 static tree
 call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target)
 {
+  const bool function_call = (Nkind (gnat_node) == N_Function_Call);
+  const bool returning_value = (function_call && !gnu_target);
   /* The GCC node corresponding to the GNAT subprogram name.  This can either
  be a FUNCTION_DECL node if we are dealing with a standard subprogram call,
  or an indirect reference expression (an INDIRECT_REF node) pointing to a
@@ -2738,17 +2749,19 @@ call_to_gnu (Node_Id gnat_node, tree *gn
   tree gnu_subprog = gnat_to_gnu (Name (gnat_node));
   /* The FUNCTION_TYPE node giving the GCC type of the subprogram.  */
   tree gnu_subprog_type = TREE_TYPE (gnu_subprog);
+  /* The return type of the FUNCTION_TYPE.  */
+  tree gnu_result_type = TREE_TYPE (gnu_subprog_type);
   tree gnu_subprog_addr = build_unary_op (ADDR_EXPR, NULL_TREE, gnu_subprog);
-  Entity_Id gnat_formal;
-  Node_Id gnat_actual;
   VEC(tree,gc) *gnu_actual_vec = NULL;
   tree gnu_name_list = NULL_TREE;
-  tree gnu_before_list = NULL_TREE;
+  tree gnu_stmt_list = NULL_TREE;
   tree gnu_after_list = NULL_TREE;
+  tree gnu_retval = NULL_TREE;
   tree gnu_call, gnu_result;
-  bool returning_value = (Nkind (gnat_node) == N_Function_Call && !gnu_target);
-  bool pushed_binding_level = false;
   bool went_into_elab_proc = false;
+  bool pushed_binding_level = false;
+  Entity_Id gnat_formal;
+  Node_Id gnat_actual;
 
   gcc_assert (TREE_CODE (gnu_subprog_type) == FUNCTION_TYPE);
 
@@ -2766,8 +2779,8 @@ call_to_gnu (Node_Id gnat_node, tree *gn
 
   if (returning_value)
 	{
-	  *gnu_result_type_p = TREE_TYPE (gnu_subprog_type);
-	  return build1 (NULL_EXPR, TREE_TYPE (gnu_subprog_type), call_expr);
+	  *gnu_result_type_p = gnu_result_type;
+	  return build1 (NULL_EXPR, gnu_result_type, call_expr);
 	}
 
   return call_expr;
@@ -2785,28 +2798,28 @@ call_to_gnu (Node_Id gnat_node, tree *gn
   else
 gnat_formal = First_Formal_With_Extras (Entity (Name (gnat_node)));
 
-  /* If we are translating a statement, push a new binding level that will
- surround it to declare the temporaries created for the call.  Likewise
- if we'll be returning a value and also have copy-in/copy-out parameters,
- as we need to create statements to fetch their value after the call.
-
- ??? We could do that unconditionally, but the middle-end doesn't seem
- to be prepared to handle the construct in nested contexts.  */
-  if (!returning_value || TYPE_CI_CO_LIST (gnu_subprog_type))
-{
-  start_stmt_group ();
-  gnat_pushlevel ();
-  push

[Patch] Update bfin parts to latest silicon revisions

2011-03-23 Thread Henderson, Stuart
The attached patch adds support for (and changes defaults to) the latest 
silicon revisions for Blackfin parts.

2011-03-23  Stuart Henderson  

* config/bfin/bfin.c (bfin_cpus): Update silicon revisions.



I don't have write permissions.

Thanks,
Stu


upstream.patch
Description: upstream.patch


Re: [x32] PATCH: PR middle-end/47725: [x32] error: unable to find a register to spill in class DIREG

2011-03-23 Thread H.J. Lu
On Wed, Mar 23, 2011 at 1:22 AM, Eric Botcazou  wrote:
>> It is:
>>
>>       op0 = parmreg;
>>       op1 = validated_mem;
>>       if (icode != CODE_FOR_nothing
>>           && insn_data[icode].operand[0].predicate (op0,
>> promoted_nominal_mode) && insn_data[icode].operand[1].predicate (op1,
>> data->passed_mode)) {
>>           enum rtx_code code = unsignedp ? ZERO_EXTEND : SIGN_EXTEND;
>>           rtx insn, insns;
>>           HARD_REG_SET hardregs;
>>
>>           start_sequence ();
>>           insn = gen_extend_insn (op0, op1, promoted_nominal_mode,
>>                                   data->passed_mode, unsignedp);
>>           emit_insn (insn);
>>           insns = get_insns ();
>
> Sure, but why is need_conversion set to true?
>

Pointer is promoted to Pmode from ptr_mode.


-- 
H.J.
---
#0  promote_mode (type=0x70e05540, mode=SImode, punsignedp=0x7fffd76c)
at /export/gnu/import/git/gcc-x32/gcc/explow.c:808
#1  0x009ef004 in default_promote_function_mode (type=0x70e05540,
mode=SImode, punsignedp=0x7fffd76c, funtype=0x70cec3f0,
for_return=2) at /export/gnu/import/git/gcc-x32/gcc/targhooks.c:128
#2  0x006d7155 in promote_function_mode (type=0x70e05540,
mode=SImode, punsignedp=0x7fffd76c, funtype=0x70cec3f0,
for_return=2) at /export/gnu/import/git/gcc-x32/gcc/explow.c:774
#3  0x007cf7de in assign_parm_setup_reg (all=0x7fffda10,
parm=0x70dec880, data=0x7fffd980)
at /export/gnu/import/git/gcc-x32/gcc/function.c:2941


[Patch] Update bfin part tests to latest silicon revision

2011-03-23 Thread Henderson, Stuart
The attached testsuite patch updates the blackfin part macro tests to expect 
the latest silicon revision, as well as fixing up some duplication in the bf51x 
parts.

2011-03-23  Stuart Henderson  

* gcc.target/bfin/mcpu-bf542.c: Update to latest silicon revision.
* gcc.target/bfin/mcpu-bf544.c: Likewise.
* gcc.target/bfin/mcpu-bf547.c: Likewise.
* gcc.target/bfin/mcpu-bf548.c: Likewise.
* gcc.target/bfin/mcpu-bf549.c: Likewise.
* gcc.target/bfin/mcpu-bf512.c: Update to latest silicon revision and
remove duplication.
* gcc.target/bfin/mcpu-bf514.c: Likewise.
* gcc.target/bfin/mcpu-bf516.c: Likewise.
* gcc.target/bfin/mcpu-bf518.c: Likewise.



I don't have write permissions.

Thanks,
Stu


upstream.patch
Description: upstream.patch


[testsuite] Skip g++.dg/guality/guality.exp on Tru64 UNIX (PR testsuite/48251)

2011-03-23 Thread Rainer Orth
As reported in the PR, the timeout running the guality_check test in the
g++.dg/guality testsuite doesn't work on Tru64 UNIX V5.1B, which hangs
the complete bootstrap.  Until this is resolved, I'm disabling this
testsuite on alpha*-dec-osf*.

Tested with the appropriate runtest invocation, installed on mainline.
Will install on the 4.6 branch once it reopens.  The 4.5 branch is not
affected.

Rainer


2011-03-23  Rainer Orth  

PR testsuite/48251
* g++.dg/guality/guality.exp: Disable on alpha*-dec-osf*.

diff -r 95f7fe097816 gcc/testsuite/g++.dg/guality/guality.exp
--- a/gcc/testsuite/g++.dg/guality/guality.exp  Wed Mar 23 10:08:59 2011 +0100
+++ b/gcc/testsuite/g++.dg/guality/guality.exp  Wed Mar 23 12:50:49 2011 +0100
@@ -4,7 +4,8 @@
 load_lib gcc-gdb-test.exp
 
 # Disable on darwin until radr://7264615 is resolved.
-if { [istarget *-*-darwin*] } {
+# Disable on Tru64 UNIX (PR testsuite/48251).
+if { [istarget *-*-darwin*] || [istarget alpha*-dec-osf*] } {
   return
 }
 
-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


PING^2: PR 47551: ARM patch for Neon-related spill failure

2011-03-23 Thread Richard Sandiford
Second ping for this ARM-specific reload fix:

http://gcc.gnu.org/ml/gcc-patches/2011-01/msg02266.html

Thanks,
Richard


Re: [4.7] Avoid global state in s390_handle_option

2011-03-23 Thread Andreas Krebbel
Hi Joseph,

sorry for the late reply to your patch.  I would like to propose a few
changes as implemented with the attached patch:

- The options mapped to an enum type seem to always need an
  initialization value.  Otherwise there is a warning when compiling
  options.c:

error: enum conversion in initialization is invalid in C++ [-Werror=c++-compat]

- I've merged s390_arch_option and processor_type enums.  Both only
  differ for z9-ec which in turn is only relevant for the pipeline
  description. The patch adjusts the pipeline description accordingly.
  With that change several other things could be simplified.

- I've also fixed two more warning statements using
  HOST_WIDE_INT_PRINT_DEC.

Tested on s390x.

What do you think?

Bye,

-Andreas-


2011-03-23  Andreas Krebbel  

* config/s390/2084.md: Enable all insn reservations also for z9_ec
cpu attribute value.
* config/s390/s390-opts.h (enum s390_arch_option): Remove.
(enum processor_type): Add PROCESSOR_2094_Z9_EC.
* config/s390/s390.c (processor_flags_table): New constant array.
(s390_handle_arch_option): Remove.
(s390_handle_option): Remove s390_handle_arch_option invocations
and OPT_mwarn_framesize_ handling.
(s390_option_override): Remove s390_handle_arch_option invocation.
(s390_emit_prologue): Remove use of HOST_WIDE_INT_PRINT_DEC in
warnings.
* config/s390/s390.md (cpu attribute): Add z9_ec value.
* config/s390/s390.opt (s390_tune, s390_arch)
(march=): Replace s390_arch_option enum and values with
processor_type.  Set variable name to s390_arch.  Set
initialization value.
(mtune=): Replace s390_arch_option with processor_type.  Set
variable name to s390_tune.  Set initialization value.


Index: gcc/config/s390/2084.md
===
*** gcc/config/s390/2084.md.orig
--- gcc/config/s390/2084.md
***
*** 62,130 
  ;;
  
  (define_insn_reservation "x_int" 1
!   (and (eq_attr "cpu" "z990,z9_109")
 (and (eq_attr "type" "integer")
  (eq_attr "atype" "reg")))
"x-e1-st,x-wr-st")
  
  (define_insn_reservation "x_agen" 1
!   (and (eq_attr "cpu" "z990,z9_109")
 (and (eq_attr "type" "integer")
  (eq_attr "atype" "agen")))
"x-e1-st,x-wr-st")
  
  (define_insn_reservation "x_lr" 1
!   (and (eq_attr "cpu" "z990,z9_109")
 (eq_attr "type" "lr"))
"x-e1-st,x-wr-st")
  
  (define_insn_reservation "x_la" 1
!   (and (eq_attr "cpu" "z990,z9_109")
 (eq_attr "type" "la"))
"x-e1-st,x-wr-st")
  
  (define_insn_reservation "x_larl" 1
!   (and (eq_attr "cpu" "z990,z9_109")
 (eq_attr "type" "larl"))
"x-e1-st,x-wr-st")
  
  (define_insn_reservation "x_load" 1
!   (and (eq_attr "cpu" "z990,z9_109")
 (eq_attr "type" "load"))
"x-e1-st+x-mem,x-wr-st")
  
  (define_insn_reservation "x_store" 1
!   (and (eq_attr "cpu" "z990,z9_109")
 (eq_attr "type" "store"))
"x-e1-st+x_store_tok,x-wr-st")
  
  (define_insn_reservation "x_branch" 1
!   (and (eq_attr "cpu" "z990,z9_109")
 (eq_attr "type" "branch"))
"x_e1_r,x_wr_r")
  
  (define_insn_reservation "x_call" 5
!   (and (eq_attr "cpu" "z990,z9_109")
 (eq_attr "type" "jsr"))
"x-e1-np*5,x-wr-np")
  
  (define_insn_reservation "x_mul_hi" 2
!   (and (eq_attr "cpu" "z990,z9_109")
 (eq_attr "type" "imulhi"))
"x-e1-np*2,x-wr-np")
  
  (define_insn_reservation "x_mul_sidi" 4
!   (and (eq_attr "cpu" "z990,z9_109")
 (eq_attr "type" "imulsi,imuldi"))
"x-e1-np*4,x-wr-np")
  
  (define_insn_reservation "x_div" 10
!   (and (eq_attr "cpu" "z990,z9_109")
 (eq_attr "type" "idiv"))
"x-e1-np*10,x-wr-np")
  
  (define_insn_reservation "x_sem" 17
!   (and (eq_attr "cpu" "z990,z9_109")
 (eq_attr "type" "sem"))
"x-e1-np+x-mem,x-e1-np*16,x-wr-st")
  
--- 62,130 
  ;;
  
  (define_insn_reservation "x_int" 1
!   (and (eq_attr "cpu" "z990,z9_109,z9_ec")
 (and (eq_attr "type" "integer")
  (eq_attr "atype" "reg")))
"x-e1-st,x-wr-st")
  
  (define_insn_reservation "x_agen" 1
!   (and (eq_attr "cpu" "z990,z9_109,z9_ec")
 (and (eq_attr "type" "integer")
  (eq_attr "atype" "agen")))
"x-e1-st,x-wr-st")
  
  (define_insn_reservation "x_lr" 1
!   (and (eq_attr "cpu" "z990,z9_109,z9_ec")
 (eq_attr "type" "lr"))
"x-e1-st,x-wr-st")
  
  (define_insn_reservation "x_la" 1
!   (and (eq_attr "cpu" "z990,z9_109,z9_ec")
 (eq_attr "type" "la"))
"x-e1-st,x-wr-st")
  
  (define_insn_reservation "x_larl" 1
!   (and (eq_attr "cpu" "z990,z9_109,z9_ec")
 (eq_attr "type" "larl"))
"x-e1-st,x-wr-st")
  
  (define_insn_reservation "x_load" 1
!   (and (eq_attr "cpu" "z990,z9_109,z9_ec")
 (eq_attr "type" "load"))
"x-e1-st+x-mem,x-wr-st")
  
  (define_insn_reservation "x_store" 1
!   (and (eq_attr "cpu" "z990,z9

Re: [PATCH] Volatile bitfields vs. inline asm memory constraints

2011-03-23 Thread Julian Brown
On Wed, 9 Feb 2011 09:37:41 -0500
Diego Novillo  wrote:

> On Mon, Nov 22, 2010 at 08:28, Julian Brown 
> wrote:
> > Hi,
> >
> > This patch fixes the issue in the (Launchpad, not GCC) bug tracker:
> >
> > https://bugs.launchpad.net/gcc-linaro/+bug/675347
> >
> > The problem was introduced by the patch from DJ to honour volatile
> > bitfield types:
> >
> > http://gcc.gnu.org/ml/gcc-patches/2010-06/msg01167.html
> >
> > but not exposed (on ARM) until the option was made the default (on
> > the Linaro branch) -- it's not yet the default on mainline.
> >
> > The issue is as follows: after DJ's patch and with
> > -fstrict-volatile-bitfields, in expr.c:expand_expr_real_1, the if
> > condition with the comment "In cases where an aligned union has an
> > unaligned object as a field, we might be extracting a BLKmode value
> > from an integer-mode (e.g., SImode) object [...]" triggers for a
> > normal (non-bitfield) volatile field of a struct/class.
> >
> 
> Could you add a comment before the test to describe why you are
> excluding non-natural alignments?
> 
> OK with that change, though I think you'll have to stage this for 4.7.

I've committed this version now we're in stage 1. (I also re-tested it
for good measure, no regressions with cross to ARM Linux.)

Thanks,

Julian

ChangeLog

gcc/
* expr.c (expand_expr_real_1): Only use BLKmode for volatile
accesses which are not naturally aligned.
Index: gcc/expr.c
===
--- gcc/expr.c	(revision 171288)
+++ gcc/expr.c	(working copy)
@@ -9202,8 +9202,11 @@ expand_expr_real_1 (tree exp, rtx target
 		&& modifier != EXPAND_CONST_ADDRESS
 		&& modifier != EXPAND_INITIALIZER)
 	/* If the field is volatile, we always want an aligned
-	   access.  */
-	|| (volatilep && flag_strict_volatile_bitfields > 0)
+	   access.  Only do this if the access is not already naturally
+	   aligned, otherwise "normal" (non-bitfield) volatile fields
+	   become non-addressable.  */
+	|| (volatilep && flag_strict_volatile_bitfields > 0
+		&& (bitpos % GET_MODE_ALIGNMENT (mode) != 0))
 	/* If the field isn't aligned enough to fetch as a memref,
 	   fetch it as a bit field.  */
 	|| (mode1 != BLKmode


Re: [PATCH] sparc and alpha baseline_symbols.txt update

2011-03-23 Thread Benjamin Kosnik

> 2011-03-22  Matthias Klose  
> 
>   * config/abi/post/sparc-linux-gnu/baseline_symbols.txt:
> Regenerated.
> 
> 2011-03-22  Uros Bizjak  
> 
>   * config/abi/post/alpha-linux-gnu/baseline_symbols.txt:
> Regenerated.

Yay. Jakub I'm deferring to you on this, your analysis seems sound. The
consistency checks between arches is a positive sign

-benjamin


Re: [PATCH 2/2] refactor emit_*_{after,before}{,_setloc} using common functions

2011-03-23 Thread Nathan Froyd
On Tue, Mar 22, 2011 at 05:06:39PM -0700, Richard Henderson wrote:
> On 03/22/2011 04:13 PM, Nathan Froyd wrote:
> > rtx
> > emit_call_insn_before_setloc (rtx pattern, rtx before, int loc)
> > {
> >   ...
> >   if (pattern == NULL_RTX)
> > return last;
> > 
> >   first = NEXT_INSN (first);
> > 
> > The jump_insn and debug_insn variants have identical behavior to
> > call_insn.
> 
> AFAICT, the !loc test really ought to be loc != UNKNOWN_LOCATION,
> and ought to apply to all of the patterns.  This makes sense once
> you look at the test written canonically -- no point in searching
> for the list of insns if there's no location to set.

Did you mean loc == UNKNOWN_LOCATION?  Also, it looks like that's
conflating INSN_LOCATORs and location_ts; it seems like it'd be better
to keep them separate.

-Nathan



Re: [v3] Regenerate Solaris 2 baselines for GCC 4.6.0 release

2011-03-23 Thread Jakub Jelinek
On Wed, Mar 23, 2011 at 01:27:53PM +0100, Rainer Orth wrote:
> Ok for mainline (once testing has finished) and 4.6 branch now?

Looks ok to me, so if Benjamin is ok with it too...

> 2011-03-15  Rainer Orth  
> 
>   * config/abi/post/solaris2.8/baseline_symbols.txt: Regenerate.
>   * config/abi/post/solaris2.8/sparcv9/baseline_symbols.txt: Likewise.
>   * config/abi/post/solaris2.10/baseline_symbols.txt: Likewise.
>   * config/abi/post/solaris2.10/amd64/baseline_symbols.txt: Likewise.
>   * config/abi/post/solaris2.10/sparcv9/baseline_symbols.txt: Likewise.
> 

Jakub


Re: [libgo] Provide strerror_r replacement (PR go/47515)

2011-03-23 Thread Rainer Orth
Jakub Jelinek  writes:

> On Tue, Mar 22, 2011 at 06:41:25PM +0100, Rainer Orth wrote:
>> Apart from the lack of wait4, libgo on IRIX 6.5 contained an undefined
>> reference to strerror_r.  This patch provides a replacement, based on
>> gnulib/lib/strerror_r.c, but massively simplified.
>
> gnulib strerror_r.c is GPLv3+ licensed, you can't just relicense it
> as BSD.

>From my understanding, this is only an issue if the code is actually
copyrightable, i.e. the idea can reasonably expressed in different
ways.  I doubt that for the case at hand, but am not certain.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [4.7] Avoid global state in s390_handle_option

2011-03-23 Thread Joseph S. Myers
On Wed, 23 Mar 2011, Andreas Krebbel wrote:

> Hi Joseph,
> 
> sorry for the late reply to your patch.  I would like to propose a few
> changes as implemented with the attached patch:

These seem reasonable to me.

-- 
Joseph S. Myers
jos...@codesourcery.com


[PATCH] Fixup stdarg handling with &MEM_REF style pointer bumps

2011-03-23 Thread Richard Guenther

This fixes the fallout of executing forwprop after FRE which runs
before stdarg.  forwprop transforms series of pointer increments to
pointer increments of larger offset and uses &MEM[ptr + CST] as
canonical form for ptr + CST (the former is is_gimple_min_invariant).

Bootstrapped and tested on x86_64-unknown-linux-gnu together with
early FRE.  Now re-bootstrapping and testing w/o that.

I'm planning to commit this after that testing finished.

Thanks,
Richard.

2011-03-23  Richard Guenther  

* tree-stdarg.c (va_list_counter_bump): Handle bumps via
MEM_REF.
(check_va_list_escapes): Likewise.
(check_all_va_list_escapes): Likewise.

Index: gcc/tree-stdarg.c
===
*** gcc/tree-stdarg.c   (revision 171340)
--- gcc/tree-stdarg.c   (working copy)
*** va_list_counter_bump (struct stdarg_info
*** 133,138 
--- 133,139 
while (lhs)
  {
enum tree_code rhs_code;
+   tree rhs1;
  
if (si->offsets[SSA_NAME_VERSION (lhs)] != -1)
{
*** va_list_counter_bump (struct stdarg_info
*** 152,172 
return (unsigned HOST_WIDE_INT) -1;
  
rhs_code = gimple_assign_rhs_code (stmt);
if ((get_gimple_rhs_class (rhs_code) == GIMPLE_SINGLE_RHS
   || gimple_assign_cast_p (stmt))
! && TREE_CODE (gimple_assign_rhs1 (stmt)) == SSA_NAME)
{
! lhs = gimple_assign_rhs1 (stmt);
  continue;
}
  
if ((rhs_code == POINTER_PLUS_EXPR
   || rhs_code == PLUS_EXPR)
! && TREE_CODE (gimple_assign_rhs1 (stmt)) == SSA_NAME
  && host_integerp (gimple_assign_rhs2 (stmt), 1))
{
  ret += tree_low_cst (gimple_assign_rhs2 (stmt), 1);
! lhs = gimple_assign_rhs1 (stmt);
  continue;
}
  
--- 153,184 
return (unsigned HOST_WIDE_INT) -1;
  
rhs_code = gimple_assign_rhs_code (stmt);
+   rhs1 = gimple_assign_rhs1 (stmt);
if ((get_gimple_rhs_class (rhs_code) == GIMPLE_SINGLE_RHS
   || gimple_assign_cast_p (stmt))
! && TREE_CODE (rhs1) == SSA_NAME)
{
! lhs = rhs1;
  continue;
}
  
if ((rhs_code == POINTER_PLUS_EXPR
   || rhs_code == PLUS_EXPR)
! && TREE_CODE (rhs1) == SSA_NAME
  && host_integerp (gimple_assign_rhs2 (stmt), 1))
{
  ret += tree_low_cst (gimple_assign_rhs2 (stmt), 1);
! lhs = rhs1;
! continue;
!   }
! 
!   if (rhs_code == ADDR_EXPR 
! && TREE_CODE (TREE_OPERAND (rhs1, 0)) == MEM_REF
! && TREE_CODE (TREE_OPERAND (TREE_OPERAND (rhs1, 0), 0)) == SSA_NAME
! && host_integerp (TREE_OPERAND (TREE_OPERAND (rhs1, 0), 1), 1))
!   {
! ret += tree_low_cst (TREE_OPERAND (TREE_OPERAND (rhs1, 0), 1), 1);
! lhs = TREE_OPERAND (TREE_OPERAND (rhs1, 0), 0);
  continue;
}
  
*** va_list_counter_bump (struct stdarg_info
*** 195,200 
--- 207,213 
while (lhs)
  {
enum tree_code rhs_code;
+   tree rhs1;
  
if (si->offsets[SSA_NAME_VERSION (lhs)] != -1)
break;
*** va_list_counter_bump (struct stdarg_info
*** 207,227 
stmt = SSA_NAME_DEF_STMT (lhs);
  
rhs_code = gimple_assign_rhs_code (stmt);
if ((get_gimple_rhs_class (rhs_code) == GIMPLE_SINGLE_RHS
   || gimple_assign_cast_p (stmt))
! && TREE_CODE (gimple_assign_rhs1 (stmt)) == SSA_NAME)
{
! lhs = gimple_assign_rhs1 (stmt);
  continue;
}
  
if ((rhs_code == POINTER_PLUS_EXPR
   || rhs_code == PLUS_EXPR)
! && TREE_CODE (gimple_assign_rhs1 (stmt)) == SSA_NAME
  && host_integerp (gimple_assign_rhs2 (stmt), 1))
{
  val -= tree_low_cst (gimple_assign_rhs2 (stmt), 1);
! lhs = gimple_assign_rhs1 (stmt);
  continue;
}
  
--- 220,251 
stmt = SSA_NAME_DEF_STMT (lhs);
  
rhs_code = gimple_assign_rhs_code (stmt);
+   rhs1 = gimple_assign_rhs1 (stmt);
if ((get_gimple_rhs_class (rhs_code) == GIMPLE_SINGLE_RHS
   || gimple_assign_cast_p (stmt))
! && TREE_CODE (rhs1) == SSA_NAME)
{
! lhs = rhs1;
  continue;
}
  
if ((rhs_code == POINTER_PLUS_EXPR
   || rhs_code == PLUS_EXPR)
! && TREE_CODE (rhs1) == SSA_NAME
  && host_integerp (gimple_assign_rhs2 (stmt), 1))
{
  val -= tree_low_cst (gimple_assign_rhs2 (stmt), 1);
! lhs = rhs1;
! continue;
!   }
! 
!   if (rhs_code == ADDR_EXPR 
! && TREE_CODE (TREE_OPERAND (rhs1, 0)) == MEM_REF
! && TREE_CODE (TREE_OPERAND (TREE_OPERAND (rhs1, 0), 0)) == SSA_NAME
! && host_integerp (TREE_OPERAND (TREE_OPERAND (rhs1, 0), 1), 1))
!   {
! val -= tree_low_cst (TREE_OPERAND (TREE_OPERAND (rhs1, 0), 1), 1);
! 

[PATCH] Remove ipa-struct-reorg and ipa-type-escape

2011-03-23 Thread Richard Guenther

IPA struct reorg has been un-enableable on the 4.6 branch for half
a year now.  This completes this disabling by removing it and
IPA type escape analysis which it is the only remaining user of.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Richard.

2011-03-23  Richard Guenther  

* Makefile.in (IPA_TYPE_ESCAPE_H): Remove.
(OBJS-archive): Remove ipa-struct-reorg.o and ipa-type-escape.o.
(tree-ssa-alias.o): Do not depend on IPA_TYPE_ESCAPE_H.
(alias.o): Likewise.
(ipa-type-escape.o): Remove.
(ipa-struct-reorg.o): Likewise.
(GTFILES): Remove ipa-struct-reorg.c.
* alias.c: Do not include ipa-type-escape.h.
* tree-ssa-alias.c: Likewise.
* common.opt (fipa-struct-reorg): Preserve for backward compatibility.
* opts.c (finish_options): Do not reset flag_ipa_struct_reorg.
* passes.c (init_optimization_passes): Remove ipa-struct-reorg
and ipa-type-escape passes.
* tree-pass.h (pass_ipa_type_escape): Remove.
(pass_ipa_struct_reorg): Likewise.
* ipa-struct-reorg.h: Remove.
* ipa-struct-reorg.c: Likewise.
* ipa-type-escape.h: Likewise.
* ipa-type-escape.c: Likewise.

* gcc.dg/struct: Remove directory and contents.

Index: trunk/gcc/Makefile.in
===
*** trunk.orig/gcc/Makefile.in  2011-03-22 13:33:17.0 +0100
--- trunk/gcc/Makefile.in   2011-03-23 14:17:15.0 +0100
*** CFGLOOP_H = cfgloop.h $(BASIC_BLOCK_H) $
*** 921,927 
$(BITMAP_H) sbitmap.h
  IPA_UTILS_H = ipa-utils.h $(TREE_H) $(CGRAPH_H)
  IPA_REFERENCE_H = ipa-reference.h $(BITMAP_H) $(TREE_H)
- IPA_TYPE_ESCAPE_H = ipa-type-escape.h $(TREE_H)
  CGRAPH_H = cgraph.h $(VEC_H) $(TREE_H) $(BASIC_BLOCK_H) $(FUNCTION_H) \
cif-code.def ipa-ref.h ipa-ref-inline.h $(LINKER_PLUGIN_API_H)
  DF_H = df.h $(BITMAP_H) $(REGSET_H) sbitmap.h $(BASIC_BLOCK_H) \
--- 921,926 
*** OBJS-archive = \
*** 1467,1474 
ipa-pure-const.o \
ipa-reference.o \
ipa-ref.o \
-   ipa-struct-reorg.o \
-   ipa-type-escape.o \
ipa-utils.o \
ipa.o \
matrix-reorg.o \
--- 1466,1471 
*** tree-ssa-alias.o : tree-ssa-alias.c $(TR
*** 2612,2618 
 $(FUNCTION_H) $(TIMEVAR_H) convert.h $(TM_H) coretypes.h langhooks.h \
 $(TREE_DUMP_H) $(TREE_PASS_H) $(PARAMS_H) $(BASIC_BLOCK_H) $(DIAGNOSTIC_H) 
\
 $(GIMPLE_H) $(VEC_H) $(TARGET_H) \
!$(IPA_TYPE_ESCAPE_H) vecprim.h pointer-set.h alloc-pool.h \
 tree-pretty-print.h
  tree-ssa-reassoc.o : tree-ssa-reassoc.c $(TREE_FLOW_H) $(CONFIG_H) \
 $(SYSTEM_H) $(TREE_H) $(DIAGNOSTIC_H) $(TIMEVAR_H) \
--- 2609,2615 
 $(FUNCTION_H) $(TIMEVAR_H) convert.h $(TM_H) coretypes.h langhooks.h \
 $(TREE_DUMP_H) $(TREE_PASS_H) $(PARAMS_H) $(BASIC_BLOCK_H) $(DIAGNOSTIC_H) 
\
 $(GIMPLE_H) $(VEC_H) $(TARGET_H) \
!vecprim.h pointer-set.h alloc-pool.h \
 tree-pretty-print.h
  tree-ssa-reassoc.o : tree-ssa-reassoc.c $(TREE_FLOW_H) $(CONFIG_H) \
 $(SYSTEM_H) $(TREE_H) $(DIAGNOSTIC_H) $(TIMEVAR_H) \
*** ipa-pure-const.o : ipa-pure-const.c $(CO
*** 3034,3052 
 $(GIMPLE_H) $(CGRAPH_H) output.h $(FLAGS_H) $(TREE_PASS_H) $(TIMEVAR_H) \
 $(DIAGNOSTIC_H) $(CFGLOOP_H) $(SCEV_H) $(LTO_STREAMER_H) \
 gimple-pretty-print.h
- ipa-type-escape.o : ipa-type-escape.c $(CONFIG_H) $(SYSTEM_H) \
-coretypes.h $(TM_H) $(TREE_H) $(TREE_FLOW_H) $(TREE_INLINE_H) langhooks.h \
-pointer-set.h $(GGC_H) $(IPA_TYPE_ESCAPE_H) $(IPA_UTILS_H) $(SPLAY_TREE_H) 
\
-$(GIMPLE_H) $(CGRAPH_H) output.h $(FLAGS_H) $(TREE_PASS_H) \
-$(TIMEVAR_H) $(DIAGNOSTIC_H) $(FUNCTION_H) tree-pretty-print.h
- ipa-struct-reorg.o: ipa-struct-reorg.c ipa-struct-reorg.h $(CONFIG_H) 
$(SYSTEM_H) \
-coretypes.h $(TM_H) $(GGC_H) $(TREE_H) $(RTL_H) $(GIMPLE_H) tree-inline.h \
-$(TREE_FLOW_H) langhooks.h pointer-set.h $(HASHTAB_H) $(DIAGNOSTIC_CORE_H) 
\
-$(FLAGS_H) debug.h $(TARGET_H) $(CGRAPH_H) $(DIAGNOSTIC_H) $(TIMEVAR_H) \
-$(PARAMS_H) $(FIBHEAP_H) intl.h $(FUNCTION_H) $(BASIC_BLOCK_H) 
tree-iterator.h \
-$(TREE_PASS_H) $(OPTS_H) $(IPA_TYPE_ESCAPE_H) $(TREE_DUMP_H) \
-$(GIMPLE_H) tree-pretty-print.h gimple-pretty-print.h
- 
  coverage.o : coverage.c $(GCOV_IO_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h \
 $(TM_H) $(RTL_H) $(TREE_H) $(FLAGS_H) output.h $(REGS_H) $(EXPR_H) \
 $(FUNCTION_H) $(BASIC_BLOCK_H) toplev.h $(DIAGNOSTIC_CORE_H) $(GGC_H) 
langhooks.h $(COVERAGE_H) \
--- 3031,3036 
*** alias.o : alias.c $(CONFIG_H) $(SYSTEM_H
*** 3303,3309 
 $(FLAGS_H) hard-reg-set.h $(BASIC_BLOCK_H) $(REGS_H) $(DIAGNOSTIC_CORE_H) 
output.h \
 $(ALIAS_H) $(EMIT_RTL_H) $(GGC_H) $(FUNCTION_H) cselib.h $(TREE_H) 
$(TM_P_H) \
 langhooks.h $(TARGET_H) gt-alias.h $(TIMEVAR_H) $(CGRAPH_H) \
!$(SPLAY_TREE_H) $(IPA_TYPE_ESCAPE_H) $(DF_H) $(TR

Re: [libgo] Provide strerror_r replacement (PR go/47515)

2011-03-23 Thread Ian Lance Taylor
Rainer Orth  writes:

> Jakub Jelinek  writes:
>
>> On Tue, Mar 22, 2011 at 06:41:25PM +0100, Rainer Orth wrote:
>>> Apart from the lack of wait4, libgo on IRIX 6.5 contained an undefined
>>> reference to strerror_r.  This patch provides a replacement, based on
>>> gnulib/lib/strerror_r.c, but massively simplified.
>>
>> gnulib strerror_r.c is GPLv3+ licensed, you can't just relicense it
>> as BSD.
>
>>From my understanding, this is only an issue if the code is actually
> copyrightable, i.e. the idea can reasonably expressed in different
> ways.  I doubt that for the case at hand, but am not certain.

I think we should just have Go code that calls strerror anyhow.  There's
no reason to drop into C here.  I'll get to that at some point if nobody
else does.

Ian


Re: [libgo] Provide strerror_r replacement (PR go/47515)

2011-03-23 Thread Rainer Orth
Ian Lance Taylor  writes:

> I think we should just have Go code that calls strerror anyhow.  There's
> no reason to drop into C here.  I'll get to that at some point if nobody
> else does.

Fine with me.  I've just noticed that not only IRIX 6.5 is affected, but
Solaris 8 and 9, too.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: PATCH: PR other/48007: Unwind library doesn't work with UNITS_PER_WORD > sizeof (void *)

2011-03-23 Thread Ian Lance Taylor
"H.J. Lu"  writes:

> On Tue, Mar 22, 2011 at 9:52 PM, Ian Lance Taylor  wrote:
>> "H.J. Lu"  writes:
>>
 This suggests that, at least, when sizeof(_Unwind_Word) > sizeof(void*),
 we need to extend _Unwind_Context with a new array at the end, and use
 that new array when by_value[REG] is true.
>>>
>>> Will there be a case where 2 copies of unwind-dw2.c are within the same
>>> process?
>>
>> Sure, that's easy.  I think what you are really asking is: will there be
>> a case where we could call functions from one copy and then pass the
>> context to the functions from a different copy.  I don't know the answer
>> to that, but it doesn't seem impossible.
>>
>
> Then. will this be acceptable?

It's an interesting idea, but following this approach I think we clearly
want UNWIND_REGISTER_AS_UNION to be defined for any target for which
sizeof (_Unwind_Word) > sizeof (void *).  There is no reason to design a
system which will break for any such target.

Also, N32 is apparently broken right now if anybody adds some
hand-written CFI of the right sort, and this approach does not fix it.

Does anybody know of any existing target for which sizeof (_Unwind_Word)
> sizeof (void *) other than MIPS N32?

Do the MIPS maintainers have any opinion on whether we can theoretically
break the N32 exception handling ABI?  The only potential problem I've
been able to construct is a shared library linked against libgcc_eh.a
with -Bsymbolic which tries to unwind an exception through the
executable.  This is an unlikely scenario as we normally tell everybody
to link against libgcc_s.so.

Ian


[PATCH] Add FRE pass to the early optimization pipeline

2011-03-23 Thread Richard Guenther

For quite some releases we'd wanted some (memory) CSE optimization
during early opts.  Currently we rely heavily on SRA which doesn't
always fulfill the "make code only smaller" promises which is
what early opts should do to improve precision of function size
estimates and to improve abstraction removal by early inlining.

Thus, this patch finally adds an early FRE pass at a suitable place.

The patch was sitting on pretty-ipa branch for some while now
and there were no noticeable issues with it there.

The patch disables FRE for the matrix-reorg testsuite - the
matrix reorg implementation is incredibly fragile with respect
to IL matching.  It also isn't useful anymore as it relies on
-fwhole-program but isn't prepared to work together with LTO,
so it at most works on single translation-unit units.  There is
no sign of anyone maintaining this code, but eventual removal
similar to struct-reorg should be handled separately from this patch.

Bootstrapped and tested on x86_64-unknown-linux-gnu (with the stdarg
patch applied).

Richard.

2011-02-23  Richard Guenther  

* passes.c (init_optimization_passes): Add FRE pass after
early SRA.

* gcc.dg/matrix/matrix.exp: Disable FRE.

Index: gcc/passes.c
===
*** gcc/passes.c.orig   2011-03-23 14:52:09.0 +0100
--- gcc/passes.c2011-03-23 14:55:34.0 +0100
*** init_optimization_passes (void)
*** 762,767 
--- 762,768 
 locals into SSA form if possible.  */
  NEXT_PASS (pass_build_ealias);
  NEXT_PASS (pass_sra_early);
+ NEXT_PASS (pass_fre);
  NEXT_PASS (pass_copy_prop);
  NEXT_PASS (pass_merge_phi);
  NEXT_PASS (pass_cd_dce);
Index: gcc/testsuite/gcc.dg/matrix/matrix.exp
===
*** gcc/testsuite/gcc.dg/matrix/matrix.exp.orig 2011-01-10 12:29:56.0 
+0100
--- gcc/testsuite/gcc.dg/matrix/matrix.exp  2011-03-23 15:08:04.0 
+0100
***
*** 20,26 
  load_lib gcc-dg.exp
  load_lib target-supports.exp
  
! set DEFAULT_MATCFLAGS "-O3 -fipa-matrix-reorg -fdump-ipa-matrix-reorg 
-fwhole-program"
  
  # Initialize `dg'.
  dg-init
--- 20,26 
  load_lib gcc-dg.exp
  load_lib target-supports.exp
  
! set DEFAULT_MATCFLAGS "-O3 -fipa-matrix-reorg -fdump-ipa-matrix-reorg 
-fwhole-program -fno-tree-fre"
  
  # Initialize `dg'.
  dg-init
*** load_lib profopt.exp
*** 52,59 
  # These are globals used by profopt-execute.  The first is options
  # needed to generate profile data, the second is options to use the
  # profile data.
! set profile_option "-fprofile-generate -O3"
! set feedback_option "-fprofile-use -fipa-matrix-reorg -fdump-ipa-matrix-reorg 
-O3 -fwhole-program"
  
  foreach src [lsort [glob -nocomplain $srcdir/$subdir/transpose-*.c]] {
  # If we're only testing specific files and this isn't one of them, skip 
it.
--- 52,59 
  # These are globals used by profopt-execute.  The first is options
  # needed to generate profile data, the second is options to use the
  # profile data.
! set profile_option "-fprofile-generate -O3 -fno-tree-fre"
! set feedback_option "-fprofile-use -fipa-matrix-reorg -fdump-ipa-matrix-reorg 
-O3 -fwhole-program -fno-tree-fre"
  
  foreach src [lsort [glob -nocomplain $srcdir/$subdir/transpose-*.c]] {
  # If we're only testing specific files and this isn't one of them, skip 
it.

2011-02-23  Richard Guenther  
 
* gcc.dg/torture/pta-structcopy-1.c: Scan ealias dump, force
foo to be inlined even at -O1.
* gcc.dg/tree-ssa/ssa-dce-4.c: Disable FRE.
* gcc.dg/ipa/ipa-pta-14.c: Likewise.
* gcc.dg/tree-ssa/ssa-fre-1.c: Adjust.

Index: gcc/testsuite/gcc.dg/torture/pta-structcopy-1.c
===
--- gcc/testsuite/gcc.dg/torture/pta-structcopy-1.c (revision 170404)
+++ gcc/testsuite/gcc.dg/torture/pta-structcopy-1.c (revision 170405)
@@ -1,5 +1,5 @@
 /* { dg-do run } */
-/* { dg-options "-fno-tree-sra -fdump-tree-alias" } */
+/* { dg-options "-fdump-tree-ealias" } */
 /* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
 
 struct X
@@ -12,10 +12,11 @@ struct X
 } y;
 };
 int i;
-static int
+static int __attribute__((always_inline))
 foo (struct X *x)
 {
   struct Y y = x->y;
+  /* In the inlined instance the dereferenced pointer needs to point to i.  */
   *y.p = 0;
   i = 1;
   return *y.p;
@@ -30,5 +31,5 @@ int main()
   return 0;
 }
 
-/* { dg-final { scan-tree-dump "points-to vars: { i }" "alias" } } */
-/* { dg-final { cleanup-tree-dump "alias" } } */
+/* { dg-final { scan-tree-dump "points-to vars: { i }" "ealias" } } */
+/* { dg-final { cleanup-tree-dump "ealias" } } */
Index: gcc/testsuite/gcc.dg/tree-ssa/ssa-dce-4.c
===
--- gcc/testsuite/gcc.dg/tree-ssa/ssa-dce-4.c   (revisio

Re: Fix a few use-after-free issues

2011-03-23 Thread Jeff Law
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 03/21/11 11:50, Jakub Jelinek wrote:
> On Mon, Mar 21, 2011 at 11:37:16AM -0600, Jeff Law wrote:
>> Similarly for redirect_edge_succ_nodup in this fragment:
>>
>> ret = redirect_edge_succ_nodup (e, dest);
>> if (dump_file)
>>  fprintf (dump_file, "Fallthru edge %i->%i redirected to %i\n",
>>   e->src->index, e->dest->index, dest->index);
>>   }
>> Luckily in this case the use-after-free only occurs when dumping, so it
>> won't typically affect end users.
> 
> Well, the message is wrong anyway, becase e->dest->index will be
> dest->index (with the exception that e has been remove_edge, but then it is
> the use after free).  Guess the message should be printed before the
> redirect_edge_succ_nodup call, or remember e->dest->index in some local
> variable and print that variable after the call.
Yea, I'll just move the message before the call to
redirecT_edge_succ_nodup.

jeff
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNigLtAAoJEBRtltQi2kC7uDUH/ReumZW8xHR6cPVhSnVzoqn4
Ft0Ot84ADY/1n31Hw+b3T4XIEUNu3yr2PX8LCo+wbS8/fsWv6AEzSvAlJH3wgO06
RQOyf9+8fskDFCQWiGNXqJKdZXSUeFo4MwPfypjH699phx2QegarR+vEjhIlbUvu
qDOSwdh1K7YsRB670ktwwvzOmDgLXoyL4KW3V6SzNTlyII8/VvlML+izOF/kwxMG
WuiQCljCZCoUnAkrYfs4kyTTLnYKYr3734B1YxvI9KyIq4gEkMAXMSTYV+TZBz9Q
38xjBu5cPoZwN+cez8j1Uq4gXYhMsQ3aE5WNSVgQ+rkToYQUywpqRDH4Y8vjnTo=
=rCaO
-END PGP SIGNATURE-


Shrink-wrapping: Introduction

2011-03-23 Thread Bernd Schmidt
I'll be posting a series of patches that add an implementation of
shrink-wrapping to gcc. I've used the algorithm in Muchnick's book as a
guideline, but ended up with an implementation that is somewhat more
conservative.

One of my goals was to reuse the existing prologue/epilogue
infrastructure as much as possible so that it is relatively easy to add
shrink-wrapping capability to a new port, rather than having to rewrite
prologue/epilogue generation for each. This implies that we still only
generate one prologue per function, rather than saving individual
registers at exactly the location where it becomes necessary. Still,
this is good enough to detect and optimize many early-exit cases.

There's a new comment at the top of thread_prologue_and_epilogue_insns
which describes the algorithm in some detail.

For now, the targets that can make use of this are ARM, MIPS and i386.
This turned out to be a fortunate choice, as these cover a large range
of situations. ARM has conditional return instructions, and requires a
distinction between return (which may pop lots of registers) and
simple_return (which just branches). MIPS has delay slots, so making it
work required fixing up reorg.c for the JUMP_LABEL changes.

One of the nastiest problems I ran into is that various RTL-level CFG
functions interpret a branch target of NULL to be the exit block, and
create branches using "return". This needed surgery to distinguish
between return and simple_return exits. JUMP_LABEL is now set and
maintained for return jumps.

A possible future enhancement is to add a targetm.gen_epilogue hook,
rather than using instruction patterns, and use that to pass information
about the set of registers that need to be saved. Epilogues for
tail-calls can be generated in multiple places, and it isn't always
necessary to restore the entire set of registers.

The patch has been in our local tree as well as the Linaro gcc tree for
a while now. That hasn't entirely been without pain, but most of the
issues we had should be ironed out by now. For this submission, I've
rested the patch (in some cases slightly earlier versions) on arm-linux,
mips64-elf and i686-linux (the latter including bootstraps).


Bernd


[Patch][AVR]: Use define_c_enum where appropriate

2011-03-23 Thread Georg-Johann Lay
Use define_c_enum instead of magic numbers to get unspec resp.
unspec_volatile constants.

2011-03-23  Georg-Johann Lay  

* config/avr/avr.md (define_constants): Move UNSPEC_*
resp. UNSPECV_* defines to...
(define_c_enum "unspec") ...this new enum resp. ...
(define_c_enum "unspecv") ...this new enum.
Index: config/avr/avr.md
===
--- config/avr/avr.md	(Revision 171340)
+++ config/avr/avr.md	(Arbeitskopie)
@@ -35,10 +35,6 @@
 ;;  ~  Output 'r' if not AVR_HAVE_JMP_CALL.
 ;;  !  Output 'e' if AVR_HAVE_EIJMP_EICALL.
 
-;; UNSPEC usage:
-;;  0  Length of a string, see "strlenhi".
-;;  1  Jump by register pair Z or by table addressed by Z, see "casesi".
-
 (define_constants
   [(REG_X	26)
(REG_Y	28)
@@ -50,17 +46,22 @@ (define_constants

(SREG_ADDR   0x5F)
(RAMPZ_ADDR  0x5B)
-   
-   (UNSPEC_STRLEN	0)
-   (UNSPEC_INDEX_JMP	1)
-   (UNSPEC_SEI		2)
-   (UNSPEC_CLI		3)
+   ])
+
+(define_c_enum "unspec"
+  [UNSPEC_STRLEN
+   UNSPEC_INDEX_JMP
+   UNSPEC_SEI
+   UNSPEC_CLI
+   ])
 
-   (UNSPECV_PROLOGUE_SAVES	0)
-   (UNSPECV_EPILOGUE_RESTORES	1)
-   (UNSPECV_WRITE_SP_IRQ_ON	2)
-   (UNSPECV_WRITE_SP_IRQ_OFF	3)
-   (UNSPECV_GOTO_RECEIVER	4)])
+(define_c_enum "unspecv"
+  [UNSPECV_PROLOGUE_SAVES
+   UNSPECV_EPILOGUE_RESTORES
+   UNSPECV_WRITE_SP_IRQ_ON
+   UNSPECV_WRITE_SP_IRQ_OFF
+   UNSPECV_GOTO_RECEIVER
+   ])
 
 (include "predicates.md")
 (include "constraints.md")


[PATCH 1/6] Disallow predicating the prologue

2011-03-23 Thread Bernd Schmidt
With prologues appearing in blocks other than the entry block, ifcvt can
decide to predicate them. This is not a good idea, as dwarf2out will
blow up trying to handle predicated frame-related things.


Bernd
* ifcvt.c (cond_exec_process_insns): Disallow converting a block
that contains the prologue.

* gcc.c-torture/compile/20110322-1.c: New test.

Index: gcc/ifcvt.c
===
--- gcc.orig/ifcvt.c
+++ gcc/ifcvt.c
@@ -304,6 +304,10 @@ cond_exec_process_insns (ce_if_block_t *
 
   for (insn = start; ; insn = NEXT_INSN (insn))
 {
+  /* dwarf2out can't cope with conditional prologues.  */
+  if (NOTE_P (insn) && NOTE_KIND (insn) == NOTE_INSN_PROLOGUE_END)
+   return FALSE;
+
   if (NOTE_P (insn) || DEBUG_INSN_P (insn))
goto insn_done;
 
Index: gcc/testsuite/gcc.c-torture/compile/20110322-1.c
===
--- /dev/null
+++ gcc/testsuite/gcc.c-torture/compile/20110322-1.c
@@ -0,0 +1,22 @@
+void asn1_length_der (unsigned long int len, unsigned char *ans, int *ans_len)
+{
+int k;
+unsigned char temp[4];
+if (len < 128) {
+   if (ans != ((void *) 0))
+   ans[0] = (unsigned char) len;
+   *ans_len = 1;
+} else {
+   k = 0;
+   while (len) {
+   temp[k++] = len & 0xFF;
+   len = len >> 8;
+   }
+   *ans_len = k + 1;
+   if (ans != ((void *) 0)) {
+   ans[0] = ((unsigned char) k & 0x7F) + 128;
+   while (k--)
+   ans[*ans_len - 1 - k] = temp[k];
+   }
+}
+}


Re: [PATCH] Remove ipa-struct-reorg and ipa-type-escape

2011-03-23 Thread Richard Guenther
On Wed, 23 Mar 2011, Richard Guenther wrote:

> 
> IPA struct reorg has been un-enableable on the 4.6 branch for half
> a year now.  This completes this disabling by removing it and
> IPA type escape analysis which it is the only remaining user of.
> 
> Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Forgot about documentation, params and timevars.

Committed.

Richard.

2011-03-23  Richard Guenther  

* Makefile.in (IPA_TYPE_ESCAPE_H): Remove.
(OBJS-archive): Remove ipa-struct-reorg.o and ipa-type-escape.o.
(tree-ssa-alias.o): Do not depend on IPA_TYPE_ESCAPE_H.
(alias.o): Likewise.
(ipa-type-escape.o): Remove.
(ipa-struct-reorg.o): Likewise.
(GTFILES): Remove ipa-struct-reorg.c.
* alias.c: Do not include ipa-type-escape.h.
* tree-ssa-alias.c: Likewise.
* common.opt (fipa-struct-reorg): Preserve for backward compatibility.
* opts.c (finish_options): Do not reset flag_ipa_struct_reorg.
* passes.c (init_optimization_passes): Remove ipa-struct-reorg
and ipa-type-escape passes.
* tree-pass.h (pass_ipa_type_escape): Remove.
(pass_ipa_struct_reorg): Likewise.
* ipa-struct-reorg.h: Remove.
* ipa-struct-reorg.c: Likewise.
* ipa-type-escape.h: Likewise.
* ipa-type-escape.c: Likewise.
* doc/invoke.texi (-fipa-struct-reorg): Remove.
(--param struct-reorg-cold-struct-ratio): Likewise.
* params.def (PARAM_STRUCT_REORG_COLD_STRUCT_RATIO): Likewise.
* params.h (STRUCT_REORG_COLD_STRUCT_RATIO): Likewise.
* timevar.def (TV_IPA_TYPE_ESCAPE): Likewise.

* gcc.dg/struct: Remove directory and contents.

Index: trunk/gcc/Makefile.in
===
*** trunk.orig/gcc/Makefile.in  2011-03-22 13:33:17.0 +0100
--- trunk/gcc/Makefile.in   2011-03-23 14:17:15.0 +0100
*** CFGLOOP_H = cfgloop.h $(BASIC_BLOCK_H) $
*** 921,927 
$(BITMAP_H) sbitmap.h
  IPA_UTILS_H = ipa-utils.h $(TREE_H) $(CGRAPH_H)
  IPA_REFERENCE_H = ipa-reference.h $(BITMAP_H) $(TREE_H)
- IPA_TYPE_ESCAPE_H = ipa-type-escape.h $(TREE_H)
  CGRAPH_H = cgraph.h $(VEC_H) $(TREE_H) $(BASIC_BLOCK_H) $(FUNCTION_H) \
cif-code.def ipa-ref.h ipa-ref-inline.h $(LINKER_PLUGIN_API_H)
  DF_H = df.h $(BITMAP_H) $(REGSET_H) sbitmap.h $(BASIC_BLOCK_H) \
--- 921,926 
*** OBJS-archive = \
*** 1467,1474 
ipa-pure-const.o \
ipa-reference.o \
ipa-ref.o \
-   ipa-struct-reorg.o \
-   ipa-type-escape.o \
ipa-utils.o \
ipa.o \
matrix-reorg.o \
--- 1466,1471 
*** tree-ssa-alias.o : tree-ssa-alias.c $(TR
*** 2612,2618 
 $(FUNCTION_H) $(TIMEVAR_H) convert.h $(TM_H) coretypes.h langhooks.h \
 $(TREE_DUMP_H) $(TREE_PASS_H) $(PARAMS_H) $(BASIC_BLOCK_H) $(DIAGNOSTIC_H) 
\
 $(GIMPLE_H) $(VEC_H) $(TARGET_H) \
!$(IPA_TYPE_ESCAPE_H) vecprim.h pointer-set.h alloc-pool.h \
 tree-pretty-print.h
  tree-ssa-reassoc.o : tree-ssa-reassoc.c $(TREE_FLOW_H) $(CONFIG_H) \
 $(SYSTEM_H) $(TREE_H) $(DIAGNOSTIC_H) $(TIMEVAR_H) \
--- 2609,2615 
 $(FUNCTION_H) $(TIMEVAR_H) convert.h $(TM_H) coretypes.h langhooks.h \
 $(TREE_DUMP_H) $(TREE_PASS_H) $(PARAMS_H) $(BASIC_BLOCK_H) $(DIAGNOSTIC_H) 
\
 $(GIMPLE_H) $(VEC_H) $(TARGET_H) \
!vecprim.h pointer-set.h alloc-pool.h \
 tree-pretty-print.h
  tree-ssa-reassoc.o : tree-ssa-reassoc.c $(TREE_FLOW_H) $(CONFIG_H) \
 $(SYSTEM_H) $(TREE_H) $(DIAGNOSTIC_H) $(TIMEVAR_H) \
*** ipa-pure-const.o : ipa-pure-const.c $(CO
*** 3034,3052 
 $(GIMPLE_H) $(CGRAPH_H) output.h $(FLAGS_H) $(TREE_PASS_H) $(TIMEVAR_H) \
 $(DIAGNOSTIC_H) $(CFGLOOP_H) $(SCEV_H) $(LTO_STREAMER_H) \
 gimple-pretty-print.h
- ipa-type-escape.o : ipa-type-escape.c $(CONFIG_H) $(SYSTEM_H) \
-coretypes.h $(TM_H) $(TREE_H) $(TREE_FLOW_H) $(TREE_INLINE_H) langhooks.h \
-pointer-set.h $(GGC_H) $(IPA_TYPE_ESCAPE_H) $(IPA_UTILS_H) $(SPLAY_TREE_H) 
\
-$(GIMPLE_H) $(CGRAPH_H) output.h $(FLAGS_H) $(TREE_PASS_H) \
-$(TIMEVAR_H) $(DIAGNOSTIC_H) $(FUNCTION_H) tree-pretty-print.h
- ipa-struct-reorg.o: ipa-struct-reorg.c ipa-struct-reorg.h $(CONFIG_H) 
$(SYSTEM_H) \
-coretypes.h $(TM_H) $(GGC_H) $(TREE_H) $(RTL_H) $(GIMPLE_H) tree-inline.h \
-$(TREE_FLOW_H) langhooks.h pointer-set.h $(HASHTAB_H) $(DIAGNOSTIC_CORE_H) 
\
-$(FLAGS_H) debug.h $(TARGET_H) $(CGRAPH_H) $(DIAGNOSTIC_H) $(TIMEVAR_H) \
-$(PARAMS_H) $(FIBHEAP_H) intl.h $(FUNCTION_H) $(BASIC_BLOCK_H) 
tree-iterator.h \
-$(TREE_PASS_H) $(OPTS_H) $(IPA_TYPE_ESCAPE_H) $(TREE_DUMP_H) \
-$(GIMPLE_H) tree-pretty-print.h gimple-pretty-print.h
- 
  coverage.o : coverage.c $(GCOV_IO_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h \
 $(TM_H) $(RTL_H) $(TREE_H) $(FLAGS_H) output.h $(REGS_H) $(EXPR_H) \
 $(FUNCTION_H) $(BASIC_BLOCK_H) toplev.h $(DIAGNOSTIC_CORE_H) $(GGC_

[PATCH 2/6] Unique return rtx

2011-03-23 Thread Bernd Schmidt
We'll start putting "return" into JUMP_LABELS in a subsequent patch, so
I've decided to make it unique as a small cleanup.

There's already another macro called "return_rtx", so the new one goes
by the name of "ret_rtx".


Bernd

* gengenrtl.c (special_rtx): PC, CC0 and RETURN are special.
* genemit.c (gen_exp): Handle RETURN.
* emit-rtl.c (verify_rtx_sharing): Likewise.
(init_emit_regs): Create pc_rtx, ret_rtx and cc0_rtx specially.
* rtl.c (copy_rtx): RETURN is shared.
* rtl.h (enum global_rtl_index): Add GR_RETURN.
(ret_rtx): New.
* jump.c (redirect_exp_1): Don't use gen_rtx_RETURN.
* config/s390/s390.c (s390_emit_epilogue): Likewise.
* config/rx/rx.c (gen_rx_rtsd_vector): Likewise.
* config/m68hc11/m68hc11.md (return): Likewise.
* config/cris/cris.c (cris_expand_return): Likewise.
* config/m68k/m68k.c (m68k_expand_epilogue): Likewise.
* config/rs6000/rs6000.c (rs6000_make_savres_rtx,
rs6000_emit_epilogue, rs6000_output_mi_thunk): Likewise.
* config/picochip/picochip.c (picochip_expand_epilogue): Likewise.
* config/h8300/h8300.c (h8300_push_pop, h8300_expand_epilogue):
Likewise.
* config/v850/v850.c (expand_epilogue): Likewise.
* config/bfin/bfin.c (bfin_expand_call): Likewise.
* config/arm/arm.md (epilogue): Likewise.

Index: gcc/gengenrtl.c
===
--- gcc.orig/gengenrtl.c
+++ gcc/gengenrtl.c
@@ -128,6 +128,9 @@ special_rtx (int idx)
  || strcmp (defs[idx].enumname, "REG") == 0
  || strcmp (defs[idx].enumname, "SUBREG") == 0
  || strcmp (defs[idx].enumname, "MEM") == 0
+ || strcmp (defs[idx].enumname, "PC") == 0
+ || strcmp (defs[idx].enumname, "CC0") == 0
+ || strcmp (defs[idx].enumname, "RETURN") == 0
  || strcmp (defs[idx].enumname, "CONST_VECTOR") == 0);
 }
 
Index: gcc/genemit.c
===
--- gcc.orig/genemit.c
+++ gcc/genemit.c
@@ -223,6 +223,9 @@ gen_exp (rtx x, enum rtx_code subroutine
 case PC:
   printf ("pc_rtx");
   return;
+case RETURN:
+  printf ("ret_rtx");
+  return;
 case CLOBBER:
   if (REG_P (XEXP (x, 0)))
{
Index: gcc/emit-rtl.c
===
--- gcc.orig/emit-rtl.c
+++ gcc/emit-rtl.c
@@ -2447,6 +2447,7 @@ verify_rtx_sharing (rtx orig, rtx insn)
 case CODE_LABEL:
 case PC:
 case CC0:
+case RETURN:
 case SCRATCH:
   return;
   /* SCRATCH must be shared because they represent distinct values.  */
@@ -5651,8 +5652,9 @@ init_emit_regs (void)
   init_reg_modes_target ();
 
   /* Assign register numbers to the globally defined register rtx.  */
-  pc_rtx = gen_rtx_PC (VOIDmode);
-  cc0_rtx = gen_rtx_CC0 (VOIDmode);
+  pc_rtx = gen_rtx_fmt_ (PC, VOIDmode);
+  ret_rtx = gen_rtx_fmt_ (RETURN, VOIDmode);
+  cc0_rtx = gen_rtx_fmt_ (CC0, VOIDmode);
   stack_pointer_rtx = gen_raw_REG (Pmode, STACK_POINTER_REGNUM);
   frame_pointer_rtx = gen_raw_REG (Pmode, FRAME_POINTER_REGNUM);
   hard_frame_pointer_rtx = gen_raw_REG (Pmode, HARD_FRAME_POINTER_REGNUM);
Index: gcc/rtl.c
===
--- gcc.orig/rtl.c
+++ gcc/rtl.c
@@ -255,6 +255,7 @@ copy_rtx (rtx orig)
 case CODE_LABEL:
 case PC:
 case CC0:
+case RETURN:
 case SCRATCH:
   /* SCRATCH must be shared because they represent distinct values.  */
   return orig;
Index: gcc/rtl.h
===
--- gcc.orig/rtl.h
+++ gcc/rtl.h
@@ -2045,6 +2045,7 @@ enum global_rtl_index
 {
   GR_PC,
   GR_CC0,
+  GR_RETURN,
   GR_STACK_POINTER,
   GR_FRAME_POINTER,
 /* For register elimination to work properly these hard_frame_pointer_rtx,
@@ -2134,6 +2135,7 @@ extern struct target_rtl *this_target_rt
 
 /* Standard pieces of rtx, to be substituted directly into things.  */
 #define pc_rtx  (global_rtl[GR_PC])
+#define ret_rtx (global_rtl[GR_RETURN])
 #define cc0_rtx (global_rtl[GR_CC0])
 
 /* All references to certain hard regs, except those created
Index: gcc/config/s390/s390.c
===
--- gcc.orig/config/s390/s390.c
+++ gcc/config/s390/s390.c
@@ -8516,7 +8516,7 @@ s390_emit_epilogue (bool sibcall)
 
   p = rtvec_alloc (2);
 
-  RTVEC_ELT (p, 0) = gen_rtx_RETURN (VOIDmode);
+  RTVEC_ELT (p, 0) = ret_rtx;
   RTVEC_ELT (p, 1) = gen_rtx_USE (VOIDmode, return_reg);
   emit_jump_insn (gen_rtx_PARALLEL (VOIDmode, p));
 }
Index: gcc/config/rx/rx.c
===
--- gcc.orig/config/rx/rx.c
+++ gcc/config/rx/rx.c
@@ -1550,7 +1550,7 @@ gen_rx_rtsd_vector (unsigned int adjust,
   

[PATCH 3/6] Allow jumps in epilogues

2011-03-23 Thread Bernd Schmidt
dwarf2out has code that starts scanning from NOTE_INSN_EPILOGUE_BEG
until it finds the return jump. When there is common code in several
blocks ending in a return, we might want to share this, and in that case
it would be possible to encounter a simplejump rather than a returnjump.
This should be safe, and the following patch allows it.


Bernd

* cfgcleanup.c (flow_find_head_matching_sequence): Ignore
epilogue notes.
* df-problems.c (can_move_insns_across): Don't stop at epilogue
notes.
* dwarf2out.c (dwarf2out_cfi_begin_epilogue): Also allow a
simplejump to end the block.

Index: gcc/cfgcleanup.c
===
--- gcc.orig/cfgcleanup.c
+++ gcc/cfgcleanup.c
@@ -1184,20 +1184,12 @@ flow_find_head_matching_sequence (basic_
 
   while (true)
 {
-  /* Ignore notes, except NOTE_INSN_EPILOGUE_BEG.  */
+  /* Ignore notes.  */
   while (!NONDEBUG_INSN_P (i1) && i1 != BB_END (bb1))
-   {
- if (NOTE_P (i1) && NOTE_KIND (i1) == NOTE_INSN_EPILOGUE_BEG)
-   break;
- i1 = NEXT_INSN (i1);
-   }
+   i1 = NEXT_INSN (i1);
 
   while (!NONDEBUG_INSN_P (i2) && i2 != BB_END (bb2))
-   {
- if (NOTE_P (i2) && NOTE_KIND (i2) == NOTE_INSN_EPILOGUE_BEG)
-   break;
- i2 = NEXT_INSN (i2);
-   }
+   i2 = NEXT_INSN (i2);
 
   if ((i1 == BB_END (bb1) && !NONDEBUG_INSN_P (i1))
  || (i2 == BB_END (bb2) && !NONDEBUG_INSN_P (i2)))
Index: gcc/df-problems.c
===
--- gcc.orig/df-problems.c
+++ gcc/df-problems.c
@@ -3953,8 +3953,6 @@ can_move_insns_across (rtx from, rtx to,
 {
   if (CALL_P (insn))
break;
-  if (NOTE_P (insn) && NOTE_KIND (insn) == NOTE_INSN_EPILOGUE_BEG)
-   break;
   if (NONDEBUG_INSN_P (insn))
{
  if (may_trap_or_fault_p (PATTERN (insn))
Index: gcc/dwarf2out.c
===
--- gcc.orig/dwarf2out.c
+++ gcc/dwarf2out.c
@@ -2939,10 +2939,10 @@ dwarf2out_frame_debug (rtx insn, bool af
 dwarf2out_flush_queued_reg_saves ();
 }
 
-/* Determine if we need to save and restore CFI information around this
-   epilogue.  If SIBCALL is true, then this is a sibcall epilogue.  If
-   we do need to save/restore, then emit the save now, and insert a
-   NOTE_INSN_CFA_RESTORE_STATE at the appropriate place in the stream.  */
+/* Determine if we need to save and restore CFI information around
+   this epilogue.  If we do need to save/restore, then emit the save
+   now, and insert a NOTE_INSN_CFA_RESTORE_STATE at the appropriate
+   place in the stream.  */
 
 void
 dwarf2out_cfi_begin_epilogue (rtx insn)
@@ -2957,8 +2957,10 @@ dwarf2out_cfi_begin_epilogue (rtx insn)
   if (!INSN_P (i))
continue;
 
-  /* Look for both regular and sibcalls to end the block.  */
-  if (returnjump_p (i))
+  /* Look for both regular and sibcalls to end the block.  Various
+optimization passes may cause us to jump to a common epilogue
+tail, so we also accept simplejumps.  */
+  if (returnjump_p (i) || simplejump_p (i))
break;
   if (CALL_P (i) && SIBLING_CALL_P (i))
break;


[patch, ARM] Fix PR46934, Thumb-1 ICE

2011-03-23 Thread Chung-Lin Tang
Hi, in the ARM "casesi" expand pattern, when the table base index
constant is 0x800, it is stored sign extended as an rtx (const_int
0x800) (assuming 64-bit HOST_WIDE_INT).

Subtraction by adding GEN_INT(-INTVAL(operands[1])) then creates
(const_int 0x8000), which is not sign-extended, and fails to match
the nonmemory_operand predicate later, causing a extract_insn failure
ICE.  So the fix is to use gen_int_mode() instead of GEN_INT, which does
the needed sign-extension.

Cross-tested on QEMU without regressions, okay for trunk?

Thanks,
Chung-Lin
Index: config/arm/arm.md
===
--- config/arm/arm.md   (revision 171339)
+++ config/arm/arm.md   (working copy)
@@ -8354,7 +8354,8 @@
rtx reg = gen_reg_rtx (SImode);
 
emit_insn (gen_addsi3 (reg, operands[0],
-  GEN_INT (-INTVAL (operands[1];
+  gen_int_mode (-INTVAL (operands[1]),
+ SImode)));
operands[0] = reg;
   }
 
Index: testsuite/gcc.target/arm/pr46934.c
===
--- testsuite/gcc.target/arm/pr46934.c  (revision 0)
+++ testsuite/gcc.target/arm/pr46934.c  (revision 0)
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-march=armv5te -mthumb -Os" }  */
+/* { dg-require-effective-target arm_thumb1_ok } */
+
+int caller (unsigned int reg_type)
+{
+  switch (reg_type)
+{
+case 0x8000:
+  return (int)foo();
+
+case 0x8003:
+  return (int) bar();
+
+case 0x8001:
+  return (int) baz();
+
+case 0x8004:
+  return (int) fooz();
+}
+}


[PATCH 5/6] Generate more shrink-wrapping opportunities

2011-03-23 Thread Bernd Schmidt
The first basic block contains insns to move incoming argument registers
to pseudos. When these pseudos live across calls, they get allocated to
call-saved registers. This in turns disables shrink-wrapping, since the
move instruction requires the prologue (saving the call-saved reg) to
occur before it.

This patch addresses the problem by moving such moves downwards through
the CFG until we find a place where the destination is used or the
incoming argument is clobbered.


Bernd

* function.c (prepare_shrink_wrap): New function.
(thread_prologue_and_epilogue_insns): Call it.

Index: gcc/function.c
===
--- gcc.orig/function.c
+++ gcc/function.c
@@ -5299,6 +5299,127 @@ requires_stack_frame_p (rtx insn)
   return true;
   return false;
 }
+
+/* Look for sets of call-saved registers in the first block of the
+   function, and move them down into successor blocks if the register
+   is used only on one path.  This exposes more opportunities for
+   shrink-wrapping.
+   These kinds of sets often occur when incoming argument registers are
+   moved to call-saved registers because their values are live across
+   one or more calls during the function.  */
+
+static void
+prepare_shrink_wrap (basic_block entry_block)
+{
+  rtx insn, curr;
+  FOR_BB_INSNS_SAFE (entry_block, insn, curr)
+{
+  basic_block next_bb;
+  edge e, live_edge;
+  edge_iterator ei;
+  rtx set, scan;
+  unsigned destreg, srcreg;
+
+  if (!NONDEBUG_INSN_P (insn))
+   continue;
+  set = single_set (insn);
+  if (!set)
+   continue;
+
+  if (!REG_P (SET_SRC (set)) || !REG_P (SET_DEST (set)))
+   continue;
+  srcreg = REGNO (SET_SRC (set));
+  destreg = REGNO (SET_DEST (set));
+  if (hard_regno_nregs[srcreg][GET_MODE (SET_SRC (set))] > 1
+ || hard_regno_nregs[destreg][GET_MODE (SET_DEST (set))] > 1)
+   continue;
+
+  next_bb = entry_block;
+  scan = insn;
+
+  for (;;)
+   {
+ live_edge = NULL;
+ FOR_EACH_EDGE (e, ei, next_bb->succs)
+   {
+ if (REGNO_REG_SET_P (df_get_live_in (e->dest), destreg))
+   {
+ if (live_edge)
+   {
+ live_edge = NULL;
+ break;
+   }
+ live_edge = e;
+   }
+   }
+ if (!live_edge)
+   break;
+ /* We can sometimes encounter dead code.  Don't try to move it
+into the exit block.  */
+ if (live_edge->dest == EXIT_BLOCK_PTR)
+   break;
+ if (EDGE_COUNT (live_edge->dest->preds) > 1)
+   break;
+ while (scan != BB_END (next_bb))
+   {
+ scan = NEXT_INSN (scan);
+ if (NONDEBUG_INSN_P (scan))
+   {
+ rtx link;
+ HARD_REG_SET set_regs;
+
+ CLEAR_HARD_REG_SET (set_regs);
+ note_stores (PATTERN (scan), record_hard_reg_sets,
+  &set_regs);
+ if (CALL_P (scan))
+   IOR_HARD_REG_SET (set_regs, call_used_reg_set);
+ for (link = REG_NOTES (scan); link; link = XEXP (link, 1))
+   if (REG_NOTE_KIND (link) == REG_INC)
+ record_hard_reg_sets (XEXP (link, 0), NULL, &set_regs);
+
+ if (TEST_HARD_REG_BIT (set_regs, srcreg)
+ || reg_referenced_p (SET_DEST (set),
+  PATTERN (scan)))
+   {
+ scan = NULL_RTX;
+ break;
+   }
+ if (CALL_P (scan))
+   {
+ rtx link = CALL_INSN_FUNCTION_USAGE (scan);
+ while (link)
+   {
+ rtx tmp = XEXP (link, 0);
+ if (GET_CODE (tmp) == USE
+ && reg_referenced_p (SET_DEST (set), tmp))
+   break;
+ link = XEXP (link, 1);
+   }
+ if (link)
+   {
+ scan = NULL_RTX;
+ break;
+   }
+   }
+   }
+   }
+ if (!scan)
+   break;
+ next_bb = live_edge->dest;
+   }
+
+  if (next_bb != entry_block)
+   {
+ rtx after = BB_HEAD (next_bb);
+ while (!NOTE_P (after)
+|| NOTE_KIND (after) != NOTE_INSN_BASIC_BLOCK)
+   after = NEXT_INSN (after);
+ emit_insn_after (PATTERN (insn), after);
+ delete_insn (insn);
+   }
+}
+}
+
 #endif
 
 #ifdef HAVE_return
@@ -5499,6 +5620,8 @@ thread_prologue_and_epilogue_insns (void
   bitmap_head bb_antic_flags;
   bitmap_head bb_on_list;
 
+  pre

[PATCH 6/6] A testcase

2011-03-23 Thread Bernd Schmidt
I don't see a good way to scan assembly output for this optimization, so
I've just added the following testcase based on scanning the dump file.
Better ideas are welcome.


Bernd

* function.c (thread_prologue_and_epilogue_insns): Emit information
about shrink wrapping in the dump file.

* gcc.target/i386/sw-1.c: New test.

Index: gcc/function.c
===
--- gcc.orig/function.c
+++ gcc/function.c
@@ -5752,6 +5752,9 @@ thread_prologue_and_epilogue_insns (void
   if (hard_reg_set_intersect_p (live_on_edge, prologue_clobbered))
entry_edge = orig_entry_edge;
 
+  if (dump_file && entry_edge != orig_entry_edge)
+   fprintf (dump_file, "Prologue moved down by shrink-wrapping.\n");
+
 fail_shrinkwrap:
   bitmap_clear (&bb_antic_flags);
   bitmap_clear (&bb_on_list);
Index: gcc/testsuite/gcc.target/i386/sw-1.c
===
--- /dev/null
+++ gcc/testsuite/gcc.target/i386/sw-1.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fshrink-wrap -fdump-rtl-pro_and_epilogue" } */
+
+#include 
+
+int c;
+int x[2000];
+__attribute__((regparm(1))) int foo (int a, int b)
+ {
+   int t[200];
+   if (a == 0)
+ return 1;
+   if (c == 0)
+ return 2;
+   memcpy (t, x + b, sizeof t);
+   return t[a];
+ }
+
+/* { dg-final { scan-rtl-dump "Prologue moved down" "pro_and_epilogue" } } */
+/* { dg-final { cleanup-rtl-dump "pro_and_epilogue" } } */


RE: [Patch][AVR]: Use define_c_enum where appropriate

2011-03-23 Thread Weddington, Eric


> -Original Message-
> From: Georg-Johann Lay [mailto:a...@gjlay.de]
> Sent: Wednesday, March 23, 2011 8:45 AM
> To: gcc-patches@gcc.gnu.org
> Cc: Denis Chertykov; Anatoly Sokolov; Weddington, Eric
> Subject: [Patch][AVR]: Use define_c_enum where appropriate
> 
> Use define_c_enum instead of magic numbers to get unspec resp.
> unspec_volatile constants.
> 

Hi Johann,

Can we hold off on this patch for just a little bit? I agree it would be good 
to clean it up, but I would like to get in the attached patch to add some 
builtin functions that Anatoly and I worked on. The patch was (nominally) for 
4.4. I need to see if it will patch cleanly to trunk, and if not, then I'd like 
to keep the changes minimal.

Eric


61-gcc-4.4.3-builtins-v6.patch
Description: 61-gcc-4.4.3-builtins-v6.patch


Re: [PATCH 5/6] Generate more shrink-wrapping opportunities

2011-03-23 Thread Jeff Law
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 03/23/11 08:55, Bernd Schmidt wrote:
> The first basic block contains insns to move incoming argument registers
> to pseudos. When these pseudos live across calls, they get allocated to
> call-saved registers. This in turns disables shrink-wrapping, since the
> move instruction requires the prologue (saving the call-saved reg) to
> occur before it.
> 
> This patch addresses the problem by moving such moves downwards through
> the CFG until we find a place where the destination is used or the
> incoming argument is clobbered.
FWIW, downward motion of the moves out of arg registers (or loads from
arg slots) is definitely a good thing.  This was a regular source of
unnecessary register pressure leading to spills in codes I've looked at.

I hope your sinking code works better than the quick and dirty one I
wrote but never contributed.

jeff
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNigvCAAoJEBRtltQi2kC7/DcH/0OPNnWZD9qoqRwrpm/Zc5qN
zaCsSc9VYFuQa5Kh6dTd0md6ORfqSWFt6v0ygOXueYt7/bni4YsEA33N52dp3VVY
xg6R0m1XEmfg8Pcn0SzyBGGmAnprgn7XpRnbOLycAT11CjfNFN9jjdeXFYbSHiNu
NkvdtiKzz2HeucmvTBEZByN1mhP3/9DeQ3R6MM7uZ9xZFuA4rBfx8wfijxTYEg2d
3T52kiDzqcTBsD6Q5apAtNcFU6X7o1KS/eZsbno+nnMcc4z7lQ+6EQVfnBPfs9m2
GLb4ZNNzYCesczNHM+DyuJfQQVAkECKx0DcAGL8AivffUr9o05l4nGsS5D4Kip8=
=gALv
-END PGP SIGNATURE-


Re: [PATCH 5/6] Generate more shrink-wrapping opportunities

2011-03-23 Thread Bernd Schmidt
On 03/23/2011 04:03 PM, Jeff Law wrote:
> On 03/23/11 08:55, Bernd Schmidt wrote:
>> The first basic block contains insns to move incoming argument registers
>> to pseudos. When these pseudos live across calls, they get allocated to
>> call-saved registers. This in turns disables shrink-wrapping, since the
>> move instruction requires the prologue (saving the call-saved reg) to
>> occur before it.
> 
>> This patch addresses the problem by moving such moves downwards through
>> the CFG until we find a place where the destination is used or the
>> incoming argument is clobbered.
> FWIW, downward motion of the moves out of arg registers (or loads from
> arg slots) is definitely a good thing.  This was a regular source of
> unnecessary register pressure leading to spills in codes I've looked at.
> 
> I hope your sinking code works better than the quick and dirty one I
> wrote but never contributed.

Sadly I'm doing it after register allocation, so it wouldn't help with
your problem.


Bernd


Re: [Patch][AVR]: Use define_c_enum where appropriate

2011-03-23 Thread Georg-Johann Lay
Weddington, Eric schrieb:
> 
>> -Original Message- From: Georg-Johann Lay
>> [mailto:a...@gjlay.de] Sent: Wednesday, March 23, 2011 8:45 AM To:
>> gcc-patches@gcc.gnu.org Cc: Denis Chertykov; Anatoly Sokolov;
>> Weddington, Eric Subject: [Patch][AVR]: Use define_c_enum where
>> appropriate
>> 
>> Use define_c_enum instead of magic numbers to get unspec resp. 
>> unspec_volatile constants.
>> 
> 
> Hi Johann,
> 
> Can we hold off on this patch for just a little bit? I agree it
> would be good to clean it up, but I would like to get in the
> attached patch to add some builtin functions that Anatoly and I
> worked on. The patch was (nominally) for 4.4. I need to see if it
> will patch cleanly to trunk, and if not, then I'd like to keep the
> changes minimal.
> 
> Eric

Of course, it's nothing urgent. Just proceed with your work and commit
this patchlet afterwards.

Already thought about posting my updated built-in patch for avr
backend. I'm digging in my patches from before my fsf assignment and
found a bluit-in patch there...

Johann


[PATCH] Fix PR48193 and dups

2011-03-23 Thread Richard Guenther

This fixes VOP renaming in IPA split (well, or rather adds to its
crudeness).  We really need to rename the reaching VDEF of the
exit of the SESE region we kill, as that VDEF will be released
when removing the definitions basic-block.  What we really would
want to do is replace that SESE region with the call using the
reaching VDEF of its entry and the reaching VDEF of its exit
as virtual operands.  But the current code is somewhat twisted
so I got lost and the following is what also works for me.

Bootstrapped and tested on x86_64-unknown-linux-gnu.

Honza, I fail to see the exact constraints on the region we
outline, so you might want to provide a better fix?

Thanks,
Richard.

2011-03-23  Richard Guenther  

PR tree-optimization/48193
* ipa-slit.c (split_function): Properly rename the reaching
VDEF.

Index: gcc/ipa-split.c
===
--- gcc/ipa-split.c (revision 171352)
+++ gcc/ipa-split.c (working copy)
@@ -169,8 +169,9 @@ static void
 dump_split_point (FILE * file, struct split_point *current)
 {
   fprintf (file,
-  "Split point at BB %i header time:%i header size: %i"
-  " split time: %i split size: %i\n  bbs: ",
+  "Split point at BB %i\n"
+  "  header time: %i header size: %i\n"
+  "  split time: %i split size: %i\n  bbs: ",
   current->entry_bb->index, current->header_time,
   current->header_size, current->split_time, current->split_size);
   dump_bitmap (file, current->split_bbs);
@@ -1036,12 +1037,13 @@ split_function (struct split_point *spli
 
   /* If RETURN_BB has virtual operand PHIs, they must be removed and the
  virtual operand marked for renaming as we change the CFG in a way that
- tree-inline is not able to compensate for. 
+ tree-inline is not able to compensate for.
 
  Note this can happen whether or not we have a return value.  If we have
  a return value, then RETURN_BB may have PHIs for real operands too.  */
   if (return_bb != EXIT_BLOCK_PTR)
 {
+  bool phi_p = false;
   for (gsi = gsi_start_phis (return_bb); !gsi_end_p (gsi);)
{
  gimple stmt = gsi_stmt (gsi);
@@ -1052,7 +1054,28 @@ split_function (struct split_point *spli
}
  mark_virtual_phi_result_for_renaming (stmt);
  remove_phi_node (&gsi, true);
+ phi_p = true;
}
+  /* In reality we have to rename the reaching definition of the
+virtual operand at return_bb as we will eventually release it
+when we remove the code region we outlined.
+So we have to rename all immediate virtual uses of that region
+if we didn't see a PHI definition yet.  */
+  /* ???  In real reality we want to set the reaching vdef of the
+ entry of the SESE region as the vuse of the call and the reaching
+vdef of the exit of the SESE region as the vdef of the call.  */
+  if (!phi_p)
+   for (gsi = gsi_start_bb (return_bb); !gsi_end_p (gsi); gsi_next (&gsi))
+ {
+   gimple stmt = gsi_stmt (gsi);
+   if (gimple_vuse (stmt))
+ {
+   gimple_set_vuse (stmt, NULL_TREE);
+   update_stmt (stmt);
+ }
+   if (gimple_vdef (stmt))
+ break;
+ }
 }
 
   /* Now create the actual clone.  */


Re: [patch, ARM] Fix PR46934, Thumb-1 ICE

2011-03-23 Thread Richard Earnshaw


On 23 Mar 2011, at 14:52, "Chung-Lin Tang"  wrote:

> Hi, in the ARM "casesi" expand pattern, when the table base index
> constant is 0x800, it is stored sign extended as an rtx (const_int
> 0x800) (assuming 64-bit HOST_WIDE_INT).
> 
> Subtraction by adding GEN_INT(-INTVAL(operands[1])) then creates
> (const_int 0x8000), which is not sign-extended, and fails to match
> the nonmemory_operand predicate later, causing a extract_insn failure
> ICE.  So the fix is to use gen_int_mode() instead of GEN_INT, which does
> the needed sign-extension.
> 
> Cross-tested on QEMU without regressions, okay for trunk?
> 
> Thanks,
> Chung-Lin
> 

Ok.  R.



Re: [PATCH 5/6] Generate more shrink-wrapping opportunities

2011-03-23 Thread Jeff Law
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 03/23/11 09:04, Bernd Schmidt wrote:
> On 03/23/2011 04:03 PM, Jeff Law wrote:
>> On 03/23/11 08:55, Bernd Schmidt wrote:
>>> The first basic block contains insns to move incoming argument registers
>>> to pseudos. When these pseudos live across calls, they get allocated to
>>> call-saved registers. This in turns disables shrink-wrapping, since the
>>> move instruction requires the prologue (saving the call-saved reg) to
>>> occur before it.
>>
>>> This patch addresses the problem by moving such moves downwards through
>>> the CFG until we find a place where the destination is used or the
>>> incoming argument is clobbered.
>> FWIW, downward motion of the moves out of arg registers (or loads from
>> arg slots) is definitely a good thing.  This was a regular source of
>> unnecessary register pressure leading to spills in codes I've looked at.
>>
>> I hope your sinking code works better than the quick and dirty one I
>> wrote but never contributed.
> 
> Sadly I'm doing it after register allocation, so it wouldn't help with
> your problem.
That'll still help :-)  I can run your sinking code, then use the
existing IRA callbacks to attempt to allocate any pseudos which didn't
previously get hard regs.  It's actually quite easy.

jeff
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNig9CAAoJEBRtltQi2kC7I3kIAJ6manYH+/ZFcdQwfxroN0im
U0Oc18wbEz5VZg3SXnw7wEm6uRPKxYLS9/t2bMo0xLY2cHCWZx2QLH9g9O09lnUv
EU5lG46H7oIJuwhuC8osvsJUbLfQL5PkGQJdF4mfab1uk/Et5RSo8wfna7HDhTXU
b8WJltvS2ZJQIggSFxXtM101eq2/oiiU286WC8wdqlbq0lgWotBcxhHNuZeO/LEj
NeGX91kcFDl8RcwQNeT2a2G+JC0i5tc1S4C3d9pGgUiqDWpmjx74WrlRpzpkF8EF
7kfYm48xY5hPcmUcZ7vJU5Aq3Ik7U2rM6aO9H3dYoFTAOmcgs22Rbj6FoDMrUXE=
=N5L7
-END PGP SIGNATURE-


Re: [patch] Enhance conditional store sinking

2011-03-23 Thread Richard Guenther
On Tue, Mar 22, 2011 at 2:28 PM, Ira Rosen  wrote:
> On 17 March 2011 16:48, Richard Guenther  wrote:
>
>>> +  then_datarefs = VEC_alloc (data_reference_p, heap, 1);
>>> +  else_datarefs = VEC_alloc (data_reference_p, heap, 1);
>>> +  then_ddrs = VEC_alloc (ddr_p, heap, 1);
>>> +  else_ddrs = VEC_alloc (ddr_p, heap, 1);
>>> +  if (!compute_data_dependences_for_bb (then_bb, false, &then_datarefs,
>>> +                                        &then_ddrs)
>>
>> Can we avoid computing dependencies if the other BB would have no
>> data-refs?  Thus, split collecting datarefs and computing dependences?
>
> Done.
>
>>
>>> +      || !compute_data_dependences_for_bb (else_bb, false, &else_datarefs,
>>> +                                           &else_ddrs)
>>> +      || !VEC_length (data_reference_p, then_datarefs)
>>> +      || !VEC_length (data_reference_p, else_datarefs))
>>> +    {
>>> +      free_data_refs (then_datarefs);
>>> +      free_data_refs (else_datarefs);
>>> +      free_dependence_relations (then_ddrs);
>>> +      free_dependence_relations (else_ddrs);
>>> +      return false;
>>> +    }
>>> +
>>> +  /* Check that there are no read-after-write or write-after-write 
>>> dependencies
>>> +     in THEN_BB.  */
>>> +  FOR_EACH_VEC_ELT (ddr_p, then_ddrs, i, ddr)
>>> +    {
>>> +      struct data_reference *dra = DDR_A (ddr);
>>> +      struct data_reference *drb = DDR_B (ddr);
>>> +
>>> +      if (DDR_ARE_DEPENDENT (ddr) != chrec_known
>>> +          && ((DR_IS_READ (dra) && DR_IS_WRITE (drb)
>>> +               && gimple_uid (DR_STMT (dra)) > gimple_uid (DR_STMT (drb)))
>>> +              || (DR_IS_READ (drb) && DR_IS_WRITE (dra)
>>> +                  && gimple_uid (DR_STMT (drb)) > gimple_uid (DR_STMT 
>>> (dra)))
>>> +              || (DR_IS_WRITE (dra) && DR_IS_WRITE (drb
>>
>> The gimple_uids are not initialized here, you need to make sure to
>> call renumber_gimple_stmt_uids () before starting.  Note that phiopt
>> incrementally changes the IL, so I'm not sure those uids will stay
>> valid as stmts are moved across blocks.
>
> I added a call to renumber_gimple_stmt_uids_in_blocks() before data
> dependence checks, and there are no code changes between that and the
> checks, so, I think, it should be OK.
>
>>
>>> +        {
>>> +          free_data_refs (then_datarefs);
>>> +          free_data_refs (else_datarefs);
>>> +          free_dependence_relations (then_ddrs);
>>> +          free_dependence_relations (else_ddrs);
>>> +          return false;
>>> +        }
>>> +    }
>>> +
>>> +  /* Check that there are no read-after-write or write-after-write 
>>> dependencies
>>> +     in ELSE_BB.  */
>>> +  FOR_EACH_VEC_ELT (ddr_p, else_ddrs, i, ddr)
>>> +    {
>>> +      struct data_reference *dra = DDR_A (ddr);
>>> +      struct data_reference *drb = DDR_B (ddr);
>>> +
>>> +      if (DDR_ARE_DEPENDENT (ddr) != chrec_known
>>> +          && ((DR_IS_READ (dra) && DR_IS_WRITE (drb)
>>> +               && gimple_uid (DR_STMT (dra)) > gimple_uid (DR_STMT (drb)))
>>> +              || (DR_IS_READ (drb) && DR_IS_WRITE (dra)
>>> +                  && gimple_uid (DR_STMT (drb)) > gimple_uid (DR_STMT 
>>> (dra)))
>>> +              || (DR_IS_WRITE (dra) && DR_IS_WRITE (drb
>>> +        {
>>> +          free_data_refs (then_datarefs);
>>> +          free_data_refs (else_datarefs);
>>> +          free_dependence_relations (then_ddrs);
>>> +          free_dependence_relations (else_ddrs);
>>> +          return false;
>>> +        }
>>> +    }
>>> +
>>> +  /* Found pairs of stores with equal LHS.  */
>>> +  FOR_EACH_VEC_ELT (data_reference_p, then_datarefs, i, then_dr)
>>> +    {
>>> +      if (DR_IS_READ (then_dr))
>>> +        continue;
>>> +
>>> +      then_store = DR_STMT (then_dr);
>>> +      then_lhs = gimple_assign_lhs (then_store);
>>> +      found = false;
>>> +
>>> +      FOR_EACH_VEC_ELT (data_reference_p, else_datarefs, j, else_dr)
>>> +        {
>>> +          if (DR_IS_READ (else_dr))
>>> +            continue;
>>> +
>>> +          else_store = DR_STMT (else_dr);
>>> +          else_lhs = gimple_assign_lhs (else_store);
>>> +
>>> +          if (operand_equal_p (then_lhs, else_lhs, 0))
>>> +            {
>>> +              found = true;
>>> +              break;
>>> +            }
>>> +        }
>>> +
>>> +      if (!found)
>>> +        continue;
>>> +
>>> +      res = cond_if_else_store_replacement_1 (then_bb, else_bb, join_bb,
>>> +                                              then_store, else_store);
>>
>> So you are executing if-else store replacement for common data reference
>> pairs only.  I think it's cheaper to collect those pairs before computing
>> dependences and only if there is at least one pair perform the optimization.
>
> OK, I changed the order.
>
>>
>> You basically perform store sinking, creating a PHI node for each store
>> you sink (that's then probably if-converted by if-conversion later, 
>> eventually
>> redundant with -ftree-loop-if-convert-stores?)
>>
>> I am concerned

Problem with ARM longcalls

2011-03-23 Thread Bernd Schmidt
I've discovered a problem with -mlong-calls on ARM. The bug was first
reported against a new target, but I'd copied the relevant code from the
ARM backend.

We use current_function_section in arm_is_long_call_p to decide whether
we're calling something that goes into the same section. The problem
with this is that current_function_section can only be used during
final, since it relies on the global variable in_cold_section_p which is
set up only in assemble_start_function. On ARM, this problem manifests
as short-calls when a long-call would be required; in the other port it
was an "insn doesn't satisfy its constraints" error.

The following patch is against 4.5, since the problem appears hidden in
mainline (the initialization of first_function_block_is_cold has
changed). Ok for trunk and branches after arm-linux tests complete?


Bernd
* function.c (init_function_start): Call decide_function_section.
* varasm.c (decide_function_section): New function.
(assemble_start_function): When not using
flag_reorder_blocks_and_partition, don't compute in_cold_section_p
or first_function_block_is_cold.
* rtl.h (decide_function_section): Declare.

* gcc.target/arm/cold-lc.c: New test.

Index: gcc/testsuite/gcc.target/arm/cold-lc.c
===
--- gcc/testsuite/gcc.target/arm/cold-lc.c  (revision 0)
+++ gcc/testsuite/gcc.target/arm/cold-lc.c  (revision 0)
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mlong-calls" } */
+/* { dg-final { scan-assembler-not "bl\[^\n\]*dump_stack" } } */
+
+extern void dump_stack (void) __attribute__ ((__cold__)) __attribute__ 
((noinline));
+struct thread_info {
+struct task_struct *task;
+};
+extern struct thread_info *current_thread_info (void);
+
+void dump_stack (void)
+{
+unsigned long stack;
+show_stack ((current_thread_info ()->task), &stack);
+}
+
+void die (char *str, void *fp, int nr)
+{
+dump_stack ();
+while (1);
+}
+
Index: gcc/function.c
===
--- gcc/function.c  (revision 170052)
+++ gcc/function.c  (working copy)
@@ -4227,6 +4227,7 @@ init_function_start (tree subr)
   else
 allocate_struct_function (subr, false);
   prepare_function_start ();
+  decide_function_section (subr);
 
   /* Warn if this value is an aggregate type,
  regardless of which calling convention we are using for it.  */
Index: gcc/varasm.c
===
--- gcc/varasm.c(revision 170052)
+++ gcc/varasm.c(working copy)
@@ -1687,6 +1687,38 @@ notice_global_symbol (tree decl)
 }
 }
 
+/* If not using flag_reorder_blocks_and_partition, decide early whether the
+   current function goes into the cold section, so that targets can use
+   current_function_section during RTL expansion.  DECL describes the
+   function.  */
+
+void
+decide_function_section (tree decl)
+{
+  first_function_block_is_cold = false;
+
+  if (flag_reorder_blocks_and_partition)
+/* We will decide in assemble_start_function.  */
+return;
+
+ if (DECL_SECTION_NAME (decl))
+{
+  /* Calls to function_section rely on first_function_block_is_cold
+being accurate.  The first block may be cold even if we aren't
+doing partitioning, if the entire function was decided by
+choose_function_section (predict.c) to be cold.  */
+
+  initialize_cold_section_name ();
+
+  if (crtl->subsections.unlikely_text_section_name
+ && strcmp (TREE_STRING_POINTER (DECL_SECTION_NAME (decl)),
+crtl->subsections.unlikely_text_section_name) == 0)
+   first_function_block_is_cold = true;
+}
+
+  in_cold_section_p = first_function_block_is_cold;
+}
+
 /* Output assembler code for the constant pool of a function and associated
with defining the name of the function.  DECL describes the function.
NAME is the function's name.  For the constant pool, we use the current
@@ -1701,7 +1733,6 @@ assemble_start_function (tree decl, cons
 
   crtl->subsections.unlikely_text_section_name = NULL;
 
-  first_function_block_is_cold = false;
   if (flag_reorder_blocks_and_partition)
 {
   ASM_GENERATE_INTERNAL_LABEL (tmp_label, "LHOTB", const_labelno);
@@ -1738,6 +1769,8 @@ assemble_start_function (tree decl, cons
 
   if (flag_reorder_blocks_and_partition)
 {
+  first_function_block_is_cold = false;
+
   switch_to_section (unlikely_text_section ());
   assemble_align (DECL_ALIGN (decl));
   ASM_OUTPUT_LABEL (asm_out_file, crtl->subsections.cold_section_label);
@@ -1754,23 +1787,8 @@ assemble_start_function (tree decl, cons
  hot_label_written = true;
  first_function_block_is_cold = true;
}
+  in_cold_section_p = first_function_block_is_cold;
 }
-  else if (DECL_SECTION_NAME (decl))
-{
-  /* Calls to function_section rely o

RE: [Patch][AVR]: Use define_c_enum where appropriate

2011-03-23 Thread Weddington, Eric


> -Original Message-
> From: Georg-Johann Lay [mailto:a...@gjlay.de]
> Sent: Wednesday, March 23, 2011 9:10 AM
> To: Weddington, Eric
> Cc: gcc-patches@gcc.gnu.org; Denis Chertykov; Anatoly Sokolov; Joerg
> Wunsch
> Subject: Re: [Patch][AVR]: Use define_c_enum where appropriate
> 
> Of course, it's nothing urgent. Just proceed with your work and commit
> this patchlet afterwards.
> 
> Already thought about posting my updated built-in patch for avr
> backend. I'm digging in my patches from before my fsf assignment and
> found a bluit-in patch there...

Then we should coordinate off-list with the other maintainers. I have a list of 
patches that I would like to get in as well. One of which I think was 
originally yours. :-)

Eric


[patch, hpux, testsuite] XFAIL pr47917.c for non-conforming snprintf

2011-03-23 Thread Steve Ellcey
This patch moves gcc.c-torture/execute/pr47917.c to
gcc.dg/torture/pr47917.c so that I can use dg-* directives in the test
and then adds xfails for HP-UX.  On HP-UX 10.* there is no snprintf
function so the test does not compile.  On HP-UX 11.[012]*, there is a
snprintf function but it is not C99 compliant so the test compiles but
fails when it is run.  On HP-UX 11.31 it is possible to get the correct
behaviour and I will be submitting a seperate patch to deal with that.

The problem is that on HP-UX snprintf is returning -1 for buffer overflow
instead of returning the number of bytes that would have been output if the
buffer hadn't filled up.

Dave, can you verify this fix on HP-UX 10.*?  I don't have any HP-UX
10.* systems anymore.  Tested on IA64 and PA HP-UX 11.11 and 11.23.

Steve Ellcey
s...@cup.hp.com


2011-03-23  Steve Ellcey  

PR target/48209
* gcc.c-torture/execute/pr47917.c: Move this...
* gcc.dg/torture/pr47917.c: to here and add xfails.

Index: gcc.c-torture/execute/pr47917.c
===
--- gcc.c-torture/execute/pr47917.c (revision 171338)
+++ gcc.c-torture/execute/pr47917.c (working copy)
@@ -1,32 +0,0 @@
-/* PR middle-end/47917 */
-
-extern int snprintf (char *, __SIZE_TYPE__, const char *, ...);
-extern int memcmp (const void *, const void *, __SIZE_TYPE__);
-extern void abort (void);
-
-char buf1[6], buf2[6], buf3[4], buf4[4];
-int i;
-
-int
-foo (void)
-{
-  int ret = snprintf (buf1, sizeof buf1, "abcde");
-  ret += snprintf (buf2, sizeof buf2, "abcdef") * 16;
-  ret += snprintf (buf3, sizeof buf3, "%s", i++ < 6 ? "abc" : "def") * 256;
-  ret += snprintf (buf4, sizeof buf4, "%s", i++ > 10 ? "abcde" : "defgh") * 
4096;
-  return ret;
-}
-
-int
-main (void)
-{
-  if (foo () != 5 + 6 * 16 + 3 * 256 + 5 * 4096)
-abort ();
-  if (memcmp (buf1, "abcde", 6) != 0
-  || memcmp (buf2, "abcde", 6) != 0
-  || memcmp (buf3, "abc", 4) != 0
-  || memcmp (buf4, "def", 4) != 0
-  || i != 2)
-abort ();
-  return 0;
-}
Index: gcc.dg/torture/pr47917.c
===
--- gcc.dg/torture/pr47917.c(revision 171278)
+++ gcc.dg/torture/pr47917.c(working copy)
@@ -1,3 +1,8 @@
+/* { dg-do run } */
+/* { dg-options "-std=c99" } */
+/* { dg-xfail-if "no C99 snprintf function" { *-*-hpux10* } } */
+/* { dg-xfail-run-if "non-conforming C99 snprintf" { *-*-hpux11.[012]* } } */
+
 /* PR middle-end/47917 */
 
 extern int snprintf (char *, __SIZE_TYPE__, const char *, ...);


Re: [Patch][AVR]: Use define_c_enum where appropriate

2011-03-23 Thread Richard Henderson
> +;; SWAP
> +(define_insn "swap"
> +  [(set (match_operand:QI 0 "register_operand" "=r")
> + (unspec:QI [(match_operand:QI 1 "register_operand" "0")]
> +UNSPEC_SWAP))]
> +  ""
> +  "swap %0"
> +  [(set_attr "length" "1")
> +   (set_attr "cc" "none")])

This is already properly represented as 

(define_insn "*rotlqi3_4"
  [(set (match_operand:QI 0 "register_operand" "=r")
(rotate:QI (match_operand:QI 1 "register_operand" "0")
   (const_int 4)))]
  ""
  "swap %0"
  [(set_attr "length" "1")
   (set_attr "cc" "none")])

you ought not need another copy; just have the builtin emit the rotate.

> +(define_insn "fmuls"
> +  [(set (match_operand:HI 0 "a_register_operand" "=r")
> + (unspec:HI [(match_operand:QI 1 "a_register_operand" "r")
> + (match_operand:QI 2 "a_register_operand" "r")]
> + UNSPEC_FMULS))]
...
> +;; Registers from r16 to 24.
> +(define_predicate "a_register_operand"
> +  (and (match_code "reg")
> +   (match_test "REGNO (op) >= 16 && REGNO (op) <= 24")))

These constraint/predicate pairs are wrong.  You should use register_operand
for all of the operands, and proper constraints.  I believe that the output
can simply use "=r", since HImode registers are already constrained to be 
aligned; the inputs should be "a".

> +  "AVR_HAVE_MUL"
> +  "fmuls %1,%2
> + movw %0,r0
> + clr r1"

The rest of the port is fairly consistent using __zero_reg__ instead
of r1.  You probably want to continue that.


r~


RE: [Patch][AVR]: Use define_c_enum where appropriate

2011-03-23 Thread Weddington, Eric


> -Original Message-
> From: Richard Henderson [mailto:r...@redhat.com]
> Sent: Wednesday, March 23, 2011 10:24 AM
> To: Weddington, Eric
> Cc: Georg-Johann Lay; gcc-patches@gcc.gnu.org; Denis Chertykov; Anatoly
> Sokolov; Joerg Wunsch
> Subject: Re: [Patch][AVR]: Use define_c_enum where appropriate
> 
 
> > +  "AVR_HAVE_MUL"
> > +  "fmuls %1,%2
> > +   movw %0,r0
> > +   clr r1"
> 
> The rest of the port is fairly consistent using __zero_reg__ instead
> of r1.  You probably want to continue that.

Yes, we will definitely need to use __zero_reg__ as there are new avr device 
variants (that need to be committed) where r0-r15 don't exist, which means that 
__zero_reg__ won't always be r1.


Re: [PATCH 3/6] Allow jumps in epilogues

2011-03-23 Thread Richard Henderson
On 03/23/2011 07:50 AM, Bernd Schmidt wrote:
> dwarf2out has code that starts scanning from NOTE_INSN_EPILOGUE_BEG
> until it finds the return jump. When there is common code in several
> blocks ending in a return, we might want to share this, and in that case
> it would be possible to encounter a simplejump rather than a returnjump.
> This should be safe, and the following patch allows it.

With no more code than this, I cannot believe you're generating correct
unwind info anymore.

It would be possible to handle code merging including epilogue blocks
if (and IMO only if) you track unwind state on a per-block basis, and
propagate this information around the CFG, finally linearizing this
when blocks are re-ordered for the last time before final.

At present, sadly, we assume steady-state for the unwind info except
before PROLOGUE_END and after EPILOGUE_BEG.


r~


Re: [PATCH 3/6] Allow jumps in epilogues

2011-03-23 Thread Bernd Schmidt
On 03/23/2011 05:46 PM, Richard Henderson wrote:
> On 03/23/2011 07:50 AM, Bernd Schmidt wrote:
>> dwarf2out has code that starts scanning from NOTE_INSN_EPILOGUE_BEG
>> until it finds the return jump. When there is common code in several
>> blocks ending in a return, we might want to share this, and in that case
>> it would be possible to encounter a simplejump rather than a returnjump.
>> This should be safe, and the following patch allows it.
> 
> With no more code than this, I cannot believe you're generating correct
> unwind info anymore.

Why not? Are you worried about the code at the destination of the jump?
That should be preceded by another block falling through into it which
also has a NOTE_INSN_EPILOGUE_BEG.

If that isn't the problem you have in mind, what is and how can we test
for it?


Bernd


Re: [PATCH 2/4] Tweaks to C++ -> call graph interface

2011-03-23 Thread Jan Hubicka
> I concede that my understanding of the C++ front-end inner workings
> are quite narrow and so the folling is basically a suggestion.  But it
> seems to me that at a few places where C++ queries the call graph for
> a node, the lazy node creation is not necessary.  If a maintainer can
> verify and approve (parts of) this after the big patch is committed,
> it would be a nice cleanup too.
> 
> Thanks,
> 
> Martin
> 
> 
> Index: src/gcc/cp/class.c
> ===
> --- src.orig/gcc/cp/class.c   2011-03-18 19:34:07.0 +0100
> +++ src/gcc/cp/class.c2011-03-18 19:34:38.0 +0100
> @@ -8405,7 +8405,7 @@ cp_fold_obj_type_ref (tree ref, tree kno
> DECL_VINDEX (fndecl)));
>  #endif
>  
> -  cgraph_get_create_node (fndecl)->local.vtable_method = true;
> +  cgraph_get_node (fndecl)->local.vtable_method = true;

I believe that vtable_method is ugly hack to work around the fact that we was
not able to optimize away functions that has address taken.  Perhaps this can
just be removed now?
>  
>return build_address (fndecl);
>  }
> Index: src/gcc/cp/decl2.c
> ===
> --- src.orig/gcc/cp/decl2.c   2011-03-18 19:34:07.0 +0100
> +++ src/gcc/cp/decl2.c2011-03-18 19:34:39.0 +0100
> @@ -3375,12 +3375,12 @@ cxx_callgraph_analyze_expr (tree *tp, in
>  case PTRMEM_CST:
>if (TYPE_PTRMEMFUNC_P (TREE_TYPE (t)))
>   cgraph_mark_address_taken_node (
> -   cgraph_get_create_node (PTRMEM_CST_MEMBER (t)));
> +   cgraph_do_get_node (PTRMEM_CST_MEMBER (t)));

I believe this si not safe in general, since it happens at cgraph construction 
time.
However perhaps all of those are gimplified away now?
>break;
>  case BASELINK:
>if (TREE_CODE (BASELINK_FUNCTIONS (t)) == FUNCTION_DECL)
>   cgraph_mark_address_taken_node (
> -   cgraph_get_create_node (BASELINK_FUNCTIONS (t)));
> +   cgraph_do_get_node (BASELINK_FUNCTIONS (t)));
>break;
>  case VAR_DECL:
>if (DECL_CONTEXT (t)
> @@ -3893,7 +3893,7 @@ cp_write_global_declarations (void)
> if (!DECL_EXTERNAL (decl)
> && decl_needed_p (decl)
> && !TREE_ASM_WRITTEN (decl)
> -   && !cgraph_get_create_node (decl)->local.finalized)
> +   && !cgraph_get_node (decl)->local.finalized)
>   {
> /* We will output the function; no longer consider it in this
>loop.  */
> Index: src/gcc/cp/method.c
> ===
> --- src.orig/gcc/cp/method.c  2011-03-18 19:34:07.0 +0100
> +++ src/gcc/cp/method.c   2011-03-18 19:34:40.0 +0100
> @@ -260,7 +260,7 @@ make_alias_for_thunk (tree function)
>if (!flag_syntax_only)
>  {
>struct cgraph_node *aliasn;
> -  aliasn = cgraph_same_body_alias (cgraph_get_create_node (function),
> +  aliasn = cgraph_same_body_alias (cgraph_do_get_node (function),
>  alias, function);
>DECL_ASSEMBLER_NAME (function);
>gcc_assert (aliasn != NULL);
> @@ -379,7 +379,7 @@ use_thunk (tree thunk_fndecl, bool emit_
>a = nreverse (t);
>DECL_ARGUMENTS (thunk_fndecl) = a;
>TREE_ASM_WRITTEN (thunk_fndecl) = 1;
> -  cgraph_add_thunk (cgraph_get_create_node (function), thunk_fndecl, 
> function,
> +  cgraph_add_thunk (cgraph_do_get_node (function), thunk_fndecl, function,

These two ought t be safe.
>   this_adjusting, fixed_offset, virtual_value,
>   virtual_offset, alias);
>  
> Index: src/gcc/cp/optimize.c
> ===
> --- src.orig/gcc/cp/optimize.c2011-03-18 19:34:07.0 +0100
> +++ src/gcc/cp/optimize.c 2011-03-18 19:34:40.0 +0100
> @@ -309,8 +309,9 @@ maybe_clone_body (tree fn)
> && (!DECL_ONE_ONLY (fns[0])
> || (HAVE_COMDAT_GROUP
> && DECL_WEAK (fns[0])))
> -   && cgraph_same_body_alias (cgraph_get_create_node (fns[0]), clone,
> -  fns[0]))
> +   && (flag_syntax_only
> +   || cgraph_same_body_alias (cgraph_do_get_node (fns[0]), clone,
> +  fns[0])))

Same here, the node we are producing alias of should exist.
>   {
> alias = true;
> if (DECL_ONE_ONLY (fns[0]))
> @@ -424,8 +425,8 @@ maybe_clone_body (tree fn)
> /* If *[CD][12]* dtors go into the *[CD]5* comdat group and dtor is
>virtual, it goes into the same comdat group as well.  */
> DECL_COMDAT_GROUP (fns[2]) = comdat_group;
> -   base_dtor_node = cgraph_get_create_node (fns[0]);
> -   deleting_dtor_node = cgraph_get_create_node (fns[2]);
> +   base_dtor_node = c

Re: [PATCH 4/4] Tweaks to objc -> call graph interface

2011-03-23 Thread Jan Hubicka
> Hi,
> 
> thi is really only based on successful testing and not much analyzis
> of the context but it seems that we don't need lazy node construction
> here.  It would be nice not to have it after the big patch gets in.
> 
> Thanks,
> 
> Martin
> 
> 
> 2011-03-18  Martin Jambor  
> 
>   * objc-act.c (mark_referenced_methods): Call cgraph_do_get_node
>   instead of cgraph_get_create_node.

Yes, this seems safe to me. Functions in protocols are finished and thus have
cgraph node.
Honza


Re: [PATCH 3/4] A tweak to fortran -> call graph interface

2011-03-23 Thread Jan Hubicka
> Hi,
> 
> it seems to me that fortran can call cgraph_create_node directly
> without checking for its existence first.
> 
> Thanks,
> 
> Martin
> 
> 
> 2011-03-18  Martin Jambor  
> 
>   * trans-decl.c (gfc_generate_function_code): Call cgraph_create_node
>   instead of cgraph_get_create_node.
> 
> Index: src/gcc/fortran/trans-decl.c
> ===
> --- src.orig/gcc/fortran/trans-decl.c 2011-03-18 19:45:10.0 +0100
> +++ src/gcc/fortran/trans-decl.c  2011-03-18 19:45:12.0 +0100
> @@ -4924,7 +4924,7 @@ gfc_generate_function_code (gfc_namespac
>if (decl_function_context (fndecl))
>  /* Register this function with cgraph just far enough to get it
> added to our parent's nested function list.  */
> -(void) cgraph_get_create_node (fndecl);
> +(void) cgraph_create_node (fndecl);

this happens when function node is being build so indeed we want to create node 
here.
Honza


Re: [PATCH 3/6] Allow jumps in epilogues

2011-03-23 Thread Richard Henderson
On 03/23/2011 09:48 AM, Bernd Schmidt wrote:
>> With no more code than this, I cannot believe you're generating correct
>> unwind info anymore.
> 
> Why not? Are you worried about the code at the destination of the jump?
> That should be preceded by another block falling through into it which
> also has a NOTE_INSN_EPILOGUE_BEG.
> 
> If that isn't the problem you have in mind, what is and how can we test
> for it?

body
body
restore r1  XXX
restore r2  XXX
jmp L2  XXX

L1: bodyYYY
bodyYYY
restore r2

L2: restore r3
return

Assume for the moment that "restore" on this target is something that
can't be delayed or repeated.  E.g. a pop, rather than a move which
leaves the saved value in memory at a unknown offset from the CFA.

This means we have to emit unwind directives immediately after the 
restore insn and cannot delay the epilogue unwind until we deallocate
the entire stack frame.

This means that your patch either gets the unwind info wrong for
the XXX sequence or the YYY sequence.

Correct unwind info would look like

body
body
.cfi_remember_state
restore r1
.cfi_restore r1
restore r2
.cfi_restore r2
jmp L2
.cfi_restore_state

L1: body
body
restore r2
.cfi_restore r2

L2: // validate the unwind info across the CFG making sure that the incoming
// edges contain the same unwind info here.
restore r3
.cfi_restore r3
return

In general, with shrink-wrapping, we can have essentially arbitrary
differences in unwind info between blocks that are sequential.  We have
to be prepared to fully adjust the unwind state between blocks.

Assume a { x } is the set of registers saved into the stack frame in a
given block.  We have both incoming and outgoing sets.

foo:// in: { }
cmp r1,r2
jne L1  // out: { }

L0: // in: { }
save r8
save r9
body
... // out: { r8, r9 }

L2: // in: { r8, r9, r10 }
body
body
... // out: { r8, r9, r10 }

L1: // in: { }
save r8
save r9
save r10
body
... // out: { r8, r9, r10 }

L3: // in: { r8, r9, r10 }
restore r10 // out: { r8, r9 }

L4: // in: { r8, r9 }
restore r9
restore r8
return

This layout requires more than just .cfi_remember_state/restore_state
between blocks.  We have to be prepared to emit full unwind info at
any point.  Assume cfi info marked with XXX exists between basic blocks
to fixup the transition points:

L0: save r8
save r9
.cfi_offset r8,x
.cfi_offset r9,y
body

.cfi_offset r10,z   XXX

L2: body
body

.cfi_restore r8 XXX
.cfi_restore r9 XXX
.cfi_restore r10XXX

L1: save r8
save r9
save r10
.cfi_offset r8,x
.cfi_offset r9,y
.cfi_offset r10,z
body

If this isn't clear, please ask questions.  The problem of unwinding is
way more complicated than what you appear to be assuming.


r~


[Patch] Ensure libbffastfp overrides libgcc

2011-03-23 Thread Henderson, Stuart
The attached patch ensures libbffastfp overrides libgcc when -mfast-fp is used 
for bfin-uclinux targets.


2011-03-23  Stuart Henderson  

   From Jie Zhang:
   * config/bfin/uclinux.h (LINK_GCC_C_SEQUENCE_SPEC): Make sure
   libbffastfp overrides libgcc when -mfast-fp.



I don't have write permissions.
Thanks,
Stu


upstream.patch
Description: upstream.patch


Re: [PATCH 3/6] Allow jumps in epilogues

2011-03-23 Thread Bernd Schmidt
On 03/23/2011 06:19 PM, Richard Henderson wrote:
>   body
>   body
>   restore r1  XXX
>   restore r2  XXX
>   jmp L2  XXX
> 
> L1:   bodyYYY
>   bodyYYY
>   restore r2
> 
> L2:   restore r3
>   return

> In general, with shrink-wrapping, we can have essentially arbitrary
> differences in unwind info between blocks that are sequential.

I don't think this can actually happen with the current implementation.
There is only one prologue, and all epilogues (the normal one and the
sibcall epilogues) match it exactly. I don't believe we can generate
code as in the example above, both before and after my patch.


Bernd


Re: [PATCH 3/6] Allow jumps in epilogues

2011-03-23 Thread Richard Henderson
On 03/23/2011 10:22 AM, Bernd Schmidt wrote:
> On 03/23/2011 06:19 PM, Richard Henderson wrote:
>>  body
>>  body
>>  restore r1  XXX
>>  restore r2  XXX
>>  jmp L2  XXX
>>
>> L1:  bodyYYY
>>  bodyYYY
>>  restore r2
>>
>> L2:  restore r3
>>  return
> 
>> In general, with shrink-wrapping, we can have essentially arbitrary
>> differences in unwind info between blocks that are sequential.
> 
> I don't think this can actually happen with the current implementation.
> There is only one prologue, and all epilogues (the normal one and the
> sibcall epilogues) match it exactly. I don't believe we can generate
> code as in the example above, both before and after my patch.

Um.. then what's this "allow jumps in epilogues" thing of which you speak?
If there's a jump, then it goes somewhere, and branches over something.
I see no constraints on what that something might be.

Could you give an example of a transformation that is allowed by this?



r~


Re: Fix a few use-after-free issues

2011-03-23 Thread Jeff Law
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 03/23/11 08:25, Jeff Law wrote:
> On 03/21/11 11:50, Jakub Jelinek wrote:
>> On Mon, Mar 21, 2011 at 11:37:16AM -0600, Jeff Law wrote:
>>> Similarly for redirect_edge_succ_nodup in this fragment:
>>>
>>> ret = redirect_edge_succ_nodup (e, dest);
>>> if (dump_file)
>>> fprintf (dump_file, "Fallthru edge %i->%i redirected to %i\n",
>>>  e->src->index, e->dest->index, dest->index);
>>>   }
>>> Luckily in this case the use-after-free only occurs when dumping, so it
>>> won't typically affect end users.
> 
>> Well, the message is wrong anyway, becase e->dest->index will be
>> dest->index (with the exception that e has been remove_edge, but then it is
>> the use after free).  Guess the message should be printed before the
>> redirect_edge_succ_nodup call, or remember e->dest->index in some local
>> variable and print that variable after the call.
> Yea, I'll just move the message before the call to
> redirecT_edge_succ_nodup.
Attached is the actual patch that was checked in after another bootstrap
and regression test.



-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNii+4AAoJEBRtltQi2kC7aLsIAJQ8JrBCCCSNC0HH+1NgAdyp
aUFEpQJUV9KgYpKzcqtKY5+kJI4WXRnRXsMmXuC4rWKV5rsnGmCzOSoHolHecLXB
F7J3KaCwg51tcJ/wxXUCPUy+MhZ/ZWHBVbLzw+aQ+O4mXqwnHoRRxnUwGmas6rDk
+pFXjmTArphMQdQ/xnOtXqUylecf4iu06Axn+0UXVy2J3CHT3jPvjuNZUHVUcVq+
qNrUTwYhDMHPXQtZWGz4RNqoACmpY/ku53xXwJq4PrcD1g/rl8Vy6aVnTPE9lONv
rXmxr/FgNFZixKxNhaYz6A+maXbM4uRGZvSoGuO0do/YulZXXN+Ym5HHlocM/pQ=
=/fA+
-END PGP SIGNATURE-
Index: cfg.c
===
*** cfg.c   (revision 171351)
--- cfg.c   (working copy)
*** redirect_edge_succ_nodup (edge e, basic_
*** 402,409 
if (s->probability > REG_BR_PROB_BASE)
s->probability = REG_BR_PROB_BASE;
s->count += e->count;
-   remove_edge (e);
redirect_edge_var_map_dup (s, e);
e = s;
  }
else
--- 402,409 
if (s->probability > REG_BR_PROB_BASE)
s->probability = REG_BR_PROB_BASE;
s->count += e->count;
redirect_edge_var_map_dup (s, e);
+   remove_edge (e);
e = s;
  }
else
Index: cfgrtl.c
===
*** cfgrtl.c(revision 171351)
--- cfgrtl.c(working copy)
*** cfg_layout_redirect_edge_and_branch (edg
*** 2537,2545 
  e->flags &= ~EDGE_FALLTHRU;
  redirected = redirect_branch_edge (e, dest);
  gcc_assert (redirected);
! e->flags |= EDGE_FALLTHRU;
! df_set_bb_dirty (e->src);
! return e;
}
/* In case we are redirecting fallthru edge to the branch edge
 of conditional jump, remove it.  */
--- 2537,2545 
  e->flags &= ~EDGE_FALLTHRU;
  redirected = redirect_branch_edge (e, dest);
  gcc_assert (redirected);
! redirected->flags |= EDGE_FALLTHRU;
! df_set_bb_dirty (redirected->src);
! return redirected;
}
/* In case we are redirecting fallthru edge to the branch edge
 of conditional jump, remove it.  */
*** cfg_layout_redirect_edge_and_branch (edg
*** 2553,2562 
  && onlyjump_p (BB_END (src)))
delete_insn (BB_END (src));
}
-   ret = redirect_edge_succ_nodup (e, dest);
if (dump_file)
fprintf (dump_file, "Fallthru edge %i->%i redirected to %i\n",
 e->src->index, e->dest->index, dest->index);
  }
else
  ret = redirect_branch_edge (e, dest);
--- 2553,2562 
  && onlyjump_p (BB_END (src)))
delete_insn (BB_END (src));
}
if (dump_file)
fprintf (dump_file, "Fallthru edge %i->%i redirected to %i\n",
 e->src->index, e->dest->index, dest->index);
+   ret = redirect_edge_succ_nodup (e, dest);
  }
else
  ret = redirect_branch_edge (e, dest);


RE: Fix for PR target/47779

2011-03-23 Thread Henderson, Stuart
Thanks.

I don't have write permissions.  Could someone apply it to trunk/appropriate 
branches?

Stu

-Original Message-
From: Bernd Schmidt [mailto:ber...@codesourcery.com]
Sent: 22 March 2011 16:03
To: Henderson, Stuart
Cc: gcc-patches@gcc.gnu.org
Subject: Re: Fix for PR target/47779

On 03/22/2011 10:54 AM, Henderson, Stuart wrote:
> ping.
> http://gcc.gnu.org/ml/gcc-patches/2011-03/msg00505.html

> Please can you review the attached patch to fix PR 47779.
>
> The register constant names for bfin were clashing with uClibc 
> (sys/ucontext.h) when cross compiling.  I've simply changed the naming 
> convention from REG_x to the more common x_REG.
>
>
> 2011-03-10  Stuart Henderson  
>
> PR target/47779
> * config/bfin/predicates.md: Change register constants from REG_x 
> form to x_REG.
> * config/bfin/bfin.c: Likewise
> * config/bfin/bfin.h: Likewise
> * config/bfin/sync.md: Likewise
> * config/bfin/bfin.md: Likewise

I still kind of think this must be a uClibc bug, but OK.


Bernd


[PATCH, 4.7] Add float/double vector reductions to VSX

2011-03-23 Thread Michael Meissner
Pat Haugen noticed we were doing stores in benchmarks where we were doing
vector reductions to extract the final float element.  So I decided to take a
look.  This code implements the vector reductions without doing stores for
float vectors, and eliminates a vector shift for double vectors.

I suspect there are more opportunities for improving vector extract and insert
with VSX.

I did a bootstrap and make check with no regressions.  Is this ok to install on
the trunk?

[gcc]
2011-03-23  Michael Meissner  

PR target/48258
* config/rs6000/vector.md (UNSPEC_REDUC): New unspec for vector
reduction.
(VEC_reduc): New code iterator and splitters for vector reduction.
(VEC_reduc_name): Ditto.
(VEC_reduc_rtx): Ditto.
(reduc__v2df): Vector reduction expanders for VSX.
(reduc__v4sf): Ditto.

* config/rs6000/rs6000.c (rs6000_expand_vector_extract): Add
support for extracting SF on VSX.

* config/rs6000/vsx.md (vsx_xscvspdp_scalar2): New insn for
generating xscvspdp.
(vsx_extract_v4sf): New insn to extract SF from V4SF vector.
(vsx_reduc__v2df): New insns and splitters for
double add, minimum, maximum vector reduction.
(vsx_reduc__v4sf): Ditto.
(vsx_reduc__v2df2_scalar): New combiner insn to
optimize double vector reduction.
(vsx_reduc__v4sf_scalar): Ditto.

[gcc/testsuite]
2011-03-23  Michael Meissner  

PR target/48258
* gcc.target/powerpc/pr48258-1.c: New file.
* gcc.target/powerpc/pr48258-2.c: Ditto.


-- 
Michael Meissner, IBM
5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA
meiss...@linux.vnet.ibm.com fax +1 (978) 399-6899
Index: gcc/config/rs6000/vector.md
===
--- gcc/config/rs6000/vector.md (revision 171306)
+++ gcc/config/rs6000/vector.md (working copy)
@@ -74,7 +74,19 @@ (define_mode_attr VEC_INT [(V4SF  "V4SI"
   (V2DF  "V2DI")])
 
 ;; constants for unspec
-(define_c_enum "unspec" [UNSPEC_PREDICATE])
+(define_c_enum "unspec" [UNSPEC_PREDICATE
+UNSPEC_REDUC])
+
+;; Vector reduction code iterators
+(define_code_iterator VEC_reduc [plus smin smax])
+
+(define_code_attr VEC_reduc_name [(plus "splus")
+ (smin "smin")
+ (smax "smax")])
+
+(define_code_attr VEC_reduc_rtx [(plus "add")
+(smin "smin")
+(smax "smax")])
 
 
 ;; Vector move instructions.
@@ -991,6 +1003,41 @@ (define_expand "vashr3"
   "TARGET_ALTIVEC"
   "")
 
+;; Vector reduction expanders for VSX
+
+(define_expand "reduc__v2df"
+  [(parallel [(set (match_operand:V2DF 0 "vfloat_operand" "")
+  (VEC_reduc:V2DF
+   (vec_concat:V2DF
+(vec_select:DF
+ (match_operand:V2DF 1 "vfloat_operand" "")
+ (parallel [(const_int 1)]))
+(vec_select:DF
+ (match_dup 1)
+ (parallel [(const_int 0)])))
+   (match_dup 1)))
+ (clobber (match_scratch:V2DF 2 ""))])]
+  "VECTOR_UNIT_VSX_P (V2DFmode)"
+  "")
+
+; The (VEC_reduc:V4SF
+;  (op1)
+;  (unspec:V4SF [(const_int 0)] UNSPEC_REDUC))
+;
+; is to allow us to use a code iterator, but not completely list all of the
+; vector rotates, etc. to prevent canonicalization
+
+(define_expand "reduc__v4sf"
+  [(parallel [(set (match_operand:V4SF 0 "vfloat_operand" "")
+  (VEC_reduc:V4SF
+   (unspec:V4SF [(const_int 0)] UNSPEC_REDUC)
+   (match_operand:V4SF 1 "vfloat_operand" "")))
+ (clobber (match_scratch:V4SF 2 ""))
+ (clobber (match_scratch:V4SF 3 ""))])]
+  "VECTOR_UNIT_VSX_P (V4SFmode)"
+  "")
+
+
 ;;; Expanders for vector insn patterns shared between the SPE and 
TARGET_PAIRED systems.
 
 (define_expand "absv2sf2"
Index: gcc/config/rs6000/rs6000.c
===
--- gcc/config/rs6000/rs6000.c  (revision 171306)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -5492,12 +5492,22 @@ rs6000_expand_vector_extract (rtx target
   enum machine_mode inner_mode = GET_MODE_INNER (mode);
   rtx mem;
 
-  if (VECTOR_MEM_VSX_P (mode) && (mode == V2DFmode || mode == V2DImode))
+  if (VECTOR_MEM_VSX_P (mode))
 {
-  rtx (*extract_func) (rtx, rtx, rtx)
-   = ((mode == V2DFmode) ? gen_vsx_extract_v2df : gen_vsx_extract_v2di);
-  emit_insn (extract_func (target, vec, GEN_INT (elt)));
-  return;
+  switch (mode)
+   {
+   default:
+ break;
+   case V2DFmode:
+ emit_insn (gen_vsx_extract_v2df (target, vec, GEN_INT (elt)));
+ return;
+   case V2DImode:
+ emit_insn (gen_vsx_extract_v2di (target, vec, GEN_INT (elt)));
+ return;
+ 

Re: PATCH: PR other/48007: Unwind library doesn't work with UNITS_PER_WORD > sizeof (void *)

2011-03-23 Thread Richard Henderson
On 03/22/2011 10:01 PM, H.J. Lu wrote:
>>> Will there be a case where 2 copies of unwind-dw2.c are within the same
>>> process?
>>
>> Sure, that's easy.  I think what you are really asking is: will there be
>> a case where we could call functions from one copy and then pass the
>> context to the functions from a different copy.  I don't know the answer
>> to that, but it doesn't seem impossible.

It really shouldn't be, but judging from the existance of 
_Unwind_IsExtendedContext
it appears that it really is.  Which, frankly, I assume is some sort of strange
packaging problem between glibc and libgcc_s.so.

Jakub, do you recall anything more specific about this?

2007-01-03  Jakub Jelinek  

* unwind-dw2.c (SIGNAL_FRAME_BIT, EXTENDED_CONTEXT_BIT): Define.
(struct _Unwind_Context): Rename args_size to flags, remove
signal_frame field, add a new args_size field and version field.
(_Unwind_IsSignalFrame, _Unwind_SetSignalFrame,
_Unwind_IsExtendedContext): New inline functions.
(_Unwind_GetGR, _Unwind_SetGR, _Unwind_GetGRPtr, _Unwind_SetGRPtr):
Assume by_value array is only present if _Unwind_IsExtendedContext.
(_Unwind_GetIPInfo, execute_cfa_program, uw_frame_state_for): Use
_Unwind_IsSignalFrame.
...

> Then. will this be acceptable?

No.

Ideally we'd remove the by_value array, but I guess that's now versioned
so it'll have to stay even though unused.

Add a new

_Unwind_Word data[DWARF_FRAME_REGISTERS+1];

at the end.  Increment the context version number.  If the version is
sufficiently high, implement _Unwind_SetGRValue via

context->data[index] = val;
context->reg[index] = &context->data[index];

and do not set by_value at all.


r~


[PATCH] reload: Avoid superfluous reloads after find_reloads_subreg_address

2011-03-23 Thread Andreas Krebbel
Hi,

find_reloads_subreg_address has to get rid of (subreg (mem ...)) RTXs.
In order to do so the full address sometimes gets reloaded. E.g. if
the resulting address is invalid and gets pushed into the literal
pool.  Unfortunately that information is not propagated into
find_reloads.  So find_reloads pushes additional reloads although the
address has already been fixed.


I've found this issue while debugging the optional_dim_3.f90 failure
on S/390 with -march=z196:

(set (reg:HI 1) (mem:HI (symbol_ref:DI ("foo"
(set (reg:SI 2) (sign_extend:SI (subreg:QI (reg:HI 1) 1)))

The (subreg:QI (mem:HI (symbol_ref:DI "foo")) 1) is folded into:

(mem:HI (const:DI (plus:DI (symbol_ref:DI ("foo")) (const_int 1

Which is an invalid address on S/390 since we cannot cope with odd
addends for symbolic constants.  So the whole thing ends up in the
literal pool and the resulting literal pool address of course is
perfectly valid.  Since this information is not propagated into
find_reloads two additional reloads get issued.

The attached patch introduces the address_reloaded flag also for
find_reloads_subreg_address and sets it accordingly.

This is probably not a correctness issue since reload will anyway be
able to fix up the invalid address.  But since it avoids pointless
reloads I think its a good thing to do and will help to improve
performance.

Bootstrapped and regtested on x86_64, s390 and s390x.

Ok for mainline?

Bye,

-Andreas-


2011-03-23  Andreas Krebbel  

* reload.c (find_reloads_subreg_address): Add address_reloaded
parameter and return true there if the full address has been
reloaded.
(find_reloads_toplev): Pass address_reloaded flag.
(find_reloads_address_1): Don't use address_reloaded parameter.


Index: gcc/reload.c
===
*** gcc/reload.c.orig
--- gcc/reload.c
*** static void find_reloads_address_part (r
*** 285,291 
   enum machine_mode, int,
   enum reload_type, int);
  static rtx find_reloads_subreg_address (rtx, int, int, enum reload_type,
!   int, rtx);
  static void copy_replacements_1 (rtx *, rtx *, int);
  static int find_inc_amount (rtx, rtx);
  static int refers_to_mem_for_reload_p (rtx);
--- 285,291 
   enum machine_mode, int,
   enum reload_type, int);
  static rtx find_reloads_subreg_address (rtx, int, int, enum reload_type,
!   int, rtx, int *);
  static void copy_replacements_1 (rtx *, rtx *, int);
  static int find_inc_amount (rtx, rtx);
  static int refers_to_mem_for_reload_p (rtx);
*** find_reloads_toplev (rtx x, int opnum, e
*** 4759,4765 
   || ! offsettable_memref_p (reg_equiv_mem[regno])
   || num_not_at_initial_offset
x = find_reloads_subreg_address (x, 1, opnum, type, ind_levels,
!insn);
  }
  
for (copied = 0, i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
--- 4759,4765 
   || ! offsettable_memref_p (reg_equiv_mem[regno])
   || num_not_at_initial_offset
x = find_reloads_subreg_address (x, 1, opnum, type, ind_levels,
!  insn, address_reloaded);
  }
  
for (copied = 0, i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
*** find_reloads_address_1 (enum machine_mod
*** 5995,6001 
{
  x = find_reloads_subreg_address (x, 0, opnum,
   ADDR_TYPE (type),
!  ind_levels, insn);
  push_reload (x, NULL_RTX, loc, (rtx*) 0, rclass,
   GET_MODE (x), VOIDmode, 0, 0, opnum, type);
  return 1;
--- 5995,6001 
{
  x = find_reloads_subreg_address (x, 0, opnum,
   ADDR_TYPE (type),
!  ind_levels, insn, NULL);
  push_reload (x, NULL_RTX, loc, (rtx*) 0, rclass,
   GET_MODE (x), VOIDmode, 0, 0, opnum, type);
  return 1;
*** find_reloads_address_part (rtx x, rtx *l
*** 6097,6105 
  
  static rtx
  find_reloads_subreg_address (rtx x, int force_replace, int opnum,
!enum reload_type type, int ind_levels, rtx insn)
  {
int regno = REGNO (SUBREG_REG (x));
  
if (reg_equiv_memory_loc[regno])
  {
--- 6097,6107 
  
  static rtx
  find_reloads_subreg_address (rtx x, int force_replace, int opnum,
!enum reload_type type, int ind_levels, rtx insn,
!int *ad

Re: Cleaning up expand optabs code

2011-03-23 Thread Anatoly Sokolov

Hi.


From: "Richard Henderson" 
Sent: Tuesday, March 22, 2011 8:48 PM


Ok.  Watch out for other target problems this week.





This patch casue ICE on H8300 target:

make[4]: Entering directory 
`/home/aesok/h83001/build/h8300-elf/h8300h/libgcc'

# If this is the top-level multilib, build all the other
# multilibs.
/home/aesok/h83001/build/./gcc/xgcc -B/home/aesok/h83001/build/./gcc/ -nostdinc
-B/home/aesok/h83001/build/h8300-elf/newlib/ -isystem 
/home/aesok/h83001/build/h
8300-elf/newlib/targ-include -isystem 
/home/aesok/h83001/combined/newlib/libc/in

clude -B/home/aesok/cross-local/h8300-elf/h8300-elf/bin/ -B/home/aesok/cross-loc
al/h8300-elf/h8300-elf/lib/ -isystem 
/home/aesok/cross-local/h8300-elf/h8300-elf
/include -isystem 
/home/aesok/cross-local/h8300-elf/h8300-elf/sys-include -L/hom

e/aesok/h83001/build/./ld-g -O2 -mh -O2  -g -O2 -DIN_GCC -DCROSS_DIRECTORY_S
TRUCTURE  -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-pro
totypes -Wold-style-definition  -isystem 
./include  -DDF=SF -g  -DIN_LIBGCC2 -D_

_GCC_FLOAT_NOT_NEEDED -fno-stack-protector -Dinhibit_libc  -I. -I. -I../../.././
gcc -I../../../../combined/libgcc -I../../../../combined/libgcc/. -I../../../../
combined/libgcc/../gcc -I../../../../combined/libgcc/../include  -DHAVE_CC_TLS 
-
DUSE_EMUTLS -o unwind-sjlj.o -MT unwind-sjlj.o -MD -MP -MF 
unwind-sjlj.dep -fexc

eptions -c ../../../../combined/libgcc/../gcc/unwind-sjlj.c
../../../../combined/libgcc/../gcc/unwind-sjlj.c: In function 
'uw_install_contex

t.isra___1':
../../../../combined/libgcc/../gcc/unwind-sjlj.c:306:11: internal compiler 
error

: in expand_jump_insn, at optabs.c:7181
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
make[4]: *** [unwind-sjlj.o] Error 1
make[4]: Leaving directory 
`/home/aesok/h83001/build/h8300-elf/h8300h/libgcc'

make[3]: *** [multi-do] Error 1
make[3]: Leaving directory `/home/aesok/h83001/build/h8300-elf/libgcc'
make[2]: *** [all-multi] Error 2
make[2]: Leaving directory `/home/aesok/h83001/build/h8300-elf/libgcc'
make[1]: *** [all-target-libgcc] Error 2
make[1]: Leaving directory `/home/aesok/h83001/build'

Anatoly. 



Re: PATCH: PR other/48007: Unwind library doesn't work with UNITS_PER_WORD > sizeof (void *)

2011-03-23 Thread Jakub Jelinek
On Wed, Mar 23, 2011 at 10:50:35AM -0700, Richard Henderson wrote:
> >>
> >> Sure, that's easy.  I think what you are really asking is: will there be
> >> a case where we could call functions from one copy and then pass the
> >> context to the functions from a different copy.  I don't know the answer
> >> to that, but it doesn't seem impossible.
> 
> It really shouldn't be, but judging from the existance of 
> _Unwind_IsExtendedContext
> it appears that it really is.  Which, frankly, I assume is some sort of 
> strange
> packaging problem between glibc and libgcc_s.so.
> 
> Jakub, do you recall anything more specific about this?

http://gcc.gnu.org/ml/gcc-patches/2006-12/msg01769.html
has some info.

> Ideally we'd remove the by_value array, but I guess that's now versioned
> so it'll have to stay even though unused.
> 
> Add a new
> 
>   _Unwind_Word data[DWARF_FRAME_REGISTERS+1];
> 
> at the end.  Increment the context version number.  If the version is

For several targets that would grow the context significantly, do you think
we really have to do that for all targets rather than just for the
sizeof (_Unwind_Word) > sizeof (void *) ones?  The accessors are wrapped
in inline functions anyway.

> sufficiently high, implement _Unwind_SetGRValue via
> 
>   context->data[index] = val;
>   context->reg[index] = &context->data[index];
> 
> and do not set by_value at all.

Jakub


Re: [Patch][AVR]: Use define_c_enum where appropriate

2011-03-23 Thread Georg-Johann Lay

Weddington, Eric schrieb:


Hi Johann,

Can we hold off on this patch for just a little bit? I agree it would
be good to clean it up, but I would like to get in the attached patch
to add some builtin functions that Anatoly and I worked on. The patch
was (nominally) for 4.4. I need to see if it will patch cleanly to
trunk, and if not, then I'd like to keep the changes minimal.


Your patch is more elaborate, I just didn't know you planned to commit 
builtin support, nothing exciting in my work.


+case AVR_BUILTIN_DELAY_CYCLES:
+  {
+arg0 = CALL_EXPR_ARG (exp, 0);
+op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
+
+if (!CONSTANT_P (op0))
+  error ("__builtin_avr_delay_cycles expects an integer 
constant.");


Should be
  if (!CONST_INT_P (op0))
 error ("__builtin_avr_delay_cycles expects a compile time 
constant.");


You use INTVAL in the insns, and symbols/addresses cannot be handled 
reasonably.


AFAIR avr-libc casts float down to int, so no need to handle/cast float?

+emit_insn (gen_delay_cycles (op0));
+return 0;
+  }
+}
+
+  for (i = 0, d = bdesc_1arg; i < ARRAY_SIZE (bdesc_1arg); i++, d++)
+if (d->code == fcode)
+  return avr_expand_unop_builtin (d->icode, exp, target);
+
+  for (i = 0, d = bdesc_1arg; i < ARRAY_SIZE (bdesc_2arg); i++, d++)
-^
Tippo?

+if (d->code == fcode)
+  return avr_expand_binop_builtin (d->icode, exp, target);

Johann


[Patch] get an order number on -fdump-tree-all

2011-03-23 Thread Pierre Vittet

Hello,

When we use fdump-tree-all, we get the dump file, however there is no 
way to know in which order the pass was executed.
We can use gdb with a breakpoint at the good position (something like 
execute_one_pass), however this solution is not satisfiying for plugin 
devellopers for exemple.
There is a number in the name of the dumpped file but from what I know 
it is a static number related to the pass but it has nothing to do with 
the order in which it is executed.


I would enjoy to have a number, giving the pass position, something like :

1.cfile.c.XXXt.pass

I have make a small change in tree-dump.c in order to have this working 
with -fdump-tree-all (patch file in attachment)


The drawback is that, as the pass is called for each function, we get a 
different file for each function, while it was written in the same file 
previously.



I am also surprized to see that the function print_current_pass is only 
called on a fail and that debug_pass doesn't appear to be called at all. 
Maybe in DEBUG, or at least with an f*_dump_all, we could print the 
order of the pass.


thanks

Pierre Vittet
Index: gcc/tree-dump.c
===
--- gcc/tree-dump.c (revision 171340)
+++ gcc/tree-dump.c (working copy)
@@ -925,21 +925,35 @@
   struct dump_file_info *dfi;
   FILE *stream;
 
+  /*allow to know how many pass have already been explored*/
+  static int nb_explored_pass = 0;
+  /*add to the name a position at which the pass is explored*/
+  char * name_with_pass_pos;
+  int name_with_pass_pos_size;
+ 
   if (phase == TDI_none || !dump_enabled_p (phase))
 return NULL;
 
   name = get_dump_file_name (phase);
+  name_with_pass_pos_size=sizeof(char)*strlen(name)+ 
sizeof(nb_explored_pass)+1;
+  name_with_pass_pos= (char*) xmalloc(name_with_pass_pos_size);
+
+  snprintf (name_with_pass_pos, name_with_pass_pos_size, "%d.%s", 
nb_explored_pass, name);
   dfi = get_dump_file_info (phase);
-  stream = fopen (name, dfi->state < 0 ? "w" : "a");
+  stream = fopen (name_with_pass_pos, dfi->state < 0 ? "w" : "a");
+
   if (!stream)
 error ("could not open dump file %qs: %m", name);
   else
 dfi->state = 1;
   free (name);
+  free (name_with_pass_pos);
 
   if (flag_ptr)
 *flag_ptr = dfi->flags;
 
+  nb_explored_pass++;
+
   return stream;
 }
 


Re: PATCH: PR other/48007: Unwind library doesn't work with UNITS_PER_WORD > sizeof (void *)

2011-03-23 Thread Richard Henderson
On 03/23/2011 11:04 AM, Jakub Jelinek wrote:
> For several targets that would grow the context significantly, do you think
> we really have to do that for all targets rather than just for the
> sizeof (_Unwind_Word) > sizeof (void *) ones?  The accessors are wrapped
> in inline functions anyway.

Given that ia64 doesn't use this file, we're talking about 512 bytes for
most 64-bit targets.  I suppose that's 512 bytes we needn't allocate for
others, but...

The problem is that we suddenly have a version mismatch.  Suppose we 
conditionally add this, then next decade we need to add some other field
unconditionally.  Now determining what version X means is non-trivial.

What targets are you worried most about?


r~


Re: PATCH: PR other/48007: Unwind library doesn't work with UNITS_PER_WORD > sizeof (void *)

2011-03-23 Thread H.J. Lu
On Wed, Mar 23, 2011 at 11:20 AM, Richard Henderson  wrote:
> On 03/23/2011 11:04 AM, Jakub Jelinek wrote:
>> For several targets that would grow the context significantly, do you think
>> we really have to do that for all targets rather than just for the
>> sizeof (_Unwind_Word) > sizeof (void *) ones?  The accessors are wrapped
>> in inline functions anyway.
>
> Given that ia64 doesn't use this file, we're talking about 512 bytes for
> most 64-bit targets.  I suppose that's 512 bytes we needn't allocate for
> others, but...
>
> The problem is that we suddenly have a version mismatch.  Suppose we
> conditionally add this, then next decade we need to add some other field
> unconditionally.  Now determining what version X means is non-trivial.
>
> What targets are you worried most about?
>

FWIW, I ran into this on x32, which is totally new and doesn't have
backward compatibility issue.



-- 
H.J.


Re: PATCH: PR other/48007: Unwind library doesn't work with UNITS_PER_WORD > sizeof (void *)

2011-03-23 Thread Richard Henderson
On 03/23/2011 11:24 AM, H.J. Lu wrote:
> FWIW, I ran into this on x32, which is totally new and doesn't have
> backward compatibility issue.

I don't care.  I'm not going to totally destroy maintainability for
the sake of one target.  There shall be a common solution.


r~


Re: [PATCH 2/2] refactor emit_*_{after,before}{,_setloc} using common functions

2011-03-23 Thread Richard Henderson
On 03/23/2011 05:09 AM, Nathan Froyd wrote:
> Did you mean loc == UNKNOWN_LOCATION?  Also, it looks like that's
> conflating INSN_LOCATORs and location_ts; it seems like it'd be better
> to keep them separate.

Ug.  Yes and yes.  I'd forgotten that insn_locators are different
from line locations.  And indeed, there's no magic define for the
no-insn-locator condition; it's just a literal zero.

But still, there's no reason not to apply the same zero optimization
for all insn types.


r~


Re: PATCH: PR other/48007: Unwind library doesn't work with UNITS_PER_WORD > sizeof (void *)

2011-03-23 Thread Jakub Jelinek
On Wed, Mar 23, 2011 at 11:20:24AM -0700, Richard Henderson wrote:
> On 03/23/2011 11:04 AM, Jakub Jelinek wrote:
> > For several targets that would grow the context significantly, do you think
> > we really have to do that for all targets rather than just for the
> > sizeof (_Unwind_Word) > sizeof (void *) ones?  The accessors are wrapped
> > in inline functions anyway.
> 
> Given that ia64 doesn't use this file, we're talking about 512 bytes for
> most 64-bit targets.  I suppose that's 512 bytes we needn't allocate for
> others, but...
> 
> The problem is that we suddenly have a version mismatch.  Suppose we 
> conditionally add this, then next decade we need to add some other field
> unconditionally.  Now determining what version X means is non-trivial.
> 
> What targets are you worried most about?

E.g. for ppc64 that's 1160 bytes, mmix 2104 bytes, ...
But if you think the 6 or so conditionals would be too much burden, just
ignore me.

Jakub


Re: PATCH: PR other/48007: Unwind library doesn't work with UNITS_PER_WORD > sizeof (void *)

2011-03-23 Thread Richard Henderson
On 03/23/2011 11:37 AM, Jakub Jelinek wrote:
> E.g. for ppc64 that's 1160 bytes, mmix 2104 bytes, ...
> But if you think the 6 or so conditionals would be too much burden, just
> ignore me.

I suppose we could interpret (a part of?) "version" as a bitmap of features,
rather than a serial number...

Guh.  The entire point of making _Unwind_Context opaque, and inventing libgcc_s,
was so that we didn't have to think about these things.  There's one and only 
one
copy of the unwind library and all uses of the structure are through accessors.
I hate hate hate that I got the export thing wrong at the very beginning.

Because, really, if we consider the structure truly public, we can't even
change the number of registers for a given port to support new features of
the cpu.  I don't suppose there's any way that we can declare these old
programs Just Broken, and drop this compatibility stuff?


r~


Re: Can't use SImode as Pmode for x32

2011-03-23 Thread Richard Henderson
On 03/19/2011 08:46 AM, H.J. Lu wrote:
> Operations on stack and frame pointers, like push/pop, require stack
> and frame pointers in DImode.  Even if I use word_mode in gen_push
> and gen_pop, I got

No they don't.  Not really.  Assuming the stack and frame pointer are
properly zero extended, and no one tries to place a stack frame across
null, then you can also represent it by an SImode operation.

> x.i:10:1: error: unrecognizable insn:
> (insn/f 22 5 23 2 (set (mem:SI (pre_dec:DI (reg/f:SI 7 sp)) [0 S4 A8])
> (reg/f:SI 6 bp)) x.i:6 -1
>  (nil))

Well, gee, that merely means a pattern needs to be adjusted.


r~


[MIPS] Hookize FUNCTION_VALUE, LIBCALL_VALUE and FUNCTION_VALUE_REGNO_P

2011-03-23 Thread Anatoly Sokolov
Hello.

  This patch removes obsolete FUNCTION_VALUE, LIBCALL_VALUE and
FUNCTION_VALUE_REGNO_P macros from MIPS  back end in the GCC and introduces
equivalent TARGET_FUNCTION_VALUE, TARGET_LIBCALL_VALUE and
TARGET_FUNCTION_VALUE_REGNO_P target hooks.

  Bootstrapped and regression tested on mips64el-unknown-linux-gnu.

  OK to install?

* config/mips/mips.h (LIBCALL_VALUE, FUNCTION_VALUE,
FUNCTION_VALUE_REGNO_P): Remove macros.
* config/mips/mips-protos.h (mips_function_value): Remove.
* config/mips/mips.c (mips_function_value): Rename to...
(mips_function_value_1): ... this. Make static.  Handle receiving
the function type in 'fn_decl_or_type' argument.
(mips_function_value, mips_libcall_value,
mips_function_value_regno_p): New function.
(TARGET_FUNCTION_VALUE, TARGET_LIBCALL_VALUE,
TARGET_FUNCTION_VALUE_REGNO_P): Define.

Index: gcc/config/mips/mips-protos.h
===
--- gcc/config/mips/mips-protos.h   (revision 171355)
+++ gcc/config/mips/mips-protos.h   (working copy)
@@ -277,7 +277,6 @@
 extern void mips_expand_before_return (void);
 extern void mips_expand_epilogue (bool);
 extern bool mips_can_use_return_insn (void);
-extern rtx mips_function_value (const_tree, const_tree, enum machine_mode);
 
 extern bool mips_cannot_change_mode_class (enum machine_mode,
   enum machine_mode, enum reg_class);
Index: gcc/config/mips/mips.c
===
--- gcc/config/mips/mips.c  (revision 171355)
+++ gcc/config/mips/mips.c  (working copy)
@@ -5247,18 +5247,24 @@
 
 }
 
-/* Implement FUNCTION_VALUE and LIBCALL_VALUE.  For normal calls,
-   VALTYPE is the return type and MODE is VOIDmode.  For libcalls,
-   VALTYPE is null and MODE is the mode of the return value.  */
+/* Implement TARGET_FUNCTION_VALUE and TERGET_LIBCALL_VALUE.
+   For normal calls, VALTYPE is the return type and MODE is VOIDmode.
+   For libcalls, VALTYPE is null and MODE is the mode of the return value.  */
 
-rtx
-mips_function_value (const_tree valtype, const_tree func, enum machine_mode 
mode)
+static rtx
+mips_function_value_1 (const_tree valtype, const_tree fn_decl_or_type,
+  enum machine_mode mode)
 {
   if (valtype)
 {
   tree fields[2];
   int unsigned_p;
+  const_tree func = fn_decl_or_type;
 
+  if (fn_decl_or_type
+ && !DECL_P (fn_decl_or_type))
+   func = NULL;
+
   mode = TYPE_MODE (valtype);
   unsigned_p = TYPE_UNSIGNED (valtype);
 
@@ -5324,6 +5330,42 @@
   return gen_rtx_REG (mode, GP_RETURN);
 }
 
+/* Implement TARGET_FUNCTION_VALUE. */
+
+static rtx
+mips_function_value (const_tree valtype, const_tree fn_decl_or_type,
+bool outgoing ATTRIBUTE_UNUSED)
+{
+  return mips_function_value_1 (valtype, fn_decl_or_type, VOIDmode);
+}
+
+/* Implement TARGET_LIBCALL_VALUE. */
+
+static rtx
+mips_libcall_value (enum machine_mode mode, const_rtx fun ATTRIBUTE_UNUSED)
+{
+  return mips_function_value_1 (NULL_TREE, NULL_TREE, mode);
+}
+
+/* Implement TARGET_FUNCTION_VALUE_REGNO_P.
+
+   Returns true if N is a possible register number for a function value.
+   On the MIPS, R2 R3 and F0 F2 are the only register thus used.
+   Currently, R2 and F0 are only implemented here (C has no complex type)  */
+
+static bool
+mips_function_value_regno_p (const unsigned int regno)
+{
+  if (regno == GP_RETURN
+  || regno == FP_RETURN
+  || (LONG_DOUBLE_TYPE_SIZE == 128
+ && FP_RETURN != GP_RETURN
+ && regno == FP_RETURN + 2))
+return true;
+
+  return false;
+}
+
 /* Implement TARGET_RETURN_IN_MEMORY.  Under the o32 and o64 ABIs,
all BLKmode objects are returned in memory.  Under the n32, n64
and embedded ABIs, small structures are returned in a register.
@@ -16521,6 +16563,12 @@
 #undef TARGET_PROMOTE_PROTOTYPES
 #define TARGET_PROMOTE_PROTOTYPES hook_bool_const_tree_true
 
+#undef TARGET_FUNCTION_VALUE
+#define TARGET_FUNCTION_VALUE mips_function_value
+#undef TARGET_LIBCALL_VALUE
+#define TARGET_LIBCALL_VALUE mips_libcall_value
+#undef TARGET_FUNCTION_VALUE_REGNO_P
+#define TARGET_FUNCTION_VALUE_REGNO_P mips_function_value_regno_p
 #undef TARGET_RETURN_IN_MEMORY
 #define TARGET_RETURN_IN_MEMORY mips_return_in_memory
 #undef TARGET_RETURN_IN_MSB
Index: gcc/config/mips/mips.h
===
--- gcc/config/mips/mips.h  (revision 171355)
+++ gcc/config/mips/mips.h  (working copy)
@@ -2150,20 +2150,6 @@
 #define FP_ARG_FIRST (FP_REG_FIRST + 12)
 #define FP_ARG_LAST  (FP_ARG_FIRST + MAX_ARGS_IN_REGISTERS - 1)
 
-#define LIBCALL_VALUE(MODE) \
-  mips_function_value (NULL_TREE, NULL_TREE, MODE)
-
-#define FUNCTION_VALUE(VALTYPE, FUNC) \
-  mips_function_value (VALTYPE, FUNC, VOIDmode)
-
-/* 1 if N is a possible register number for a functio

[RFC PATCH, i386]: ICE: in final_scan_insn due to late split

2011-03-23 Thread Uros Bizjak
Hello!

The testcase from the PR triggers a split in *movdf_internal_rex64
move pattern too late in the compilation process.  Attached patch
fixes this by emitting relevant moves directly, without splitting them
to DImode moves at all [it looks to me, that _rex64 pattern was copied
directly from 32bit *movdf_internal, since it doesn't take into
account the fact, that we can move DFmode value with movq/movabsq
insn].

The only complication is with DFmode immediates. A movabsq insn can
copy the value into register directly, with a bit of trickery in
ix86_print_operand. However, to encourage gcc to load FP constants
from memory, "F -> r" case is penalized with "!". "F -> m" case is
also penalized, since there is no direct DF/DImode move of immediate
to memory, and this alternative still has to be split (this
alternative is the same as in DImode case). As an added benefit, all
new instructions (modulo F->m case) can be marked as "imove" type
instead of "multi" type.

2011-03-23  Uros Bizjak  

PR target/48237
* config/i386/i386.md (*movdf_internal_rex64): Do not split
alternatives that can be handled with movq or movabsq insn.
(*movdf_internal): Disable for !TARGET_64BIT.
(*movdf_internal_nointeger): Ditto.
* config/i386/i386.c (ix86_print_operand): Handle DFmode immediates.

testsuite/ChangeLog:

2011-03-23  Uros Bizjak  

PR target/48237
* gcc.target/i386/pr48237.c: New test.

The newly added code in ix86_print_operand is in fact never triggered
in the testsuite, and I was not able to construct a testcase that
would exercise this part of the compiler, so in order to avoid nasty
surprises, I would kindly ask other x86 maintainers to review newly
added code, especially ix86_print_operand part (the approach was in
fact copied from output_pic_addr_const function).

Patch was bootstrapped and regression tested on x86_64-pc-linux-gnu {, -m32}.

Thanks,
Uros.
Index: config/i386/i386.md
===
--- config/i386/i386.md (revision 171353)
+++ config/i386/i386.md (working copy)
@@ -2915,9 +2915,9 @@
 
 (define_insn "*movdf_internal_rex64"
   [(set (match_operand:DF 0 "nonimmediate_operand"
-   "=f,m,f,r  ,m ,Y2*x,Y2*x,Y2*x,m   ,Yi,r ")
+   "=f,m,f,r ,m,!r,!m,Y2*x,Y2*x,Y2*x,m   ,Yi,r ")
(match_operand:DF 1 "general_operand"
-   "fm,f,G,rmF,Fr,C   ,Y2*x,m   ,Y2*x,r ,Yi"))]
+   "fm,f,G,rm,r,F ,F ,C   ,Y2*x,m   ,Y2*x,r ,Yi"))]
   "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
&& (reload_in_progress || reload_completed
|| (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
@@ -2938,9 +2938,15 @@
 
 case 3:
 case 4:
-  return "#";
+  return "mov{q}\t{%1, %0|%0, %1}";
 
 case 5:
+  return "movabs{q}\t{%1, %0|%0, %1}";
+
+case 6:
+  return "#";
+
+case 7:
   switch (get_attr_mode (insn))
{
case MODE_V4SF:
@@ -2958,9 +2964,9 @@
default:
  gcc_unreachable ();
}
-case 6:
-case 7:
 case 8:
+case 9:
+case 10:
   switch (get_attr_mode (insn))
{
case MODE_V4SF:
@@ -2995,17 +3001,27 @@
  gcc_unreachable ();
}
 
-case 9:
-case 10:
+case 11:
+case 12:
 return "%vmovd\t{%1, %0|%0, %1}";
 
 default:
   gcc_unreachable();
 }
 }
-  [(set_attr "type" 
"fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov,ssemov,ssemov")
+  [(set_attr "type" 
"fmov,fmov,fmov,imov,imov,imov,multi,sselog1,ssemov,ssemov,ssemov,ssemov,ssemov")
+   (set (attr "modrm")
+ (if_then_else
+   (and (eq_attr "alternative" "5") (eq_attr "type" "imov"))
+(const_string "0")
+(const_string "*")))
+   (set (attr "length_immediate")
+ (if_then_else
+   (and (eq_attr "alternative" "5") (eq_attr "type" "imov"))
+(const_string "8")
+(const_string "*")))
(set (attr "prefix")
- (if_then_else (eq_attr "alternative" "0,1,2,3,4")
+ (if_then_else (eq_attr "alternative" "0,1,2,3,4,5,6")
(const_string "orig")
(const_string "maybe_vex")))
(set (attr "prefix_data16")
@@ -3015,18 +3031,18 @@
(set (attr "mode")
 (cond [(eq_attr "alternative" "0,1,2")
 (const_string "DF")
-  (eq_attr "alternative" "3,4,9,10")
+  (eq_attr "alternative" "3,4,5,6,11,12")
 (const_string "DI")
 
   /* For SSE1, we have many fewer alternatives.  */
   (eq (symbol_ref "TARGET_SSE2") (const_int 0))
-(cond [(eq_attr "alternative" "5,6")
+(cond [(eq_attr "alternative" "7,8")
  (const_string "V4SF")
   ]
   (const_string "V2SF"))
 
   /* xorps is one byte shorter.  */
-  (eq_attr "alternative" "5")
+  (eq_attr "alternative" "7")
 (cond [

Re: PATCH: PR other/48007: Unwind library doesn't work with UNITS_PER_WORD > sizeof (void *)

2011-03-23 Thread Jakub Jelinek
On Wed, Mar 23, 2011 at 12:01:37PM -0700, Richard Henderson wrote:
> Guh.  The entire point of making _Unwind_Context opaque, and inventing 
> libgcc_s,
> was so that we didn't have to think about these things.  There's one and only 
> one
> copy of the unwind library and all uses of the structure are through 
> accessors.
> I hate hate hate that I got the export thing wrong at the very beginning.

I think the situation now is much better than it used to be when
libgcc_s/libgcc_eh was added, at that point there was no --as-needed support
and we wanted to avoid linking -lgcc_s into every program when it didn't
actually need it.  So currently that is mostly compatibility with very old
stuff or with people doing weird things (e.g. linking -lgcc_eh in), or
with people on less capable targets, or if we were to add new _Unwind_*
entrypoints (e.g. _Unwind_GETIPInfo was problematic, as older unwinder
implementations didn't have that symbol and thus it could be picked from
a different unwinder that had it).

Jakub


Re: PATCH: PR other/48007: Unwind library doesn't work with UNITS_PER_WORD > sizeof (void *)

2011-03-23 Thread Ulrich Weigand
Richard Henderson wrote:
> Because, really, if we consider the structure truly public, we can't even
> change the number of registers for a given port to support new features of
> the cpu.

Indeed, and I remember we got bitten by that a long time ago, which is why
s390.h now has this comment:

/* Number of hardware registers that go into the DWARF-2 unwind info.
   To avoid ABI incompatibility, this number must not change even as
   'fake' hard registers are added or removed.  */
#define DWARF_FRAME_REGISTERS 34

> I don't suppose there's any way that we can declare these old
> programs Just Broken, and drop this compatibility stuff?

I wouldn't like that ... we did run into this problem in the wild, and
some s390 users really run very old programs for some reason.

However, I'm wondering: this bug that leaked the implementation of
_Unwind_Context only ever affected the *original* version of the
structure -- it was fixed before the extended context was ever
added, right?

If this is true, we'd still need to keep the original context format
unchanged, but we'd be free to modify the *extended* format at any
time, without ABI considerations and need for further versioning ...

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  ulrich.weig...@de.ibm.com


[PATCH] Better .debug_aranges fix (PR debug/48253)

2011-03-23 Thread Jakub Jelinek
Hi!

As the testcases in the PR show (I think they are hardly suitable
for gcc testsuite though, better for gdb or elfutils testsuite),
we still don't cover all code in the CU with .debug_aranges (regression from
4.5) and with -freorder-blocks-and-partition we do even more bad things.

The problem are the new .text.startup/.text.exit sections, also
that __attribute__((cold)) functions can be placed as whole into
.text.unlikely, etc.

I think if we are emitting ranges for DW_TAG_compile_unit, then
.debug_ranges should cover exactly the same ranges, there is IMHO no need
to use a separate data structure to track that.  For the two
standard sections (text_section and cold_text_section) we just mark the
whole section contribution, for the rest we add each individual range.

There was another bug, in that DW_TAG_subprogram's DW_AT_ranges
could contain two ranges covering the same partition and none
covering the other partition, because fde->in_std_section was
a wrong check for the "was the section switch from hot to cold",
as say with -ffunction-section hot partition is say .text.f1
and thus not text_section.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk and 4.6.1?

2011-03-23  Jakub Jelinek  

PR debug/48253
* dwarf2out.c (dwarf2out_switch_text_section): Update
fde->in_std_section when switching from cold to hot section.
(arange_table, arange_table_allocated, arange_table_in_use,
ARANGE_TABLE_INCREMENT, add_arange): Removed.
(size_of_aranges): Count !in_std_section and !cold_in_std_section
hunks in fdes, instead of looking at arange_table_in_use.
(output_aranges): Add aranges_length argument, don't call
size_of_aranges here.  Instead of using aranges_table*
emit ranges for fdes when !in_std_section resp.
!cold_in_std_section.
(gen_subprogram_die): Don't call add_arange.  Use
!fde->dw_fde_switched_cold_to_hot instead of fde->in_std_section.
(dwarf2out_begin_function): Initialize cold_text_section even
when function_section () isn't text_section.
(prune_unused_types): Don't walk arange_table.
(dwarf2out_finish): Don't needlessly test
flag_reorder_blocks_and_partition when testing cold_text_section_used.
If info_section_emitted, call size_of_aranges and if it indicates
non-empty .debug_aranges, call output_aranges with the computed
size.

--- gcc/dwarf2out.c.jj  2011-03-23 09:34:39.0 +0100
+++ gcc/dwarf2out.c 2011-03-23 13:04:37.0 +0100
@@ -4291,6 +4291,7 @@ dwarf2out_note_section_used (void)
 void
 dwarf2out_switch_text_section (void)
 {
+  section *sect;
   dw_fde_ref fde = current_fde ();
 
   gcc_assert (cfun && fde && !fde->dw_fde_switched_sections);
@@ -4316,7 +4317,13 @@ dwarf2out_switch_text_section (void)
 fprintf (asm_out_file, "\t.cfi_endproc\n");
 
   /* Now do the real section switch.  */
-  switch_to_section (current_function_section ());
+  sect = current_function_section ();
+  switch_to_section (sect);
+
+  if (fde->dw_fde_switched_cold_to_hot)
+fde->in_std_section
+  = (sect == text_section
+|| (cold_text_section && sect == cold_text_section));
 
   if (dwarf2out_do_cfi_asm ())
 {
@@ -6212,19 +6219,6 @@ static GTY (()) VEC (pubname_entry, gc) 
defines/undefines (and file start/end markers).  */
 static GTY (()) VEC (macinfo_entry, gc) * macinfo_table;
 
-/* Array of dies for which we should generate .debug_arange info.  */
-static GTY((length ("arange_table_allocated"))) dw_die_ref *arange_table;
-
-/* Number of elements currently allocated for arange_table.  */
-static GTY(()) unsigned arange_table_allocated;
-
-/* Number of elements in arange_table currently in use.  */
-static GTY(()) unsigned arange_table_in_use;
-
-/* Size (in elements) of increments by which we may expand the
-   arange_table.  */
-#define ARANGE_TABLE_INCREMENT 64
-
 /* Array of dies for which we should generate .debug_ranges info.  */
 static GTY ((length ("ranges_table_allocated"))) dw_ranges_ref ranges_table;
 
@@ -6432,8 +6426,7 @@ static void add_pubname (tree, dw_die_re
 static void add_pubname_string (const char *, dw_die_ref);
 static void add_pubtype (tree, dw_die_ref);
 static void output_pubnames (VEC (pubname_entry,gc) *);
-static void add_arange (tree, dw_die_ref);
-static void output_aranges (void);
+static void output_aranges (unsigned long);
 static unsigned int add_ranges_num (int);
 static unsigned int add_ranges (const_tree);
 static void add_ranges_by_labels (dw_die_ref, const char *, const char *,
@@ -10881,7 +10874,20 @@ size_of_aranges (void)
 size += 2 * DWARF2_ADDR_SIZE;
   if (cold_text_section_used)
 size += 2 * DWARF2_ADDR_SIZE;
-  size += 2 * DWARF2_ADDR_SIZE * arange_table_in_use;
+  if (have_multiple_function_sections)
+{
+  unsigned fde_idx = 0;
+
+  for (fde_idx = 0; fde_idx < fde_table_in_use; fde_idx++)
+   {
+ dw_fde_ref

[PATCH] Fix simplify_const_unary_operation (PR debug/48204)

2011-03-23 Thread Jakub Jelinek
Hi!

simplify_const_unary_operation assumes it doesn't have to change anything
in REAL_VALUE_TYPE for FLOAT_EXTEND, which is wrong when FLOAT_EXTENDing
e.g. from SFmode to DDmode or SDmode to DFmode, where the number
needs to be converted from binary to decimal or vice versa.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk/4.6.1?

2011-03-23  Jakub Jelinek  

PR debug/48204
* simplify-rtx.c (simplify_const_unary_operation): Call
real_convert when changing mode class with FLOAT_EXTEND.

* gcc.dg/dfp/pr48204.c: New test.

--- gcc/simplify-rtx.c.jj   2011-03-21 13:00:09.0 +0100
+++ gcc/simplify-rtx.c  2011-03-23 16:39:13.0 +0100
@@ -1526,7 +1526,8 @@ simplify_const_unary_operation (enum rtx
 }
 
   else if (GET_CODE (op) == CONST_DOUBLE
-  && SCALAR_FLOAT_MODE_P (mode))
+  && SCALAR_FLOAT_MODE_P (mode)
+  && SCALAR_FLOAT_MODE_P (GET_MODE (op)))
 {
   REAL_VALUE_TYPE d, t;
   REAL_VALUE_FROM_CONST_DOUBLE (d, op);
@@ -1549,7 +1550,10 @@ simplify_const_unary_operation (enum rtx
  d = real_value_truncate (mode, d);
  break;
case FLOAT_EXTEND:
- /* All this does is change the mode.  */
+ /* All this does is change the mode, unless changing
+mode class.  */
+ if (GET_MODE_CLASS (mode) != GET_MODE_CLASS (GET_MODE (op)))
+   real_convert (&d, mode, &d);
  break;
case FIX:
  real_arithmetic (&d, FIX_TRUNC_EXPR, &d, NULL);
--- gcc/testsuite/gcc.dg/dfp/pr48204.c.jj   2011-03-23 16:44:09.0 
+0100
+++ gcc/testsuite/gcc.dg/dfp/pr48204.c  2011-03-23 16:43:35.0 +0100
@@ -0,0 +1,10 @@
+/* PR debug/48204 */
+/* { dg-do compile } */
+/* { dg-options "-O -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-fre -g" } 
*/
+
+void
+foo (void)
+{
+  float cf = 3.0f;
+  _Decimal64 d64 = cf;
+}

Jakub


Re: [PATCH 2/2] refactor emit_*_{after,before}{,_setloc} using common functions

2011-03-23 Thread Nathan Froyd
On Wed, Mar 23, 2011 at 11:36:26AM -0700, Richard Henderson wrote:
> On 03/23/2011 05:09 AM, Nathan Froyd wrote:
> > Did you mean loc == UNKNOWN_LOCATION?  Also, it looks like that's
> > conflating INSN_LOCATORs and location_ts; it seems like it'd be better
> > to keep them separate.
> 
> Ug.  Yes and yes.  I'd forgotten that insn_locators are different
> from line locations.  And indeed, there's no magic define for the
> no-insn-locator condition; it's just a literal zero.
> 
> But still, there's no reason not to apply the same zero optimization
> for all insn types.

Zero optimization implemented, !loc test retained.  Bootstrapped OK; OK
to commit?

-Nathan

* emit-rtl.c (emit_pattern_after_setloc): New function.
(emit_insn_after_setloc, emit_jump_insn_after_setloc): Call it.
(emit_call_insn_after_setloc, emit_debug_insn_after_setloc): Likewise.
(emit_pattern_after): New function.
(emit_insn_after, emit_jump_insn_after): Call it.
(emit_call_insn_after, emit_debug_insn_after): Likewise.
(emit_pattern_before_setloc): New function.
(emit_insn_before_setloc, emit_jump_insn_before_setloc): Call it.
(emit_call_insn_before_setloc, emit_debug_insn_before_setloc):
Likewise.
(emit_pattern_before): New function.
(emit_insn_before, emit_jump_insn_before): Call it.
(emit_call_insn_before, emit_debug_insn_before): Likewise.

diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index 9b6f0f8..a4e8f8a 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -4316,11 +4316,14 @@ emit_note_after (enum insn_note subtype, rtx after)
   return note;
 }
 
-/* Like emit_insn_after_noloc, but set INSN_LOCATOR according to SCOPE.  */
-rtx
-emit_insn_after_setloc (rtx pattern, rtx after, int loc)
+/* Insert PATTERN after AFTER, setting its INSN_LOCATION to LOC.
+   MAKE_RAW indicates how to turn PATTERN into a real insn.  */
+
+static rtx
+emit_pattern_after_setloc (rtx pattern, rtx after, int loc,
+  rtx (*make_raw) (rtx))
 {
-  rtx last = emit_insn_after_noloc (pattern, after, NULL);
+  rtx last = emit_pattern_after_noloc (pattern, after, NULL, make_raw);
 
   if (pattern == NULL_RTX || !loc)
 return last;
@@ -4337,130 +4340,96 @@ emit_insn_after_setloc (rtx pattern, rtx after, int 
loc)
   return last;
 }
 
-/* Like emit_insn_after_noloc, but set INSN_LOCATOR according to AFTER.  */
-rtx
-emit_insn_after (rtx pattern, rtx after)
+/* Insert PATTERN after AFTER.  MAKE_RAW indicates how to turn PATTERN
+   into a real insn.  SKIP_DEBUG_INSNS indicates whether to insert after
+   any DEBUG_INSNs.  */
+
+static rtx
+emit_pattern_after (rtx pattern, rtx after, bool skip_debug_insns,
+   rtx (*make_raw) (rtx))
 {
   rtx prev = after;
 
-  while (DEBUG_INSN_P (prev))
-prev = PREV_INSN (prev);
+  if (skip_debug_insns)
+while (DEBUG_INSN_P (prev))
+  prev = PREV_INSN (prev);
 
   if (INSN_P (prev))
-return emit_insn_after_setloc (pattern, after, INSN_LOCATOR (prev));
+return emit_pattern_after_setloc (pattern, after, INSN_LOCATOR (prev),
+ make_raw);
   else
-return emit_insn_after_noloc (pattern, after, NULL);
+return emit_pattern_after_noloc (pattern, after, NULL, make_raw);
 }
 
-/* Like emit_jump_insn_after_noloc, but set INSN_LOCATOR according to SCOPE.  
*/
+/* Like emit_insn_after_noloc, but set INSN_LOCATOR according to LOC.  */
 rtx
-emit_jump_insn_after_setloc (rtx pattern, rtx after, int loc)
+emit_insn_after_setloc (rtx pattern, rtx after, int loc)
 {
-  rtx last = emit_jump_insn_after_noloc (pattern, after);
+  return emit_pattern_after_setloc (pattern, after, loc, make_insn_raw);
+}
 
-  if (pattern == NULL_RTX || !loc)
-return last;
+/* Like emit_insn_after_noloc, but set INSN_LOCATOR according to AFTER.  */
+rtx
+emit_insn_after (rtx pattern, rtx after)
+{
+  return emit_pattern_after (pattern, after, true, make_insn_raw);
+}
 
-  after = NEXT_INSN (after);
-  while (1)
-{
-  if (active_insn_p (after) && !INSN_LOCATOR (after))
-   INSN_LOCATOR (after) = loc;
-  if (after == last)
-   break;
-  after = NEXT_INSN (after);
-}
-  return last;
+/* Like emit_jump_insn_after_noloc, but set INSN_LOCATOR according to LOC.  */
+rtx
+emit_jump_insn_after_setloc (rtx pattern, rtx after, int loc)
+{
+  return emit_pattern_after_setloc (pattern, after, loc, make_jump_insn_raw);
 }
 
 /* Like emit_jump_insn_after_noloc, but set INSN_LOCATOR according to AFTER.  
*/
 rtx
 emit_jump_insn_after (rtx pattern, rtx after)
 {
-  rtx prev = after;
-
-  while (DEBUG_INSN_P (prev))
-prev = PREV_INSN (prev);
-
-  if (INSN_P (prev))
-return emit_jump_insn_after_setloc (pattern, after, INSN_LOCATOR (prev));
-  else
-return emit_jump_insn_after_noloc (pattern, after);
+  return emit_pattern_after (pattern, after, true, make_jump_insn_raw);
 }
 
-/* Like emit_call_insn_after_noloc, but set INSN_LOCATOR accordin

Re: [v3] Regenerate Solaris 2 baselines for GCC 4.6.0 release

2011-03-23 Thread Benjamin Kosnik

> 2011-03-15  Rainer Orth  
> 
>   * config/abi/post/solaris2.8/baseline_symbols.txt: Regenerate.
>   * config/abi/post/solaris2.8/sparcv9/baseline_symbols.txt:
> Likewise.
>   * config/abi/post/solaris2.10/baseline_symbols.txt: Likewise.
>   * config/abi/post/solaris2.10/amd64/baseline_symbols.txt:
> Likewise.
>   * config/abi/post/solaris2.10/sparcv9/baseline_symbols.txt:
> Likewise.

OK.

Looks great thanks Ranier.

-benjamin


Re: [patch, hpux, testsuite] XFAIL pr47917.c for non-conforming snprintf

2011-03-23 Thread John David Anglin
> This patch moves gcc.c-torture/execute/pr47917.c to
> gcc.dg/torture/pr47917.c so that I can use dg-* directives in the test
> and then adds xfails for HP-UX.  On HP-UX 10.* there is no snprintf

The new gcc.dg/torture/pr47917.c lacks some code.

> Dave, can you verify this fix on HP-UX 10.*?  I don't have any HP-UX
> 10.* systems anymore.  Tested on IA64 and PA HP-UX 11.11 and 11.23.

This will take some time.  I would just go ahead without this check
if moving the test is ok.

> 2011-03-23  Steve Ellcey  
> 
>   PR target/48209
>   * gcc.c-torture/execute/pr47917.c: Move this...
>   * gcc.dg/torture/pr47917.c: to here and add xfails.
> 
> Index: gcc.c-torture/execute/pr47917.c
> ===
> --- gcc.c-torture/execute/pr47917.c   (revision 171338)
> +++ gcc.c-torture/execute/pr47917.c   (working copy)
> @@ -1,32 +0,0 @@
> -/* PR middle-end/47917 */
> -
> -extern int snprintf (char *, __SIZE_TYPE__, const char *, ...);
> -extern int memcmp (const void *, const void *, __SIZE_TYPE__);
> -extern void abort (void);
> -
> -char buf1[6], buf2[6], buf3[4], buf4[4];
> -int i;
> -
> -int
> -foo (void)
> -{
> -  int ret = snprintf (buf1, sizeof buf1, "abcde");
> -  ret += snprintf (buf2, sizeof buf2, "abcdef") * 16;
> -  ret += snprintf (buf3, sizeof buf3, "%s", i++ < 6 ? "abc" : "def") * 256;
> -  ret += snprintf (buf4, sizeof buf4, "%s", i++ > 10 ? "abcde" : "defgh") * 
> 4096;
> -  return ret;
> -}
> -
> -int
> -main (void)
> -{
> -  if (foo () != 5 + 6 * 16 + 3 * 256 + 5 * 4096)
> -abort ();
> -  if (memcmp (buf1, "abcde", 6) != 0
> -  || memcmp (buf2, "abcde", 6) != 0
> -  || memcmp (buf3, "abc", 4) != 0
> -  || memcmp (buf4, "def", 4) != 0
> -  || i != 2)
> -abort ();
> -  return 0;
> -}
> Index: gcc.dg/torture/pr47917.c
> ===
> --- gcc.dg/torture/pr47917.c  (revision 171278)
> +++ gcc.dg/torture/pr47917.c  (working copy)
> @@ -1,3 +1,8 @@
> +/* { dg-do run } */
> +/* { dg-options "-std=c99" } */
> +/* { dg-xfail-if "no C99 snprintf function" { *-*-hpux10* } } */
> +/* { dg-xfail-run-if "non-conforming C99 snprintf" { *-*-hpux11.[012]* } } */
> +
>  /* PR middle-end/47917 */
>  
>  extern int snprintf (char *, __SIZE_TYPE__, const char *, ...);
> 

Dave
-- 
J. David Anglin  dave.ang...@nrc-cnrc.gc.ca
National Research Council of Canada  (613) 990-0752 (FAX: 952-6602)


Re: [patch, hpux, testsuite] XFAIL pr47917.c for non-conforming snprintf

2011-03-23 Thread Steve Ellcey
On Wed, 2011-03-23 at 16:34 -0400, John David Anglin wrote:
> > This patch moves gcc.c-torture/execute/pr47917.c to
> > gcc.dg/torture/pr47917.c so that I can use dg-* directives in the test
> > and then adds xfails for HP-UX.  On HP-UX 10.* there is no snprintf
> 
> The new gcc.dg/torture/pr47917.c lacks some code.

It's there, but the diff only showed the changes from the original file
that it was moved from.

> > Dave, can you verify this fix on HP-UX 10.*?  I don't have any HP-UX
> > 10.* systems anymore.  Tested on IA64 and PA HP-UX 11.11 and 11.23.
> 
> This will take some time.  I would just go ahead without this check
> if moving the test is ok.

Sounds good.  I think moving the test is OK, that was what I was told to
do last time I needed to XFAIL a test in gcc.c-torture.

Steve Ellcey
s...@cup.hp.com




Re: [PATCH 2/2] refactor emit_*_{after,before}{,_setloc} using common functions

2011-03-23 Thread Richard Henderson
On 03/23/2011 01:17 PM, Nathan Froyd wrote:
>   * emit-rtl.c (emit_pattern_after_setloc): New function.
>   (emit_insn_after_setloc, emit_jump_insn_after_setloc): Call it.
>   (emit_call_insn_after_setloc, emit_debug_insn_after_setloc): Likewise.
>   (emit_pattern_after): New function.
>   (emit_insn_after, emit_jump_insn_after): Call it.
>   (emit_call_insn_after, emit_debug_insn_after): Likewise.
>   (emit_pattern_before_setloc): New function.
>   (emit_insn_before_setloc, emit_jump_insn_before_setloc): Call it.
>   (emit_call_insn_before_setloc, emit_debug_insn_before_setloc):
>   Likewise.
>   (emit_pattern_before): New function.
>   (emit_insn_before, emit_jump_insn_before): Call it.
>   (emit_call_insn_before, emit_debug_insn_before): Likewise.

Ok.

Please look into removing the "last" parameter from 
emit_pattern_before_noloc, which would allow removing the "insnp"
parameter from emit_pattern_before_setloc.

I can't see how emitting a NULL_RTX should be a Good Thing, ever,
and thus I don't see why we should be doing special things to 
handle it.


r~


[patch] Fix invalid GIMPLE out of SRA

2011-03-23 Thread Eric Botcazou
Hi,

this is a fallout of one of my gimplifier changes.  For the attached testcase, 
the compiler generates invalid GIMPLE at -O1 or above:

p.adb: In function 'P.F':
p.adb:24:1: error: invalid operand in unary operation
D.2361_107 = (integer[1:1] *) &*S15b.16_56[D.2327_91 ...]{lb: 1 sz: 4};

  if (!is_gimple_val (rhs1))
{
  error ("invalid operand in unary operation");
  return true;
}

(gdb) p rhs_code
$6 = NOP_EXPR
(gdb) p debug_generic_expr(rhs1)
&*S15b.16_56[D.2327_91 ...]{lb: 1 sz: 4}

i.e ADDR_EXPR of ARRAY_RANGE_REF with non-constant operand #1.

The invalid statement is generated by the early SRA pass:

  integer a1[1:1];

  VIEW_CONVERT_EXPR(*S15b.16_56[D.2327_91 ...]{lb: 1 sz: 4}) = 
a1;

is rewritten into:

  Created a replacement for a1 offset: 0, size: 32: a1$1

  D.2361_107 = (integer[1:1] *) &*S15b.16_56[D.2327_91 ...]{lb: 1 sz: 4};
  MEM[(integer[1:D.2312] *)D.2361_107] = a1$1_92;


It turns out that the problematic NOP_EXPR is a useless type conversion emitted 
by build_fold_addr_expr: if you add a call to force_gimple_operand at the hot 
spot, it ends up removing the NOP_EXPR and nothing else.  So the proposed fix 
is just to add a call to STRIP_USELESS_TYPE_CONVERSION there.

Tested on i586-suse-linux, OK for the mainline?


2011-03-23  Eric Botcazou  

* tree-sra.c (build_ref_for_offset): Call STRIP_USELESS_TYPE_CONVERSION
on the address built for a reference with variable offset.


2011-03-23  Eric Botcazou  

* gnat.dg/array15.ad[sb]: New test.
* gnat.dg/array15_pkg.ads: New helper.


-- 
Eric Botcazou
-- { dg-do compile }
-- { dg-options "-O -gnatws" }

package body P is

   type Arr is array (Natural range <>) of Integer;

   Table : Arr (1 .. 4);

   N : Natural := 1;

   procedure Zero is
   begin
  N := 0;
   end;

   function F (I : Integer) return Integer is
  A1 : Arr := (1 => I);
  A2 : Arr := Table (1 .. N) & A1;
   begin
  return A2 (I);
   end;

end P;
package P is

   function F (I : Integer) return Integer;

end P;
package Q is

   type Arr is array (Natural range <>) of Integer;

   procedure Proc (A : Arr);

end Q;
Index: tree-sra.c
===
--- tree-sra.c	(revision 171345)
+++ tree-sra.c	(working copy)
@@ -1376,6 +1376,7 @@ build_ref_for_offset (location_t loc, tr
   add_referenced_var (tmp);
   tmp = make_ssa_name (tmp, NULL);
   addr = build_fold_addr_expr (unshare_expr (prev_base));
+  STRIP_USELESS_TYPE_CONVERSION (addr);
   stmt = gimple_build_assign (tmp, addr);
   gimple_set_location (stmt, loc);
   SSA_NAME_DEF_STMT (tmp) = stmt;


Re: [MIPS] Hookize FUNCTION_VALUE, LIBCALL_VALUE and FUNCTION_VALUE_REGNO_P

2011-03-23 Thread Richard Sandiford
Anatoly Sokolov  writes:
> -/* Implement FUNCTION_VALUE and LIBCALL_VALUE.  For normal calls,
> -   VALTYPE is the return type and MODE is VOIDmode.  For libcalls,
> -   VALTYPE is null and MODE is the mode of the return value.  */
> +/* Implement TARGET_FUNCTION_VALUE and TERGET_LIBCALL_VALUE.

typo: TARGET.

> +   For normal calls, VALTYPE is the return type and MODE is VOIDmode.
> +   For libcalls, VALTYPE is null and MODE is the mode of the return value.  
> */
>  
> -rtx
> -mips_function_value (const_tree valtype, const_tree func, enum machine_mode 
> mode)
> +static rtx
> +mips_function_value_1 (const_tree valtype, const_tree fn_decl_or_type,
> +  enum machine_mode mode)
>  {
>if (valtype)
>  {
>tree fields[2];
>int unsigned_p;
> +  const_tree func = fn_decl_or_type;
>  
> +  if (fn_decl_or_type
> + && !DECL_P (fn_decl_or_type))
> +   func = NULL;
> +

Nitlet, but I'd prefer:

  const_tree func;

  if (fn_decl_or_type && DECL_P (fn_decl_or_type))
func = fn_decl_or_type;
  else
func = NULL_TREE;

> +   Returns true if N is a possible register number for a function value.
> +   On the MIPS, R2 R3 and F0 F2 are the only register thus used.
> +   Currently, R2 and F0 are only implemented here (C has no complex type)  */

"N" isn't right any more.  Let's just drop that line.  (The rest of
the comment looks dodgy, but that's certainly not your fault. :-)
I agree we should keep the pre-existing comment when doing changes
like this.)

> +mips_function_value_regno_p (const unsigned int regno)

Let's drop the "const".

OK with those changes, thanks.

Richard


libgo patch committed: send on a closed channel panics

2011-03-23 Thread Ian Lance Taylor
The Go language spec has been changed to say that sending on a closed
channel panics.  This patch implements that.  Also, there is no longer
any limit on the number of times a program may receive a value from a
closed channel.  Also, calling close on a closed channel panics.
Bootstrapped and tested on x86_64-unknown-linux-gnu.  Committed to
mainline.

Ian

diff -r 1845bb5cbcca libgo/runtime/channel.h
--- a/libgo/runtime/channel.h	Mon Mar 21 15:00:19 2011 -0700
+++ b/libgo/runtime/channel.h	Wed Mar 23 13:36:20 2011 -0700
@@ -36,8 +36,6 @@
   pthread_cond_t cond;
   /* The size of elements on this channel.  */
   size_t element_size;
-  /* Number of operations on closed channel.  */
-  unsigned short closed_op_count;
   /* True if a goroutine is waiting to send on a synchronous
  channel.  */
   _Bool waiting_to_send;
@@ -84,22 +82,15 @@
acquired while this mutex is held.  */
 extern pthread_mutex_t __go_select_data_mutex;
 
-/* Maximum permitted number of operations on a closed channel.  */
-#define MAX_CLOSED_OPERATIONS (0x100)
-
 extern struct __go_channel *__go_new_channel (size_t, size_t);
 
 extern _Bool __go_synch_with_select (struct __go_channel *, _Bool);
 
 extern void __go_broadcast_to_select (struct __go_channel *);
 
-extern _Bool __go_send_acquire (struct __go_channel *, _Bool);
+extern void __go_send_acquire (struct __go_channel *, _Bool);
 
-#define SEND_NONBLOCKING_ACQUIRE_SPACE 0
-#define SEND_NONBLOCKING_ACQUIRE_NOSPACE 1
-#define SEND_NONBLOCKING_ACQUIRE_CLOSED 2
-
-extern int __go_send_nonblocking_acquire (struct __go_channel *);
+extern _Bool __go_send_nonblocking_acquire (struct __go_channel *);
 
 extern void __go_send_release (struct __go_channel *);
 
diff -r 1845bb5cbcca libgo/runtime/go-close.c
--- a/libgo/runtime/go-close.c	Mon Mar 21 15:00:19 2011 -0700
+++ b/libgo/runtime/go-close.c	Wed Mar 23 13:36:20 2011 -0700
@@ -5,6 +5,7 @@
license that can be found in the LICENSE file.  */
 
 #include "go-assert.h"
+#include "go-panic.h"
 #include "channel.h"
 
 /* Close a channel.  After a channel is closed, sends are no longer
@@ -24,6 +25,13 @@
   __go_assert (i == 0);
 }
 
+  if (channel->is_closed)
+{
+  i = pthread_mutex_unlock (&channel->lock);
+  __go_assert (i == 0);
+  __go_panic_msg ("close of closed channel");
+}
+
   channel->is_closed = 1;
 
   i = pthread_cond_broadcast (&channel->cond);
diff -r 1845bb5cbcca libgo/runtime/go-new-channel.c
--- a/libgo/runtime/go-new-channel.c	Mon Mar 21 15:00:19 2011 -0700
+++ b/libgo/runtime/go-new-channel.c	Wed Mar 23 13:36:20 2011 -0700
@@ -39,7 +39,6 @@
   i = pthread_cond_init (&ret->cond, NULL);
   __go_assert (i == 0);
   ret->element_size = element_size;
-  ret->closed_op_count = 0;
   ret->waiting_to_send = 0;
   ret->waiting_to_receive = 0;
   ret->selected_for_send = 0;
diff -r 1845bb5cbcca libgo/runtime/go-rec-nb-small.c
--- a/libgo/runtime/go-rec-nb-small.c	Mon Mar 21 15:00:19 2011 -0700
+++ b/libgo/runtime/go-rec-nb-small.c	Wed Mar 23 13:36:20 2011 -0700
@@ -32,16 +32,6 @@
 	  ? channel->next_store == 0
 	  : channel->next_fetch == channel->next_store))
 {
-  if (channel->saw_close)
-	{
-	  ++channel->closed_op_count;
-	  if (channel->closed_op_count >= MAX_CLOSED_OPERATIONS)
-	{
-	  i = pthread_mutex_unlock (&channel->lock);
-	  __go_assert (i == 0);
-	  __go_panic_msg ("too many operations on closed channel");
-	}
-	}
   channel->saw_close = 1;
   __go_unlock_and_notify_selects (channel);
   return RECEIVE_NONBLOCKING_ACQUIRE_CLOSED;
diff -r 1845bb5cbcca libgo/runtime/go-rec-small.c
--- a/libgo/runtime/go-rec-small.c	Mon Mar 21 15:00:19 2011 -0700
+++ b/libgo/runtime/go-rec-small.c	Wed Mar 23 13:36:20 2011 -0700
@@ -123,12 +123,6 @@
 	  ? channel->next_store == 0
 	  : channel->next_fetch == channel->next_store))
 	{
-	  if (channel->saw_close)
-	{
-	  ++channel->closed_op_count;
-	  if (channel->closed_op_count >= MAX_CLOSED_OPERATIONS)
-		__go_panic_msg ("too many operations on closed channel");
-	}
 	  channel->saw_close = 1;
 	  channel->selected_for_receive = 0;
 	  __go_unlock_and_notify_selects (channel);
diff -r 1845bb5cbcca libgo/runtime/go-send-big.c
--- a/libgo/runtime/go-send-big.c	Mon Mar 21 15:00:19 2011 -0700
+++ b/libgo/runtime/go-send-big.c	Wed Mar 23 13:36:20 2011 -0700
@@ -21,8 +21,7 @@
   alloc_size = ((channel->element_size + sizeof (uint64_t) - 1)
 		/ sizeof (uint64_t));
 
-  if (!__go_send_acquire (channel, for_select))
-return;
+  __go_send_acquire (channel, for_select);
 
   offset = channel->next_store * alloc_size;
   __builtin_memcpy (&channel->data[offset], val, channel->element_size);
diff -r 1845bb5cbcca libgo/runtime/go-send-nb-big.c
--- a/libgo/runtime/go-send-nb-big.c	Mon Mar 21 15:00:19 2011 -0700
+++ b/libgo/runtime/go-send-nb-big.c	Wed Mar 23 13:36:20 2011 -0700
@@ -17,9 +17,8 @@
   alloc_size = ((channel->element_size + sizeof (uint64_t) - 1)
 		/ sizeof (uint64_t));
 
-  int data 

[lto] Minor cleanups, export some functions (issue4272068)

2011-03-23 Thread Diego Novillo

This patch has a few cleanups and exports 5 functions from the LTO streamer
that we are using from PPH.

- When calling output_string_with_length, every caller would first
  write a 0 to indicate that the string is not NULL before writing the
  actual string.  I moved that into output_string_with_length.
- The functions to read/write raw data blocks was private to
  lto-opts.c.  I moved it as a general available function into
  lto-streamer-*.c.
- Similarly, the functions to read/write strings and the code to emit
  decl streams and references were private.  I made them extern so
  they can be called from pph.

None of the above changes behaviour in LTO.  The patch bootstrap and
tests on x86_64.  OK for trunk?


Diego.


* lto-opts.c (input_data_block): Move to lto-streamer-in.c.
* lto-streamer-in.c (input_string_internal): Add clarifying
comments.
(lto_input_data_block): Move from lto-opts.c.  Make extern.
Update all users.
(lto_input_string): Rename from input_string.  Make extern.
Update all users.
* lto-streamer-out.c (lto_output_string_with_length): Rename from
output_string_with_length.
Output 0 to indicate a non-NULL string.  Update all callers to
not emit 0.
(lto_output_string): Rename from output_string.  Make extern.
Update all users.
(lto_output_decl_state_streams): Make extern.
(lto_output_decl_state_refs): Make extern.
* lto-streamer.h (lto_input_string): Declare.
(lto_input_data_block): Declare.
(lto_output_string): Declare.
(lto_output_string_with_length): Declare.
(lto_output_decl_state_streams): Declare.
(lto_output_decl_state_refs): Declare.

diff --git a/gcc/lto-opts.c b/gcc/lto-opts.c
index ec4e78d..9979e8d 100644
--- a/gcc/lto-opts.c
+++ b/gcc/lto-opts.c
@@ -162,18 +162,6 @@ output_string_stream (struct lto_output_stream *stream, 
const char *string)
 output_data_stream (stream, &flag, sizeof (flag));
 }
 
-/* Read LENGTH bytes from STREAM to ADDR.  */
-
-static void
-input_data_block (struct lto_input_block *ib, void *addr, size_t length)
-{
-  size_t i;
-  unsigned char *const buffer = (unsigned char *const) addr;
-
-  for (i = 0; i < length; i++)
-buffer[i] = lto_input_1_unsigned (ib);
-}
-
 /* Return a string from IB.  The string is allocated, and the caller is
responsible for freeing it.  */
 
@@ -182,15 +170,15 @@ input_string_block (struct lto_input_block *ib)
 {
   bool flag;
 
-  input_data_block (ib, &flag, sizeof (flag));
+  lto_input_data_block (ib, &flag, sizeof (flag));
   if (flag)
 {
   size_t length;
   char *string;
 
-  input_data_block (ib, &length, sizeof (length));
+  lto_input_data_block (ib, &length, sizeof (length));
   string = (char *) xcalloc (1, length + 1);
-  input_data_block (ib, string, length);
+  lto_input_data_block (ib, string, length);
 
   return string;
 }
@@ -336,16 +324,16 @@ input_options (struct lto_input_block *ib)
 {
   size_t length, i;
 
-  input_data_block (ib, &length, sizeof (length));
+  lto_input_data_block (ib, &length, sizeof (length));
 
   for (i = 0; i < length; i++)
 {
   opt_t o;
 
-  input_data_block (ib, &o.type, sizeof (o.type));
-  input_data_block (ib, &o.code, sizeof (o.code));
+  lto_input_data_block (ib, &o.type, sizeof (o.type));
+  lto_input_data_block (ib, &o.code, sizeof (o.code));
   o.arg = input_string_block (ib);
-  input_data_block (ib, &o.value, sizeof (o.value));
+  lto_input_data_block (ib, &o.value, sizeof (o.value));
   VEC_safe_push (opt_t, heap, file_options, &o);
 }
 }
diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c
index a873258..383bfc2 100644
--- a/gcc/lto-streamer-in.c
+++ b/gcc/lto-streamer-in.c
@@ -140,7 +140,10 @@ input_string_internal (struct data_in *data_in, struct 
lto_input_block *ib,
   unsigned int loc;
   const char *result;
 
+  /* Read the location of the string from IB.  */
   loc = lto_input_uleb128 (ib);
+
+  /* Get the string stored at location LOC in DATA_IN->STRINGS.  */
   LTO_INIT_INPUT_BLOCK (str_tab, data_in->strings, loc, data_in->strings_len);
   len = lto_input_uleb128 (&str_tab);
   *rlen = len;
@@ -191,10 +194,24 @@ input_identifier (struct data_in *data_in, struct 
lto_input_block *ib)
   return get_identifier_with_length (ptr, len);
 }
 
+
+/* Read LENGTH bytes from STREAM to ADDR.  */
+
+void
+lto_input_data_block (struct lto_input_block *ib, void *addr, size_t length)
+{
+  size_t i;
+  unsigned char *const buffer = (unsigned char *const) addr;
+
+  for (i = 0; i < length; i++)
+buffer[i] = lto_input_1_unsigned (ib);
+}
+
+
 /* Read a NULL terminated string from the string table in DATA_IN.  */
 
-static const char *
-input_string (struct data_in *data_in, struct lto_input_block *ib)
+const char *
+lto_input_string (struct data_in *data_in, struct lto_input_block *ib)
 {
   unsigned int len;

Re: [PATCH 2/2] refactor emit_*_{after,before}{,_setloc} using common functions

2011-03-23 Thread Nathan Froyd
On Wed, Mar 23, 2011 at 01:55:34PM -0700, Richard Henderson wrote:
> I can't see how emitting a NULL_RTX should be a Good Thing, ever,
> and thus I don't see why we should be doing special things to 
> handle it.

Ah, I thought the same thing and gcc_assert'ed emitting a NULL_RTX.  I
didn't get very far; at least reload (and possibly other places) assume
that they can do something like:

x = NULL_RTX;
...do something maybe setting x to a useful pattern...
...emit x unconditionally...

I can look into just how many places might need to be fixed up because
of this, but scattering a bunch of ifs all over the place seemed less
elegant than handling it all in the emit* functions.

-Nathan


[doc patch] obvious partial fix for other/48254

2011-03-23 Thread Jonathan Wakely
Committed to 4.4 and 4.5 branches as obvious, will apply to 4.6 after
4.6.0 is released. The option's gone on the trunk so not relevant
there.

2011-03-23  Jonathan Wakely  

   PR other/48254
   * doc/invoke.texi (-fipa-struct-reorg): Fix typo.



Index: doc/invoke.texi
===
--- doc/invoke.texi (revision 171365)
+++ doc/invoke.texi (working copy)
@@ -6121,7 +6121,7 @@ Enabled by default at @option{-O} and hi
 @opindex fipa-struct-reorg
 Perform structure reorganization optimization, that change C-like structures
 layout in order to better utilize spatial locality.  This transformation is
-affective for programs containing arrays of structures.  Available in two
+effective for programs containing arrays of structures.  Available in two
 compilation modes: profile-based (enabled with @option{-fprofile-generate})
 or static (which uses built-in heuristics).  Require @option{-fipa-type-escape}
 to provide the safety of this transformation.  It works only in whole program


[pph] AST streaming (1/4) (issue4303049)

2011-03-23 Thread Diego Novillo

This set of 4 patches sets up the basic streaming facility for PPH.
The idea is to re-use common code in LTO streaming and add streaming
hooks for dealing with front end specific data.

As we discussed earlier today (http://gcc.gnu.org/ml/gcc/2011-03/msg00354.html),
the front end needs to handle more tree codes that we do not care
about in gimple.  Furthermore, we are interested in removing some of
the tree codes that gimple is forced to handle.  So, the actual
pickling of trees will eventually move into language specific files
and we will add streaming hooks to call from common code.

These patches are actually a single unit, but I split them in 4 parts
for clarity:

1- Adds the inevitable tracer flag (-fpph-tracer) to show what the
   writer and the reader think they are doing.

2- Adds the main streaming support.
   For now PPH files are very simple:
- Identification string
- Version (major, minor, patchlevel)
- Size of string table.
- String table.
- Symbol table.
   This is the extent of the data that we are currently streaming.

   PPH streaming works similarly to FILE I/O:

pph_stream_open(): Opens a pph file by setting up all the
data structures and tables needed by LTO routines.
pph_output_*/pph_input_*: Wrappers around LTO streaming
routines.
pph_stream_close(): Writes out all the streams built by the
pph_output_* calls.

Above these pph streaming routines we are implementing the
high-level logic for saving and restoring the parser state.  This
patch works now for PTH (pre-tokenized headers).  There is also
some early saving of parsed trees, but it is still very
incomplete.

3- Exports some LTO functions that were private to the LTO streamer.

4- Hacks around some checks and assumptions that LTO makes about
   gimple.  These are the ones that I will need to either add hooks or
   factor out somehow.  For now I marked them with FIXME notes.  I
   want to get most/all of them before I decide how to factor things
   out.

Lawrence, we have some regressions in pph.exp because we can't handle
template decls.  I'll be fixing that in the next few days.

Tested on x86_64.


Diego.


c-family/ChangeLog.pph

* c-family/c.opt (fpph-hdr, fpph-map): Re-order.
(fpph-tracer): New.

diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index fd4406f..211586a 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -925,14 +925,6 @@ fpph
 C++ Var(flag_pph)
 -fpph   Enable pre-parsed header (PPH) support
 
-fpph-hdr=
-C++ ObjC++ Joined MissingArgError(missing filename after %qs)
--fpph-hdr=   A mapping from .h to .pph
-
-fpph-map=
-C++ ObjC++ Joined MissingArgError(missing filename after %qs)
--fpph-map=   A file of mappings from #include to PPH file
-
 fpph-debug=
 C++ Joined RejectNegative UInteger Var(flag_pph_debug)
 -fpph-debug=N   Enable debugging output at level N from PPH support
@@ -945,14 +937,26 @@ fpph-fmt=
 C++ Joined RejectNegative UInteger Var(flag_pph_fmt)
 -fpph-fmt=N   Output format is (0) normal (1) pretty summary (2) dump
 
+fpph-hdr=
+C++ ObjC++ Joined MissingArgError(missing filename after %qs)
+-fpph-hdr=   A mapping from .h to .pph
+
 fpph-logfile=
 C++ Joined RejectNegative Var(flag_pph_logfile)
 -fpph-logfile=  Emit PPH debug information to 
 
+fpph-map=
+C++ ObjC++ Joined MissingArgError(missing filename after %qs)
+-fpph-map=   A file of mappings from #include to PPH file
+
 fpph-stats
 C++ Var(flag_pph_stats)
 -fpph-statsEnable statistics gathering for PPH
 
+fpph-tracer
+C++ Var(flag_pph_tracer)
+-fpph-tracer   Enable tracing of PPH streaming operations
+
 fpreprocessed
 C ObjC C++ ObjC++
 Treat the input file as already preprocessed

--
This patch is available for review at http://codereview.appspot.com/4303049


[pph] AST streaming (2/4) (issue4303049)

2011-03-23 Thread Diego Novillo
Main streaming support.

See http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01556.html for details.

cp/ChangeLog.pph

2011-03-23  Diego Novillo  

* Make-lang.in (cp/pph-streamer.o): Add dependencies on
tree-pretty-print.h, CXX_PPH_H, TREE_PASS_H, version.h and
cppbuiltin.h
* pph-streamer.c: Include tree-pretty-print.h, pph.h,
tree-pass.h, version.h and cppbuiltin.h.
(pph_get_section_data): New.
(pph_free_section_data): New.
(pph_stream_init_read): Rename from pph_file_read.
Initialize LTO streaming data structures.
Read pph file in memory.
(pph_stream_init_write): Factor out of ...
(pph_stream_open): ... here.
(pph_stream_write_header): New.
(pph_stream_write_body): Factor out of ...
(pph_stream_close): ... here.
Call pph_stream_write_header.
(enum pph_trace_type): Declare.
(pph_stream_trace): New.
(pph_stream_trace_tree): New.
(pph_stream_trace_uint): New.
(pph_stream_trace_bytes): New.
(pph_stream_trace_string): New.
(pph_stream_trace_string_with_length): New.
* pph-streamer.h (PPH_NUM_SECTIONS): Define.
(PPH_USE_FILE_IO): Remove.  Update all users.
(pph_id_str): Define.
(pph_file_header): Declare.
(pph_stream): Add fields pph_sections, file_data and file_size.
(pph_stream_open): Change second argument to const char *.
Update all users.
(pph_stream_trace_tree): Declare.
(pph_stream_trace_uint): Declare.
(pph_stream_trace_bytes): Declare.
(pph_stream_trace_string): Declare.
(pph_stream_trace_string_with_length): Declare.
(pph_output_tree): Call pph_stream_trace_tree if flag_pph_tracer
is enabled.
(pph_input_tree): Likewise.
(pph_output_uint): Call pph_stream_trace_uint if flag_pph_tracer
is enabled.
(pph_input_uint): Likewise.
(pph_output_bytes): Call pph_stream_trace_bytes if flag_pph_tracer
is enabled.
(pph_input_bytes): Likewise.
(pph_output_string): Call pph_stream_trace_string if flag_pph_tracer
is enabled.
(pph_input_string): Likewise.
(pph_output_string_with_length): Call
pph_stream_trace_string_with_length if flag_pph_tracer is
enabled.
* pph.c (pph_print_macro_defs_before): Call pph_output_string.
(pph_print_macro_defs_after): Likewise.
(pth_load_token_value): Do not free the read string.
(pth_load_identifiers): Likewise.
(pth_load_include): Likewise.
(pth_load_image): Call pph_input_bytes to read the header.
(write_pph_print): Call pph_output_tree.
(write_pph_file_object): Remove fprintf() call.
(pth_include_handler): Remove FIXME marker.
(pph_include_handler): Tidy.

diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in
index 3a52e1f..bcb2ba1 100644
--- a/gcc/cp/Make-lang.in
+++ b/gcc/cp/Make-lang.in
@@ -324,12 +324,10 @@ cp/parser.o: cp/parser.c $(CXX_TREE_H) $(TM_H) 
$(DIAGNOSTIC_CORE_H) \
   $(CXX_PPH_H)
 cp/cp-gimplify.o: cp/cp-gimplify.c $(CXX_TREE_H) $(C_COMMON_H) \
$(TM_H) coretypes.h pointer-set.h tree-iterator.h
-
 cp/name-lookup.o: cp/name-lookup.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) $(CXX_TREE_H) $(TIMEVAR_H) gt-cp-name-lookup.h \
$(DIAGNOSTIC_CORE_H) $(FLAGS_H) debug.h tree-pretty-print.h \
$(CXX_PPH_H)
-
 cp/cxx-pretty-print.o: cp/cxx-pretty-print.c $(CXX_PRETTY_PRINT_H) \
   $(CONFIG_H) $(SYSTEM_H) $(TM_H) coretypes.h $(CXX_TREE_H) tree-pretty-print.h
 cp/pph.o: cp/pph.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(CPPLIB_H) \
@@ -337,4 +335,5 @@ cp/pph.o: cp/pph.c $(CONFIG_H) $(SYSTEM_H) coretypes.h 
$(CPPLIB_H) \
fixed-value.h $(TREE_PASS_H) $(TREE_INLINE_H) tree-pretty-print.h \
$(CXX_PARSER_H) $(CXX_PPH_H) $(CXX_PPH_STREAMER_H)
 cp/pph-streamer.o: cp/pph-streamer.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
-   $(TREE_H) $(LTO_STREAMER_H) $(CXX_PPH_STREAMER_H)
+   $(TREE_H) tree-pretty-print.h $(LTO_STREAMER_H) $(CXX_PPH_STREAMER_H) \
+   $(CXX_PPH_H) $(TREE_PASS_H) version.h cppbuiltin.h
diff --git a/gcc/cp/pph-streamer.c b/gcc/cp/pph-streamer.c
index c170f1f..cca42e6 100644
--- a/gcc/cp/pph-streamer.c
+++ b/gcc/cp/pph-streamer.c
@@ -23,68 +23,147 @@ along with GCC; see the file COPYING3.  If not see
 #include "coretypes.h"
 #include "tree.h"
 #include "langhooks.h"
+#include "tree-pretty-print.h"
 #include "lto-streamer.h"
 #include "pph-streamer.h"
-
-#if !defined PPH_USE_FILE_IO
+#include "pph.h"
+#include "tree-pass.h"
+#include "version.h"
+#include "cppbuiltin.h"
+
+/* FIXME pph.  This holds the FILE handle for the current PPH file
+   that we are writing.  It is necessary because the LTO callbacks do
+   not allow passing a FILE handle to them.  */
 static FILE *current_pph_file = NULL;
-#endif
+
+
+/* Get the section with name NAME and typ

[pph] AST streaming (3/4) (issue4303049)

2011-03-23 Thread Diego Novillo
LTO cleanups.

See http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01556.html for details.


* lto-streamer-in.c (input_string_internal): Add clarifying
comments.
* lto-streamer-out.c (lto_output_string_with_length): Rename from
output_string_with_length.
Output 0 to indicate a non-NULL string.  Update all callers to
not emit 0.
(lto_output_string): Rename from output_string.  Make extern.
Update all users.

diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c
index b86008b..d2f0075 100644
--- a/gcc/lto-streamer-in.c
+++ b/gcc/lto-streamer-in.c
@@ -140,7 +140,10 @@ input_string_internal (struct data_in *data_in, struct 
lto_input_block *ib,
   unsigned int loc;
   const char *result;
 
+  /* Read the location of the string from IB.  */
   loc = lto_input_uleb128 (ib);
+
+  /* Get the string stored at location LOC in DATA_IN->STRINGS.  */
   LTO_INIT_INPUT_BLOCK (str_tab, data_in->strings, loc, data_in->strings_len);
   len = lto_input_uleb128 (&str_tab);
   *rlen = len;
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index a66e1fb..d3d8294 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -170,6 +170,9 @@ lto_output_string_with_length (struct output_block *ob,
   s_slot.len = len;
   s_slot.slot_num = 0;
 
+  /* Indicate that this is not a NULL string.  */
+  lto_output_uleb128_stream (index_stream, 0);
+
   slot = (struct string_slot **) htab_find_slot (ob->string_hash_table,
 &s_slot, INSERT);
   if (*slot == NULL)
@@ -206,11 +209,8 @@ lto_output_string (struct output_block *ob,
   const char *string)
 {
   if (string)
-{
-  lto_output_uleb128_stream (index_stream, 0);
-  lto_output_string_with_length (ob, index_stream, string,
-strlen (string) + 1);
-}
+lto_output_string_with_length (ob, index_stream, string,
+  strlen (string) + 1);
   else
 lto_output_uleb128_stream (index_stream, 1);
 }
@@ -225,12 +225,9 @@ output_string_cst (struct output_block *ob,
   tree string)
 {
   if (string)
-{
-  lto_output_uleb128_stream (index_stream, 0);
-  lto_output_string_with_length (ob, index_stream,
-TREE_STRING_POINTER (string),
-TREE_STRING_LENGTH (string));
-}
+lto_output_string_with_length (ob, index_stream,
+  TREE_STRING_POINTER (string),
+  TREE_STRING_LENGTH (string ));
   else
 lto_output_uleb128_stream (index_stream, 1);
 }
@@ -245,12 +242,9 @@ output_identifier (struct output_block *ob,
   tree id)
 {
   if (id)
-{
-  lto_output_uleb128_stream (index_stream, 0);
-  lto_output_string_with_length (ob, index_stream,
-IDENTIFIER_POINTER (id),
-IDENTIFIER_LENGTH (id));
-}
+lto_output_string_with_length (ob, index_stream,
+  IDENTIFIER_POINTER (id),
+  IDENTIFIER_LENGTH (id));
   else
 lto_output_uleb128_stream (index_stream, 1);
 }

--
This patch is available for review at http://codereview.appspot.com/4303049


[pph] AST streaming (4/4) (issue4303049)

2011-03-23 Thread Diego Novillo
Ugly LTO hacks.  To be nuked.

See http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01556.html for details.


Diego.

* lto-streamer-in.c (lto_input_ts_decl_non_common_tree_pointers):
Always read DECL_SAVED_TREE.
* lto-streamer-out.c (lto_output_ts_decl_common_tree_pointers):
Igonore varpool nodes.
(lto_output_ts_decl_non_common_tree_pointers): Output NULL
DECL_SAVED_TREE.

diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c
index b86008b..d2f0075 100644
--- a/gcc/lto-streamer-in.c
+++ b/gcc/lto-streamer-in.c
@@ -2025,6 +2028,10 @@ lto_input_ts_decl_non_common_tree_pointers (struct 
lto_input_block *ib,
 {
   if (TREE_CODE (expr) == FUNCTION_DECL)
 {
+  /* FIXME pph - Hookize.  */
+#if 1
+  DECL_SAVED_TREE (expr) = lto_input_tree (ib, data_in);
+#endif
   DECL_ARGUMENTS (expr) = lto_input_tree (ib, data_in);
   DECL_RESULT (expr) = lto_input_tree (ib, data_in);
 }
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index a66e1fb..d3d8294 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -854,6 +848,8 @@ lto_output_ts_decl_common_tree_pointers (struct 
output_block *ob, tree expr,
   && TREE_CODE (expr) != TRANSLATION_UNIT_DECL)
 {
   tree initial = DECL_INITIAL (expr);
+  /* FIXME pph - Hookize.  */
+#if 0
   if (TREE_CODE (expr) == VAR_DECL
  && (TREE_STATIC (expr) || DECL_EXTERNAL (expr))
  && initial)
@@ -866,6 +862,7 @@ lto_output_ts_decl_common_tree_pointers (struct 
output_block *ob, tree expr,
  vnode))
initial = NULL;
}
+#endif
 
   lto_output_tree_or_ref (ob, initial, ref_p);
 }
@@ -898,11 +895,16 @@ lto_output_ts_decl_non_common_tree_pointers (struct 
output_block *ob,
 {
   if (TREE_CODE (expr) == FUNCTION_DECL)
 {
+#if 0
   /* DECL_SAVED_TREE holds the GENERIC representation for DECL.
 At this point, it should not exist.  Either because it was
 converted to gimple or because DECL didn't have a GENERIC
 representation in this TU.  */
   gcc_assert (DECL_SAVED_TREE (expr) == NULL_TREE);
+#else
+  /* FIXME pph - Hookize and handle FE ASTs.  */
+  lto_output_tree_or_ref (ob, NULL, ref_p);
+#endif
   lto_output_tree_or_ref (ob, DECL_ARGUMENTS (expr), ref_p);
   lto_output_tree_or_ref (ob, DECL_RESULT (expr), ref_p);
 }

--
This patch is available for review at http://codereview.appspot.com/4303049


Go testsuite patch committed: Ignore //// lines in errchk

2011-03-23 Thread Ian Lance Taylor
This patch to the Go testsuite driver ignores lines containing  when
handling an errchk test (which is similar to a dg-test).  This reflects
a change to the master errchk driver, which is a perl script.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian


2011-03-23  Ian Lance Taylor  

* go.test/go-test.exp (errchk): Ignore lines containing .


Index: gcc/testsuite/go.test/go-test.exp
===
--- gcc/testsuite/go.test/go-test.exp	(revision 171359)
+++ gcc/testsuite/go.test/go-test.exp	(working copy)
@@ -51,6 +51,10 @@ proc errchk { test } {
 set fdout [open $filename w]
 fconfigure $fdout -encoding binary
 while { [gets $fdin copy_line] >= 0 } {
+	if [string match "**" $copy_line] {
+	puts $fdout $copy_line
+	continue
+	}
 	regsub "// \(GCCGO_\)?ERROR \"\(\[^\"\]*\)\".*$" $copy_line "// \{ dg-error \"\\2\" \}" out_line
 	if [string match "*dg-error*.\**" $out_line] {
 	# I worked out the right number of backslashes by


Go patch committed: Change c <- v from an expression to a statement

2011-03-23 Thread Ian Lance Taylor
Go used to have special handling if c <- v (send a value on a channel)
were used as an expression rather than as a statement.  However, that is
no longer true.  Now c <- v must always be a statement.  This patch
implements that in the Go frontend, and adjusts test cases to match.  In
this patch I also removed some old code related to testing the value of
<-c, and I fixed the case of sending an untyped constant in a select
statement.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

diff -r b85d5fc1bf9f go/expressions.cc
--- a/go/expressions.cc	Wed Mar 23 13:40:40 2011 -0700
+++ b/go/expressions.cc	Wed Mar 23 16:44:58 2011 -0700
@@ -12357,103 +12357,6 @@
   return new Receive_expression(channel, location);
 }
 
-// Class Send_expression.
-
-// Traversal.
-
-int
-Send_expression::do_traverse(Traverse* traverse)
-{
-  if (Expression::traverse(&this->channel_, traverse) == TRAVERSE_EXIT)
-return TRAVERSE_EXIT;
-  return Expression::traverse(&this->val_, traverse);
-}
-
-// Get the type.
-
-Type*
-Send_expression::do_type()
-{
-  if (this->is_value_discarded_)
-return Type::make_void_type();
-  else
-return Type::lookup_bool_type();
-}
-
-// Set types.
-
-void
-Send_expression::do_determine_type(const Type_context*)
-{
-  this->channel_->determine_type_no_context();
-
-  Type* type = this->channel_->type();
-  Type_context subcontext;
-  if (type->channel_type() != NULL)
-subcontext.type = type->channel_type()->element_type();
-  this->val_->determine_type(&subcontext);
-}
-
-// Check types.
-
-void
-Send_expression::do_check_types(Gogo*)
-{
-  Type* type = this->channel_->type();
-  if (type->is_error_type())
-{
-  this->set_is_error();
-  return;
-}
-  Channel_type* channel_type = type->channel_type();
-  if (channel_type == NULL)
-{
-  error_at(this->location(), "left operand of %<<-%> must be channel");
-  this->set_is_error();
-  return;
-}
-  Type* element_type = channel_type->element_type();
-  if (element_type != NULL
-  && !Type::are_assignable(element_type, this->val_->type(), NULL))
-{
-  this->report_error(_("incompatible types in send"));
-  return;
-}
-  if (!channel_type->may_send())
-{
-  this->report_error(_("invalid send on receive-only channel"));
-  return;
-}
-}
-
-// Get a tree for a send expression.
-
-tree
-Send_expression::do_get_tree(Translate_context* context)
-{
-  tree channel = this->channel_->get_tree(context);
-  tree val = this->val_->get_tree(context);
-  if (channel == error_mark_node || val == error_mark_node)
-return error_mark_node;
-  Channel_type* channel_type = this->channel_->type()->channel_type();
-  val = Expression::convert_for_assignment(context,
-	   channel_type->element_type(),
-	   this->val_->type(),
-	   val,
-	   this->location());
-  return Gogo::send_on_channel(channel, val, this->is_value_discarded_,
-			   this->for_select_, this->location());
-}
-
-// Make a send expression
-
-Send_expression*
-Expression::make_send(Expression* channel, Expression* val,
-		  source_location location)
-{
-  return new Send_expression(channel, val, location);
-}
-
 // An expression which evaluates to a pointer to the type descriptor
 // of a type.
 
diff -r b85d5fc1bf9f go/expressions.h
--- a/go/expressions.h	Wed Mar 23 13:40:40 2011 -0700
+++ b/go/expressions.h	Wed Mar 23 16:44:58 2011 -0700
@@ -36,7 +36,6 @@
 class Interface_field_reference_expression;
 class Type_guard_expression;
 class Receive_expression;
-class Send_expression;
 class Named_object;
 class Export;
 class Import;
@@ -89,7 +88,6 @@
 EXPRESSION_COMPOSITE_LITERAL,
 EXPRESSION_HEAP_COMPOSITE,
 EXPRESSION_RECEIVE,
-EXPRESSION_SEND,
 EXPRESSION_TYPE_DESCRIPTOR,
 EXPRESSION_TYPE_INFO,
 EXPRESSION_STRUCT_FIELD_OFFSET,
@@ -271,10 +269,6 @@
   static Receive_expression*
   make_receive(Expression* channel, source_location);
 
-  // Make a send expression.
-  static Send_expression*
-  make_send(Expression* channel, Expression* val, source_location);
-
   // Make an expression which evaluates to the type descriptor of a
   // type.
   static Expression*
@@ -356,8 +350,7 @@
 
   // This is called by the parser if the value of this expression is
   // being discarded.  This issues warnings about computed values
-  // being unused, and handles send expressions which act differently
-  // depending upon whether the value is used.
+  // being unused.
   void
   discarding_value()
   { this->do_discarding_value(); }
@@ -1807,7 +1800,7 @@
  public:
   Receive_expression(Expression* channel, source_location location)
 : Expression(EXPRESSION_RECEIVE, location),
-  channel_(channel), is_value_discarded_(false), for_select_(false)
+  channel_(channel), for_select_(false)
   { }
 
   // Return the channel.
@@ -1827,7 +1820,7 @@
 
   void
   do_discarding_value()
-  { this->is_value_discarded_ = true; }
+  { }
 
   Type*
   do_

Re: [PATCH: ARM] PR 45335 Use ldrd and strd to access two consecutive words

2011-03-23 Thread Mike Stump
On Jan 18, 2011, at 6:59 AM, Carrot Wei wrote:
> +(define_insn "*ldrd"
> +  [(parallel [(set (match_operand:SI 0 "arm_hard_register_operand" "")

parallel is implicit, you can safely remove it from all define_insns.


Go patch committed: if statement condition is not optional

2011-03-23 Thread Ian Lance Taylor
The Go language used to permit omitting the condition from an if
statement.  This was useless, but was permitted by analogy with a for
statement.  This useless feature has now been removed.  This patch
removes it from the gccgo frontend, and adjusts some tests to match.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

diff -r bed5c6bbeeb9 go/parse.cc
--- a/go/parse.cc	Wed Mar 23 16:53:20 2011 -0700
+++ b/go/parse.cc	Wed Mar 23 17:28:56 2011 -0700
@@ -3703,8 +3703,7 @@
 			  location));
 }
 
-// IfStat = "if" [ [ SimpleStat ] ";" ] [ Condition ]
-// Block [ "else" Statement ] .
+// IfStmt= "if" [ SimpleStmt ";" ] Expression Block [ "else" Statement ] .
 
 void
 Parse::if_stat()
@@ -3728,8 +3727,7 @@
 {
   if (this->peek_token()->is_op(OPERATOR_SEMICOLON))
 	this->advance_token();
-  if (!this->peek_token()->is_op(OPERATOR_LCURLY))
-	cond = this->expression(PRECEDENCE_NORMAL, false, false, NULL);
+  cond = this->expression(PRECEDENCE_NORMAL, false, false, NULL);
 }
 
   this->gogo_->start_block(this->location());
diff -r bed5c6bbeeb9 go/statements.cc
--- a/go/statements.cc	Wed Mar 23 16:53:20 2011 -0700
+++ b/go/statements.cc	Wed Mar 23 17:28:56 2011 -0700
@@ -2956,12 +2956,8 @@
 int
 If_statement::do_traverse(Traverse* traverse)
 {
-  if (this->cond_ != NULL)
-{
-  if (this->traverse_expression(traverse, &this->cond_) == TRAVERSE_EXIT)
-	return TRAVERSE_EXIT;
-}
-  if (this->then_block_->traverse(traverse) == TRAVERSE_EXIT)
+  if (this->traverse_expression(traverse, &this->cond_) == TRAVERSE_EXIT
+  || this->then_block_->traverse(traverse) == TRAVERSE_EXIT)
 return TRAVERSE_EXIT;
   if (this->else_block_ != NULL)
 {
@@ -2974,11 +2970,8 @@
 void
 If_statement::do_determine_types()
 {
-  if (this->cond_ != NULL)
-{
-  Type_context context(Type::lookup_bool_type(), false);
-  this->cond_->determine_type(&context);
-}
+  Type_context context(Type::lookup_bool_type(), false);
+  this->cond_->determine_type(&context);
   this->then_block_->determine_types();
   if (this->else_block_ != NULL)
 this->else_block_->determine_types();
@@ -2989,14 +2982,11 @@
 void
 If_statement::do_check_types(Gogo*)
 {
-  if (this->cond_ != NULL)
-{
-  Type* type = this->cond_->type();
-  if (type->is_error_type())
-	this->set_is_error();
-  else if (!type->is_boolean_type())
-	this->report_error(_("expected boolean expression"));
-}
+  Type* type = this->cond_->type();
+  if (type->is_error_type())
+this->set_is_error();
+  else if (!type->is_boolean_type())
+this->report_error(_("expected boolean expression"));
 }
 
 // Whether the overall statement may fall through.
@@ -3014,12 +3004,9 @@
 tree
 If_statement::do_get_tree(Translate_context* context)
 {
-  gcc_assert(this->cond_ == NULL
-	 || this->cond_->type()->is_boolean_type()
+  gcc_assert(this->cond_->type()->is_boolean_type()
 	 || this->cond_->type()->is_error_type());
-  tree cond_tree = (this->cond_ == NULL
-		? boolean_true_node
-		: this->cond_->get_tree(context));
+  tree cond_tree = this->cond_->get_tree(context);
   tree then_tree = this->then_block_->get_tree(context);
   tree else_tree = (this->else_block_ == NULL
 		? NULL_TREE
Index: gcc/testsuite/go.test/test/if1.go
===
--- gcc/testsuite/go.test/test/if1.go	(revision 171359)
+++ gcc/testsuite/go.test/test/if1.go	(working copy)
@@ -1,20 +0,0 @@
-// $G $F.go && $L $F.$A && ./$A.out
-
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package main
-
-import "os"
-
-func main() {
-	count := 7
-	if one := 1; {
-		count = count + one
-	}
-	if count != 8 {
-		print(count, " should be 8\n")
-		os.Exit(1)
-	}
-}
Index: gcc/testsuite/go.test/test/ken/robif.go
===
--- gcc/testsuite/go.test/test/ken/robif.go	(revision 171359)
+++ gcc/testsuite/go.test/test/ken/robif.go	(working copy)
@@ -1,97 +0,0 @@
-// $G $D/$F.go && $L $F.$A && ./$A.out
-
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package main
-
-func assertequal(is, shouldbe int, msg string) {
-	if is != shouldbe {
-		print("assertion fail" + msg + "\n");
-		panic(1);
-	}
-}
-
-func main() {
-	i5 := 5;
-	i7 := 7;
-
-	var count int;
-
-	count = 0;
-	if true {
-		count = count + 1;
-	}
-	assertequal(count, 1, "if true");
-
-	count = 0;
-	if false {
-		count = count + 1;
-	}
-	assertequal(count, 0, "if false");
-
-	count = 0;
-	if one := 1; true {
-		count = count + one;
-	}
-	assertequal(count, 1, "if true one");
-
-	count = 0;
-	if one := 1; false {
-		_ = one;
-		count = count + 1;
-	}
-	assertequal(count, 0, "if false one");
-
-	count = 

Re: Can't use SImode as Pmode for x32

2011-03-23 Thread H.J. Lu
On Wed, Mar 23, 2011 at 12:06 PM, Richard Henderson  wrote:
> On 03/19/2011 08:46 AM, H.J. Lu wrote:
>> Operations on stack and frame pointers, like push/pop, require stack
>> and frame pointers in DImode.  Even if I use word_mode in gen_push
>> and gen_pop, I got
>
> No they don't.  Not really.  Assuming the stack and frame pointer are
> properly zero extended, and no one tries to place a stack frame across
> null, then you can also represent it by an SImode operation.
>
>> x.i:10:1: error: unrecognizable insn:
>> (insn/f 22 5 23 2 (set (mem:SI (pre_dec:DI (reg/f:SI 7 sp)) [0 S4 A8])
>>         (reg/f:SI 6 bp)) x.i:6 -1
>>      (nil))
>
> Well, gee, that merely means a pattern needs to be adjusted.
>
>

Are you suggesting that we should say that SP and BP are 32bits so
that x32 has 16 integer registers, 14 are 64 bites and 2 are 32 bits?
How will it work with RA? Can I use BP for integer operations?

-- 
H.J.


  1   2   >