Re: [PATCH 7/7] Plug ipa-prop escape analysis into gimple_call_arg_flags

2014-05-24 Thread Jan Hubicka
> I'm fine with enlarging tree_function_decl for now - ideally we'd push
> stuff from it elsewhere (like target and optimization option tree nodes,
> or most of the visibility and symbol related stuff).  Not sure why
> tree_type_decl inherits from tree_decl_non_common (and thus
> tree_decl_with_vis).  Probably because of the non-common parts
> being (ab-)used by FEs.  Otherwise I'd say simply put a symtab
> node pointer into tree_decl_with_vis ... (can we move
> section_name and comdat_group more easily than assembler_name?)

Hi,
this patch removes comdat_group pointer and adds direct symtab pointer.  As
expected, the change is not completely easy. The main uglyness in C++'s version
of duplicate_decl that creates a duplicated decl with duplicated symtab node
now and needs to remove it.  Other problem is copy_node and c's duplicate_decl
that does memcpy on a node and thus also copie the symtab pointer that is not
the right thing to do.

On the other hand on middle-end side several things simplify, so I think overall
the approach works relatively well.

I have bootstrapped/regtested x86_64-linux and I plan to give it more testing
tomorrow and commit if there are no complains.  Incrementally I would like then
to cleanup way the decl_with_vis.symtab_node pointer is maintained.  I do not
want to allow users to tamper with it, so I did not make accessor macro for
it, however there are more direct uses than I would like: I will need to figure
out how to reduce those.

I can also incrementally move DECL_SECTION and some other stuff I think now.

Honza

* tree-core.h (tree_decl_with_vis): Replace comdat_group by
symtab_node pointer.
* tree.c (copy_node_stat): Be sure tonot copy
symtab_node pointer.
(find_decls_types_r): Do not walk COMDAT_GROUP.
* tree.h (DECL_COMDAT_GROUP): Revamp to use decl_comdat_group.
* varasm.c (make_decl_one_only): Use set_comdat_group;
create node if needed.
* ipa-inline-transform.c (save_inline_function_body): Update
way we decl->symtab mapping.
* symtab.c (symtab_hash, hash_node, eq_node
symtab_insert_node_to_hashtable): Remove.
(symtab_register_node): Update.
(symtab_unregister_node): Update.
(symtab_get_node): Reimplement as inline function.
(symtab_add_to_same_comdat_group): Update.
(symtab_dissolve_same_comdat_group_list): Update.
(dump_symtab_base): Update.
(verify_symtab_base): Update.
(symtab_make_decl_local): Update.
(fixup_same_cpp_alias_visibility): Update.
(symtab_nonoverwritable_alias): Update.
* cgraphclones.c (set_new_clone_decl_and_node_flags): Update.
* ipa.c (update_visibility_by_resolution_info): UPdate.
* bb-reorder.c: Include cgraph.h
* lto-streamer-out.c (DFS_write_tree_body, hash_tree): Do not deal
with comdat groups.
* ipa-comdats.c (set_comdat_group, ipa_comdats): Update.
* cgraph.c (cgraph_get_create_node): Update.
* cgraph.h (struct symtab_node): Add get_comdat_group, set_comdat_group
and comdat_group_.
(symtab_get_node): Make inline.
(symtab_insert_node_to_hashtable): Remove.
(symtab_can_be_discarded): Update.
(decl_comdat_group): New function.
* tree-streamer-in.c (lto_input_ts_decl_with_vis_tree_pointers): Update.
* lto-cgraph.c (lto_output_node, lto_output_varpool_node): Stream out
comdat group name.
(read_comdat_group): New function.
(input_node, input_varpool_node): Use it.
* trans-mem.c (ipa_tm_create_version_alias): Update code creating
comdat groups.
* mips.c (mips_start_unique_function): Likewise.
(ix86_code_end): Likewise.
(rs6000_code_end): Likweise.
* tree-streamer-out.c (DECL_COMDAT_GROUP): Do not stream
comdat group.

* lto-symtab.c (lto_symtab_merge_symbols): Update code setting
symtab pointer.
* lto.c (compare_tree_sccs_1): Do not compare comdat groups.

* optmize.c (maybe_thunk_body): Use set_comdat_group.
(maybe_clone_body): Likewise.
* decl.c (duplicate_decls): Update code duplicating comdat group;
do not copy symtab pointer; before freeing newdecl remove it
from symtab.
* decl2.c (constrain_visibility): Use set_comdat_group.

* c-decl.c (merge_decls): Preserve symtab node pointers.
(duplicate_decls): Free new decl.
Index: tree-core.h
===
--- tree-core.h (revision 210887)
+++ tree-core.h (working copy)
@@ -1442,7 +1442,7 @@ struct GTY(()) tree_decl_with_vis {
  struct tree_decl_with_rtl common;
  tree assembler_name;
  tree section_name;
- tree comdat_group;
+ struct symtab_node *symtab_node;
 
  /* Belong to VAR_DECL exclusively.  */
  unsigned defer_output : 1;
Index: tree.c

Re: [C PATCH] Warn if switch has boolean value (PR c/60439)

2014-05-24 Thread Marek Polacek
On Thu, May 01, 2014 at 11:09:04PM -0600, Jeff Law wrote:
> Looks reasonable, though I do wonder if we should be warning for this in the
> C++ front-end as well?

Yep, I think so.  Luckily the code for the C++ FE is pretty much the
same and, in fact, simpler.
Two issues came up:
1) I think there should be a way how to suppress the warning.  This
   can be done by casting the value of a controlling expression to
   a type other than bool.  The problem was in the C FE, because the
   type of expressions like && is int - so the cast to int was already
   lost in c_start_case.  I resorted to a not very pretty, but
   hopefully simple enough hack
2) Since the warning is now enabled even for the C++ FE, it's
   exercised during bootstrap.  Turned out that gengtype generates
   code like
   switch (TREE_CODE (...) == INTEGER_TYPE) { ... }
   that would mar the bootstrap - so I tweaked it to generate
   switch ((int) (TREE_CODE (...) == INTEGER_TYPE) { ... })
   instead.  Does that make sense?

Regtested/bootstrapped on x86_64-linux, ok for trunk?

2014-05-24  Marek Polacek  

PR c/60439
* doc/invoke.texi: Document -Wswitch-bool.
* function.c (stack_protect_epilogue): Cast controlling expression of
the switch to int.
* gengtype.c (walk_type): Generate switch expression with its
controlling expression cast to int.
c/
* c-parser.c (c_parser_switch_statement): Pass explicit_cast_p to
c_start_case.
* c-tree.h (c_start_case): Update.
* c-typeck.c (c_start_case): Add new boolean parameter.  Warn if
switch condition has boolean value.
cp/
* semantics.c (finish_switch_cond): Warn if switch condition has
boolean value.
c-family/
* c.opt (Wswitch-bool): New option.
testsuite/
* c-c++-common/pr60439.c: New test.
* g++.dg/eh/scope1.C (f4): Add dg-warning.

diff --git gcc/c-family/c.opt gcc/c-family/c.opt
index c586e65..5d36a80 100644
--- gcc/c-family/c.opt
+++ gcc/c-family/c.opt
@@ -534,6 +534,10 @@ Wswitch-enum
 C ObjC C++ ObjC++ Var(warn_switch_enum) Warning
 Warn about all enumerated switches missing a specific case
 
+Wswitch-bool
+C ObjC C++ ObjC++ Warning Init(1)
+Warn about switches with boolean controlling expression
+
 Wmissing-format-attribute
 C ObjC C++ ObjC++ Alias(Wsuggest-attribute=format)
 ;
diff --git gcc/c/c-parser.c gcc/c/c-parser.c
index 88edf36..fc4865e 100644
--- gcc/c/c-parser.c
+++ gcc/c/c-parser.c
@@ -5196,9 +5196,13 @@ c_parser_switch_statement (c_parser *parser)
   gcc_assert (c_parser_next_token_is_keyword (parser, RID_SWITCH));
   c_parser_consume_token (parser);
   block = c_begin_compound_stmt (flag_isoc99);
+  bool explicit_cast_p = false;
   if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
 {
   switch_cond_loc = c_parser_peek_token (parser)->location;
+  if (c_parser_next_token_is (parser, CPP_OPEN_PAREN)
+ && c_token_starts_typename (c_parser_peek_2nd_token (parser)))
+   explicit_cast_p = true;
   ce = c_parser_expression (parser);
   ce = convert_lvalue_to_rvalue (switch_cond_loc, ce, true, false);
   expr = ce.value;
@@ -5216,7 +5220,7 @@ c_parser_switch_statement (c_parser *parser)
   switch_cond_loc = UNKNOWN_LOCATION;
   expr = error_mark_node;
 }
-  c_start_case (switch_loc, switch_cond_loc, expr);
+  c_start_case (switch_loc, switch_cond_loc, expr, explicit_cast_p);
   save_break = c_break_label;
   c_break_label = NULL_TREE;
   body = c_parser_c99_block_statement (parser);
diff --git gcc/c/c-tree.h gcc/c/c-tree.h
index e7dcb35..133930f 100644
--- gcc/c/c-tree.h
+++ gcc/c/c-tree.h
@@ -614,7 +614,7 @@ extern void process_init_element (location_t, struct 
c_expr, bool,
  struct obstack *);
 extern tree build_compound_literal (location_t, tree, tree, bool);
 extern void check_compound_literal_type (location_t, struct c_type_name *);
-extern tree c_start_case (location_t, location_t, tree);
+extern tree c_start_case (location_t, location_t, tree, bool);
 extern void c_finish_case (tree);
 extern tree build_asm_expr (location_t, tree, tree, tree, tree, tree, bool);
 extern tree build_asm_stmt (tree, tree);
diff --git gcc/c/c-typeck.c gcc/c/c-typeck.c
index 74a5ebd..24958c4 100644
--- gcc/c/c-typeck.c
+++ gcc/c/c-typeck.c
@@ -9347,12 +9347,13 @@ struct c_switch *c_switch_stack;
 
 /* Start a C switch statement, testing expression EXP.  Return the new
SWITCH_EXPR.  SWITCH_LOC is the location of the `switch'.
-   SWITCH_COND_LOC is the location of the switch's condition.  */
+   SWITCH_COND_LOC is the location of the switch's condition.
+   EXPLICIT_CAST_P is true if the expression EXP has explicit cast.  */
 
 tree
 c_start_case (location_t switch_loc,
  location_t switch_cond_loc,
- tree exp)
+ tree exp, bool explicit_cast_p)
 {
   tree orig_type = error_mark_node;
   struct c_switch *cs;
@@ -9373,6 +9374,19 @@ c_start_case (locat

Re: [PATCH, fortran-dev] Fix regexps

2014-05-24 Thread Dominique Dhumieres
> Please do commit the patch ...

Done as r210890 and r210891.

> How many regressions are we down to now?

4(5) mvbits_7(8).f90, old ones caused by some changes
by Tobias a long time ago.

pr48636.f90
vect/vect-gems.f90
vect/fast-math-vect-8.f90

missed optimization due to your last changes.

Dominique


Re: RFA: speeding up dg-extract-results.sh

2014-05-24 Thread Bernd Schmidt

On 02/13/2014 10:18 AM, Richard Sandiford wrote:

contrib/
* dg-extract-results.py: New file.
* dg-extract-results.sh: Use it if the environment seems suitable.


I'm now seeing the following:

Traceback (most recent call last):
  File "../../git/gcc/../contrib/dg-extract-results.py", line 581, in 


Prog().main()
  File "../../git/gcc/../contrib/dg-extract-results.py", line 569, in main
self.output_tool (self.runs[name])
  File "../../git/gcc/../contrib/dg-extract-results.py", line 534, in 
output_tool

self.output_variation (tool, variation)
  File "../../git/gcc/../contrib/dg-extract-results.py", line 483, in 
output_variation

for harness in sorted (variation.harnesses.values()):
TypeError: unorderable types: HarnessRun() < HarnessRun()

$ /usr/bin/python --version
Python 3.3.3


Bernd



Re: profile mode maintenance patch

2014-05-24 Thread Jonathan Wakely

On 12/05/14 22:14 +0200, François Dumont wrote:

Hi

   Here is a maintenance patch for profile mode. It does:

- Use inheritance to limit duplication of code in constructors to 
register for the different profiling mode diagnostics data structure.
- Remove many code keeping only instrumented methods or methods that 
where the container type itself appears in the signature..

- Extend the map to unordered_map to all ordered containers.

   And of course code cleanup and usage of default implementation for 
special methods as much as possible.


   Regarding Makefile.in I miss last time. I moved to a new system 
lately, a Ubuntu based one, and still need to find out what version of 
automake/autoreconf I need to install. For the moment I have updated 
Makefile.in manually.


This is OK

(I'm in favour of any change that reduces the amount of code in the
Profile Mode :)

Please correct a minor spelling mistake (in two places) before
committing:


+  /** If hint is used we consider that the map and unordered_map
+   * operations have equivalent insertion cost so we do not update metrics
+   * about it.
+   * Note that to find out if hint has been used is libstdc++
+   * implementation dependant.


s/dependant/dependent/

Thanks!


PING [Patch] Minor fixes for regtesting gfortran with -flto

2014-05-24 Thread Dominique Dhumieres
Ping!

https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00219.html

Dominique


Re: Use resolution info to get rid of weak symbols

2014-05-24 Thread Bernhard Reutner-Fischer

On 18 May 2014 21:38:47 Jan Hubicka  wrote:


Hi,
this patch makes GCC to use resolution info to turn COMDAT and WEAK
symbols into regular symbols based on feedback given by linker plugin.
If resolution says that given symbol is prevailing, it is possible
to turn them into normal symbols, while when resolution says it
is prevailed, it is possible to turn them into external symbols.

Doing so makes rest of the backend to work smoother on them.
We previously did this transformation partly for functions, this patch
just makes it to happen for variables too and implements the second
part (turning the symbol into external definition).

Bootstrapped/regtested x86_64-linux and tested with libreoffice
build.  Will commit it shortly.

* ipa.c (update_visibility_by_resolution_info): New function.
(function_and_variable_visibility): Use it.
Index: ipa.c
===
--- ipa.c   (revision 210522)
+++ ipa.c   (working copy)
@@ -978,6 +978,50 @@ can_replace_by_local_alias (symtab_node
  && !symtab_can_be_discarded (node));
 }

+/* In LTO we can remove COMDAT groups and weak symbols.
+   Either turn them into normal symbols or external symbol depending on +  
 resolution info.  */

+
+static void
+update_visibility_by_resolution_info (symtab_node * node)
+{
+  bool define;
+
+  if (!node->externally_visible
+  || (!DECL_WEAK (node->decl) && !DECL_ONE_ONLY (node->decl))
+  || node->resolution == LDPR_UNKNOWN)
+return;
+
+  define = (node->resolution == LDPR_PREVAILING_DEF_IRONLY
+   || node->resolution == LDPR_PREVAILING_DEF
+   || node->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP);
+
+  /* The linker decisions ought to agree in the whole group.  */
+  if (node->same_comdat_group)
+for (symtab_node *next = node->same_comdat_group;
+next != node; next = next->same_comdat_group)
+  gcc_assert (!node->externally_visible


really !node->externally_visible and not !next->externally_visible ?

Above you already returned if !node->externally_visible ...

Thanks,


+ || define == (next->resolution == LDPR_PREVAILING_DEF_IRONLY
+   || next->resolution == LDPR_PREVAILING_DEF
+   || next->resolution == 
LDPR_PREVAILING_DEF_IRONLY_EXP));
+
+  if (node->same_comdat_group)
+for (symtab_node *next = node->same_comdat_group;
+next != node; next = next->same_comdat_group)
+  {
+   DECL_COMDAT_GROUP (next->decl) = NULL;
+   DECL_WEAK (next->decl) = false;
+   if (next->externally_visible
+   && !define)
+ DECL_EXTERNAL (next->decl) = true;
+  }
+  DECL_COMDAT_GROUP (node->decl) = NULL;
+  DECL_WEAK (node->decl) = false;
+  if (!define)
+DECL_EXTERNAL (node->decl) = true;
+  symtab_dissolve_same_comdat_group_list (node);
+}
+
 /* Mark visibility of all functions.

A local function is one whose calls can occur only in the current
@@ -1116,38 +1160,7 @@ function_and_variable_visibility (bool w
DECL_EXTERNAL (node->decl) = 1;
}

-  /* If whole comdat group is used only within LTO code, we can 
dissolve it,

-we handle the unification ourselves.
-We keep COMDAT and weak so visibility out of DSO does not change.
-Later we may bring the symbols static if they are not exported.  */
-  if (DECL_ONE_ONLY (node->decl)
- && (node->resolution == LDPR_PREVAILING_DEF_IRONLY
- || node->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP))
-   {
- symtab_node *next = node;
-
- if (node->same_comdat_group)
-   for (next = node->same_comdat_group;
-next != node;
-next = next->same_comdat_group)
- if (next->externally_visible
- && (next->resolution != LDPR_PREVAILING_DEF_IRONLY
- && next->resolution != LDPR_PREVAILING_DEF_IRONLY_EXP))
-   break;
- if (node == next)
-   {
- if (node->same_comdat_group)
-   for (next = node->same_comdat_group;
-next != node;
-next = next->same_comdat_group)
-   {
- DECL_COMDAT_GROUP (next->decl) = NULL;
- DECL_WEAK (next->decl) = false;
-   }
- DECL_COMDAT_GROUP (node->decl) = NULL;
- symtab_dissolve_same_comdat_group_list (node);
-   }
-   }
+  update_visibility_by_resolution_info (node);
 }
   FOR_EACH_DEFINED_FUNCTION (node)
 {
@@ -1234,6 +1247,7 @@ function_and_variable_visibility (bool w
symtab_dissolve_same_comdat_group_list (vnode);
  vnode->resolution = LDPR_PREVAILING_DEF_IRONLY;
}
+  update_visibility_by_resolution_info (vnode);
 }

   if (dump_file)



Sent with AquaMail for Android
http://www.aqua-mail.com




Re: PING [Patch] Minor fixes for regtesting gfortran with -flto

2014-05-24 Thread Jerry DeLisle
On 05/24/2014 05:14 AM, Dominique Dhumieres wrote:
> Ping!
> 
> https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00219.html
> 
> Dominique
> 
> 

Yes, OK, thanks for fixes.

Jerry


[ping] Re: [PATCH] dump_case_nodes: Treat unsigned as unsigned, don't ICE

2014-05-24 Thread Segher Boessenkool
Ping?

On Tue, May 20, 2014 at 10:58:27AM -0700, Segher Boessenkool wrote:
> The current code converts every tree to signed hwi; this ICEs with
> values not representable as shwi, like 999ULL in
> pr34154.c (and if it didn't ICE, it would print the wrong value).
> 
> This fixes it.  Bootstrapped and tested on powerpc64-linux.  Okay
> to apply?
> 
> 
> Segher
> 
> 
> 2014-05-20  Segher Boessenkool  
> 
> gcc/
>   * stmt.c (dump_case_nodes): Don't convert values to HOST_WIDE_INT
>   before printing.
> 
> ---
>  gcc/stmt.c | 18 +++---
>  1 file changed, 7 insertions(+), 11 deletions(-)
> 
> diff --git a/gcc/stmt.c b/gcc/stmt.c
> index 163d495..722d34f 100644
> --- a/gcc/stmt.c
> +++ b/gcc/stmt.c
> @@ -774,24 +774,20 @@ static void
>  dump_case_nodes (FILE *f, struct case_node *root,
>int indent_step, int indent_level)
>  {
> -  HOST_WIDE_INT low, high;
> -
>if (root == 0)
>  return;
>indent_level++;
>  
>dump_case_nodes (f, root->left, indent_step, indent_level);
>  
> -  low = tree_to_shwi (root->low);
> -  high = tree_to_shwi (root->high);
> -
>fputs (";; ", f);
> -  if (high == low)
> -fprintf (f, "%*s" HOST_WIDE_INT_PRINT_DEC,
> -  indent_step * indent_level, "", low);
> -  else
> -fprintf (f, "%*s" HOST_WIDE_INT_PRINT_DEC " ... " 
> HOST_WIDE_INT_PRINT_DEC,
> -  indent_step * indent_level, "", low, high);
> +  fprintf (f, "%*s", indent_step * indent_level, "");
> +  print_dec (root->low, f, TYPE_SIGN (TREE_TYPE (root->low)));
> +  if (!tree_int_cst_equal (root->low, root->high))
> +{
> +  fprintf (f, " ... ");
> +  print_dec (root->high, f, TYPE_SIGN (TREE_TYPE (root->high)));
> +}
>fputs ("\n", f);
>  
>dump_case_nodes (f, root->right, indent_step, indent_level);
> -- 
> 1.8.1.4


[PATCH, commited] [4.7 Regression] Needless realloc with array constructor.

2014-05-24 Thread Dominique Dhumieres
Committed as r210893 and 210894 (approved by Paul Thomas on IRC).

Dominique

2014-05-24  Dominique d'Humieres 

Backport r195492 and r195815
2013-01-27  Paul Thomas  

PR fortran/55789
PR fortran/56047
* gfortran.h : Add associate_var to symbol_attr.
* resolve.c (resolve_assoc_var): Set associate_var attribute.
If the target class_ok is set, set it for the associate
variable.
* check.c (allocatable_check): Associate variables should not
have the allocatable attribute even if their symbols do.
* class.c (gfc_build_class_symbol): Symbols with associate_var
set will always have a good class container.

2013-02-06  Paul Thomas  

PR fortran/55789
* trans-array.c (trans_array_constructor): Remove condition
'dynamic' = true if the loop ubound is a VAR_DECL.


and

2014-05-24  Dominique d'Humieres 

Backport r195492 and r195815
2013-01-27  Paul Thomas  

PR fortran/55789
* gfortran.dg/associate_14.f90: New test.

PR fortran/56047
* gfortran.dg/associate_13.f90: New test.

2013-02-06  Paul Thomas 

PR fortran/55789 
* gfortran.dg/array_constructor_41.f90: New test.



Re: [patch, libgfortran] [4.9/4.10 Regression] Erroneous "end of file" with internal read

2014-05-24 Thread Dominique Dhumieres
Dear Jerry,

I have regstrapped r210889 with your patch without regression.
I have also run the NIST suite without failure.

Thanks for the patch,

Dominique


Re: [patch ping] libstdc++ testsuite cxxflags

2014-05-24 Thread David Edelsohn
This patch broke the ability to run the libstdc++ testsuite on AIX.

I now see the following errors:

bad switch "-O": must be -all, -about, -indices, -inline, -expanded, -line, -lin
estop, -lineanchor, -nocase, -start, or --
while executing
"regexp "\-O" $cxxflags"
(procedure "libstdc++_init" line 183)
invoked from within
"${tool}_init $test_file_name"
invoked from within
"if [info exists tool] {
if { [info procs "${tool}_init"] != "" } {
${tool}_init $test_file_name
}
}"
invoked from within
"if [file exists $test_file_name] {
set timestart [timestamp]

if [info exists tool] {
if { [info procs "${tool}_init"] != "" } {
${tool}_init..."
(procedure "runtest" line 14)
invoked from within
"runtest $test_name"
("foreach" body line 42)
invoked from within
"foreach test_name [lsort [find ${dir} *.exp]] {
if { ${test_name} == "" } {
continue
}
# Ignore this one if asked to.
if { ${ignore..."
("foreach" body line 54)
invoked from within
"foreach dir "${test_top_dirs}" {
if { ${dir} != ${srcdir} } {
# Ignore this directory if is a directory to be
# ignored.
if {[info..."
("foreach" body line 121)
invoked from within
"foreach pass $multipass {

# multipass_name is set for `record_test' to use (see framework.exp).
if { [lindex $pass 0] != "" } {
set multipass_..."
("foreach" body line 51)
invoked from within
"foreach current_target $target_list {
verbose "target is $current_target"
set current_target_name $current_target
set tlist [split $curren..."
(file "/gsa/yktgsa/home/e/d/edelsohn/share/dejagnu/runtest.exp" line 1625)


Re: [RS6000] Fix PR61098, Poor code setting count register

2014-05-24 Thread David Edelsohn
On Fri, May 23, 2014 at 11:23 AM, Alan Modra  wrote:
> OK, let's start again from scratch.  This patch fixes PR61098, a
> problem caused by trying to do arithmetic on the count register.  The
> fix is to provide a new pseudo in rs6000_emit_set_long_const so
> arithmetic will be done in a gpr.
>
> Additionally, the patch fixes a number of other bugs and cleanup
> issues with rs6000_emit_set_{,long_}const.
>
> - rs6000_emit_set_long_const took two HWI constant parameters, a relic
>   from the days when HWI might be 32 bits on powerpc.  We're only
>   setting a 64-bit value, so remove the unnecessary parameter.
>
> - The !TARGET_POWERPC64 handling of DImode assumed a 32 bit HWI, and
>   the insn setting the low 32-bit reg was wrongly marked with a
>   reg_equiv note saying the reg contained the entire 64-bit constant.
>   I hadn't spotted the bad reg_equiv when writing the previous patch.
>
> - The comments describing the functions are inaccurate and misleading.
>
> - rs6000_emit_set_long_const always returns DEST, so it's caller can
>   assume this and rs6000_emit_set_long_const return void.
>
> - The code testing for a NULL DEST in rs6000_emit_set_const is dead.
>   DEST cannot be NULL, since the three uses of the function are in
>   rs6000.md splitters where DEST (operand[0]) satisfies
>   gpc_reg_operand.
>
> - The above two points mean that rs6000_emit_set_const always returns
>   DEST, which in turn would allow rs6000_emit_set_const to return
>   void.  However, in view of a possible future change that might need
>   to return status on whether rs6000_emit_set_const emitted anything,
>   return a bool.
>
> - rs6000_emit_set_const parameter N is currently unused, and MODE
>   always matches GET_MODE (DEST), so N and MODE can be removed.
>
> - The code is liberally sprinkled with copy_rtx.  DEST/TEMP is always
>   used once without copy_rtx, but which insn uses copy_rtx varies.  I
>   changed the code to always use a bare DEST as the last insn for
>   consistency.  (Writing the code this way might allow us to omit the
>   copy_rtx on DEST/TEMP entirely.  Before reload TEMP will be a new
>   pseudo reg, thus doesn't need copy_rtx, and after reload we
>   shouldn't have a SUBREG DEST.  I wasn't sure of exactly what might
>   happen during reload, so left well enough alone.)
>
> Bootstrapped and regression tested powerpc64-linux.  OK to apply
> mainline?

This is a much clearer start. Thanks for the revised version.

This is okay.

Thanks, David


Re: [ping] Re: [PATCH] dump_case_nodes: Treat unsigned as unsigned, don't ICE

2014-05-24 Thread Steven Bosscher
On Sat, May 24, 2014 at 4:25 PM, Segher Boessenkool wrote:
> Ping?

OK.

Ciao!
Steven





> On Tue, May 20, 2014 at 10:58:27AM -0700, Segher Boessenkool wrote:
>> The current code converts every tree to signed hwi; this ICEs with
>> values not representable as shwi, like 999ULL in
>> pr34154.c (and if it didn't ICE, it would print the wrong value).
>>
>> This fixes it.  Bootstrapped and tested on powerpc64-linux.  Okay
>> to apply?
>>
>>
>> Segher
>>
>>
>> 2014-05-20  Segher Boessenkool  
>>
>> gcc/
>>   * stmt.c (dump_case_nodes): Don't convert values to HOST_WIDE_INT
>>   before printing.
>>
>> ---
>>  gcc/stmt.c | 18 +++---
>>  1 file changed, 7 insertions(+), 11 deletions(-)
>>
>> diff --git a/gcc/stmt.c b/gcc/stmt.c
>> index 163d495..722d34f 100644
>> --- a/gcc/stmt.c
>> +++ b/gcc/stmt.c
>> @@ -774,24 +774,20 @@ static void
>>  dump_case_nodes (FILE *f, struct case_node *root,
>>int indent_step, int indent_level)
>>  {
>> -  HOST_WIDE_INT low, high;
>> -
>>if (root == 0)
>>  return;
>>indent_level++;
>>
>>dump_case_nodes (f, root->left, indent_step, indent_level);
>>
>> -  low = tree_to_shwi (root->low);
>> -  high = tree_to_shwi (root->high);
>> -
>>fputs (";; ", f);
>> -  if (high == low)
>> -fprintf (f, "%*s" HOST_WIDE_INT_PRINT_DEC,
>> -  indent_step * indent_level, "", low);
>> -  else
>> -fprintf (f, "%*s" HOST_WIDE_INT_PRINT_DEC " ... " 
>> HOST_WIDE_INT_PRINT_DEC,
>> -  indent_step * indent_level, "", low, high);
>> +  fprintf (f, "%*s", indent_step * indent_level, "");
>> +  print_dec (root->low, f, TYPE_SIGN (TREE_TYPE (root->low)));
>> +  if (!tree_int_cst_equal (root->low, root->high))
>> +{
>> +  fprintf (f, " ... ");
>> +  print_dec (root->high, f, TYPE_SIGN (TREE_TYPE (root->high)));
>> +}
>>fputs ("\n", f);
>>
>>dump_case_nodes (f, root->right, indent_step, indent_level);
>> --
>> 1.8.1.4


Re: [patch ping] libstdc++ testsuite cxxflags

2014-05-24 Thread Jonathan Wakely
On 24 May 2014 17:07, David Edelsohn wrote:
> This patch broke the ability to run the libstdc++ testsuite on AIX.
>
> I now see the following errors:
>
> bad switch "-O": must be -all, -about, -indices, -inline, -expanded, -line, 
> -lin
> estop, -lineanchor, -nocase, -start, or --
> while executing
> "regexp "\-O" $cxxflags"

Would this work instead?

   regexp ".*-O" $cxxflags


Re: RFA: speeding up dg-extract-results.sh

2014-05-24 Thread Mike Stump
On May 24, 2014, at 4:17 AM, Bernd Schmidt  wrote:
> On 02/13/2014 10:18 AM, Richard Sandiford wrote:
>> contrib/
>>  * dg-extract-results.py: New file.
>>  * dg-extract-results.sh: Use it if the environment seems suitable.
> 
> I'm now seeing the following:
> 
> Traceback (most recent call last):
>  File "../../git/gcc/../contrib/dg-extract-results.py", line 581, in 
>Prog().main()
>  File "../../git/gcc/../contrib/dg-extract-results.py", line 569, in main
>self.output_tool (self.runs[name])
>  File "../../git/gcc/../contrib/dg-extract-results.py", line 534, in 
> output_tool
>self.output_variation (tool, variation)
>  File "../../git/gcc/../contrib/dg-extract-results.py", line 483, in 
> output_variation
>for harness in sorted (variation.harnesses.values()):
> TypeError: unorderable types: HarnessRun() < HarnessRun()
> 
> $ /usr/bin/python --version
> Python 3.3.3

Seems unfortunate…  I’d put in a, if on 3.3 or later, don’t use line until a 
python person can address it.

Can you try something like the below and see if it works better for you…  If it 
does, I’d approve it, if you would like to put it in.

Index: dg-extract-results.sh
===
--- dg-extract-results.sh   (revision 210894)
+++ dg-extract-results.sh   (working copy)
@@ -32,7 +32,7 @@ PROGNAME=dg-extract-results.sh
 PYTHON_VER=`echo "$0" | sed 's/sh$/py/'`
 if test "$PYTHON_VER" != "$0" &&
test -f "$PYTHON_VER" &&
-   python -c 'import sys; sys.exit (0 if sys.version_info >= (2, 6) else 1)' \
+   python -c 'import sys; sys.exit (0 if sys.version_info >= (2, 6) and 
sys.version_info < (3, 3) else 1)' \
  > /dev/null 2> /dev/null; then
   exec python $PYTHON_VER "$@"
 fi


Re: RFA: speeding up dg-extract-results.sh

2014-05-24 Thread Trevor Saunders
On Sat, May 24, 2014 at 10:14:54AM -0700, Mike Stump wrote:
> On May 24, 2014, at 4:17 AM, Bernd Schmidt  wrote:
> > On 02/13/2014 10:18 AM, Richard Sandiford wrote:
> >> contrib/
> >>* dg-extract-results.py: New file.
> >>* dg-extract-results.sh: Use it if the environment seems suitable.
> > 
> > I'm now seeing the following:
> > 
> > Traceback (most recent call last):
> >  File "../../git/gcc/../contrib/dg-extract-results.py", line 581, in 
> > 
> >Prog().main()
> >  File "../../git/gcc/../contrib/dg-extract-results.py", line 569, in main
> >self.output_tool (self.runs[name])
> >  File "../../git/gcc/../contrib/dg-extract-results.py", line 534, in 
> > output_tool
> >self.output_variation (tool, variation)
> >  File "../../git/gcc/../contrib/dg-extract-results.py", line 483, in 
> > output_variation
> >for harness in sorted (variation.harnesses.values()):
> > TypeError: unorderable types: HarnessRun() < HarnessRun()
> > 
> > $ /usr/bin/python --version
> > Python 3.3.3
> 
> Seems unfortunate…  I’d put in a, if on 3.3 or later, don’t use line until a 
> python person can address it.

it looks like __cmp__ which the named class implements doesn't work in
python3, and instead you get to implement __eq__, __ne__, __gt__,
__ge__, __lt__, and __le__ or whatever subset of those is enough to make
sorted happy.

Trev

> 
> Can you try something like the below and see if it works better for you…  If 
> it does, I’d approve it, if you would like to put it in.
> 
> Index: dg-extract-results.sh
> ===
> --- dg-extract-results.sh (revision 210894)
> +++ dg-extract-results.sh (working copy)
> @@ -32,7 +32,7 @@ PROGNAME=dg-extract-results.sh
>  PYTHON_VER=`echo "$0" | sed 's/sh$/py/'`
>  if test "$PYTHON_VER" != "$0" &&
> test -f "$PYTHON_VER" &&
> -   python -c 'import sys; sys.exit (0 if sys.version_info >= (2, 6) else 1)' 
> \
> +   python -c 'import sys; sys.exit (0 if sys.version_info >= (2, 6) and 
> sys.version_info < (3, 3) else 1)' \
>   > /dev/null 2> /dev/null; then
>exec python $PYTHON_VER "$@"
>  fi


signature.asc
Description: Digital signature


Re: [PATCH] Fix PR middle-end/61141

2014-05-24 Thread John David Anglin

On 20-May-14, at 5:23 PM, Jeff Law wrote:


I believe that the backend must handle the deleted insns in the delay
slot as there are are no compilation errors or regressions.
However, like you, I'm not 100% certain this done correctly.
I'm pretty sure we're getting this wrong in the backend.   In fact,  
the more I think about it, a NOTE_INSN_DELETED in a delay slot is  
just asking for all kinds of trouble.


In general, if we have an insn with a filled delay slot, then we  
will emit the two insns independently of each other (most of the  
time, there are exceptions).


A NOTE_INSN_DELETED in a delay slot still looks like a filled slot.   
So the target code isn't going to emit a NOP or anything like that.   
It's going to leave it up to the generic code to emit the insn with  
the delay slot and the delay slot insn itself (the NOTE_INSN_DELETED  
in this case).


Of course we don't output anything for a NOTE_INSN_DELETED.  So the  
net result is we, in essence, fill the delay slot with whatever  
random instruction happens to fall next in the insn chain.


Amazingly, nothing seems to be failing, but I've seen far worse bugs  
go unnoticed for a long time.


Sadly,I think we need to start digging deeper to find out what's  
deleting those insns and take corrective action.


Perhaps writing a little routine to peek at all the filled delay  
slots and squawk if it finds a NOTE_INSN_DELETED.  Then call it  
after each RTL pass that follows reorg in the pass manager.  That'd  
at least narrow it down to a pass that's mucking things up.


The insns are being deleted in "final" after the assembly output has  
being done.  So, for example, pa_output_call is
never called with a delayed branch sequence containing a  
NOTE_INSN_DELETED.


It would seem to me that this "cleanup" should be done before the  
"dbr" pass.


If dbr_sequence() ignored notes, we would emit the nop.  However, it  
doesn't look like it does.  It fairly
easy to check for this case but I hesitate to add code to handle cases  
that aren't supposed to happen.


Dave
--
John David Anglin   dave.ang...@bell.net





Re: [PATCH] Fix PR54733 Optimize endian independent load/store

2014-05-24 Thread Andreas Schwab
* gcc.c-torture/execute/bswap-2.c (main): Handle more bitfield
layouts.

diff --git a/gcc/testsuite/gcc.c-torture/execute/bswap-2.c 
b/gcc/testsuite/gcc.c-torture/execute/bswap-2.c
index e91b487..38f18fd 100644
--- a/gcc/testsuite/gcc.c-torture/execute/bswap-2.c
+++ b/gcc/testsuite/gcc.c-torture/execute/bswap-2.c
@@ -74,11 +74,11 @@ main ()
 return 0;
   bfin.inval = (struct ok) { 0x83, 0x85, 0x87, 0x89 };
   out = partial_read_le32 (bfin);
-  if (out != 0x09070503 && out != 0x88868482)
+  if (out != 0x09070503 && out != 0x88868482 && out != 0x78306141)
 __builtin_abort ();
   bfin.inval = (struct ok) { 0x83, 0x85, 0x87, 0x89 };
   out = partial_read_be32 (bfin);
-  if (out != 0x03050709 && out != 0x82848688)
+  if (out != 0x03050709 && out != 0x82848688 && out != 0x41613078)
 __builtin_abort ();
   out = fake_read_le32 (cin, &cin[2]);
   if (out != 0x89018583)
-- 
1.9.3

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


Re: profile mode maintenance patch

2014-05-24 Thread François Dumont

On 24/05/2014 13:33, Jonathan Wakely wrote:

On 12/05/14 22:14 +0200, François Dumont wrote:

Hi

   Here is a maintenance patch for profile mode. It does:

- Use inheritance to limit duplication of code in constructors to 
register for the different profiling mode diagnostics data structure.
- Remove many code keeping only instrumented methods or methods that 
where the container type itself appears in the signature..

- Extend the map to unordered_map to all ordered containers.

   And of course code cleanup and usage of default implementation for 
special methods as much as possible.


   Regarding Makefile.in I miss last time. I moved to a new system 
lately, a Ubuntu based one, and still need to find out what version 
of automake/autoreconf I need to install. For the moment I have 
updated Makefile.in manually.


This is OK

(I'm in favour of any change that reduces the amount of code in the
Profile Mode :)

Please correct a minor spelling mistake (in two places) before
committing:


+  /** If hint is used we consider that the map and unordered_map
+   * operations have equivalent insertion cost so we do not 
update metrics

+   * about it.
+   * Note that to find out if hint has been used is libstdc++
+   * implementation dependant.


s/dependant/dependent/

Thanks!


Done but I forgot to fix the spelling. I will fix it in the future patch.

François



[Patch, Fortran] Support distance/failed argument with coarray's THIS_IMAGE/NUM_IMAGES

2014-05-24 Thread Tobias Burnus
The library and the compiler (trans*c) already supported the distance 
argument to this_image/num_images – and the failed argument to 
num_images. This patch makes them available to the user.


The distance/failed arguments are new with the upcoming Technical 
Specification (TS) 18508; the former is to be used with teams (not yet 
supported); the latter is for failure recover, if any image (but the 
first) failes. In the current state, the feature is not really useful, 
but one has to start somewhere ;-)


Additionally, it corrects an argument-name bug: this_image's argument is 
COARRAY= not ARRAY=.


Build and regtested on x86-64-gnu-linux.
OK for the trunk?

Tobias
2014-05-24  Tobias Burnus  

	* check.c (gfc_check_num_images): New.
	(gfc_check_this_image): Handle distance argument.
	* intrinsic.c (add_functions): Update this_image and num_images
	for new distance and failed arguments.
	* intrinsic.texi (THIS_IMAGE, NUM_IMAGES): Document the new
	arguments.
	* intrinsic.h (gfc_check_num_images): New.
	(gfc_check_this_image, gfc_simplify_num_images,
	gfc_simplify_this_image, gfc_resolve_this_image): Update prototype.
	* iresolve.c (gfc_resolve_this_image): Handle distance argument.
	* simplify.c (gfc_simplify_num_images, gfc_simplify_this_image):
	Handle new arguments.
	* trans-intrinsic.c (trans_this_image, trans_num_images): Ditto.
	(gfc_conv_intrinsic_function): Update trans_num_images call.

2014-05-24  Tobias Burnus  

	* gfortran.dg/coarray_10.f90: Update dg-warning.
	* gfortran.dg/coarray_this_image_1.f90: New.
	* gfortran.dg/coarray_this_image_2.f90: New.

diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index 9dd6071..20af75f 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -4552,7 +4552,7 @@ gfc_check_image_index (gfc_expr *coarray, gfc_expr *sub)
 
 
 bool
-gfc_check_this_image (gfc_expr *coarray, gfc_expr *dim)
+gfc_check_num_images (gfc_expr *distance, gfc_expr *failed)
 {
   if (gfc_option.coarray == GFC_FCOARRAY_NONE)
 {
@@ -4560,16 +4560,96 @@ gfc_check_this_image (gfc_expr *coarray, gfc_expr *dim)
   return false;
 }
 
-  if (dim != NULL &&  coarray == NULL)
+  if (distance)
 {
-  gfc_error ("DIM argument without ARRAY argument not allowed for THIS_IMAGE "
-"intrinsic at %L", &dim->where);
+  if (!type_check (distance, 0, BT_INTEGER))
+	return false;
+
+  if (!nonnegative_check ("DISTANCE", distance))
+	return false;
+
+  if (!scalar_check (distance, 0))
+	return false;
+
+  if (!gfc_notify_std (GFC_STD_F2008_TS, "DISTANCE= argument to "
+			   "NUM_IMAGES at %L", &distance->where))
+	return false;
+}
+
+   if (failed)
+{
+  if (!type_check (failed, 1, BT_LOGICAL))
+	return false;
+
+  if (!scalar_check (failed, 1))
+	return false;
+
+  if (!gfc_notify_std (GFC_STD_F2008_TS, "FAILED= argument to "
+			   "NUM_IMAGES at %L", &distance->where))
+	return false;
+}
+
+  return true;
+}
+
+
+bool
+gfc_check_this_image (gfc_expr *coarray, gfc_expr *dim, gfc_expr *distance)
+{
+  if (gfc_option.coarray == GFC_FCOARRAY_NONE)
+{
+  gfc_fatal_error ("Coarrays disabled at %C, use -fcoarray= to enable");
   return false;
 }
 
-  if (coarray == NULL)
+  if (coarray == NULL && dim == NULL && distance == NULL)
 return true;
 
+  if (dim != NULL && coarray == NULL)
+{
+  gfc_error ("DIM argument without COARRAY argument not allowed for "
+		 "THIS_IMAGE intrinsic at %L", &dim->where);
+  return false;
+}
+
+  if (distance && (coarray || dim))
+{
+  gfc_error ("The DISTANCE argument may not be specified together with the "
+		 "COARRAY or DIM argument in intrinsic at %L",
+		 &distance->where);
+  return false;
+}
+
+  /* Assume that we have "this_image (distance)".  */
+  if (coarray && !gfc_is_coarray (coarray) && coarray->ts.type == BT_INTEGER)
+{
+  if (dim)
+	{
+	  gfc_error ("Unexpected DIM argument with noncoarray argument at %L",
+		 &coarray->where);
+	  return false;
+	}
+  distance = coarray;
+}
+
+  if (distance)
+{
+  if (!type_check (distance, 2, BT_INTEGER))
+	return false;
+
+  if (!nonnegative_check ("DISTANCE", distance))
+	return false;
+
+  if (!scalar_check (distance, 2))
+	return false;
+
+  if (!gfc_notify_std (GFC_STD_F2008_TS, "DISTANCE= argument to "
+			   "THIS_IMAGE at %L", &distance->where))
+	return false;
+
+  return true;
+}
+
   if (!coarray_check (coarray, 0))
 return false;
 
diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c
index 4c2eaa5..bf784b5 100644
--- a/gcc/fortran/intrinsic.c
+++ b/gcc/fortran/intrinsic.c
@@ -1205,7 +1205,7 @@ add_functions (void)
 *z = "z", *ln = "len", *ut = "unit", *han = "handler",
 *num = "number", *tm = "time", *nm = "name", *md = "mode",
 *vl = "values", *p1 = "path1", *p2 = "path2", *com = "command",
-*ca = "coarray", *sub = "sub";
+*ca = "coarray", *sub = "sub", *dist = "distance", *failed="failed";
 
   int 

Re: profile mode maintenance patch

2014-05-24 Thread Jonathan Wakely
On 24 May 2014 22:10, François Dumont wrote:
> Done but I forgot to fix the spelling. I will fix it in the future patch.

No problem, it's clear what the comment means.


Re: -fuse-caller-save - Collect register usage information

2014-05-24 Thread Jan Hubicka
> 2013-04-29  Radovan Obradovic  
> Tom de Vries  
> 
>   * cgraph.h (struct cgraph_node): Add function_used_regs,
>   function_used_regs_initialized and function_used_regs_valid fields.
>   * final.c: Move include of hard-reg-set.h to before rtl.h to declare
>   find_all_hard_reg_sets.
>   (collect_fn_hard_reg_usage, get_call_fndecl, get_call_cgraph_node)
>   (get_call_reg_set_usage): New function.
>   (rest_of_handle_final): Use collect_fn_hard_reg_usage.
> ---
>  gcc/cgraph.h |   7 
>  gcc/final.c  | 117 
> ++-
>  gcc/regs.h   |   4 ++
>  3 files changed, 127 insertions(+), 1 deletion(-)
> 
> diff --git a/gcc/cgraph.h b/gcc/cgraph.h
> index 84fc1d9..d1f 100644
> --- a/gcc/cgraph.h
> +++ b/gcc/cgraph.h
> @@ -408,6 +408,13 @@ public:
>/* Time profiler: first run of function.  */
>int tp_first_run;
>  
> +  /* Call unsaved hard registers really used by the corresponding
> + function (including ones used by functions called by the
> + function).  */
> +  HARD_REG_SET function_used_regs;
> +  /* Set if function_used_regs is valid.  */
> +  unsigned function_used_regs_valid: 1;
> +

This approach seems resonable, but please move the data into cgraph_rtl_info
substructure and access it via cgraph_rtl_info.  (I have plan to move it off
cgraph_node, so it doesn't consume memory at WPA stage)

The cgraph bits are OK with this change.

I am sorry for late reply,
Honza


Re: -fuse-caller-save - Collect register usage information

2014-05-24 Thread Jan Hubicka
> +/* Get the declaration of the function called by INSN.  */
> +
> +static tree
> +get_call_fndecl (rtx insn)
> +{
> +  rtx note, datum;
> +
> +  note = find_reg_note (insn, REG_CALL_DECL, NULL_RTX);
> +  if (note == NULL_RTX)
> +return NULL_TREE;
> +
> +  datum = XEXP (note, 0);
> +  if (datum != NULL_RTX)
> +return SYMBOL_REF_DECL (datum);
> +
> +  return NULL_TREE;
> +}
> +
> +static struct cgraph_node *
> +get_call_cgraph_node (rtx insn)
> +{
> +  tree fndecl;
> +
> +  if (insn == NULL_RTX)
> +return NULL;
> +
> +  fndecl = get_call_fndecl (insn);
> +  if (fndecl == NULL_TREE
> +  || !targetm.binds_local_p (fndecl))
> +return NULL;
> +
> +  return cgraph_get_node (fndecl);
> +}

So far we do not have any RTL code in cgraph*.c, so lets keep it here until we
get some other uses for it.  Then I think it can go to rtlanal.

get_call_cgraph_node is missing description and probably should emhatize the
fact that it returns NULL for call targets that can be overwritten.
You want to test decl_binds_to_current_def_p instead of binds_local_p.
Consider hidden weak symbol - that one binds local, but it can be rewritten by
other implementation at linktime.

With this change and after the data are moved to rtl info, the patch is OK 
(given that 
Eric already approved the RTL bits I can't)

Note that this patch will interfere rather badly with Martin's work to order 
functions
in execution order, since it wants to have callee before caller.  I wonder if 
we can't
add support for GAS section fragments in this case to order functions in a way 
we want.

Honza


ipa-visibility TLC 1/n: move to separate file

2014-05-24 Thread Jan Hubicka
Hi,
ipa-visibility will be soon 10 years old and deserves some cleanups, since it
keeps getting new special cases and features.  This patch does nothing except
for moving it to separate file and adding a toplevel comment.

Bootstrapped/regtsted x86_64-linux, comitted.

Honza

* ipa.c (cgraph_non_local_node_p_1, cgraph_local_node_p, 
address_taken_from_non_vtable_p,
comdat_can_be_unshared_p_1, comdat_can_be_unshared_p, 
cgraph_externally_visible_p,
varpool_externally_visible_p, can_replace_by_local_alias,
update_visibility_by_resolution_info, function_and_variable_visibility,
pass_data_ipa_function_and_variable_visibility,
make_pass_ipa_function_and_variable_visibility,
whole_program_function_and_variable_visibility,
pass_data_ipa_whole_program_visibility,
make_pass_ipa_whole_program_visibility): Move to ipa-visibility.c
* cgraph.h (cgraph_local_node_p): Declare.
* ipa-visibility.c: New file.
* Makefile.in (OBJS): Add ipa-visiblity.o
Index: ipa-visibility.c
===
--- ipa-visibility.c(revision 0)
+++ ipa-visibility.c(revision 0)
@@ -0,0 +1,758 @@
+/* IPA visibility pass
+   Copyright (C) 2003-2014 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+.  */
+
+/* This file implements two related passes: 
+
+ - pass_data_ipa_function_and_variable_visibility run just after
+   symbol table, references and callgraph are built
+
+ - pass_data_ipa_function_and_variable_visibility run as first
+   proper IPA pass (that is after early optimization, or, (with LTO)
+   as a first pass done at link-time.
+
+   Purpose of both passes is to set correctly visibility properties
+   of all symbols.  This includes:
+
+- Symbol privatization:
+
+  Some symbols that are declared public by frontend may be
+  turned local (either by -fwhole-program flag, by linker plugin feedback
+  or by other reasons)
+
+- Discovery of local functions:
+
+  A local function is one whose calls can occur only in the current
+  compilation unit and all its calls are explicit, so we can change
+  its calling convention.  We simply mark all static functions whose
+  address is not taken as local.
+
+  externally_visible flag is set for symbols that can not be privatized.
+  For privatized symbols we clear TREE_PUBLIC flag and dismantle comdat
+  group.
+
+- Dismantling of comdat groups:
+
+  Comdat group represent a section that may be replaced by linker by
+  a different copy of the same section from other unit.
+  If we have resolution information (from linker plugin) and we know that
+  a given comdat gorup is prevailing, we can dismantle it and turn symbols
+  into normal symbols.  If the resolution information says that the
+  section was previaled by copy from non-LTO code, we can also dismantle
+  it and turn all symbols into external.
+
+- Local aliases:
+
+  Some symbols can be interposed by dynamic linker. Refering to these
+  symbols is expensive, since it needs to be overwritable by the dynamic
+  linker.  In some cases we know that the interposition does not change
+  semantic and we can always refer to a local copy (as in the case of
+  inline function).  In this case we produce a local alias and redirect
+  calls to it.
+
+  TODO: This should be done for references, too.
+
+- Removal of static ocnstructors and destructors that have no side effects.
+
+- Regularization of several oddities introduced by frontends that may
+  be impractical later in the optimization queue.  */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "tree.h"
+#include "cgraph.h"
+#include "tree-pass.h"
+#include "pointer-set.h"
+#include "calls.h"
+#include "gimple-expr.h"
+
+/* Return true when NODE can not be local. Worker for cgraph_local_node_p.  */
+
+static bool
+cgraph_non_local_node_p_1 (struct cgraph_node *node, void *data 
ATTRIBUTE_UNUSED)
+{
+   /* FIXME: Aliases can be local, but i386 gets thunks wrong then.  */
+   return !(cgraph_only_called_directly_or_aliased_p (node)
+   && !ipa_ref_has_aliases_p (&node->ref_list)
+   && node->definition
+   && !DECL_EXTERNAL (node->decl)

[patch, fortran] PR55117 Programs fails to read namelist (contains derived types objects)

2014-05-24 Thread Jerry DeLisle
Hi folks,

This patch combines Tobias front-end patch with my libgfortran patch to resolve
this PR.

To denote extended derived types (classes) we use a '+' rather than '%' in
certain parts of the namelist name internally to identify that an extended type
is being dealt with.  The runtime is modified to look for this '+' and when it
is seen, scan ahead for the varname match.

For inherited types, a match could be found in two different ways.

parent%cousin%child

parent%child

This would be internally represented as:

parent+cousin%child

So the '+' sign is used to signal that we have to do a special matching check
for both possible cases depending on how the user chose to represent it, usually
as the shorter version of the name.

Admittedly, I do not have very many examples of code that use this feature yet.

Regression tested on x86-64.  Test case attached with patch.

OK for trunk?

Regards,

Jerry

2014-05-24  Tobias Burnus  

PR fortran/55117
* trans-io.c (nml_full_name, transfer_namelist_element): Insert
a '+' rather then '%' to differentiate namelist variable names
that are based on extended derived types.

2014-05-24  Jerry DeLisle  

PR libgfortran/55117
* io/list_read.c (extended_look_ahead): New helper function to
scan the namelist name and look for matches with the new '+'
extended type parent indicator.  (str_comp_extended): New
helper function to compare the namelist name with the varname
namelist. (find_nml_name): Use the new helper functions to match
the extended type varnames.

Index: gcc/fortran/trans-io.c
===
--- gcc/fortran/trans-io.c	(revision 210573)
+++ gcc/fortran/trans-io.c	(working copy)
@@ -1452,10 +1452,10 @@ gfc_trans_wait (gfc_code * code)
 
 
 /* nml_full_name builds up the fully qualified name of a
-   derived type component.  */
+   derived type component. '+' is used to denote a type extension.  */
 
 static char*
-nml_full_name (const char* var_name, const char* cmp_name)
+nml_full_name (const char* var_name, const char* cmp_name, bool parent)
 {
   int full_name_length;
   char * full_name;
@@ -1463,7 +1463,7 @@ static char*
   full_name_length = strlen (var_name) + strlen (cmp_name) + 1;
   full_name = XCNEWVEC (char, full_name_length + 1);
   strcpy (full_name, var_name);
-  full_name = strcat (full_name, "%");
+  full_name = strcat (full_name, parent ? "+" : "%");
   full_name = strcat (full_name, cmp_name);
   return full_name;
 }
@@ -1634,7 +1634,8 @@ transfer_namelist_element (stmtblock_t * block, co
 
   for (cmp = ts->u.derived->components; cmp; cmp = cmp->next)
 	{
-	  char *full_name = nml_full_name (var_name, cmp->name);
+	  char *full_name = nml_full_name (var_name, cmp->name,
+	   ts->u.derived->attr.extension);
 	  transfer_namelist_element (block,
  full_name,
  NULL, cmp, expr);
Index: libgfortran/io/list_read.c
===
--- libgfortran/io/list_read.c	(revision 210898)
+++ libgfortran/io/list_read.c	(working copy)
@@ -2557,6 +2557,38 @@ err_ret:
   return false;
 }
 
+
+static bool
+extended_look_ahead (char *p, char *q)
+{
+  char *r, *s;
+
+  /* Scan ahead to find a '%' in the p string.  */
+  for(r = p, s = q; *r && *s; s++)
+if ((*s == '%' || *s == '+') && strcmp (r + 1, s + 1) == 0)
+  return true;
+  return false;
+}
+
+
+static bool
+strcmp_extended_type (char *p, char *q)
+{
+  char *r, *s;
+  
+  for (r = p, s = q; *r && *s; r++, s++)
+{
+  if (*r != *s)
+	{
+	  if (*r == '%' && *s == '+' && extended_look_ahead (r, s))
+	return true;
+	  break;
+	}
+}
+  return false;
+}
+
+
 static namelist_info *
 find_nml_node (st_parameter_dt *dtp, char * var_name)
 {
@@ -2568,6 +2600,11 @@ find_nml_node (st_parameter_dt *dtp, char * var_na
 	  t->touched = 1;
 	  return t;
 	}
+  if (strcmp_extended_type (var_name, t->var_name))
+	{
+	  t->touched = 1;
+	  return t;
+	}
   t = t->next;
 }
   return NULL;
! { dg-do run }
! PR55117  Programs fails namelist read (contains derived types objects)
program test_type_extension

  type tk_t
 real :: x
  end type tk_t

  type, extends(tk_t) :: tke_t
 character(8) :: string
  end type tke_t

  type, extends(tke_t) :: deep
integer :: int1
real :: y
character(10) :: the_name
  end type deep

  type other
integer :: one_oh
integer :: two_oh
  end type other

  type plain_type
integer :: var1
type(other) :: var2
real :: var3
  end type plain_type

  type some_other
complex :: varx
type(tke_t) :: tke
type (plain_type) :: varpy
real  :: vary
  end type some_other

  type(deep) :: trouble
  type(some_other) :: somethinelse
  type(tke_t) :: tke
  integer :: answer
  
  namelist /test_NML/ trouble, somethinelse, tke, answer

  tke%x = 0.0
  tke%string = ""
  answer = 5
  trouble%x = 5.34
  t

Re: patch to add test for PR61215

2014-05-24 Thread Vladimir Makarov

On 2014-05-23, 11:45 AM, Jakub Jelinek wrote:

On Fri, May 23, 2014 at 11:36:33AM -0400, Vladimir Makarov wrote:

The following patch adds missed test for the PR.

Committed to the trunk as rev. 210838.

2014-05-23  Vladimir Makarov  

 PR rtl-optimization/61215
 * gcc.target/i386/pr61215.c: New.

Index: testsuite/gcc.target/i386/pr61215.c
===
--- testsuite/gcc.target/i386/pr61215.c (revision 0)
+++ testsuite/gcc.target/i386/pr61215.c (working copy)
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target ia32 } */
+/* { dg-options "-O2 -march=i686" } */
+
+void fn1 (int *, ...);
+int fn2 (int p1)
+{
+  fn1 (0, (short)(int)&p1);
+  return 0;
+}


What is i?86 specific on this testcase?
I'd say move it to gcc.dg/, remove effective-target,
/* { dg-options "-O2" } */
/* { dg-additional-options "-march=i686" { target ia32 } } */

and use (__INTPTR_TYPE__) instead of (int) - no change for i?86.



I believe it is still a machine-dependent test.  So many machine 
dependent params should coincide to occur the bug.  RA is not a 
machine-independent optimization as most SSA ones.  No way the bug will 
occur on other target for this test.


Running the test for all target is just wasting machine cycles.  The 
running all GCC tests on some slow targets are a real problem.  Waiting 
the test results might take a day.  So I don't want to make this problem 
worse.




Re: [patch, fortran] PR55117 Programs fails to read namelist (contains derived types objects)

2014-05-24 Thread Jerry DeLisle
I attached the wrong test case.

use the one attached.

On 05/24/2014 07:14 PM, Jerry DeLisle wrote:
> Hi folks,
> 
> This patch combines Tobias front-end patch with my libgfortran patch to 
> resolve
> this PR.
> 
> To denote extended derived types (classes) we use a '+' rather than '%' in
> certain parts of the namelist name internally to identify that an extended 
> type
> is being dealt with.  The runtime is modified to look for this '+' and when it
> is seen, scan ahead for the varname match.
> 
> For inherited types, a match could be found in two different ways.
> 
> parent%cousin%child
> 
> parent%child
> 
> This would be internally represented as:
> 
> parent+cousin%child
> 
> So the '+' sign is used to signal that we have to do a special matching check
> for both possible cases depending on how the user chose to represent it, 
> usually
> as the shorter version of the name.
> 
> Admittedly, I do not have very many examples of code that use this feature 
> yet.
> 
> Regression tested on x86-64.  Test case attached with patch.
> 
> OK for trunk?
> 
> Regards,
> 
> Jerry
> 
> 2014-05-24  Tobias Burnus  
> 
>   PR fortran/55117
>   * trans-io.c (nml_full_name, transfer_namelist_element): Insert
>   a '+' rather then '%' to differentiate namelist variable names
>   that are based on extended derived types.
>   
> 2014-05-24  Jerry DeLisle  
> 
>   PR libgfortran/55117
>   * io/list_read.c (extended_look_ahead): New helper function to
>   scan the namelist name and look for matches with the new '+'
>   extended type parent indicator.  (str_comp_extended): New
>   helper function to compare the namelist name with the varname
>   namelist. (find_nml_name): Use the new helper functions to match
>   the extended type varnames.
> 
! { dg-do run  }
! { dg-options -std=gnu }
! PR55117  Programs fails namelist read (contains derived types objects)
program test_type_extension

  type tk_t
 real :: x
  end type tk_t

  type, extends(tk_t) :: tke_t
 character(8) :: string
  end type tke_t

  type, extends(tke_t) :: deep
integer :: int1
real :: y
character(10) :: the_name
  end type deep

  type other
integer :: one_oh
integer :: two_oh
  end type other

  type plain_type
integer :: var1
type(other) :: var2
real :: var3
  end type plain_type

  type some_other
complex :: varx
type(tke_t) :: tke
type (plain_type) :: varpy
real  :: vary
  end type some_other

  type(deep) :: trouble
  type(some_other) :: somethinelse
  type(tke_t) :: tke
  integer :: answer
  
  namelist /test_NML/ trouble, somethinelse, tke, answer

  tke%x = 0.0
  tke%string = ""
  answer = 5
  trouble%x = 5.34
  trouble%y = 4.25
  trouble%string = ""
  trouble%the_name = "mischief"

  open(10, status="scratch")
  
  write(10,*) "&TEST_NML"
  write(10,*) "TKE%X=  3.14,"
  write(10,*) "TKE%STRING='kf7rcc',"
  write(10,*) "ANSWER=  42,"
  write(10,*) "/"
  rewind(10)
  
  read(10,NML=test_NML)
  if (tke%x - 3.1410 > .1) call abort
  if (tke%string /= "kf7rcc") call abort
  if (answer /= 42) call abort ! hitchkikers guide to the galaxy
end program test_type_extension


ipa-visibility TLC 2/n

2014-05-24 Thread Jan Hubicka
Hi,
this patch adds code to rerite references in vtable initializers to local 
aliases
when doing so is a win.

Bootstrapped/regtested x86_64-linux, comitted.

Honza

* ipa-visibility.c (can_replace_by_local_alias_in_vtable): New function.
(update_vtable_references): New function.
(function_and_variable_visibility): Rewrite also vtable initializers.
* varpool.c (cgraph_variable_initializer_availability): Remove assert.
Index: varpool.c
===
--- varpool.c   (revision 210908)
+++ varpool.c   (working copy)
@@ -355,7 +355,6 @@ varpool_add_new_variable (tree decl)
 enum availability
 cgraph_variable_initializer_availability (varpool_node *node)
 {
-  gcc_assert (cgraph_function_flags_ready);
   if (!node->definition)
 return AVAIL_NOT_AVAILABLE;
   if (!TREE_PUBLIC (node->decl))
Index: ipa-visibility.c
===
--- ipa-visibility.c(revision 210908)
+++ ipa-visibility.c(working copy)
@@ -343,6 +343,36 @@ can_replace_by_local_alias (symtab_node
  && !symtab_can_be_discarded (node));
 }
 
+/* Return true if we can replace refernece to NODE by local alias
+   within a virtual table.  Generally we can replace function pointers
+   and virtual table pointers.  */
+
+bool
+can_replace_by_local_alias_in_vtable (symtab_node *node)
+{
+  if (is_a  (node)
+  && !DECL_VIRTUAL_P (node->decl))
+return false;
+  return can_replace_by_local_alias (node);
+}
+
+/* walk_tree callback that rewrites initializer references.   */
+
+static tree
+update_vtable_references (tree *tp, int *walk_subtrees, void *data 
ATTRIBUTE_UNUSED)
+{
+  if (TREE_CODE (*tp) == VAR_DECL
+  || TREE_CODE (*tp) == FUNCTION_DECL)
+{
+  if (can_replace_by_local_alias_in_vtable (symtab_get_node (*tp)))
+   *tp = symtab_nonoverwritable_alias (symtab_get_node (*tp))->decl;
+  *walk_subtrees = 0;
+}
+  else if (IS_TYPE_OR_DECL_P (*tp))
+*walk_subtrees = 0;
+  return NULL;
+}
+
 /* In LTO we can remove COMDAT groups and weak symbols.
Either turn them into normal symbols or external symbol depending on 
resolution info.  */
@@ -625,6 +655,34 @@ function_and_variable_visibility (bool w
  vnode->resolution = LDPR_PREVAILING_DEF_IRONLY;
}
   update_visibility_by_resolution_info (vnode);
+
+  /* Update virutal tables to point to local aliases where possible.  */
+  if (DECL_VIRTUAL_P (vnode->decl)
+ && !DECL_EXTERNAL (vnode->decl))
+   {
+ int i;
+ struct ipa_ref *ref;
+ bool found = false;
+
+ /* See if there is something to update.  */
+ for (i = 0; ipa_ref_list_referring_iterate (&vnode->ref_list,
+ i, ref); i++)
+   if (ref->use == IPA_REF_ADDR
+   && can_replace_by_local_alias_in_vtable (ref->referred))
+ {
+   found = true;
+   break;
+ }
+ if (found)
+   {
+ struct pointer_set_t *visited_nodes = pointer_set_create ();
+ walk_tree (&DECL_INITIAL (vnode->decl),
+update_vtable_references, NULL, visited_nodes);
+ pointer_set_destroy (visited_nodes);
+ ipa_remove_all_references (&vnode->ref_list);
+ record_references_in_initializer (vnode->decl, false);
+   }
+   }
 }
 
   if (dump_file)