Re: [PATCH] Ubsan and cgraph rebuilding (PR sanitizer/65538)

2015-03-27 Thread Jakub Jelinek
On Fri, Mar 27, 2015 at 12:50:09AM +0100, Marek Polacek wrote:
> 2015-03-26  Marek Polacek  
> 
>   PR sanitizer/65583
>   * ubsan.c (ubsan_create_edge): New function.
>   (instrument_bool_enum_load): Call it.
>   (instrument_nonnull_arg): Likewise.
>   (instrument_nonnull_return): Likewise.
>   (instrument_object_size): Likewise.
> 
>   * g++.dg/ubsan/pr65583.C: New test.

Ok.

> @@ -1834,6 +1853,17 @@ instrument_object_size (gimple_stmt_iterator *gsi, 
> bool is_lhs)
>  integer_zero_node);
>sizet = force_gimple_operand_gsi (gsi, sizet, false, NULL_TREE, true,
>   GSI_SAME_STMT);
> +  /* If the call above didn't end up being an integer constant, go one
> +  statement back and get the __builtin_object_size stmt.  Save it,

Though, perhaps for GCC 6 it would be better to avoid building tree __bos
call and instead just call compute_builtin_object_size and build_int_cstu
if it returns non--1, and otherwise just gimple_build_call.

Jakub


Re: Fix PR 65177: diamonds are not valid execution threads for jump threading

2015-03-27 Thread Richard Biener
On Thu, Mar 26, 2015 at 4:50 PM, Jeff Law  wrote:
> On 03/25/2015 05:09 PM, Sebastian Pop wrote:
>>>
>>> Specifically, it seems to me that copy_bbs should be refactored into
>>> copy_bbs and copy_bbs_for_threading or somesuch.  Where those
>>> routines call into refactored common subroutines, but obviously
>>> handle wiring up the outgoing edges from the copied blocks
>>> differently.
>>>
>>
>> That would be a good cleanup: I don't like to arbitrarily redirect edges
>> in
>> copy_bbs just to redirect them back to their initial place in the caller.
>
> Exactly.
>
>>
>>> The goal would be to eliminate the overly complex block copy/CFG
>>> update scheme in tree-ssa-threadupdate.c as part of a larger project
>>> to convert to a backward threader that can run independently of DOM.
>>
>>
>> I have a start of a patch for that cleanup, it currently runs wild as it
>> would
>> replace the existing threadupdate code generator with a call to the new
>> duplicate_thread_path.  I think we should take smaller more manageable
>> steps to
>> ease the review and to not destabilize the jump-threader.  In particular I
>> think
>> we should have both code generators for a while and turn one on/off with
>> an option.
>
> I hadn't planned on supporting both with an option, I'd rather make the
> switch and not look back :-)   An option just adds maintenance burdens
> (supporting both approaches) and doesn't actually help the end users (though
> it would help us as developers).
>
> Regardless, probably the first step is a common API for the two path
> duplication approaches.

Yeah, and refactoring copy_bbs so that the actual edge duplication happens
in another function (thus we can have two of them).

Note we have way too many copy-XYZ APIs/workers on GIMPLE already.

I was also playing with the idea to support value-numbering the stmts
on-the-fly as we copy them and use this for cost estimation of copies
(ok, well - basically do the copy and then either throw it away again
or accept it).
I thought about applying this to loop unrolling, but obviously this also applies
to any block duplication we do during jump threading.

Richard.

> Jeff


Re: [PATCH] S390: Hotpatching fixes.

2015-03-27 Thread Andreas Krebbel
On 03/26/2015 09:56 PM, Jakub Jelinek wrote:
> Hi!
> 
> On Mon, Mar 09, 2015 at 01:19:38PM +0100, Dominik Vogt wrote:
>> @@ -11368,6 +11349,7 @@ static void
>>  s390_reorg (void)
>>  {
>>bool pool_overflow = false;
>> +  int hw_before, hw_after;
>>  
>>/* Make sure all splits have been performed; splits after
>>   machine_dependent_reorg might confuse insn length counts.  */
>> @@ -11503,6 +11485,40 @@ s390_reorg (void)
>>if (insn_added_p)
>>  shorten_branches (get_insns ());
>>  }
>> +
>> +  s390_function_num_hotpatch_hw (current_function_decl, &hw_before, 
>> &hw_after);
>> +  if (hw_after > 0)
> 
> Two minor issues, both for nested functions:
> 
> 1) the s390_function_num_hotpatch_hw assigns to ints whose addresses are
> passed as arguments, even when it later decides to return false and in this
> spot you ignore the return value.  Which means that hw_after could be
> non-zero, even when you should be ignoring it.
> So, either you should check above the return value too, or
> change s390_function_num_hotpatch_hw so that it stores 0 for the nested
> functions before returning false.
> 2) as s390_function_num_hotpatch_hw is now called twice for the same
> function, for nested functions you'll get the warning reported twice too.
> Perhaps add some additional argument whether you want the warning or not
> and use it in one of the callers and not in the other one?
> Plus supposedly add testsuite coverage for that.

At a second glance it is not really clear to me why we disable hotpatching for 
nested functions at
all. While it is probably a bit difficult to actually hotpatch them I don't see 
why we should
prevent it. We probably just copied that over from the x86 ms_hook_prologue 
attribute implementation:

static bool
ix86_function_ms_hook_prologue (const_tree fn)
{
  if (fn && lookup_attribute ("ms_hook_prologue", DECL_ATTRIBUTES (fn)))
{
  if (decl_function_context (fn) != NULL_TREE)
error_at (DECL_SOURCE_LOCATION (fn),
  "ms_hook_prologue is not compatible with nested function");
  else
return true;
}
  return false;
}

Also the kernel guys (one of the main users of that feature) confirmed that 
they in principle prefer
hotpatching to behave more like -pg and -pg does insert an mcount call for 
nested functions.
(Although I would be surprised to hear of nested functions in the Linux kernel).

So I'm inclined to just remove that special handling of nested functions.

This would also fix 1)

Bye,

-Andreas-



Re: Fix can_inline_edge_p and code marking calls unreachable

2015-03-27 Thread Christophe Lyon
On 27 March 2015 at 03:14, Jan Hubicka  wrote:
>> On 2015.03.27 at 00:46 +0100, Jan Hubicka wrote:
>> > > On 26 March 2015 at 22:12, Jan Hubicka  wrote:
>> > > After this fix, I can see build failures in glibc:
>> > > key_call.c:574:1: internal compiler error: in inline_call, at
>> > > ipa-inline-transform.c:386
>> >
>> > Can you please send me preprocessed testcase? It is probably another 
>> > misaccounting
>> > bug in ipa-inline-analysis.  I may just silence this assert for this stage 
>> > 4.
>>
>> Also happens when building the Linux kernel:
>>
>> trippels@gcc2-power8 linux-3.18.8 % cat nf_sockopt.i
>> int a;
>> int (*b)(), (*c)();
>> int fn1(int p1) {
>>   if (a)
>> return 0;
>>   if (p1) {
>> c();
>> b();
>>   }
>> }
>> void fn2() { fn1(0); }
>
> Great, Markus, having a testcase is important for covering this code path.
> I am attaching a fix, will test it with your testcase and commit.
>
> * ipa-inline-analysis.c (redirect_to_unreachable): Be prepared for
> edge to change by speculation resolution or redirection.
> (edge_set_predicate): Likewise.
> (inline_summary_t::duplicate): Likewise.
> (remap_edge_summaries): Likewise.

This commit (221718) does fix the problems I saw, thanks.

Christophe.

> Index: ipa-inline-analysis.c
> ===
> --- ipa-inline-analysis.c   (revision 221706)
> +++ ipa-inline-analysis.c   (working copy)
> @@ -762,20 +762,20 @@ account_size_time (struct inline_summary
>
>  /* We proved E to be unreachable, redirect it to __bultin_unreachable.  */
>
> -static void
> +static struct cgraph_edge *
>  redirect_to_unreachable (struct cgraph_edge *e)
>  {
>struct cgraph_node *callee = !e->inline_failed ? e->callee : NULL;
> -  struct inline_edge_summary *es = inline_edge_summary (e);
>
>if (e->speculative)
> -e->resolve_speculation (builtin_decl_implicit (BUILT_IN_UNREACHABLE));
> -  if (!e->callee)
> +e = e->resolve_speculation (builtin_decl_implicit 
> (BUILT_IN_UNREACHABLE));
> +  else if (!e->callee)
>  e->make_direct (cgraph_node::get_create
>   (builtin_decl_implicit (BUILT_IN_UNREACHABLE)));
>else
>  e->redirect_callee (cgraph_node::get_create
> (builtin_decl_implicit (BUILT_IN_UNREACHABLE)));
> +  struct inline_edge_summary *es = inline_edge_summary (e);
>e->inline_failed = CIF_UNREACHABLE;
>e->frequency = 0;
>e->count = 0;
> @@ -783,6 +783,7 @@ redirect_to_unreachable (struct cgraph_e
>es->call_stmt_time = 0;
>if (callee)
>  callee->remove_symbol_and_inline_clones ();
> +  return e;
>  }
>
>  /* Set predicate for edge E.  */
> @@ -790,12 +791,12 @@ redirect_to_unreachable (struct cgraph_e
>  static void
>  edge_set_predicate (struct cgraph_edge *e, struct predicate *predicate)
>  {
> -  struct inline_edge_summary *es = inline_edge_summary (e);
> -
>/* If the edge is determined to be never executed, redirect it
>   to BUILTIN_UNREACHABLE to save inliner from inlining into it.  */
>if (predicate && false_predicate_p (predicate))
> -redirect_to_unreachable (e);
> +e = redirect_to_unreachable (e);
> +
> +  struct inline_edge_summary *es = inline_edge_summary (e);
>if (predicate && !true_predicate_p (predicate))
>  {
>if (!es->predicate)
> @@ -1184,7 +1185,7 @@ inline_summary_t::duplicate (cgraph_node
>size_time_entry *e;
>int optimized_out_size = 0;
>bool inlined_to_p = false;
> -  struct cgraph_edge *edge;
> +  struct cgraph_edge *edge, *next;
>
>info->entry = 0;
>known_vals.safe_grow_cleared (count);
> @@ -1229,10 +1230,11 @@ inline_summary_t::duplicate (cgraph_node
>
>/* Remap edge predicates with the same simplification as above.
>   Also copy constantness arrays.   */
> -  for (edge = dst->callees; edge; edge = edge->next_callee)
> +  for (edge = dst->callees; edge; edge = next)
> {
>   struct predicate new_predicate;
>   struct inline_edge_summary *es = inline_edge_summary (edge);
> + next = edge->next_callee;
>
>   if (!edge->inline_failed)
> inlined_to_p = true;
> @@ -1249,10 +1251,11 @@ inline_summary_t::duplicate (cgraph_node
>
>/* Remap indirect edge predicates with the same simplificaiton as 
> above.
>   Also copy constantness arrays.   */
> -  for (edge = dst->indirect_calls; edge; edge = edge->next_callee)
> +  for (edge = dst->indirect_calls; edge; edge = next)
> {
>   struct predicate new_predicate;
>   struct inline_edge_summary *es = inline_edge_summary (edge);
> + next = edge->next_callee;
>
>   gcc_checking_assert (edge->inline_failed);
>   if (!es->predicate)
> @@ -3484,11 +3487,12 @@ remap_edge_summaries (struct cgraph_edge
>   clause_t possible_truths,
>   struct predicate *t

Re: [PATCH] S390: Hotpatching fixes.

2015-03-27 Thread Jakub Jelinek
On Fri, Mar 27, 2015 at 10:30:38AM +0100, Andreas Krebbel wrote:
> At a second glance it is not really clear to me why we disable hotpatching 
> for nested functions at
> all. While it is probably a bit difficult to actually hotpatch them I don't 
> see why we should
> prevent it. We probably just copied that over from the x86 ms_hook_prologue 
> attribute implementation:
> 
> static bool
> ix86_function_ms_hook_prologue (const_tree fn)
> {
>   if (fn && lookup_attribute ("ms_hook_prologue", DECL_ATTRIBUTES (fn)))
> {
>   if (decl_function_context (fn) != NULL_TREE)
>   error_at (DECL_SOURCE_LOCATION (fn),
> "ms_hook_prologue is not compatible with nested function");
>   else
> return true;
> }
>   return false;
> }
> 
> Also the kernel guys (one of the main users of that feature) confirmed that 
> they in principle prefer
> hotpatching to behave more like -pg and -pg does insert an mcount call for 
> nested functions.
> (Although I would be surprised to hear of nested functions in the Linux 
> kernel).
> 
> So I'm inclined to just remove that special handling of nested functions.

Agreed, I also wondered what would be so special about nested functions
here.
Sure, one could hotpatch them with code clobbering the static chain
register, but that wouldn't be a gcc issue.

Jakub


[PATCH, PR target/65495] List available languages for all chkp options

2015-03-27 Thread Ilya Enkovich
Hi,

This patch avoids various ICEs due to -fcheck-pointer-bounds used for not 
supported languages.  All options get the same languages list.  Bootstrapped 
and tested on x86_64-unknown-linux-gnu.  Does it look OK?

Thanks,
Ilya
--
2015-03-27  Ilya Enkovich  

PR target/65495
* c-family/c.opt (fcheck-pointer-bounds): List supported languages.
(fchkp-check-incomplete-type): Add LTO.
(fchkp-zero-input-bounds-for-main): Likewise.
(fchkp-first-field-has-own-bounds): Likewise.
(fchkp-narrow-bounds): Likewise.
(fchkp-narrow-to-innermost-array): Likewise.
(fchkp-use-static-bounds): Likewise.
(fchkp-use-static-const-bounds): Likewise.
(fchkp-treat-zero-dynamic-size-as-infinite): Likewise.


diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 2692fb5..983f4a8 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -964,32 +964,32 @@ C ObjC C++ ObjC++
 Where shorter, use canonicalized paths to systems headers.
 
 fcheck-pointer-bounds
-Common Report Var(flag_check_pointer_bounds)
+C ObjC C++ ObjC++ LTO Report Var(flag_check_pointer_bounds)
 Add Pointer Bounds Checker instrumentation.  fchkp-* flags are used to
 control instrumentation.  Currently available for C, C++ and ObjC.
 
 fchkp-check-incomplete-type
-C ObjC C++ ObjC++ Report Var(flag_chkp_incomplete_type) Init(1)
+C ObjC C++ ObjC++ LTO Report Var(flag_chkp_incomplete_type) Init(1)
 Generate pointer bounds checks for variables with incomplete type
 
 fchkp-zero-input-bounds-for-main
-C ObjC C++ ObjC++ Report Var(flag_chkp_zero_input_bounds_for_main) Init(0)
+C ObjC C++ ObjC++ LTO Report Var(flag_chkp_zero_input_bounds_for_main) Init(0)
 Use zero bounds for all incoming arguments in 'main' function.  It helps when
 instrumented binaries are used with legacy libs.
 
 fchkp-first-field-has-own-bounds
-C ObjC C++ ObjC++ RejectNegative Report 
Var(flag_chkp_first_field_has_own_bounds)
+C ObjC C++ ObjC++ LTO RejectNegative Report 
Var(flag_chkp_first_field_has_own_bounds)
 Forces Pointer Bounds Checker to use narrowed bounds for address of the first
 field in the structure.  By default pointer to the first field has the same
 bounds as pointer to the whole structure.
 
 fchkp-narrow-bounds
-C ObjC C++ ObjC++ Report Var(flag_chkp_narrow_bounds) Init(1)
+C ObjC C++ ObjC++ LTO Report Var(flag_chkp_narrow_bounds) Init(1)
 Control how Pointer Bounds Checker handle pointers to object fields.  When
 narrowing is on, field bounds are used.  Otherwise full object bounds are used.
 
 fchkp-narrow-to-innermost-array
-C ObjC C++ ObjC++ RejectNegative Report 
Var(flag_chkp_narrow_to_innermost_arrray)
+C ObjC C++ ObjC++ LTO RejectNegative Report 
Var(flag_chkp_narrow_to_innermost_arrray)
 Forces Pointer Bounds Checker to use bounds of the innermost arrays in case of
 nested static arryas access.  By default outermost array is used.
 
@@ -1007,17 +1007,17 @@ C ObjC C++ ObjC++ LTO Report 
Var(flag_chkp_use_nochk_string_functions) Init(0)
 Allow to use *_nochk versions of string functions by Pointer Bounds Checker.
 
 fchkp-use-static-bounds
-C ObjC C++ ObjC++ Report Var(flag_chkp_use_static_bounds) Init(1)
+C ObjC C++ ObjC++ LTO Report Var(flag_chkp_use_static_bounds) Init(1)
 Use statically initialized variable for vars bounds instead of
 generating them each time it is required.
 
 fchkp-use-static-const-bounds
-C ObjC C++ ObjC++ Report Var(flag_chkp_use_static_const_bounds) Init(-1)
+C ObjC C++ ObjC++ LTO Report Var(flag_chkp_use_static_const_bounds) Init(-1)
 Use statically initialized variable for constant bounds instead of
 generating them each time it is required.
 
 fchkp-treat-zero-dynamic-size-as-infinite
-C ObjC C++ ObjC++ Report Var(flag_chkp_zero_dynamic_size_as_infinite) Init(0)
+C ObjC C++ ObjC++ LTO Report Var(flag_chkp_zero_dynamic_size_as_infinite) 
Init(0)
 With this option zero size obtained dynamically for objects with
 incomplete type will be treated as infinite.
 


[PATCH] Fix typo in a comment

2015-03-27 Thread Marek Polacek
Ok?

2015-03-27  Marek Polacek  

* gimple-iterator.h (gsi_prev_nondebug): Fix typo.

diff --git gcc/gimple-iterator.h gcc/gimple-iterator.h
index 6be88dd..9aa7508 100644
--- gcc/gimple-iterator.h
+++ gcc/gimple-iterator.h
@@ -250,7 +250,7 @@ gsi_next_nondebug (gimple_stmt_iterator *i)
   while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
 }
 
-/* Advance the iterator to the next non-debug gimple statement.  */
+/* Advance the iterator to the previous non-debug gimple statement.  */
 
 static inline void
 gsi_prev_nondebug (gimple_stmt_iterator *i)

Marek


Re: [PATCH] Fix typo in a comment

2015-03-27 Thread Jakub Jelinek
On Fri, Mar 27, 2015 at 10:55:48AM +0100, Marek Polacek wrote:
> Ok?

Sure, it is obvious.

> 2015-03-27  Marek Polacek  
> 
>   * gimple-iterator.h (gsi_prev_nondebug): Fix typo.
> 
> diff --git gcc/gimple-iterator.h gcc/gimple-iterator.h
> index 6be88dd..9aa7508 100644
> --- gcc/gimple-iterator.h
> +++ gcc/gimple-iterator.h
> @@ -250,7 +250,7 @@ gsi_next_nondebug (gimple_stmt_iterator *i)
>while (!gsi_end_p (*i) && is_gimple_debug (gsi_stmt (*i)));
>  }
>  
> -/* Advance the iterator to the next non-debug gimple statement.  */
> +/* Advance the iterator to the previous non-debug gimple statement.  */
>  
>  static inline void
>  gsi_prev_nondebug (gimple_stmt_iterator *i)
> 
>   Marek

Jakub


PR c/65586: Skipping omp pragmas with -fopenmp-simd

2015-03-27 Thread Tobias Burnus
For -fopenmp-simd, GCC did not properly jump passed the clauses of
ignored directives. It worked, for "for simd" directives and for
those without clauses.

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

Tobias
2015-03-28  Tobias Burnus  

	PR c/65586
gcc/c/
	* c-parser.c (c_parser_skip_to_pragma_eol): Optionally, don't
	error out.
	(c_parser_omp_for, c_parser_omp_parallel, c_parser_omp_distribute,
	c_parser_omp_teams, c_parser_omp_target, c_parser_omp_declare):
	Update calls to not error for skipped omp pragmas with -fopenmp-simd.

gcc/cp/
	* parser.c (cp_parser_omp_for, cp_parser_omp_parallel,
	cp_parser_omp_distribute, cp_parser_omp_teams, cp_parser_omp_target,
	cp_parser_omp_declare): Don't show error for skipped omp pragmas with
	-fopenmp-simd.

gcc/testsuite/
	* g++.dg/gomp/openmp-simd-3.C: New.
	* gcc.dg/gomp/openmp-simd-3.c: New.

diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 5cc3892..18faa6e 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -991,24 +991,26 @@ c_parser_skip_to_end_of_parameter (c_parser *parser)
end of line marker.  */
 
 static void
-c_parser_skip_to_pragma_eol (c_parser *parser)
+c_parser_skip_to_pragma_eol (c_parser *parser, bool error_if_not_eol = true)
 {
   gcc_assert (parser->in_pragma);
   parser->in_pragma = false;
 
-  if (!c_parser_require (parser, CPP_PRAGMA_EOL, "expected end of line"))
-while (true)
-  {
-	c_token *token = c_parser_peek_token (parser);
-	if (token->type == CPP_EOF)
+  if (error_if_not_eol && c_parser_peek_token (parser)->type != CPP_PRAGMA_EOL)
+c_parser_error (parser, "expected end of line");
+
+  while (true)
+{
+  c_token *token = c_parser_peek_token (parser);
+  if (token->type == CPP_EOF)
+	break;
+  if (token->type == CPP_PRAGMA_EOL)
+	{
+	  c_parser_consume_token (parser);
 	  break;
-	if (token->type == CPP_PRAGMA_EOL)
-	  {
-	c_parser_consume_token (parser);
-	break;
-	  }
-	c_parser_consume_token (parser);
-  }
+	}
+  c_parser_consume_token (parser);
+}
 
   parser->error = false;
 }
@@ -13223,7 +13225,7 @@ c_parser_omp_for (location_t loc, c_parser *parser,
 }
   if (!flag_openmp)  /* flag_openmp_simd  */
 {
-  c_parser_skip_to_pragma_eol (parser);
+  c_parser_skip_to_pragma_eol (parser, false);
   return NULL_TREE;
 }
 
@@ -13448,7 +13450,7 @@ c_parser_omp_parallel (location_t loc, c_parser *parser,
 }
   else if (!flag_openmp)  /* flag_openmp_simd  */
 {
-  c_parser_skip_to_pragma_eol (parser);
+  c_parser_skip_to_pragma_eol (parser, false);
   return NULL_TREE;
 }
   else if (c_parser_next_token_is (parser, CPP_NAME))
@@ -13708,7 +13710,7 @@ c_parser_omp_distribute (location_t loc, c_parser *parser,
 }
   if (!flag_openmp)  /* flag_openmp_simd  */
 {
-  c_parser_skip_to_pragma_eol (parser);
+  c_parser_skip_to_pragma_eol (parser, false);
   return NULL_TREE;
 }
 
@@ -13776,7 +13778,7 @@ c_parser_omp_teams (location_t loc, c_parser *parser,
 }
   if (!flag_openmp)  /* flag_openmp_simd  */
 {
-  c_parser_skip_to_pragma_eol (parser);
+  c_parser_skip_to_pragma_eol (parser, false);
   return NULL_TREE;
 }
 
@@ -13921,7 +13923,7 @@ c_parser_omp_target (c_parser *parser, enum pragma_context context)
 	}
   else if (!flag_openmp)  /* flag_openmp_simd  */
 	{
-	  c_parser_skip_to_pragma_eol (parser);
+	  c_parser_skip_to_pragma_eol (parser, false);
 	  return false;
 	}
   else if (strcmp (p, "data") == 0)
@@ -14604,7 +14606,7 @@ c_parser_omp_declare (c_parser *parser, enum pragma_context context)
 	}
   if (!flag_openmp)  /* flag_openmp_simd  */
 	{
-	  c_parser_skip_to_pragma_eol (parser);
+	  c_parser_skip_to_pragma_eol (parser, false);
 	  return;
 	}
   if (strcmp (p, "target") == 0)
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index a18f38c..4d6b479 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -30768,7 +30768,7 @@ cp_parser_omp_for (cp_parser *parser, cp_token *pragma_tok,
 }
   if (!flag_openmp)  /* flag_openmp_simd  */
 {
-  cp_parser_require_pragma_eol (parser, pragma_tok);
+  cp_parser_skip_to_pragma_eol (parser, pragma_tok);
   return NULL_TREE;
 }
 
@@ -30979,7 +30979,7 @@ cp_parser_omp_parallel (cp_parser *parser, cp_token *pragma_tok,
 }
   else if (!flag_openmp)  /* flag_openmp_simd  */
 {
-  cp_parser_require_pragma_eol (parser, pragma_tok);
+  cp_parser_skip_to_pragma_eol (parser, pragma_tok);
   return NULL_TREE;
 }
   else if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
@@ -31242,7 +31242,7 @@ cp_parser_omp_distribute (cp_parser *parser, cp_token *pragma_tok,
 }
   if (!flag_openmp)  /* flag_openmp_simd  */
 {
-  cp_parser_require_pragma_eol (parser, pragma_tok);
+  cp_parser_skip_to_pragma_eol (parser, pragma_tok);
   return NULL_TREE;
 }
 
@@ -31321,7 +31321,7 @@ cp_parser_omp_teams (cp_parser *parser, cp_token *pragma_tok,
 }
   if (!flag

Re: [PATCH][expr.c] PR 65358 Avoid clobbering partial argument during sibcall

2015-03-27 Thread Kyrill Tkachov

Ping.
https://gcc.gnu.org/ml/gcc-patches/2015-03/msg01014.html
Thanks,
Kyrill

On 19/03/15 14:39, Kyrill Tkachov wrote:

Hi all,

This patch fixes PR 65358. For details look at the excellent write-up
by Honggyu in bugzilla. The problem is that we're trying to pass a struct
partially on the stack and partially in regs during a tail-call optimisation
but the struct we're passing is also a partial incoming arg though the split
between stack and regs is different from its outgoing usage.

The emit_push_insn code ends up doing a block move for the on-stack part but
ends up overwriting the part that needs to be loaded into regs.
My first thought was to just load the regs part first and then do the stack
part but that doesn't work as multiple comments in that function indicate
(the block move being expanded to movmem or other functions being one of the
reasons).

My proposed solution is to detect when the overlap happens, find the
overlapping region and load it before the stack pushing into pseudos and
after the stack pushing is done move the overlapping values from the pseudos
into the hard argument regs that they're supposed to go.

That way this new functionality should only ever be triggered when there's
the overlap in this PR (causing wrong-code) and shouldn't affect codegen
anywhere else.

Bootstrapped and tested on arm-none-linux-gnueabihf, aarch64-none-linux-gnu
and x86_64-linux-gnu.

According to the PR this appears at least as far back 4.6 so this isn't a
regression on the release branches, but it is a wrong-code bug.

I'll let Honggyu upstream the testcase separately
(https://gcc.gnu.org/ml/gcc-patches/2015-03/msg00984.html)
After guidance from Jeff, I'll take this testcase in as well if this is 
approved.




I'll be testing this on the 4.8 and 4.9 branches.
Thoughts on this approach?

Thanks,
Kyrill

2015-03-19  Kyrylo Tkachov  

  PR middle-end/65358
  * expr.c (memory_load_overlap): New function.
  (emit_push_insn): When pushing partial args to the stack would
  clobber the register part load the overlapping part into a pseudo
  and put it into the hard reg after pushing.




Re: PR c/65586: Skipping omp pragmas with -fopenmp-simd

2015-03-27 Thread Jakub Jelinek
On Fri, Mar 27, 2015 at 10:58:14AM +0100, Tobias Burnus wrote:
> For -fopenmp-simd, GCC did not properly jump passed the clauses of
> ignored directives. It worked, for "for simd" directives and for
> those without clauses.
> 
> Bootstrapped and regtested on x86-64-gnu-linux.
> OK for the trunk?
> 
> Tobias

> +  while (true)
> +{
> +  c_token *token = c_parser_peek_token (parser);
> +  if (token->type == CPP_EOF)
> + break;
> +  if (token->type == CPP_PRAGMA_EOL)
> + {
> +   c_parser_consume_token (parser);
> break;
> - if (token->type == CPP_PRAGMA_EOL)
> -   {
> - c_parser_consume_token (parser);
> - break;
> -   }
> - c_parser_consume_token (parser);
> -  }
> + }
> +  c_parser_consume_token (parser);
> +}

Can't you use

  cpp_ttype token_type;
  do
{
  c_token *token = c_parser_peek_token (parser);
  token_type = token->type;
  if (token_type == CPP_EOF)
break;
  c_parser_consume_token (parser);
}
  while (token_type != CPP_PRAGMA_EOL);

instead?

Ok either way.

Jakub


Re: [PATCH, ARM, PR64208] LRA ICE Fix

2015-03-27 Thread Yvan Roux
Hi Xingxing,

do you know if it is possible to test this patch inside Marvell (as it
is a fix for iWMMXT arch.) ?

Thanks a lot
Yvan

On 23 March 2015 at 18:47, Yvan Roux  wrote:
> Hi,
>
> On 23 March 2015 at 17:08, Ramana Radhakrishnan
>  wrote:
>> On Wed, Mar 18, 2015 at 10:19 AM, Yvan Roux  wrote:
>>> Hi,
>>>
>>> This is a fix for PR64208 where LRA loops when dealing with
>>> iwmmxt_arm_movdi insn.  As explain in the PR, the issue was introduced
>>> on trunk and 4.9 branch by fix of PR rtl-optimization/60969 and then
>>> workaround by r211798 (-fuse-caller-save enable for ARM).
>>>
>>> The changes in IRA cost made by PR60969, changed the register class of
>>> this insn output from GENERAL_REGS to IWMMXT_REGS, and the
>>> redundancies in the insn pattern alternatives description force LRA to
>>> reload the pseudo, which generates the same iwmmxt_arm_movdi insn,
>>> which can't be resolved, and so on ...
>>>
>>> Removing the redundancies fixes the issue, as LRA find that
>>> alternative 8 (Uy => y) matches.
>>>
>>> This issue is present in 4.9 branch, but latent on trunk (the
>>> clobbering of IP and CC information added during -fuse-caller-save
>>> patch changed the register allocation).
>>>
>>> Cross compiled and regression tested on ARM targets (but not on an
>>> IWMMXT one), is it ok for trunk and 4.9 branch ?
>>
>>
>> This looks sane. It doesn't look reasonable for alternatives to be
>> duplicating each other.
>>
>> Given I have neither the time nor the hardware to test this patch on,
>> I'd rather someone with an interest in iwMMX possibly folks from
>> Marvell can pick up testing for this patch.
>
> Ok, Thanks Ramana, I'll wait for somebody able to test it. Notice,
> that without this patch on the 4.9 branch, building a cross compiler
> which default to iWMMXT architectures ICE on that during LRA while
> building of libgcc.
>
> Cheers,
> Yvan
>
>> regards
>> Ramana
>>
>>>
>>> Rq: I think that adding IP and CC clobbers to
>>> CALL_INSN_FUNCTION_USAGE, as specified by AAPCS, in 4.9 branch is
>>> something we need too, I've a patch for that if you agree on that.
>>>
>>> Thanks,
>>> Yvan
>>>
>>> 2105-03-17  Yvan Roux  
>>>
>>> PR target/64208
>>> * config/arm/iwmmxt.md ("*iwmmxt_arm_movdi"): Cleanup redundant
>>> alternatives.


Re: [PATCH, PR target/65495] List available languages for all chkp options

2015-03-27 Thread Richard Biener
On Fri, Mar 27, 2015 at 10:44 AM, Ilya Enkovich  wrote:
> Hi,
>
> This patch avoids various ICEs due to -fcheck-pointer-bounds used for not 
> supported languages.  All options get the same languages list.  Bootstrapped 
> and tested on x86_64-unknown-linux-gnu.  Does it look OK?

Ok, but do we really need all the -fchkp- options in LTO?  Are they
not only used by
instrumentation which happens before LTO?

Richard.

> Thanks,
> Ilya
> --
> 2015-03-27  Ilya Enkovich  
>
> PR target/65495
> * c-family/c.opt (fcheck-pointer-bounds): List supported languages.
> (fchkp-check-incomplete-type): Add LTO.
> (fchkp-zero-input-bounds-for-main): Likewise.
> (fchkp-first-field-has-own-bounds): Likewise.
> (fchkp-narrow-bounds): Likewise.
> (fchkp-narrow-to-innermost-array): Likewise.
> (fchkp-use-static-bounds): Likewise.
> (fchkp-use-static-const-bounds): Likewise.
> (fchkp-treat-zero-dynamic-size-as-infinite): Likewise.
>
>
> diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
> index 2692fb5..983f4a8 100644
> --- a/gcc/c-family/c.opt
> +++ b/gcc/c-family/c.opt
> @@ -964,32 +964,32 @@ C ObjC C++ ObjC++
>  Where shorter, use canonicalized paths to systems headers.
>
>  fcheck-pointer-bounds
> -Common Report Var(flag_check_pointer_bounds)
> +C ObjC C++ ObjC++ LTO Report Var(flag_check_pointer_bounds)
>  Add Pointer Bounds Checker instrumentation.  fchkp-* flags are used to
>  control instrumentation.  Currently available for C, C++ and ObjC.
>
>  fchkp-check-incomplete-type
> -C ObjC C++ ObjC++ Report Var(flag_chkp_incomplete_type) Init(1)
> +C ObjC C++ ObjC++ LTO Report Var(flag_chkp_incomplete_type) Init(1)
>  Generate pointer bounds checks for variables with incomplete type
>
>  fchkp-zero-input-bounds-for-main
> -C ObjC C++ ObjC++ Report Var(flag_chkp_zero_input_bounds_for_main) Init(0)
> +C ObjC C++ ObjC++ LTO Report Var(flag_chkp_zero_input_bounds_for_main) 
> Init(0)
>  Use zero bounds for all incoming arguments in 'main' function.  It helps when
>  instrumented binaries are used with legacy libs.
>
>  fchkp-first-field-has-own-bounds
> -C ObjC C++ ObjC++ RejectNegative Report 
> Var(flag_chkp_first_field_has_own_bounds)
> +C ObjC C++ ObjC++ LTO RejectNegative Report 
> Var(flag_chkp_first_field_has_own_bounds)
>  Forces Pointer Bounds Checker to use narrowed bounds for address of the first
>  field in the structure.  By default pointer to the first field has the same
>  bounds as pointer to the whole structure.
>
>  fchkp-narrow-bounds
> -C ObjC C++ ObjC++ Report Var(flag_chkp_narrow_bounds) Init(1)
> +C ObjC C++ ObjC++ LTO Report Var(flag_chkp_narrow_bounds) Init(1)
>  Control how Pointer Bounds Checker handle pointers to object fields.  When
>  narrowing is on, field bounds are used.  Otherwise full object bounds are 
> used.
>
>  fchkp-narrow-to-innermost-array
> -C ObjC C++ ObjC++ RejectNegative Report 
> Var(flag_chkp_narrow_to_innermost_arrray)
> +C ObjC C++ ObjC++ LTO RejectNegative Report 
> Var(flag_chkp_narrow_to_innermost_arrray)
>  Forces Pointer Bounds Checker to use bounds of the innermost arrays in case 
> of
>  nested static arryas access.  By default outermost array is used.
>
> @@ -1007,17 +1007,17 @@ C ObjC C++ ObjC++ LTO Report 
> Var(flag_chkp_use_nochk_string_functions) Init(0)
>  Allow to use *_nochk versions of string functions by Pointer Bounds Checker.
>
>  fchkp-use-static-bounds
> -C ObjC C++ ObjC++ Report Var(flag_chkp_use_static_bounds) Init(1)
> +C ObjC C++ ObjC++ LTO Report Var(flag_chkp_use_static_bounds) Init(1)
>  Use statically initialized variable for vars bounds instead of
>  generating them each time it is required.
>
>  fchkp-use-static-const-bounds
> -C ObjC C++ ObjC++ Report Var(flag_chkp_use_static_const_bounds) Init(-1)
> +C ObjC C++ ObjC++ LTO Report Var(flag_chkp_use_static_const_bounds) Init(-1)
>  Use statically initialized variable for constant bounds instead of
>  generating them each time it is required.
>
>  fchkp-treat-zero-dynamic-size-as-infinite
> -C ObjC C++ ObjC++ Report Var(flag_chkp_zero_dynamic_size_as_infinite) Init(0)
> +C ObjC C++ ObjC++ LTO Report Var(flag_chkp_zero_dynamic_size_as_infinite) 
> Init(0)
>  With this option zero size obtained dynamically for objects with
>  incomplete type will be treated as infinite.
>


[PATCH] fix building for alpha-dec-vms

2015-03-27 Thread tbsaunde+gcc
From: Trevor Saunders 

Hi,

Unfortunately when testing r217869 I didn't realize the modified code in
alpha.c was only used for some alpha targets.  So testing alpha-linux wasn't
enough or even really useful :(

I tested cc1 for alpha-dec-vms now builds as discussed before make all-gcc is
still broken because the vms targets don't support c++ and don't say it
shouldn't be built in config.gcc.  Is this ok?

Trev


diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 37258ad..fac42d6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2015-03-27  Trevor Saunders  
+
+   * config/alpha/alpha.c (alpha_use_linkage): Change type of slot to
+   alpha_links **.
+   (alpha_write_one_linkage): Correct typo.
+
 2015-03-27  Marek Polacek  
 
PR sanitizer/65583
diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c
index 554ff09..67c15dc 100644
--- a/gcc/config/alpha/alpha.c
+++ b/gcc/config/alpha/alpha.c
@@ -9665,7 +9665,7 @@ alpha_use_linkage (rtx func, bool lflag, bool rflag)
   if (cfun->machine->links)
 {
   /* Is this name already defined?  */
-  alpha_links *slot = cfun->machine->links->get (name);
+  alpha_links **slot = cfun->machine->links->get (name);
   if (slot)
al = *slot;
 }
@@ -9711,7 +9711,7 @@ alpha_use_linkage (rtx func, bool lflag, bool rflag)
 }
 
 static int
-alpha_write_one_linkage (const char *name, alpha_links *link, FILE *steam)
+alpha_write_one_linkage (const char *name, alpha_links *link, FILE *stream)
 {
   ASM_OUTPUT_INTERNAL_LABEL (stream, XSTR (link->linkage, 0));
   if (link->rkind == KIND_CODEADDR)
-- 
2.1.4



Re: [PATCH, PR target/65495] List available languages for all chkp options

2015-03-27 Thread Ilya Enkovich
2015-03-27 13:13 GMT+03:00 Richard Biener :
> On Fri, Mar 27, 2015 at 10:44 AM, Ilya Enkovich  
> wrote:
>> Hi,
>>
>> This patch avoids various ICEs due to -fcheck-pointer-bounds used for not 
>> supported languages.  All options get the same languages list.  Bootstrapped 
>> and tested on x86_64-unknown-linux-gnu.  Does it look OK?
>
> Ok, but do we really need all the -fchkp- options in LTO?  Are they
> not only used by
> instrumentation which happens before LTO?

There are several things which happen later: constructors generation
and instrumentation, chkp optimizations.

Ilya

>
> Richard.
>
>> Thanks,
>> Ilya
>> --
>> 2015-03-27  Ilya Enkovich  
>>
>> PR target/65495
>> * c-family/c.opt (fcheck-pointer-bounds): List supported languages.
>> (fchkp-check-incomplete-type): Add LTO.
>> (fchkp-zero-input-bounds-for-main): Likewise.
>> (fchkp-first-field-has-own-bounds): Likewise.
>> (fchkp-narrow-bounds): Likewise.
>> (fchkp-narrow-to-innermost-array): Likewise.
>> (fchkp-use-static-bounds): Likewise.
>> (fchkp-use-static-const-bounds): Likewise.
>> (fchkp-treat-zero-dynamic-size-as-infinite): Likewise.
>>
>>
>> diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
>> index 2692fb5..983f4a8 100644
>> --- a/gcc/c-family/c.opt
>> +++ b/gcc/c-family/c.opt
>> @@ -964,32 +964,32 @@ C ObjC C++ ObjC++
>>  Where shorter, use canonicalized paths to systems headers.
>>
>>  fcheck-pointer-bounds
>> -Common Report Var(flag_check_pointer_bounds)
>> +C ObjC C++ ObjC++ LTO Report Var(flag_check_pointer_bounds)
>>  Add Pointer Bounds Checker instrumentation.  fchkp-* flags are used to
>>  control instrumentation.  Currently available for C, C++ and ObjC.
>>
>>  fchkp-check-incomplete-type
>> -C ObjC C++ ObjC++ Report Var(flag_chkp_incomplete_type) Init(1)
>> +C ObjC C++ ObjC++ LTO Report Var(flag_chkp_incomplete_type) Init(1)
>>  Generate pointer bounds checks for variables with incomplete type
>>
>>  fchkp-zero-input-bounds-for-main
>> -C ObjC C++ ObjC++ Report Var(flag_chkp_zero_input_bounds_for_main) Init(0)
>> +C ObjC C++ ObjC++ LTO Report Var(flag_chkp_zero_input_bounds_for_main) 
>> Init(0)
>>  Use zero bounds for all incoming arguments in 'main' function.  It helps 
>> when
>>  instrumented binaries are used with legacy libs.
>>
>>  fchkp-first-field-has-own-bounds
>> -C ObjC C++ ObjC++ RejectNegative Report 
>> Var(flag_chkp_first_field_has_own_bounds)
>> +C ObjC C++ ObjC++ LTO RejectNegative Report 
>> Var(flag_chkp_first_field_has_own_bounds)
>>  Forces Pointer Bounds Checker to use narrowed bounds for address of the 
>> first
>>  field in the structure.  By default pointer to the first field has the same
>>  bounds as pointer to the whole structure.
>>
>>  fchkp-narrow-bounds
>> -C ObjC C++ ObjC++ Report Var(flag_chkp_narrow_bounds) Init(1)
>> +C ObjC C++ ObjC++ LTO Report Var(flag_chkp_narrow_bounds) Init(1)
>>  Control how Pointer Bounds Checker handle pointers to object fields.  When
>>  narrowing is on, field bounds are used.  Otherwise full object bounds are 
>> used.
>>
>>  fchkp-narrow-to-innermost-array
>> -C ObjC C++ ObjC++ RejectNegative Report 
>> Var(flag_chkp_narrow_to_innermost_arrray)
>> +C ObjC C++ ObjC++ LTO RejectNegative Report 
>> Var(flag_chkp_narrow_to_innermost_arrray)
>>  Forces Pointer Bounds Checker to use bounds of the innermost arrays in case 
>> of
>>  nested static arryas access.  By default outermost array is used.
>>
>> @@ -1007,17 +1007,17 @@ C ObjC C++ ObjC++ LTO Report 
>> Var(flag_chkp_use_nochk_string_functions) Init(0)
>>  Allow to use *_nochk versions of string functions by Pointer Bounds Checker.
>>
>>  fchkp-use-static-bounds
>> -C ObjC C++ ObjC++ Report Var(flag_chkp_use_static_bounds) Init(1)
>> +C ObjC C++ ObjC++ LTO Report Var(flag_chkp_use_static_bounds) Init(1)
>>  Use statically initialized variable for vars bounds instead of
>>  generating them each time it is required.
>>
>>  fchkp-use-static-const-bounds
>> -C ObjC C++ ObjC++ Report Var(flag_chkp_use_static_const_bounds) Init(-1)
>> +C ObjC C++ ObjC++ LTO Report Var(flag_chkp_use_static_const_bounds) Init(-1)
>>  Use statically initialized variable for constant bounds instead of
>>  generating them each time it is required.
>>
>>  fchkp-treat-zero-dynamic-size-as-infinite
>> -C ObjC C++ ObjC++ Report Var(flag_chkp_zero_dynamic_size_as_infinite) 
>> Init(0)
>> +C ObjC C++ ObjC++ LTO Report Var(flag_chkp_zero_dynamic_size_as_infinite) 
>> Init(0)
>>  With this option zero size obtained dynamically for objects with
>>  incomplete type will be treated as infinite.
>>


Fix ICE in is_a invocation from cgraph_update_edges_for_call_stmt_node

2015-03-27 Thread Jan Hubicka
Hi,
this patch fixes ICE in is_a test when cgraph_update_edges_for_call_stmt_node
tries to convert non-call stmt to call.  I have bootstrapped/regtested
x86_64-linux and tested firefox/chromium LTO build, so hope it is the last
issue surfacing from the today verifier change.

PR middle-end/65595
* cgraph.c (cgraph_update_edges_for_call_stmt_node): Only
do redirection if the call is not optimized out.

* gcc.c-torture/compile/pr65595.c: New testcase.
Index: cgraph.c
===
--- cgraph.c(revision 221707)
+++ cgraph.c(working copy)
@@ -1516,7 +1516,7 @@ cgraph_update_edges_for_call_stmt_node (
   if (e)
{
  /* Keep calls marked as dead dead.  */
- if (e->callee
+ if (new_call && e->callee
  && DECL_BUILT_IN_CLASS (e->callee->decl) == BUILT_IN_NORMAL
  && DECL_FUNCTION_CODE (e->callee->decl) == BUILT_IN_UNREACHABLE)
{
Index: testsuite/gcc.c-torture/compile/pr65595.c
===
--- testsuite/gcc.c-torture/compile/pr65595.c   (revision 0)
+++ testsuite/gcc.c-torture/compile/pr65595.c   (revision 0)
@@ -0,0 +1,19 @@
+extern void *memcpy(void *, const void *, unsigned long);
+struct in6_addr {
+  struct {
+int u6_addr32[4];
+  };
+};
+struct foo {
+  struct in6_addr daddr;
+  struct in6_addr saddr;
+} a;
+extern void ip6_route_output(struct foo, int);
+int b;
+static void find_route_ipv6(struct in6_addr *p1) {
+  if (p1)
+memcpy(0, p1, sizeof(struct in6_addr));
+  ip6_route_output(a, b);
+}
+void cxgbi_ep_connect() { find_route_ipv6(0); }
+


[PATCH 4.8][AArch64] Backport r207785 from trunk: Fix PCH on AArch64, (PR pch/60010)

2015-03-27 Thread Alan Lawrence

Original post https://gcc.gnu.org/ml/gcc-patches/2014-01/msg02096.html

Tested check-gcc on aarch64-none-linux-gnu (native), fixes all variants of
gcc.dg/pch/largefile.c (below).

Ok?

Cheers, Alan

gcc/ChangeLog:

Backport r207785 from mainline
2014-01-31  Kyle McMartin 

PR pch/60010
* config/host-linux.c (TRY_EMPTY_VM_SPACE): Define for AArch64.

-
Tests that now work, but didn't before:

gcc.dg/pch/largefile.c   -O0  assembly comparison
gcc.dg/pch/largefile.c   -O1  assembly comparison
gcc.dg/pch/largefile.c   -O2  assembly comparison
gcc.dg/pch/largefile.c   -O3 -fomit-frame-pointer  assembly comparison
gcc.dg/pch/largefile.c   -O3 -g  assembly comparison
gcc.dg/pch/largefile.c   -Os  assembly comparison
gcc.dg/pch/largefile.c  -O0 -g assembly comparison
largefile.c   -O0  -I. -Dwith_PCH (test for excess errors)
largefile.c   -O1  -I. -Dwith_PCH (test for excess errors)
largefile.c   -O2  -I. -Dwith_PCH (test for excess errors)
largefile.c   -O3 -fomit-frame-pointer  -I. -Dwith_PCH (test for excess errors)
largefile.c   -O3 -g  -I. -Dwith_PCH (test for excess errors)
largefile.c   -Os  -I. -Dwith_PCH (test for excess errors)
largefile.c  -O0 -g -I. -Dwith_PCH (test for excess errors)

Old tests that failed, that have disappeared: (Eeek!)

largefile.c   -O0  -I. -Dwith_PCH (internal compiler error)
largefile.c   -O1  -I. -Dwith_PCH (internal compiler error)
largefile.c   -O2  -I. -Dwith_PCH (internal compiler error)
largefile.c   -O3 -fomit-frame-pointer  -I. -Dwith_PCH (internal compiler error)
largefile.c   -O3 -g  -I. -Dwith_PCH (internal compiler error)
largefile.c   -Os  -I. -Dwith_PCH (internal compiler error)
largefile.c  -O0 -g -I. -Dwith_PCH (internal compiler error)


commit 39f9a388f15e12f43e3f59c314325cc087eab377
Author: Alan Lawrence 
Date:   Tue Mar 10 12:20:12 2015 +

Kyle McMartin patch

diff --git a/gcc/config/host-linux.c b/gcc/config/host-linux.c
index 1f10823..0774ecf 100644
--- a/gcc/config/host-linux.c
+++ b/gcc/config/host-linux.c
@@ -86,6 +86,8 @@
 # define TRY_EMPTY_VM_SPACE	0x6000
 #elif defined(__mc68000__)
 # define TRY_EMPTY_VM_SPACE	0x4000
+#elif defined(__aarch64__)
+# define TRY_EMPTY_VM_SPACE	0x10
 #elif defined(__ARM_EABI__)
 # define TRY_EMPTY_VM_SPACE 0x6000
 #elif defined(__mips__) && defined(__LP64__)




[Committed][testsuite][PR65594] Scale down libgomp.graphite/force-parallel-6.c

2015-03-27 Thread Tom de Vries

Hi,

I regularly run into a timeout of libgomp.graphite/force-parallel-6.c (filed as 
PR65594).


This patch scales down libgomp.graphite/force-parallel-6.c, which fixes the 
timeout.

Committed as approved by Jakub here: 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65594#c8 .


Thanks,
- Tom
Scale down libgomp.graphite/force-parallel-6.c

2015-03-27  Tom de Vries  

	* testsuite/libgomp.graphite/force-parallel-6.c (M): Define.
	(foo): Use M for non-inner loops to scale down test-case.
---
 libgomp/testsuite/libgomp.graphite/force-parallel-6.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libgomp/testsuite/libgomp.graphite/force-parallel-6.c b/libgomp/testsuite/libgomp.graphite/force-parallel-6.c
index 5071630..e9e4b56 100644
--- a/libgomp/testsuite/libgomp.graphite/force-parallel-6.c
+++ b/libgomp/testsuite/libgomp.graphite/force-parallel-6.c
@@ -1,4 +1,5 @@
 #define N 500
+#define M 50
 
 int X[2*N], Y[2*N], B[2*N];
 int A[2*N][2*N], C[2*N][2*N];
@@ -7,10 +8,10 @@ int foo(void)
 {
   int i, j, k;
 
-  for (i = 0; i < N; i++)
+  for (i = 0; i < M; i++)
 {
   X[i] = Y[i] + 10;
-  for (j = 0; j < N; j++)
+  for (j = 0; j < M; j++)
 	{
 	  B[j] = A[j][N];
 	  for (k = 0; k < N; k++)
-- 
1.9.1



[Committed][testsuite][PR65594] Add verification to libgomp.graphite/force-parallel-6.c

2015-03-27 Thread Tom de Vries

Hi,

this patch adds verification to libgomp.graphite/force-parallel-6.c.

Committed as approved by Jakub here: 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65594#c8 .


Thanks,
- Tom
Add verification to libgomp.graphite/force-parallel-6.c

2015-03-27  Tom de Vries  

	* testsuite/libgomp.graphite/force-parallel-6.c (abort): Declare.
	(init, check): New function.
	(foo): Change return type to void.
	(main): Call init and check.
---
 .../testsuite/libgomp.graphite/force-parallel-6.c  | 52 --
 1 file changed, 49 insertions(+), 3 deletions(-)

diff --git a/libgomp/testsuite/libgomp.graphite/force-parallel-6.c b/libgomp/testsuite/libgomp.graphite/force-parallel-6.c
index e9e4b56..cbc5735 100644
--- a/libgomp/testsuite/libgomp.graphite/force-parallel-6.c
+++ b/libgomp/testsuite/libgomp.graphite/force-parallel-6.c
@@ -1,10 +1,31 @@
+void abort (void);
+
 #define N 500
 #define M 50
 
 int X[2*N], Y[2*N], B[2*N];
 int A[2*N][2*N], C[2*N][2*N];
 
-int foo(void)
+static void __attribute__((noinline,noclone))
+init (void)
+{
+  volatile int i, j;
+
+  for (i = 0; i < 2 * N; ++i)
+{
+  B[i] = 1;
+  X[i] = 1;
+  Y[i] = 1;
+  for (j = 0; j < 2 * N; ++j)
+	{
+	  A[i][j] = 1;
+	  C[i][j] = 1;
+	}
+}
+}
+
+static void __attribute__((noinline,noclone))
+foo (void)
 {
   int i, j, k;
 
@@ -21,13 +42,38 @@ int foo(void)
 	  Y[i+j] = A[j+1][N];
 	}
 }
+}
 
-  return A[1][5]*B[6];
+static void __attribute__((noinline,noclone))
+check (void)
+{
+  volatile int i, j;
+
+  for (i = 0; i < 2 * N; ++i)
+{
+  int expect_x = i < M ? 11 : 1;
+
+  if (B[i] != 1
+	  || X[i] != expect_x
+	  || Y[i] != 1)
+	abort ();
+
+  for (j = 0; j < 2 * N; ++j)
+	{
+	  int expect_a = (0 < i && i <= M && j < N) ? 2 : 1;
+
+	  if (A[i][j] != expect_a
+	  || C[i][j] != 1)
+	abort ();
+	}
+}
 }
 
 int main(void)
 {
-  foo();
+  init ();
+  foo ();
+  check ();
 
   return 0;
 }
-- 
1.9.1



[Patch, testsuite] Fixed comment in testcase

2015-03-27 Thread Andre Vehreschild
Hi all,

commited as r221729 to meet the legal requirements and fix some typos.

Regards,
Andre
-- 
Andre Vehreschild * Email: vehre ad gmx dot de 
Index: gcc/testsuite/ChangeLog
===
--- gcc/testsuite/ChangeLog	(Revision 221728)
+++ gcc/testsuite/ChangeLog	(Arbeitskopie)
@@ -1,3 +1,8 @@
+2015-03-27  Andre Vehreschild  
+
+	* gfortran.dg/unlimited_polymorphic_24.f03: Added copyright
+	statement and cleanup. Fixed typos.
+
 2015-03-26  Jan Hubicka  
 
 	PR middle-end/65595
Index: gcc/testsuite/gfortran.dg/unlimited_polymorphic_24.f03
===
--- gcc/testsuite/gfortran.dg/unlimited_polymorphic_24.f03	(Revision 221728)
+++ gcc/testsuite/gfortran.dg/unlimited_polymorphic_24.f03	(Arbeitskopie)
@@ -1,9 +1,11 @@
 ! { dg-do run }
 !
+! Copyright 2011 STMicroelectronics
+!
 ! Test case for unlimited polymorphism that is derived from the article
-! by Mark Leair, in the 'PGI Insider':
+! by Mark Leair, in the 'PGInsider':
 ! https://www.pgroup.com/lit/articles/insider/v3n2a2.htm
-! Note that 'getValue' has been removed from the generic 'add' becuse
+! Note that 'addValue' has been removed from the generic 'add' because
 ! gfortran asserts that this is ambiguous. See
 ! https://gcc.gnu.org/ml/fortran/2015-03/msg2.html for a discussion.
 !
@@ -213,3 +215,4 @@
   end do
 end program main
 
+! { dg-final { cleanup-modules "list_mod link_mod" } }


Re: [Patch, libstdc++/65420] Use constexpr variables as regex_constans flags

2015-03-27 Thread Jonathan Wakely

On 15/03/15 23:27 -0700, Tim Shen wrote:

+#include 
+#include 
+
+// libstdc++/65420
+void
+test01()
+{
+  bool test __attribute__((unused)) = true;


I forgot to say that for a { dg-do compile } test you don't need a
'test' variable and don't need to #include ,



[patch] libstdc++/65499 make duration literals visible in std::chrono namespace

2015-03-27 Thread Jonathan Wakely

This is a tiny tweak to add a missing piece of C++14 support, the
duration literals should be usable via "using namespace std::chrono".
It doesn't affect anything in C++03 or C++11 mode so safe for trunk
now.

Tested x86_64-linux, committed to trunk.

commit 907f5e128d855d339829abbd1d314f382e3ae6fc
Author: Jonathan Wakely 
Date:   Thu Mar 26 20:12:36 2015 +

	PR libstdc++/65499
	* include/std/chrono: Add using-directive for literals to std::chrono.
	* testsuite/20_util/duration/literals/65499.cc: New.

diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono
index e5baa56..50a2bbf 100644
--- a/libstdc++-v3/include/std/chrono
+++ b/libstdc++-v3/include/std/chrono
@@ -866,6 +866,15 @@ _GLIBCXX_END_NAMESPACE_VERSION
   } // inline namespace chrono_literals
   } // inline namespace literals
 
+  namespace chrono
+  {
+  _GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+  using namespace literals::chrono_literals;
+
+  _GLIBCXX_END_NAMESPACE_VERSION
+  } // namespace chrono
+
 #endif // __cplusplus > 201103L
 
   // @} group chrono
diff --git a/libstdc++-v3/testsuite/20_util/duration/literals/65499.cc b/libstdc++-v3/testsuite/20_util/duration/literals/65499.cc
new file mode 100644
index 000..62c4f5a
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/duration/literals/65499.cc
@@ -0,0 +1,26 @@
+// Copyright (C) 2015 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library 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.
+
+// This library 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 this library; see the file COPYING3.  If not see
+// .
+
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// PR libstdc++/65499
+
+#include 
+
+using namespace std::chrono;
+minutes min = 36min;


Re: [Patch, Fortran, pr60322] was: [Patch 1/2, Fortran, pr60322] [OOP] Incorrect bounds on polymorphic dummy array

2015-03-27 Thread Paul Richard Thomas
Dear Andre,

I am in the UK as of last night. Before leaving, I bootstrapped and
regtested your patch and all was well. I must drive to Cambridge this
afternoon to see my mother and will try to get to it either this
evening or tomorrow morning. There is so much of it and it touches
many places; so I must give it a very careful looking over before
giving the green light. Bear with me please.

Great work though!

Paul

On 24 March 2015 at 18:06, Andre Vehreschild  wrote:
> Hi all,
>
> I have worked on the comments Mikael gave me. I am now checking for
> class_pointer in the way he pointed out.
>
> Furthermore did I *join the two parts* of the patch into this one, because
> keeping both in sync was no benefit but only tedious and did not prove to be
> reviewed faster.
>
> Paul, Dominique: I have addressed the LOC issue that came up lately. Or rather
> the patch addressed it already. I feel like this is not tested very well, not
> the loc() call nor the sizeof() call as given in the 57305 second's download.
> Unfortunately, is that download not runable. I would love to see a test 
> similar
> to that download, but couldn't come up with one, that satisfied me. Given that
> the patch's review will last some days, I still have enough time to come up
> with something beautiful which I will add then.
>
> Bootstraps and regtests ok on x86_64-linux-gnu/F20.
>
> Regards,
> Andre
>
>
> On Tue, 24 Mar 2015 11:13:27 +0100
> Paul Richard Thomas  wrote:
>
>> Dear Andre,
>>
>> Dominique pointed out to me that the 'loc' patch causes a ICE in the
>> testsuite. It seems that 'loc' should provide the address of the class
>> container in some places and the address of the data in others. I will
>> put my thinking cap on tonight :-)
>>
>> Cheers
>>
>> Paul
>>
>> On 23 March 2015 at 13:43, Andre Vehreschild  wrote:
>> > Hi Mikael,
>> >
>> > thanks for looking at the patch. Please note, that Paul has sent an
>> > addendum to the patches for 60322, which I deliberately have attached.
>> >
>> >>  26/02/2015 18:17, Andre Vehreschild a écrit :
>> >> > This first patch is only preparatory and does not change any of the
>> >> > semantics of gfortran at all.
>> >> Sure?
>> >
>> > With the counterexample you found below, this of course is a wrong
>> > statement.
>> >
>> >> > diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
>> >> > index ab6f7a5..d28cf77 100644
>> >> > --- a/gcc/fortran/expr.c
>> >> > +++ b/gcc/fortran/expr.c
>> >> > @@ -4059,10 +4060,10 @@ gfc_lval_expr_from_sym (gfc_symbol *sym)
>> >> >lval->symtree = gfc_find_symtree (sym->ns->sym_root, sym->name);
>> >> >
>> >> >/* It will always be a full array.  */
>> >> > -  lval->rank = sym->as ? sym->as->rank : 0;
>> >> > +  as = sym->as;
>> >> > +  lval->rank = as ? as->rank : 0;
>> >> >if (lval->rank)
>> >> > -gfc_add_full_array_ref (lval, sym->ts.type == BT_CLASS ?
>> >> > -   CLASS_DATA (sym)->as : sym->as);
>> >> > +gfc_add_full_array_ref (lval, as);
>> >>
>> >> This is a change of semantics.  Or do you know that sym->ts.type !=
>> >> BT_CLASS?
>> >
>> > You are completely right. I have made a mistake here. I have to tell the
>> > truth, I never ran a regtest with only part 1 of the patches applied. The
>> > second part of the patch will correct this, by setting the variable as
>> > depending on whether type == BT_CLASS or not. Sorry for the mistake.
>> >
>> >> > diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
>> >> > index 3664824..e571a17 100644
>> >> > --- a/gcc/fortran/trans-decl.c
>> >> > +++ b/gcc/fortran/trans-decl.c
>> >> > @@ -1013,16 +1017,24 @@ gfc_build_dummy_array_decl (gfc_symbol * sym,
>> >> > tree dummy) tree decl;
>> >> >tree type;
>> >> >gfc_array_spec *as;
>> >> > +  symbol_attribute *array_attr;
>> >> >char *name;
>> >> >gfc_packed packed;
>> >> >int n;
>> >> >bool known_size;
>> >> >
>> >> > -  if (sym->attr.pointer || sym->attr.allocatable
>> >> > -  || (sym->as && sym->as->type == AS_ASSUMED_RANK))
>> >> > +  /* Use the array as and attr.  */
>> >> > +  as = sym->as;
>> >> > +  array_attr = &sym->attr;
>> >> > +
>> >> > +  /* The pointer attribute is always set on a _data component, 
>> >> > therefore
>> >> > check
>> >> > + the sym's attribute only.  */
>> >> > +  if (sym->attr.pointer || array_attr->allocatable
>> >> > +  || (as && as->type == AS_ASSUMED_RANK))
>> >> >  return dummy;
>> >> >
>> >> Any reason to sometimes use array_attr, sometimes not, like here?
>> >> By the way, the comment is misleading: for classes, there is the
>> >> class_pointer attribute (and it is a pain, I know).
>> >
>> > Yes, and a good one. Array_attr is sometimes sym->attr and sometimes
>> > CLASS_DATA(sym)->attr aka sym->ts.u.derived->components->attr. In the later
>> > case .pointer is always set to 1 in the _data component's attr. I.e., the
>> > above if, would always yield true for a class_array, which is not intended,
>> > but rather destructive. I know about t

Re: [PATCH] gcc/config/c6x/c6x.md: Remove "clobber (match_scratch ...)" in "movmisalign_store".

2015-03-27 Thread Bernd Schmidt

On 03/27/2015 01:05 AM, Chen Gang wrote:

For misalignment memory access, c6x gcc will cause issue, so need remove
"clobber (match_scratch ...)" which will be symmetric with "movmisalign
_load", then pass compiling and generate correct assembly code.




* config/c6x/c6x.md (movmisalign_store): Remove "clobber
(match_scratch ...)".


No, that just will make the compiler confuse loads and stores. I've 
committed the following to fix it (I thought I'd done so a year ago, but 
probably it was one of those commit against an out-of-date tree 
situations and it didn't go through).



Bernd

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8e4b6c1..d5535f9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,8 @@
 2015-03-27  Bernd Schmidt  
 
+	* config/c6x/c6x.md (movmisalign): Use MEM_P, not
+	memory_operand.
+
 	PR target/65052
 * config/c6x/constraints.md (S3): New constraint.
 * config/c6x/c6x.md (real_jump): Use it.
diff --git a/gcc/config/c6x/c6x.md b/gcc/config/c6x/c6x.md
index fafefa6..e957eca 100644
--- a/gcc/config/c6x/c6x.md
+++ b/gcc/config/c6x/c6x.md
@@ -775,7 +775,7 @@
 		   UNSPEC_MISALIGNED_ACCESS))]
   "TARGET_INSNS_64"
 {
-  if (memory_operand (operands[0], mode))
+  if (MEM_P (operands[0]))
 {
   emit_insn (gen_movmisalign_store (operands[0], operands[1]));
   DONE;


Fix PR65052

2015-03-27 Thread Bernd Schmidt
This is a problem where we reject labels on a jump instruction because 
they are invalid with pic for the 's' constraint. It seems that the 
constraint wasn't checked in earlier versions of the compiler.


Fixed by adding a new constraint and using that instead.


Bernd
commit 432e3b7c5e3e47fdc9232805519d54f516c18008
Author: Bernd Schmidt 
Date:   Fri Mar 27 13:32:31 2015 +0100

Fix c6x-uclinux build failure.

	* config/c6x/constraints.md (S3): New constraint.
	* config/c6x/c6x.md (real_jump): Use it.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5cee0a5..8e4b6c1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2015-03-27  Bernd Schmidt  
+
+	PR target/65052
+* config/c6x/constraints.md (S3): New constraint.
+* config/c6x/c6x.md (real_jump): Use it.
+
 2015-03-26  Jan Hubicka  
 
 	PR middle-end/65595
diff --git a/gcc/config/c6x/c6x.md b/gcc/config/c6x/c6x.md
index 892aac4..fafefa6 100644
--- a/gcc/config/c6x/c6x.md
+++ b/gcc/config/c6x/c6x.md
@@ -1519,7 +1519,7 @@
 ;; -
 
 (define_insn "real_jump"
-  [(unspec [(match_operand 0 "c6x_jump_operand" "a,b,s") (const_int 0)]
+  [(unspec [(match_operand 0 "c6x_jump_operand" "a,b,S3") (const_int 0)]
 	   UNSPEC_REAL_JUMP)]
   ""
 {
diff --git a/gcc/config/c6x/constraints.md b/gcc/config/c6x/constraints.md
index 9d88912..b8cdc0e 100644
--- a/gcc/config/c6x/constraints.md
+++ b/gcc/config/c6x/constraints.md
@@ -160,6 +160,11 @@ not C64X or higher).")
Any SYMBOL_REF or LABEL_REF."
   (ior (match_code "symbol_ref") (match_code "label_ref")))
 
+(define_constraint "S3"
+  "Matches a symbolic integer constant, even if invalid for PIC."
+  (and (match_test "CONSTANT_P (op)")
+   (match_test "!CONST_SCALAR_INT_P (op)")))
+
 (define_constraint "Si"
   "@internal
Any immediate value, unless it matches the S0 constraint."


Re: [Patch, fortran, pr65548, v1] [5 Regression] gfc_conv_procedure_call

2015-03-27 Thread Dominique Dhumieres
> please find attached a fix for the recently introduced regression when
> allocating arrays with an intrinsic function for source=. ...

I confirm that the patch fixes pr65548 without regression.

Thanks,

Dominique


[PATCH, stage1][PR65443] Add transform_to_exit_first_loop_alt

2015-03-27 Thread Tom de Vries

Hi,

this patch fixes PR65443, a todo in the parloops pass for function 
transform_to_exit_first_loop:

...
   TODO: the common case is that latch of the loop is empty and immediately
   follows the loop exit.  In this case, it would be better not to copy the
   body of the loop, but only move the entry of the loop directly before the
   exit check and increase the number of iterations of the loop by one.
   This may need some additional preconditioning in case NIT = ~0.
...

The current implementation of transform_to_exit_first_loop transforms the loop 
by moving and duplicating the loop body. This patch transforms the loop into the 
same normal form, but without the duplication, if that's possible (determined by 
try_transform_to_exit_first_loop_alt).


The actual transformation, done by transform_to_exit_first_loop_alt transforms 
this loop:

...
 bb preheader:
 ...
 goto 

 :
 ...
 if (ivtmp < n)
   goto ;
 else
   goto ;

 :
 ivtmp = ivtmp + inc;
 goto 
...

into this one:
...
 bb preheader:
 ...
 goto 

 :
 ...
 goto ;

 :
 if (ivtmp < n + 1)
   goto ;
 else
   goto ;

 :
 ivtmp = ivtmp + inc;
 goto 
...

Bootstrapped and reg-tested on x86_64.

OK for stage1 trunk?

Thanks,
- Tom
Add transform_to_exit_first_loop_alt

2015-03-27  Tom de Vries  

	PR tree-optimization/65443
	* tree-parloops.c (replace_imm_uses, replace_uses_in_bb_by)
	(replace_uses_in_bbs_by, transform_to_exit_first_loop_alt)
	(try_transform_to_exit_first_loop_alt): New function.
	(transform_to_exit_first_loop): Use
	try_transform_to_exit_first_loop_alt.

	* gcc.dg/parloops-exit-first-loop-alt-2.c: New test.
	* gcc.dg/parloops-exit-first-loop-alt-3.c: New test.
	* gcc.dg/parloops-exit-first-loop-alt.c: New test.

	* testsuite/libgomp.c/parloops-exit-first-loop-alt-2.c: New test.
	* testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c: New test.
	* testsuite/libgomp.c/parloops-exit-first-loop-alt.c: New test.
---
 .../gcc.dg/parloops-exit-first-loop-alt-2.c|  27 ++
 .../gcc.dg/parloops-exit-first-loop-alt-3.c|  26 ++
 .../gcc.dg/parloops-exit-first-loop-alt.c  |  27 ++
 gcc/tree-parloops.c| 344 -
 .../libgomp.c/parloops-exit-first-loop-alt-2.c |  48 +++
 .../libgomp.c/parloops-exit-first-loop-alt-3.c |  29 ++
 .../libgomp.c/parloops-exit-first-loop-alt.c   |  48 +++
 7 files changed, 538 insertions(+), 11 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-2.c
 create mode 100644 gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-3.c
 create mode 100644 gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt.c
 create mode 100644 libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-2.c
 create mode 100644 libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c
 create mode 100644 libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt.c

diff --git a/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-2.c b/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-2.c
new file mode 100644
index 000..a4d6cb2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-2.c
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target pthread } */
+/* { dg-options "-O2 -ftree-parallelize-loops=2 -fdump-tree-parloops" } */
+
+#define N 1000
+
+unsigned int a[N];
+unsigned int b[N];
+unsigned int c[N];
+
+void __attribute__((noclone,noinline))
+f (unsigned int n)
+{
+  int i;
+
+for (i = 0; i < N; ++i)
+  c[i] = a[i] + b[i];
+}
+
+/* Three times three array accesses:
+   - three in f._loopfn.0
+   - three in the parallel
+   - three in the low iteration count loop
+   Crucially, none for a peeled off last iteration following the parallel.  */
+/* { dg-final { scan-tree-dump-times "(?n)\\\[i" 9 "parloops" } } */
+
+/* { dg-final { cleanup-tree-dump "parloops" } } */
diff --git a/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-3.c b/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-3.c
new file mode 100644
index 000..c7ab51f88
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-3.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target pthread } */
+/* { dg-options "-O2 -ftree-parallelize-loops=2 -fdump-tree-parloops" } */
+
+unsigned int *a;
+
+unsigned int __attribute__((noclone,noinline))
+f (unsigned int n)
+{
+  int i;
+  unsigned int sum = 1;
+
+  for (i = 0; i < n; ++i)
+sum += a[i];
+
+  return sum;
+}
+
+/* Three array accesses:
+   - one in f._loopfn.0
+   - one in the parallel
+   - one in the low iteration count loop
+   Crucially, none for a peeled off last iteration following the parallel.  */
+/* { dg-final { scan-tree-dump-times "(?n)\\\* 4" 3 "parloops" } } */
+
+/* { dg-final { cleanup-tree-dump "parloops" } } */
diff --git a/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt.c b/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt.c

RE: [RFC: Patch, PR 60158] gcc/varasm.c : Pass actual alignment value to output_constant_pool_2

2015-03-27 Thread rohitarul...@freescale.com
Hi,

I would like to resubmit these patches for comments. The previous detailed 
discussion is available in the below mentioned link.
https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01679.html
https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00489.html

The issue is still reproducible on GCC v4.8 branch.

I have tested both the attached patches with e500v2 tool chain on GCC v4.8 
branch [rev 221667] and GCC trunk [rev 221310] with no regressions.

Patch1 [gcc.fix_pr60158_fixup_table_fsf_1]: Pass actual alignment value to 
output_constant_pool_2.
Patch2 [gcc.fix_pr60158_fixup_table_fsf_2]: Use the alignment data available in 
the first argument (constant_descriptor_rtx) of output_constant_pool_1.
(Note: this generates ".align" directive twice).

Please let me know your comments.

Regards,
Rohit


-Original Message-
From: Dharmakan Rohit-B30502 
Sent: Wednesday, June 04, 2014 4:46 PM
To: gcc-patches@gcc.gnu.org
Subject: RE: [Patch, PR 60158] gcc/varasm.c : Pass actual alignment value to 
output_constant_pool_2

Ping.
I have changed the subject line accordingly.

Regards,
Rohit

> -Original Message-
> From: David Edelsohn [mailto:dje@gmail.com]
> Sent: Thursday, May 08, 2014 9:28 PM
> To: Dharmakan Rohit-B30502; Jakub Jelinek; Richard Biener
> Cc: Alan Modra; gcc-patches@gcc.gnu.org; Wienskoski Edmar-RA8797
> Subject: Re: [Patch, PR 60158] Generate .fixup sections for 
> .data.rel.ro.local entries.
> 
> Rohit,
> 
> The subject line and thread may confuse people that this is a PowerPC- 
> specific issue. You need approval from a reviewer with authority over 
> varasm.c.
> 
> Thanks, David
> 
> On Thu, May 8, 2014 at 9:54 AM, rohitarul...@freescale.com 
>  wrote:
> >> -Original Message-
> >> From: Alan Modra [mailto:amo...@gmail.com]
> >> Sent: Saturday, April 26, 2014 11:52 AM
> >> To: Dharmakan Rohit-B30502
> >> Cc: gcc-patches@gcc.gnu.org; dje@gmail.com; Wienskoski
> >> Edmar-RA8797
> >> Subject: Re: [Patch, PR 60158] Generate .fixup sections for 
> >> .data.rel.ro.local entries.
> >>
> >> On Fri, Apr 25, 2014 at 02:57:38PM +, 
> >> rohitarul...@freescale.com
> >> wrote:
> >> > Source file: gcc-4.8.2/gcc/varasm.c @@ -7120,7 +7120,7 @@
> >> >if (CONSTANT_POOL_ADDRESS_P (symbol))
> >> > {
> >> >   desc = SYMBOL_REF_CONSTANT (symbol);
> >> >   output_constant_pool_1 (desc, 1);
> >> - (A)
> >> >   offset += GET_MODE_SIZE (desc->mode);
> >>
> >> I think the reason 1 is passed here for align is that with 
> >> -fsection- anchors, in output_object_block we've already laid out 
> >> everything in the block, assigning offsets from the start of the 
> >> block.  Aligning shouldn't be necessary, because we've already done 
> >> that..  OTOH, it shouldn't hurt to align again.
> >>
> > Thanks. I have tested for both the cases on e500v2, e500mc, e5500,
> ppc64 (GCC v4.8.2 branch) with no regressions.
> >
> > Patch1 [gcc.fix_pr60158_fixup_table-fsf]: Pass actual alignment 
> > value
> to output_constant_pool_2.
> > Patch2 [gcc.fix_pr60158_fixup_table-fsf-2]: Use the alignment data
> available in the first argument (constant_descriptor_rtx) of 
> output_constant_pool_1.
> > (Note: this generates ".align" directive twice).
> >
> > Is it ok to commit? Any comments?
> >
> > Regards,
> > Rohit
> >


gcc.fix_pr60158_fixup_table_trunk_fsf_1
Description: gcc.fix_pr60158_fixup_table_trunk_fsf_1


gcc.fix_pr60158_fixup_table_trunk_fsf_2
Description: gcc.fix_pr60158_fixup_table_trunk_fsf_2


C++ PATCH for c++/65556 (ICE with switch and bit-fields)

2015-03-27 Thread Marek Polacek
In this testcase we were crashing while trying to gimplify a switch, because
the types of the switch condition and case constants didn't match.  This ICE
started with my -Wswitch-with-enum-bit-fields fix where I used the unlowered
type so that we're able to get hold of the enum type.  The problem with that
is with ordinary bit-fields: we'll get the underlying type (e.g. long int),
but subsequent perform_integral_promotions promotes that to int, see
cp_perform_integral_promotions.  Fixed by using the type of the condition in
case we're not dealing with an enum bit-field, i.e. do what we've been doing
before the -Wswitch fix, which ought to make this fix very safe.

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

2015-03-27  Marek Polacek  

PR c++/65556
* semantics.c (finish_switch_cond): If the unlowered type is not an
enum, use the type of the condition.

* c-c++-common/pr65556.c: New test.

diff --git gcc/cp/semantics.c gcc/cp/semantics.c
index f325e41..74af7e8 100644
--- gcc/cp/semantics.c
+++ gcc/cp/semantics.c
@@ -1165,6 +1165,8 @@ finish_switch_cond (tree cond, tree switch_stmt)
}
   /* We want unlowered type here to handle enum bit-fields.  */
   orig_type = unlowered_expr_type (cond);
+  if (TREE_CODE (orig_type) != ENUMERAL_TYPE)
+   orig_type = TREE_TYPE (cond);
   if (cond != error_mark_node)
{
  /* Warn if the condition has boolean value.  */
diff --git gcc/testsuite/c-c++-common/pr65556.c 
gcc/testsuite/c-c++-common/pr65556.c
index e69de29..c6729a1 100644
--- gcc/testsuite/c-c++-common/pr65556.c
+++ gcc/testsuite/c-c++-common/pr65556.c
@@ -0,0 +1,23 @@
+/* PR c++/65556 */
+/* { dg-do compile } */
+
+struct S
+{
+  long l: 1;
+  long l2: 41;
+  unsigned long ul: 1;
+  unsigned long ul2: 41;
+} s;
+
+void
+fn ()
+{
+  switch (s.l)
+case 0:;
+  switch (s.ul)
+case 0:;
+  switch (s.l2)
+case 0:;
+  switch (s.ul2)
+case 0:;
+}

Marek


patch to fix PR65407

2015-03-27 Thread Vladimir Makarov

The following patch fixes

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65407

The patch was bootstrapped and tested on x86/x86-64, ppc64, aarch64.

Committed as rev. 221734.

2015-03-27  Vladimir Makarov  

PR target/65407
* ira-costs.c (record_reg_classes): Process all constraint string
containing 0-9.

2015-03-27  Vladimir Makarov  

PR target/65407
* gcc.target/i386/avx512f-kandnw-1.c: Add scanning kmovw.


Index: ira-costs.c
===
--- ira-costs.c (revision 221669)
+++ ira-costs.c (working copy)
@@ -589,7 +589,7 @@ record_reg_classes (int n_alts, int n_op
  while (*p == '%' || *p == '=' || *p == '+' || *p == '&')
p++;
 
- if (p[0] >= '0' && p[0] <= '0' + i && (p[1] == ',' || p[1] == 0))
+ if (p[0] >= '0' && p[0] <= '0' + i)
{
  /* Copy class and whether memory is allowed from the
 matching alternative.  Then perform any needed cost
@@ -754,14 +754,7 @@ record_reg_classes (int n_alts, int n_op
  && ! find_reg_note (insn, REG_DEAD, op))
alt_cost += 2;
 
- /* This is in place of ordinary cost computation for
-this operand, so skip to the end of the
-alternative (should be just one character).  */
- while (*p && *p++ != ',')
-   ;
-
- constraints[i] = p;
- continue;
+ p++;
}
}
 
Index: testsuite/gcc.target/i386/avx512f-kandnw-1.c
===
--- testsuite/gcc.target/i386/avx512f-kandnw-1.c(revision 221669)
+++ testsuite/gcc.target/i386/avx512f-kandnw-1.c(working copy)
@@ -1,6 +1,7 @@
 /* { dg-do compile } */
 /* { dg-options "-mavx512f -O2" } */
 /* { dg-final { scan-assembler-times "kandnw\[ 
\\t\]+\[^\{\n\]*%k\[0-7\](?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "kmovw" 2 } } */
 
 #include 
 


Fix ICE in resolve_speculation

2015-03-27 Thread Jan Hubicka
Hi,
this patch fixes ice in resolve_speculatoin expecting that there is callgraph
node for declaration it is passed.  I also revisited earlier fix to
cgraph_update_edges_for_call_stmt_node: the function would still ICE if
dead indirect call was updated.  I do not think it happens as only user
is fold_marked_statements and fold_stmt will likely only suceed either
fodling out the builtin or turning indirect call to direct, but it is better
to be safe.

Bootstrapped/regtested x86_64-linux, comitted.

PR ipa/65600
* cgraph.c (cgraph_update_edges_for_call_stmt_node): Fix the case
of optimized out indirect call.
(redirect_to_unreachable): Always build symbol table node for
BUILT_IN_UNREACHABLE
* g++.dg/torture/pr65600.C: New testcase.
Index: testsuite/g++.dg/torture/pr65600.C
===
--- testsuite/g++.dg/torture/pr65600.C  (revision 0)
+++ testsuite/g++.dg/torture/pr65600.C  (revision 0)
@@ -0,0 +1,28 @@
+// { dg-do compile }
+// { dg-options "-std=c++11" }
+class A {
+public:
+  virtual void m_fn1() {}
+  int weak_release___trans_tmp_1;
+  void m_fn2() {
+__asm__("\n\n\n\n");
+if (weak_release___trans_tmp_1)
+  m_fn1();
+  }
+};
+class weak_count {
+  A *pi_;
+
+public:
+  weak_count() : pi_() {}
+  ~weak_count() {
+if (pi_)
+  pi_->m_fn2();
+  }
+};
+class B {
+  weak_count pn;
+};
+int
+main() { B a; }
+
Index: cgraph.c
===
--- cgraph.c(revision 221726)
+++ cgraph.c(working copy)
@@ -1516,7 +1516,7 @@ cgraph_update_edges_for_call_stmt_node (
   if (e)
{
  /* Keep calls marked as dead dead.  */
- if (new_call && e->callee
+ if (new_stmt && is_gimple_call (new_stmt) && e->callee
  && DECL_BUILT_IN_CLASS (e->callee->decl) == BUILT_IN_NORMAL
  && DECL_FUNCTION_CODE (e->callee->decl) == BUILT_IN_UNREACHABLE)
{
Index: ipa-inline-analysis.c
===
--- ipa-inline-analysis.c   (revision 221725)
+++ ipa-inline-analysis.c   (working copy)
@@ -766,15 +766,15 @@ static struct cgraph_edge *
 redirect_to_unreachable (struct cgraph_edge *e)
 {
   struct cgraph_node *callee = !e->inline_failed ? e->callee : NULL;
+  struct cgraph_node *target = cgraph_node::get_create
+ (builtin_decl_implicit (BUILT_IN_UNREACHABLE));
 
   if (e->speculative)
-e = e->resolve_speculation (builtin_decl_implicit (BUILT_IN_UNREACHABLE));
+e = e->resolve_speculation (target->decl);
   else if (!e->callee)
-e->make_direct (cgraph_node::get_create
- (builtin_decl_implicit (BUILT_IN_UNREACHABLE)));
+e->make_direct (target);
   else
-e->redirect_callee (cgraph_node::get_create
-   (builtin_decl_implicit (BUILT_IN_UNREACHABLE)));
+e->redirect_callee (target);
   struct inline_edge_summary *es = inline_edge_summary (e);
   e->inline_failed = CIF_UNREACHABLE;
   e->frequency = 0;


Re: libgomp nvptx plugin: rework initialisation and support the proposed load/unload hooks (was: Merge current set of OpenACC changes from gomp-4_0-branch)

2015-03-27 Thread Julian Brown
On Thu, 26 Mar 2015 13:09:19 +0100
Jakub Jelinek  wrote:

> On Mon, Mar 23, 2015 at 10:44:39PM +0300, Ilya Verbin wrote:
> > If it is too late for such global changes (rework initialization in
> > libgomp, change mic and ptx plugins), then here is a small
> > workaround patch to fix offloading from libraries.  Likely, it will
> > not affect OpenACC programs with one image.  make
> > check-target-libgomp passed.
> 
> Sorry for not getting to this earlier, really busy with severe
> regressions bugfixing lately.
> 
> Anyway, IMHO it is not too late to fixing it properly, after all,
> the current code is majorly broken.  As I've said earlier, e.g. the
> lack of mutex guarding gomp_target_init (which is using pthread_once
> guaranteed to be run just once) vs. concurrent GOMP_offload_register
> calls (if those are run from ctors, then I guess something like
> dl_load_lock ensures at least on glibc that multiple
> GOMP_offload_register calls aren't performed at the same time) in
> accessing/reallocating offload_images and num_offload_images and the
> lack of support to register further images after the gomp_target_init
> call (if you dlopen further shared libraries) is really bad.  And it
> would be really nice to support the unloading.
> 
> But I'm afraid I'm lost in what is the latest posted patch for that,
> and how has it been tested (whether just on MIC or MIC emul, or also
> for nvptx).
> 
> So can you please post a link to the latest full patch and how it has
> been tested, and if it is still error prone if say one thread executes
> GOMP_target the first time and another at the same time dlopens some
> shared library that has offloading regions in it, fix that too?

I couldn't say about that -- I don't have all the state on the locking
problems at the moment.

> We still have a week or so to get this sorted out.

Apologies again for the delay in getting this out. Here's a "current"
version of the patch against the gomp4 branch (on top of Ilya's
load/unload patch) which passes testing for nvptx/openacc/libgomp,
modulo the usual (timing-related) noise in the lib-83.c test.

Thomas, can we get this tested on mainline and with MIC emulation?

This version fixes (some if not all) regressions with multiple
NVidia devices, and removes the memory-map lock and is_initialised
fields, reverting to just a splay tree in gomp_device_descr (as the
code was before the OpenACC merge). (Our multi-GPU machine is
temporarily out of action, so I can't easily test that setup at the
moment).

HTH,

Julian

ChangeLog

gcc/
* config/nvptx/mkoffload.c (process): Support variable mapping.

libgomp/
* libgomp.h (target_mem_desc: Remove mem_map field.
(struct gomp_memory_mapping): Remove.
(acc_dispatch_t): Remove open_device_func, close_device_func,
get_device_num_func, set_device_num_func, target_data members.
Change create_thread_data_func argument to device number instead of
generic pointer.
(struct gomp_device_descr): Replace mem_map field with splay tree
directly.
(gomp_free_memmap): Update prototype.
* oacc-async.c (assert.h): Include.
(acc_async_test, acc_async_test_all, acc_wait, acc_wait_async)
(acc_wait_all, acc_wait_all_async): Use current host thread's
active device, not base_dev.
* oacc-cuda.c (acc_get_current_cuda_device)
(acc_get_current_cuda_context, acc_get_cuda_stream)
(acc_set_cuda_stream): Likewise.
* oacc-host.c (host_dispatch): Don't set open_device_func,
close_device_func, get_device_num_func or set_device_num_func.
(goacc_host_init): Don't initialise host_dispatch.mem_map.lock.
* oacc-init.c (base_dev, init_key): Remove.
(cached_base_dev): New.
(name_of_acc_device_t): New.
(acc_init_1): Initialise default-numbered device, not zeroth.
(acc_shutdown_1): Close all devices of a given type.
(goacc_destroy_thread): Don't use base_dev.
(lazy_open, lazy_init, lazy_init_and_open): Remove.
(goacc_attach_host_thread_to_device): New.
(acc_init): Reimplement with goacc_attach_host_thread_to_device.
(acc_get_num_devices): Don't use base_dev.
(acc_set_device_type): Reimplement.
(acc_get_device_type): Don't use base_dev.
(acc_get_device_num): Tweak logic.
(acc_set_device_num): Likewise.
(goacc_runtime_initialize): Initialize cached_base_dev not base_dev.
(goacc_lazy_initialize): Reimplement with acc_init and
goacc_attach_host_thread_to_device.
* oacc-int.h (goacc_thread): Add base_dev field.
(base_dev): Remove extern declaration.
(goacc_attach_host_thread_to_device): Add prototype.
* oacc-mem.c (lookup_host): Change first argument to
gomp_device_descr. Use lock/splay tree from gomp_device_descr.
(lookup_dev): Use lock from devicep not mem_map.
(acc_malloc): Use current thread's device instead of base_dev.
(acc_free): Likewise.
(acc_memcpy_to_device): Likewise.
(acc_memcpy_from_device): Likewise.
(acc_deviceptr, acc_map_data, acc_u

Fix ice on comdat groups with -check-pointer-bounds

2015-03-27 Thread Jan Hubicka
Hi,
this patch fixes bug in symtab_node::verify_symtab_nodes pointed out by Ilya.
The loop checking that there all comdats are linked by same_comdat_group was
completely bogus.  In addition it checked also external symbols that are
currently not kept in groups.  This bug was in mainline for months but
apparently bounds checking is first code producing interesting comdat groups to
trigger it.

Ilya, can you please mind comitting the testcase? I am not quite sure where
bounds checking should go offhand.

Also concerning linking the comdat groups, currently all non-DECL_EXTERNAL 
symbols
are linked and all !DECL_EXTERNAL symbols are non-linked.  Bounds checking 
should
follow this scheme.  It may be cleaner to keep links for DECL_EXTERNAL, but lets
deffer that for next stage1.

Bootstrapped/regtested x86_64-linux. Committed.

Honza

Index: ChangeLog
===
--- ChangeLog   (revision 221735)
+++ ChangeLog   (working copy)
@@ -1,5 +1,11 @@
 2015-03-27  Jan Hubicka  
 
+   PR target/65531
+   * symtab.c (symtab_node::verify_symtab_nodes): Fix verification of
+   comdat groups.
+
+2015-03-27  Jan Hubicka  
+
PR ipa/65600
* cgraph.c (cgraph_update_edges_for_call_stmt_node): Fix the case
of optimized out indirect call.
Index: symtab.c
===
--- symtab.c(revision 221734)
+++ symtab.c(working copy)
@@ -1130,15 +1130,20 @@ symtab_node::verify_symtab_nodes (void)
  &existed);
  if (!existed)
*entry = node;
- else
-   for (s = (*entry)->same_comdat_group; s != NULL && s != node; s = 
s->same_comdat_group)
+ else if (!DECL_EXTERNAL (node->decl))
+   {
+ for (s = (*entry)->same_comdat_group; s != NULL && s != node;
+  s = s->same_comdat_group)
+   ;
  if (!s || s == *entry)
{
- error ("Two symbols with same comdat_group are not linked by 
the same_comdat_group list.");
+ error ("Two symbols with same comdat_group are not linked by "
+"the same_comdat_group list.");
  (*entry)->debug ();
  node->debug ();
  internal_error ("symtab_node::verify failed");
}
+   }
}
 }
 }


Fix detailed mem report WRT hash tables

2015-03-27 Thread Jan Hubicka
Hi,
I notieced that GGC hash tables are now accounted to hash-table.h:alloc_entries
that is not very informative (we do not have any stats for heap hash tables that
would be nice to have).

This patch fixes the first problem by adding annotations. OK (perhaps for next 
stage1?)
Bootstrapped/regtested x86_64-linux with and without gathering stats.

Honza

* hash-table.c (hash_table constructor): Add mem stats.
(alloc_entries): Likewise.
Index: hash-table.h
===
--- hash-table.h(revision 221734)
+++ hash-table.h(working copy)
@@ -615,7 +615,7 @@ class hash_table class Allocator>
-hash_table::hash_table (size_t size) :
+hash_table::hash_table (size_t size
+ MEM_STAT_DECL) :
   m_n_elements (0), m_n_deleted (0), m_searches (0), m_collisions (0)
 {
   unsigned int size_prime_index;
@@ -1116,7 +1117,7 @@ class hash_table friend void gt_pch_nx (hash_table *,
  gt_pointer_operator, void *);
 
-  value_type *alloc_entries (size_t n) const;
+  value_type *alloc_entries (size_t n CXX_MEM_STAT_INFO) const;
   value_type *find_empty_slot_for_expand (hashval_t);
   void expand ();
   static bool is_deleted (value_type &v)
@@ -1295,7 +1296,8 @@ private:
 };
 
 template class Allocator>
-hash_table::hash_table (size_t size, bool ggc) :
+hash_table::hash_table (size_t size, bool ggc
+MEM_STAT_DECL) :
   m_n_elements (0), m_n_deleted (0), m_searches (0), m_collisions (0),
   m_ggc (ggc)
 {
@@ -1304,7 +1306,7 @@ hash_table:
   size_prime_index = hash_table_higher_prime_index (size);
   size = prime_tab[size_prime_index].prime;
 
-  m_entries = alloc_entries (size);
+  m_entries = alloc_entries (size PASS_MEM_STAT);
   m_size = size;
   m_size_prime_index = size_prime_index;
 }
@@ -1326,14 +1328,15 @@ hash_table:
 
 template class Allocator>
 inline typename hash_table::value_type *
-hash_table::alloc_entries (size_t n) const
+hash_table::alloc_entries
+(size_t n MEM_STAT_DECL) const
 {
   value_type *nentries;
 
   if (!m_ggc)
 nentries = Allocator  ::data_alloc (n);
   else
-nentries = ::ggc_cleared_vec_alloc (n);
+nentries = ::ggc_cleared_vec_alloc (n PASS_MEM_STAT);
 
   gcc_assert (nentries != NULL);
   for (size_t i = 0; i < n; i++)


Fix ICE with hard register

2015-03-27 Thread Jan Hubicka
Hi,
this patch fixes ICE with register variable when WHOPR decides to partition
it.  I did not include testcase because it depends on partitining and thus
it is huge. It may be possible to produce smaller one with
-flto-partition=max

Bootstrap/regtest x86_64-linux is running, will commit it once it finishes.
PR ipa/65588
* symtab.c (symtab_node::get_partitioning_class): Register vars
are duplicated.
(symbol_table::output_variables) Do not assemble unefined decls
for non-symbols.
Index: symtab.c
===
--- symtab.c(revision 221736)
+++ symtab.c(working copy)
@@ -1689,6 +1689,8 @@ symtab_node::get_partitioning_class (voi
  objects that can not be duplicated across partitions.  */
   if (DECL_IN_CONSTANT_POOL (decl))
return SYMBOL_DUPLICATE;
+  if (DECL_HARD_REGISTER (decl))
+   return SYMBOL_DUPLICATE;
   gcc_checking_assert (vnode->definition);
 }
   /* Functions that are cloned may stay in callgraph even if they are unused.
Index: varpool.c
===
--- varpool.c   (revision 221734)
+++ varpool.c   (working copy)
@@ -737,7 +737,9 @@ symbol_table::output_variables (void)
   timevar_push (TV_VAROUT);
 
   FOR_EACH_VARIABLE (node)
-if (!node->definition)
+if (!node->definition
+   && !DECL_HAS_VALUE_EXPR_P (node->decl)
+   && !DECL_HARD_REGISTER (node->decl))
   assemble_undefined_decl (node->decl);
   FOR_EACH_DEFINED_VARIABLE (node)
 {


C++ PATCH for c++/65509 (constexpr address comparison)

2015-03-27 Thread Jason Merrill
This was breaking because ancient code in the front end to avoid 
emitting unreferenced static const variables was preventing the 
vdefinition flag from being set on the varpool node for the variables. 
Now that we have cgraph controlling what gets emitted, there is no point 
in keeping this code around.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit 3fac157f5884e88d15a42b9c3136fd0e7024595a
Author: Jason Merrill 
Date:   Fri Mar 27 12:01:44 2015 -0400

	PR c++/65509
	* decl.c (make_rtl_for_nonlocal_decl): Don't defer static
	constants.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index cb0f11f..f05aefa 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -6061,7 +6061,6 @@ make_rtl_for_nonlocal_decl (tree decl, tree init, const char* asmspec)
 {
   int toplev = toplevel_bindings_p ();
   int defer_p;
-  const char *filename;
 
   /* Set the DECL_ASSEMBLER_NAME for the object.  */
   if (asmspec)
@@ -6109,32 +6108,9 @@ make_rtl_for_nonlocal_decl (tree decl, tree init, const char* asmspec)
  DECL_EXPR is expanded.  */
   defer_p = DECL_FUNCTION_SCOPE_P (decl) || DECL_VIRTUAL_P (decl);
 
-  /* We try to defer namespace-scope static constants so that they are
- not emitted into the object file unnecessarily.  */
-  filename = LOCATION_FILE (input_location);
-  if (!DECL_VIRTUAL_P (decl)
-  && TREE_READONLY (decl)
-  && DECL_INITIAL (decl) != NULL_TREE
-  && DECL_INITIAL (decl) != error_mark_node
-  && filename != NULL
-  && ! EMPTY_CONSTRUCTOR_P (DECL_INITIAL (decl))
-  && toplev
-  && !TREE_PUBLIC (decl))
-{
-  /* Fool with the linkage of static consts according to #pragma
-	 interface.  */
-  struct c_fileinfo *finfo = get_fileinfo (filename);
-  if (!finfo->interface_unknown && !TREE_PUBLIC (decl))
-	{
-	  TREE_PUBLIC (decl) = 1;
-	  DECL_EXTERNAL (decl) = finfo->interface_only;
-	}
-
-  defer_p = 1;
-}
-  /* Likewise for template instantiations.  */
-  else if (DECL_LANG_SPECIFIC (decl)
-	   && DECL_IMPLICIT_INSTANTIATION (decl))
+  /* Defer template instantiations.  */
+  if (DECL_LANG_SPECIFIC (decl)
+  && DECL_IMPLICIT_INSTANTIATION (decl))
 defer_p = 1;
 
   /* If we're not deferring, go ahead and assemble the variable.  */
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrcomp1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrcomp1.C
new file mode 100644
index 000..2eee1b0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrcomp1.C
@@ -0,0 +1,8 @@
+// PR c++/65509
+// { dg-do compile { target c++11 } }
+
+const int i1 = 1;
+const int i2 = 2;
+
+#define SA(X) static_assert (X,#X)
+SA(&i1 != &i2);


[gcc patch] libcc1: '@' GDB array operator

2015-03-27 Thread Jan Kratochvil
Hi,

there is now pending GDB patch for: (gdb) compile print EXPR
[PATCH 4/4] compile: New 'compile print'
https://sourceware.org/ml/gdb-patches/2015-03/msg00875.html

Reasons for this patch:
How to implement '@' GDB-like operator for libcc1
https://gcc.gnu.org/ml/gcc/2015-03/msg00175.html

Testcase is in the GDB patch.  There could be a testcase in the 'guality' part
of GCC testsuite.

I have some doubts if the copy_node() way is right.

The error for stray '@' is now reported elsewhere so for example
int a=1@a;
produced
stray.c:1:8: error: stray ‘@’ in program
 int a=1@a;
^
stray.c:1:9: error: expected ‘,’ or ‘;’ before ‘a’
 int a=1@a;
 ^
but now it produces:
stray.c:1:8: error: stray ‘@’ in program
 int a=1@a;
^
stray.c:1:8: error: expected ‘,’ or ‘;’ before ‘@’ token
It is because in c-family/c-common.c we cannot yet access c_binding_oracle
(whether GDB is present) as c_binding_oracle is c-specific symbol while
c-family/c-common.c is linked for both c and c++; so c_binding_oracle symbol
is missing when linking cc1plus.  As there should be also C++ support for
libcc1 in the future c_binding_oracle will need to be present for both C and
C++.  But so far I have left it as submitted.

GCC testsuite has passed without regressions.


Thanks,
Jan
gcc/c-family/
2015-03-27  Jan Kratochvil  

* c-common.c (c_fully_fold_internal, binary_op_error): Add ATSIGN_EXPR.
* c-lex.c (c_lex_with_flags): Add ATSIGN_EXPR.

gcc/c/
2015-03-27  Jan Kratochvil  

* c-parser.c (enum c_parser_prec): Add PREC_ATSIGN.
(c_parser_binary_expression): Add CPP_ATSIGN.
* c-typeck.c (build_binary_op): Add ATSIGN_EXPR.

gcc/
2015-03-27  Jan Kratochvil  

* tree-pretty-print.c (dump_generic_node, op_symbol_code): Add
ATSIGN_EXPR.
* tree.def: Add ATSIGN_EXPR.

diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 456c619..37cb104c 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -1289,6 +1289,28 @@ c_fully_fold_internal (tree expr, bool in_init, bool 
*maybe_const_operands,
   ret = fold (ret);
   goto out;
 
+case ATSIGN_EXPR:
+  orig_op0 = op0 = TREE_OPERAND (expr, 0);
+  orig_op1 = op1 = TREE_OPERAND (expr, 1);
+  op0 = c_fully_fold_internal (op0, in_init, maybe_const_operands,
+  maybe_const_itself);
+  STRIP_TYPE_NOPS (op0);
+  op1 = c_fully_fold_internal (op1, in_init, maybe_const_operands,
+  maybe_const_itself);
+  STRIP_TYPE_NOPS (op1);
+  op1 = decl_constant_value_for_optimization (op1);
+  ret = copy_node (op0);
+  TREE_TYPE (ret) = build_array_type_nelts (TREE_TYPE (op0),
+   tree_to_uhwi (op1));
+  if (ret != expr)
+   {
+ TREE_READONLY (ret) = TREE_READONLY (expr);
+ TREE_SIDE_EFFECTS (ret) = TREE_SIDE_EFFECTS (expr);
+ TREE_THIS_VOLATILE (ret) = TREE_THIS_VOLATILE (expr);
+   }
+  ret = fold (ret);
+  goto out;
+
 case COMPOUND_EXPR:
 case MODIFY_EXPR:
 case PREDECREMENT_EXPR:
@@ -4084,6 +4106,8 @@ binary_op_error (location_t location, enum tree_code code,
   opname = "||"; break;
 case BIT_XOR_EXPR:
   opname = "^"; break;
+case ATSIGN_EXPR:
+  opname = "@"; break;
 default:
   gcc_unreachable ();
 }
diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c
index bb55be8..3a9f968 100644
--- a/gcc/c-family/c-lex.c
+++ b/gcc/c-family/c-lex.c
@@ -515,7 +515,10 @@ c_lex_with_flags (tree *value, location_t *loc, unsigned 
char *cpp_flags,
  break;
}
 
-  /* FALLTHROUGH */
+  // Create ATSIGN_EXPR for GDB.
+  *value = NULL_TREE;
+  break;
+
 case CPP_HASH:
 case CPP_PASTE:
   {
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 5cc3892..2a30d72 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -1173,6 +1173,7 @@ enum c_parser_prec {
   PREC_EQ,
   PREC_REL,
   PREC_SHIFT,
+  PREC_ATSIGN,
   PREC_ADD,
   PREC_MULT,
   NUM_PRECS
@@ -6283,6 +6284,16 @@ c_parser_binary_expression (c_parser *parser, struct 
c_expr *after,
  oprec = PREC_ADD;
  ocode = MINUS_EXPR;
  break;
+   case CPP_ATSIGN:
+ if (!c_binding_oracle)
+   {
+ error_at (c_parser_peek_token (parser)->location,
+   "stray %qs in program", "@");
+ goto out;
+   }
+ oprec = PREC_ATSIGN;
+ ocode = ATSIGN_EXPR;
+ break;
case CPP_LSHIFT:
  oprec = PREC_SHIFT;
  ocode = LSHIFT_EXPR;
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index ebe4c73..22e7bd8 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -10976,6 +10976,19 @@ build_binary_op (location_t location, enum tree_code 
code,
maybe_warn_b

Re: C++ PATCH for c++/65556 (ICE with switch and bit-fields)

2015-03-27 Thread Jason Merrill

OK.

Jason


Re: [PATCH] Fix size & type for cold partition names (hot-cold function partitioning)

2015-03-27 Thread Caroline Tice
It took  me a while to get a test case I'm happy with, so I'm
re-submitting the whole patch for approval.

2015-03-27  Caroline Tice  

* final.c (final_scan_insn): Change 'cold_function_name' to
'cold_partition_name' and make it a global variable; also output
assembly to give it a 'FUNC' type, if appropriate.
* varasm.c (cold_partition_name): Declare and initialize global
variable.
(assemble_start_function): Re-set value for cold_partition_name.
(assemble_end_function): Output assembly to calculate size of cold
partition, and associate size with name, if appropriate.
* varash.h (cold_partition_name): Add extern declaration for global
variable.
* testsuite/gcc.dg/tree-prof/cold_partition_label.c: Add dg-final-use
to scan assembly for cold partition name and size.


I've attached the whole patch, with the testcase (which is the only
thing that has changed since the previous patch).

-- Caroline Tice
cmt...@google.com

On Mon, Dec 8, 2014 at 1:06 PM, Jeff Law  wrote:
> On 12/05/14 15:41, Caroline Tice wrote:
>>
>> When hot/cold function splitting occurs, a symbol is generated for the
>> cold partition, and gets output in the assembly & debug info, but the
>> symbol currently gets a size of 0 and a type of NOTYPE, as in this
>> example (on x86_64-linux) from the cold_partition_label test in the
>> testsuite:
>>
>> $ readelf -sW cold_partition_label.x02 | grep foo
>>  36: 00400450 0 NOTYPE  LOCAL  DEFAULT   12 foo.cold.0
>>  58: 0040049043 FUNCGLOBAL DEFAULT   12 foo
>> $
>>
>> This patch fixes this by calculating the right size for the partition,
>> and outputing the size and type fo the cold partition symbol.  After
>> applying this patch and looking at the same test, I get:
>>
>> $ readelf -sW cold_partition_label.x02 | grep foo
>>  36: 0040045029 FUNCLOCAL  DEFAULT   12 foo.cold.0
>>  58: 0040049043 FUNCGLOBAL DEFAULT   12 foo
>> $
>>
>> This patch has been tested by bootstrapping the compiler, running the
>> dejagnu testsuite with no regressions, and checked as shown above that
>> it fixes the original problem.  Is this patch OK to commit to ToT?
>>
>> -- Caroline Tice
>> cmt...@google.com
>>
>>   2014-12-05  Caroline Tice  
>>
>>  * final.c (final_scan_insn): Change 'cold_function_name' to
>>  'cold_partition_name' and make it a global variable; also output
>>  assembly to give it a 'FUNC' type, if appropriate.
>>  * varasm.c (cold_partition_name): Declare and initialize global
>>  variable.
>>  (assemble_start_function): Re-set value for cold_partition_name.
>>  (assemble_end_function): Output assembly to calculate size of
>> cold
>>  partition, and associate size with name, if appropriate.
>>  * varash.h (cold_partition_name): Add extern declaration for
>> global
>>  variable.
>
> OK for the trunk.  I'm ever-so-slightly worried about the PA and PTX ports
> are they're probably the most sensitive to types.  But we'll deal with them
> if they complain.
>
> Adding a testcase would be helpful.  I believe some of the LTO tests use
> readelf, so there should be some infrastructure you can factor out and
> reuse.
>
> jeff
Index: gcc/final.c
===
--- gcc/final.c	(revision 221669)
+++ gcc/final.c	(working copy)
@@ -2236,10 +2236,16 @@
 	 suffixing "cold" to the original function's name.  */
 	  if (in_cold_section_p)
 	{
-	  tree cold_function_name
+	  cold_function_name
 		= clone_function_name (current_function_decl, "cold");
+#ifdef ASM_DECLARE_FUNCTION_NAME
+	  ASM_DECLARE_FUNCTION_NAME (asm_out_file,
+	 IDENTIFIER_POINTER (cold_function_name),
+	 current_function_decl);
+#else
 	  ASM_OUTPUT_LABEL (asm_out_file,
 IDENTIFIER_POINTER (cold_function_name));
+#endif
 	}
 	  break;
 
Index: gcc/testsuite/gcc.dg/tree-prof/cold_partition_label.c
===
--- gcc/testsuite/gcc.dg/tree-prof/cold_partition_label.c	(revision 221669)
+++ gcc/testsuite/gcc.dg/tree-prof/cold_partition_label.c	(working copy)
@@ -35,4 +35,6 @@
   return 0;
 }
 
+/* { dg-final-use { scan-assembler "foo\[._\]+cold\[\._\]+0" } } */
+/* { dg-final-use { scan-assembler "size\[ \ta-zA-Z0-0\]+foo\[._\]+cold\[\._\]+0" } } */
 /* { dg-final-use { cleanup-saved-temps } } */
Index: gcc/varasm.c
===
--- gcc/varasm.c	(revision 221669)
+++ gcc/varasm.c	(working copy)
@@ -187,6 +187,13 @@
at the cold section.  */
 bool in_cold_section_p;
 
+/* The following global holds the "function name" for the code in the
+   cold section of a function, if hot/cold function splitting is enabled
+   and there was actually code that went into the cold section.  A
+   pseudo function name is need

Re: [PATCH] PR target/65248: Copy relocation against protected symbol doesn't work

2015-03-27 Thread H.J. Lu
On Wed, Mar 18, 2015 at 12:11 PM, H.J. Lu  wrote:
> On Wed, Mar 18, 2015 at 11:58 AM, Mike Stump  wrote:
>> On Mar 18, 2015, at 2:55 AM, Uros Bizjak  wrote:
>>>
 Here is the updated patch with testcases.  Tested on Linux/x86.  OK
 for trunk?
>>
>>> This patch needs global reviewer approval (I have added Jakub to CC)
>>> and Darwin maintainer approval.
>>
>> So, my concern would be this, does the bug also impact darwin, and does the 
>> bug fix also fix darwin?
>
> This bug doesn't impact darwin.
>
>> If no and the change doesn’t change code-gen for darwin (which I think it 
>> does not), then the darwin bits are ok.
>>
>> I did a quick check of the test case on darwin, no protected variables (we 
>> ignore the protected request).  When compiled, the program works (returns 0).
>
> It is expected.  This bug only affects targets which support protected
> visibility and use copy relocation.
>

Hi Jakub,

I'd like to fix this bug for GCC 5.  Is that OK for trunk:

https://gcc.gnu.org/ml/gcc-patches/2015-03/msg00325.html

It only impacts Linux/x86.

Thanks.

-- 
H.J.


Re: [PATCH] PR target/65248: Copy relocation against protected symbol doesn't work

2015-03-27 Thread Uros Bizjak
On Fri, Mar 27, 2015 at 5:52 PM, H.J. Lu  wrote:
> On Wed, Mar 18, 2015 at 12:11 PM, H.J. Lu  wrote:
>> On Wed, Mar 18, 2015 at 11:58 AM, Mike Stump  wrote:
>>> On Mar 18, 2015, at 2:55 AM, Uros Bizjak  wrote:

> Here is the updated patch with testcases.  Tested on Linux/x86.  OK
> for trunk?
>>>
 This patch needs global reviewer approval (I have added Jakub to CC)
 and Darwin maintainer approval.
>>>
>>> So, my concern would be this, does the bug also impact darwin, and does the 
>>> bug fix also fix darwin?
>>
>> This bug doesn't impact darwin.
>>
>>> If no and the change doesn’t change code-gen for darwin (which I think it 
>>> does not), then the darwin bits are ok.
>>>
>>> I did a quick check of the test case on darwin, no protected variables (we 
>>> ignore the protected request).  When compiled, the program works (returns 
>>> 0).
>>
>> It is expected.  This bug only affects targets which support protected
>> visibility and use copy relocation.
>>
>
> Hi Jakub,
>
> I'd like to fix this bug for GCC 5.  Is that OK for trunk:
>
> https://gcc.gnu.org/ml/gcc-patches/2015-03/msg00325.html
>
> It only impacts Linux/x86.

Jakub, does the patch look OK to you? I am not that familiar with this
part of the code ...

Uros.


[PATCH] Fix ICE with -fpie (PR target/65593)

2015-03-27 Thread Jakub Jelinek
Hi!

For %rip addressing, we only can use disp32 and thus can add
constants to the symbol/label, but not a register etc., as
there is no instruction supporting (plus (symbol_ref) (reg))
for PIC.

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

2015-03-27  Jakub Jelinek  

PR target/65593
* config/i386/i386.c (legitimize_pic_address): If base
is SYMBOL_REF or LABEL_REF using %rip addressing, force
it to reg to avoid PLUS of SYMBOL_REF/LABEL_REF and register.

* gcc.c-torture/compile/pr65593.c: New test.

--- gcc/config/i386/i386.c.jj   2015-03-23 16:31:27.0 +0100
+++ gcc/config/i386/i386.c  2015-03-27 14:19:54.646117550 +0100
@@ -13881,6 +13881,12 @@ legitimize_pic_address (rtx orig, rtx re
}
  else
{
+ /* For %rip addressing, we have to use just disp32, not
+base nor index.  */
+ if (TARGET_64BIT
+ && (GET_CODE (base) == SYMBOL_REF
+ || GET_CODE (base) == LABEL_REF))
+   base = force_reg (mode, base);
  if (GET_CODE (new_rtx) == PLUS
  && CONSTANT_P (XEXP (new_rtx, 1)))
{
--- gcc/testsuite/gcc.c-torture/compile/pr65593.c.jj2015-03-27 
14:40:55.973767411 +0100
+++ gcc/testsuite/gcc.c-torture/compile/pr65593.c   2015-03-27 
14:42:19.697417036 +0100
@@ -0,0 +1,4 @@
+/* PR target/65593 */
+/* { dg-additional-options "-fpie" { target pie } } */
+
+#include "pr20928.c"

Jakub


Re: [PATCH] Fix ICE with -fpie (PR target/65593)

2015-03-27 Thread Uros Bizjak
On Fri, Mar 27, 2015 at 6:08 PM, Jakub Jelinek  wrote:

> For %rip addressing, we only can use disp32 and thus can add
> constants to the symbol/label, but not a register etc., as
> there is no instruction supporting (plus (symbol_ref) (reg))
> for PIC.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK for trunk and release branches.

Thanks,
Uros.


Re: [PATCH, alpha]: Fix PR/47230 [4.6/4.7 Regression] gcc fails to bootstrap on alpha in stage2 with "relocation truncated to fit: GPREL16 against ..."

2015-03-27 Thread Uros Bizjak
On Wed, Mar 4, 2015 at 3:30 PM, Uros Bizjak  wrote:
> On Wed, Mar 4, 2015 at 2:56 PM, Uros Bizjak  wrote:
>
>>> Unfortunately, while "normal" bootstrap works OK with alpha-linux-gnu
>>> and alphaev68-linux-gnu, the bootstrap still fails when configured
>>> --with-build-config=bootstrap-lto:
>
> [...]
>
>>> ../../gcc-svn/trunk/gcc/lto/Make-lang.in:71: recipe for target 'lto1' failed
>>> gmake[3]: *** [lto1] Error 1
>>
>> I just noticed that this error is from LTO profiledbootstrap build,
>> with the failed command:

The removal of the GPREL16 failure workaround has been reverted.

Uros.


Re: [PATCH] PR target/65248: Copy relocation against protected symbol doesn't work

2015-03-27 Thread Richard Henderson
On 03/06/2015 05:42 AM, H.J. Lu wrote:
> gcc/
> 
>   PR target/65248
>   * output.h (default_binds_local_p_2): New.
>   * varasm.c (default_binds_local_p_2): Renamed to ...
>   (default_binds_local_p_3): This.  Don't return true on protected
>   data symbol if protected data may be external.
>   (default_binds_local_p): Use default_binds_local_p_3.
>   (default_binds_local_p_1): Likewise.
>   (default_binds_local_p_2): New.
>   * config/i386/i386.c (TARGET_BINDS_LOCAL_P): Replace
>   darwin_binds_local_p with default_binds_local_p_2.

Ok.

>   PR target/65248
>   * gcc.target/i386/pr65248-1.c: New file.
>   * gcc.target/i386/pr65248-2.c: Likewise.
>   * gcc.target/i386/pr65248-3.c: Likewise.
>   * gcc.target/i386/pr65248-4.c: Likewise.

These need some tidying, I think.

> +/* { dg-final { scan-assembler-not "movl\[ \t\]xxx\\(%rip\\), %eax" { target 
> { ! ia32 } } } } */
> +/* { dg-final { scan-assembler "xxx@GOTPCREL" { target { ! ia32 } } } } */
> +/* { dg-final { scan-assembler-not "movl\[ \t\]xxx@GOTOFF\\(%\[^,\]*\\), 
> %eax" { target ia32 } } } */
> +/* { dg-final { scan-assembler "movl\[ \t\]xxx@GOT\\(%\[^,\]*\\), %eax" { 
> target ia32 } } } */

The second line is what the rest of these should look like.  You don't need to
scan for movl or %eax.  The relocation used is the only thing that's relevant.
 Thus

xxx\\(%rip\\)
xxx@GOTPCREL
xxx@GOTOFF
xxx@GOT\\(

respectively.


r~


[PR64164] drop copyrename, integrate into expand

2015-03-27 Thread Alexandre Oliva
This patch reworks the out-of-ssa expander to enable coalescing of SSA
partitions that don't share the same base name.  This is done only when
optimizing.

The test we use to tell whether two partitions can be merged no longer
demands them to have the same base variable when optimizing, so they
become eligible for coalescing, as they would after copyrename.  We then
compute the partitioning we'd get if all coalescible partitions were
coalesced, using this partition assignment to assign base vars numbers.
These base var numbers are then used to identify conflicts, which used
to be based on shared base vars or base types.

We now propagate base var names during coalescing proper, only towards
the leader variable.  I'm no longer sure this is still needed, but
something about handling variables and results led me this way and I
didn't revisit it.  I might rework that with a later patch, or a later
revision of this patch; it would require other means to identify
partitions holding result_decls during merging, or allow that and deal
with param and result decls in a different way during expand proper.

I had to fix two lingering bugs in order for the whole thing to work: we
perform conflict detection after abnormal coalescing, but we computed
live ranges involving only the partition leaders, so conflicts with
other names already coalesced wouldn't be detected.  The other problem
was that we didn't track default defs for parms as live at entry, so
they might end up coalesced.  I guess none of these problems would have
been exercised in practice, because we wouldn't even consider merging
ssa names associated with different variables.

In the end, I verified that this fixed the codegen regression in the
PR64164 testcase, that failed to merge two partitions that could in
theory be merged, but that wasn't even considered due to differences in
the SSA var names.

I'd agree that disregarding the var names and dropping 4 passes is too
much of a change to fix this one problem, but...  it's something we
should have long tackled, and it gets this and other jobs done, so...

Regstrapped on x86_64-linux-gnu native and on i686-pc-linux-gnu native
on x86_64, so without lto.  Is this ok to install?


for  gcc/ChangeLog

PR rtl-optimization/64164
* Makefile.in (OBJS): Drop tree-ssa-copyrename.o.
* tree-ssa-copyrename.c: Removed.
* opts.c (default_options_table): Drop -ftree-copyrename.
* passes.def: Drop all occurrences of pass_rename_ssa_copies.
* common.opt (ftree-copyrename): Ignore.
(ftree-coalesce-vars, ftree-coalesce-inlined-vars): Likewise.
* doc/invoke.texi: Remove the ignored options above.
* gimple-expr.c (gimple_can_coalesce_p): Allow coalescing
across base variables when optimizing.
* tree-ssa-coalesce.c (build_ssa_conflict_graph): Process
PARM_DECLs's default defs at the entry point.
(attempt_coalesce): Add param_defaults argument, and
track the presence of default defs for params in each
partition.  Propagate base var to leader on merge, preferring
parms and results, named vars, ignored vars, and then anon
vars.  Refuse to merge a RESULT_DECL partition with a default
PARM_DECL one.
(perform_abnormal_coalescing): Add param_defaults argument,
and pass it to attempt_coalesce.
(coalesce_partitions): Likewise.
(dump_part_var_map): New.
(compute_optimized_partition_bases): New, called by...
(coalesce_ssa_name): ... when optimizing, disabling
partition_view_bitmap's base assignment.  Pass local
param_defaults to coalescer functions.
* tree-ssa-live.c (var_map_base_init): Note use only when not
optimizing.
(calculate_live_ranges): Initialize for all SSA names, not
just partition leaders.
---
 gcc/Makefile.in   |1 
 gcc/common.opt|   12 +
 gcc/doc/invoke.texi   |   29 ---
 gcc/gimple-expr.c |7 -
 gcc/opts.c|1 
 gcc/passes.def|5 
 gcc/tree-ssa-coalesce.c   |  336 ++
 gcc/tree-ssa-copyrename.c |  499 -
 gcc/tree-ssa-live.c   |   11 +
 9 files changed, 347 insertions(+), 554 deletions(-)
 delete mode 100644 gcc/tree-ssa-copyrename.c

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index de1f3b6..b3149ba 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1427,7 +1427,6 @@ OBJS = \
tree-ssa-ccp.o \
tree-ssa-coalesce.o \
tree-ssa-copy.o \
-   tree-ssa-copyrename.o \
tree-ssa-dce.o \
tree-ssa-dom.o \
tree-ssa-dse.o \
diff --git a/gcc/common.opt b/gcc/common.opt
index b49ac46..fefaee7 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2207,16 +2207,16 @@ Common Report Var(flag_tree_ch) Optimization
 Enable loop header copying on trees
 
 ftree-coalesce-inlined-vars
-Common Report Var(flag_ssa

Re: [PATCH] PR target/65248: Copy relocation against protected symbol doesn't work

2015-03-27 Thread H.J. Lu
On Fri, Mar 27, 2015 at 10:19 AM, Richard Henderson  wrote:
> On 03/06/2015 05:42 AM, H.J. Lu wrote:
>> gcc/
>>
>>   PR target/65248
>>   * output.h (default_binds_local_p_2): New.
>>   * varasm.c (default_binds_local_p_2): Renamed to ...
>>   (default_binds_local_p_3): This.  Don't return true on protected
>>   data symbol if protected data may be external.
>>   (default_binds_local_p): Use default_binds_local_p_3.
>>   (default_binds_local_p_1): Likewise.
>>   (default_binds_local_p_2): New.
>>   * config/i386/i386.c (TARGET_BINDS_LOCAL_P): Replace
>>   darwin_binds_local_p with default_binds_local_p_2.
>
> Ok.
>
>>   PR target/65248
>>   * gcc.target/i386/pr65248-1.c: New file.
>>   * gcc.target/i386/pr65248-2.c: Likewise.
>>   * gcc.target/i386/pr65248-3.c: Likewise.
>>   * gcc.target/i386/pr65248-4.c: Likewise.
>
> These need some tidying, I think.
>
>> +/* { dg-final { scan-assembler-not "movl\[ \t\]xxx\\(%rip\\), %eax" { 
>> target { ! ia32 } } } } */
>> +/* { dg-final { scan-assembler "xxx@GOTPCREL" { target { ! ia32 } } } } */
>> +/* { dg-final { scan-assembler-not "movl\[ \t\]xxx@GOTOFF\\(%\[^,\]*\\), 
>> %eax" { target ia32 } } } */
>> +/* { dg-final { scan-assembler "movl\[ \t\]xxx@GOT\\(%\[^,\]*\\), %eax" { 
>> target ia32 } } } */
>
> The second line is what the rest of these should look like.  You don't need to
> scan for movl or %eax.  The relocation used is the only thing that's relevant.
>  Thus
>
> xxx\\(%rip\\)
> xxx@GOTPCREL
> xxx@GOTOFF
> xxx@GOT\\(
>
> respectively.
>

This is the patch I am checking in.

Thanks.

-- 
H.J.
From ee047bc7f6f7cdaf955cc018ddd746b09b7708e2 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" 
Date: Fri, 27 Mar 2015 11:05:13 -0700
Subject: [PATCH] Add default_binds_local_p_2 and use it for x86

Protected data symbol means that it can't be pre-emptied.  It doesn't mean
its address won't be external.  This is true for pointer to protected
function.  With copy relocation, address of protected data defined in the
shared library may also be external.  We only know that for sure at
run-time.  TARGET_BINDS_LOCAL_P should return false on protected data
symbol.

gcc/

	PR target/65248
	* output.h (default_binds_local_p_2): New.
	* varasm.c (default_binds_local_p_2): Renamed to ...
	(default_binds_local_p_3): This.  Don't return true on protected
	data symbol if protected data may be external.
	(default_binds_local_p): Use default_binds_local_p_3.
	(default_binds_local_p_1): Likewise.
	(default_binds_local_p_2): New.
	* config/i386/i386.c (TARGET_BINDS_LOCAL_P): Replace
	darwin_binds_local_p with default_binds_local_p_2.

gcc/testsuite/

	PR target/65248
	* gcc.target/i386/pr65248-1.c: New file.
	* gcc.target/i386/pr65248-2.c: Likewise.
	* gcc.target/i386/pr65248-3.c: Likewise.
	* gcc.target/i386/pr65248-4.c: Likewise.
---
 gcc/config/i386/i386.c|  3 +++
 gcc/output.h  |  1 +
 gcc/testsuite/gcc.target/i386/pr65248-1.c | 17 +
 gcc/testsuite/gcc.target/i386/pr65248-2.c | 17 +
 gcc/testsuite/gcc.target/i386/pr65248-3.c | 17 +
 gcc/testsuite/gcc.target/i386/pr65248-4.c | 17 +
 gcc/varasm.c  | 18 +++---
 7 files changed, 87 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr65248-1.c
 create mode 100644 gcc/testsuite/gcc.target/i386/pr65248-2.c
 create mode 100644 gcc/testsuite/gcc.target/i386/pr65248-3.c
 create mode 100644 gcc/testsuite/gcc.target/i386/pr65248-4.c

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 22bc81f..01eb41d 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -51894,6 +51894,9 @@ ix86_initialize_bounds (tree var, tree lb, tree ub, tree *stmts)
 #if TARGET_MACHO
 #undef TARGET_BINDS_LOCAL_P
 #define TARGET_BINDS_LOCAL_P darwin_binds_local_p
+#else
+#undef TARGET_BINDS_LOCAL_P
+#define TARGET_BINDS_LOCAL_P default_binds_local_p_2
 #endif
 #if TARGET_DLLIMPORT_DECL_ATTRIBUTES
 #undef TARGET_BINDS_LOCAL_P
diff --git a/gcc/output.h b/gcc/output.h
index 217d979..53e47d0 100644
--- a/gcc/output.h
+++ b/gcc/output.h
@@ -586,6 +586,7 @@ extern void default_asm_output_anchor (rtx);
 extern bool default_use_anchors_for_symbol_p (const_rtx);
 extern bool default_binds_local_p (const_tree);
 extern bool default_binds_local_p_1 (const_tree, int);
+extern bool default_binds_local_p_2 (const_tree);
 extern void default_globalize_label (FILE *, const char *);
 extern void default_globalize_decl_name (FILE *, tree);
 extern void default_emit_unwind_label (FILE *, tree, int, int);
diff --git a/gcc/testsuite/gcc.target/i386/pr65248-1.c b/gcc/testsuite/gcc.target/i386/pr65248-1.c
new file mode 100644
index 000..735adde
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr65248-1.c
@@ -0,0 +1,17 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fpic" }

Re: [PR64164] drop copyrename, integrate into expand

2015-03-27 Thread Alexandre Oliva
On Mar 27, 2015, Alexandre Oliva  wrote:

> Regstrapped on x86_64-linux-gnu native and on i686-pc-linux-gnu native
> on x86_64, so without lto.  Is this ok to install?

Err, sorry, wrong keystroke, I didn't mean to post that message yet, I
was just drafting it while several of the issues were still fresh, and a
wrong keystroke got it out.  I still have a couple of ICEs to look into,
and a number of guality regressions to analyze.  Apologies for setting
false expectations, but I will get there, and when I do, I'll post a
revised patch.

Comments on the one I posted are welcome nevertheless.

-- 
Alexandre Oliva, freedom fighterhttp://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer


Re: [PATCH, ARM] Fix arm_subsi3_insn alternatives

2015-03-27 Thread Kyrill Tkachov


On 24/03/15 19:53, Yvan Roux wrote:

Hi,

after the issue with duplicated alternatives exhibited by PR64208, I
checked the arm.md file and found that *arm_subsi3_insn has a
duplication where alt 4 is (r,rI,r) and alt 6 is (r,r,r), this results
in emitting an rsb instruction instead of a sub one, but it has also
an impact on scheduling as the type attribute affected to alt 4 is
alu_imm when it could only involve registers.

This is fixed by this small patch. Cross builded and regtested for
arm/armeb targets.
Ok for trunk (maybe for stage 1 as no PR is attached to that) ?


Hi Yvan,

I've kicked off two bootstraps of this patch on arm-none-linux-gnueabihf:
one with arm mode and one with thumb. Both are well in stage3 so I don't 
expect

there to be any problems and the patch looks ok to me code-wise (though
I can't approve).

This is stage 1 material by now though since there's no regression 
associated.


Cheers,
Kyrill



Cheers,
Yvan

  2105-03-24  Yvan Roux  

 * config/arm/arm.md ("*arm_subsi3_insn"): Fixed redundant alternatives.




Typo: gcc-5/changes.html

2015-03-27 Thread Magnus Fromreide
In gcc-5/changes.html the section about __has_include and __has_include_next
says:

The header search paths for __has_include_next and __has_include_next are 
equivalent to those of the standard directive #include and the extension 
#include_next respectively.

I think the first __has_include_next should be an __has_include.

/MF


Backport of patch for PR64688 to gcc-4.9 branch

2015-03-27 Thread Vladimir Makarov

  The following patch was ported to gcc-4.9 branch from the mainline.

  The patch was bootstrapped on x86/x86-64.

  Committed as rev. 221743.

2015-03-27  Vladimir Makarov  

Backport from mainline
2015-01-30  Vladimir Makarov 

PR target/64688
* lra-constraints.c (original_subreg_reg_mode): New.
(simplify_operand_subreg): Try to simplify subreg of const.  Use
original_subreg_reg_mode for it.
(swap_operands): Update original_subreg_reg_mode.
(curr_insn_transform): Set up original_subreg_reg_mode.

2015-03-27  Vladimir Makarov  

Backport from mainline
2015-01-30  Vladimir Makarov 

PR target/64688
* g++.dg/pr64688-2.C: New.

Index: lra-constraints.c
===
--- lra-constraints.c   (revision 220294)
+++ lra-constraints.c   (working copy)
@@ -170,6 +170,10 @@ static basic_block curr_bb;
 static lra_insn_recog_data_t curr_id;
 static struct lra_static_insn_data *curr_static_id;
 static machine_mode curr_operand_mode[MAX_RECOG_OPERANDS];
+/* Mode of the register substituted by its equivalence with VOIDmode
+   (e.g. constant) and whose subreg is given operand of the current
+   insn.  VOIDmode in all other cases.  */
+static machine_mode original_subreg_reg_mode[MAX_RECOG_OPERANDS];
 
 
 
@@ -1382,13 +1386,13 @@ static int valid_address_p (machine_mode
 
 /* Make reloads for subreg in operand NOP with internal subreg mode
REG_MODE, add new reloads for further processing.  Return true if
-   any reload was generated.  */
+   any change was done.  */
 static bool
 simplify_operand_subreg (int nop, machine_mode reg_mode)
 {
   int hard_regno;
   rtx_insn *before, *after;
-  machine_mode mode;
+  machine_mode mode, innermode;
   rtx reg, new_reg;
   rtx operand = *curr_id->operand_loc[nop];
   enum reg_class regclass;
@@ -1401,6 +1405,7 @@ simplify_operand_subreg (int nop, machin
 
   mode = GET_MODE (operand);
   reg = SUBREG_REG (operand);
+  innermode = GET_MODE (reg);
   type = curr_static_id->operand[nop].type;
   /* If we change address for paradoxical subreg of memory, the
  address might violate the necessary alignment or the access might
@@ -1419,7 +1424,7 @@ simplify_operand_subreg (int nop, machin
   alter_subreg (curr_id->operand_loc[nop], false);
   subst = *curr_id->operand_loc[nop];
   lra_assert (MEM_P (subst));
-  if (! valid_address_p (GET_MODE (reg), XEXP (reg, 0),
+  if (! valid_address_p (innermode, XEXP (reg, 0),
 MEM_ADDR_SPACE (reg))
  || valid_address_p (GET_MODE (subst), XEXP (subst, 0),
  MEM_ADDR_SPACE (subst)))
@@ -1434,6 +1439,20 @@ simplify_operand_subreg (int nop, machin
   alter_subreg (curr_id->operand_loc[nop], false);
   return true;
 }
+  else if (CONSTANT_P (reg))
+{
+  /* Try to simplify subreg of constant.  It is usually result of
+equivalence substitution.  */
+  if (innermode == VOIDmode
+ && (innermode = original_subreg_reg_mode[nop]) == VOIDmode)
+   innermode = curr_static_id->operand[nop].mode;
+  if ((new_reg = simplify_subreg (mode, reg, innermode,
+ SUBREG_BYTE (operand))) != NULL_RTX)
+   {
+ *curr_id->operand_loc[nop] = new_reg;
+ return true;
+   }
+}
   /* Put constant into memory when we have mixed modes.  It generates
  a better code in most cases as it does not need a secondary
  reload memory.  It also prevents LRA looping when LRA is using
@@ -1453,9 +1472,9 @@ simplify_operand_subreg (int nop, machin
&& (hard_regno = lra_get_regno_hard_regno (REGNO (reg))) >= 0
/* Don't reload paradoxical subregs because we could be looping
  having repeatedly final regno out of hard regs range.  */
-   && (hard_regno_nregs[hard_regno][GET_MODE (reg)]
+   && (hard_regno_nregs[hard_regno][innermode]
   >= hard_regno_nregs[hard_regno][mode])
-   && simplify_subreg_regno (hard_regno, GET_MODE (reg),
+   && simplify_subreg_regno (hard_regno, innermode,
 SUBREG_BYTE (operand), mode) < 0
/* Don't reload subreg for matching reload.  It is actually
  valid subreg in LRA.  */
@@ -1481,7 +1500,7 @@ simplify_operand_subreg (int nop, machin
  bitmap_set_bit (&lra_subreg_reload_pseudos, REGNO (new_reg));
 
  insert_before = (type != OP_OUT
-  || GET_MODE_SIZE (GET_MODE (reg)) > GET_MODE_SIZE 
(mode));
+  || GET_MODE_SIZE (innermode) > GET_MODE_SIZE (mode));
  insert_after = (type != OP_IN);
  insert_move_for_subreg (insert_before ? &before : NULL,
  insert_after ? &after : NULL,
@@ -1524,7 +1543,7 @@ simplify_operand_subreg (int nop, machin
   else if (REG_P (reg)
   && REGNO (reg) >= FIRST_PSEUDO_REGISTER
  

Re: Fix PR 65177: diamonds are not valid execution threads for jump threading

2015-03-27 Thread Jeff Law

On 03/27/2015 02:53 AM, Richard Biener wrote:


Yeah, and refactoring copy_bbs so that the actual edge duplication happens
in another function (thus we can have two of them).

Exactly.




I was also playing with the idea to support value-numbering the stmts
on-the-fly as we copy them and use this for cost estimation of copies
(ok, well - basically do the copy and then either throw it away again
or accept it).
I thought about applying this to loop unrolling, but obviously this also applies
to any block duplication we do during jump threading.
It'd definitely be useful in threading.  It's often the case that PHIs 
in the duplicates are degenerates and we can/should cprop them away and 
perform resultant simplifications that propagation enables.


If we could do that integrated with the actual duplication, then we'd be 
able to drop the phi-only cprop pass which exists solely to clean up 
that stuff.


jeff


[PATCH] fortran/65429 -- don't dereference a null pointer

2015-03-27 Thread Steve Kargl
The following patch avoids the dereferencing of
a null pointer, which led to an ICE.  The patch
here is a slight variation on the patch submitted
by drikosev at otenet dot gr.  The testcase is a
slight variation on the code submitted by FX.

Built and regression tested on x86_64-*-freebsd.

OK to commit?

2015-03-27  Steven G. Kargl  

PR fortran/65429
* decl.c (add_init_expr_to_sym): Do not dereference a null pointer.

2015-03-27  Steven G. Kargl  

PR fortran/65429
* pr65429.f90: New test.

-- 
Steve

Index: gcc/fortran/decl.c
===
--- gcc/fortran/decl.c  (revision 220943)
+++ gcc/fortran/decl.c  (working copy)
@@ -1406,7 +1406,7 @@ add_init_expr_to_sym (const char *name, 
{
  gfc_constructor *c;
  c = gfc_constructor_first (init->value.constructor);
- clen = c->expr->value.character.length;
+ clen = c ? c->expr->value.character.length : 0;
  sym->ts.u.cl->length
= gfc_get_int_expr (gfc_default_integer_kind,
NULL, clen);
Index: gcc/testsuite/gfortran.dg/pr65429.f90
===
--- gcc/testsuite/gfortran.dg/pr65429.f90   (revision 0)
+++ gcc/testsuite/gfortran.dg/pr65429.f90   (working copy)
@@ -0,0 +1,8 @@
+! { dg-do run }
+! PR fortran/65429
+program foo
+character(*), parameter :: s(*)  = [ character(5) :: 'abcde', 'fghij' ]
+if (s(1) /= 'abcde') call abort
+if (s(2) /= 'fghij') call abort
+end program foo
+


Re: C++ PATCH for c++/65556 (ICE with switch and bit-fields)

2015-03-27 Thread H.J. Lu
On Fri, Mar 27, 2015 at 7:38 AM, Marek Polacek  wrote:
> In this testcase we were crashing while trying to gimplify a switch, because
> the types of the switch condition and case constants didn't match.  This ICE
> started with my -Wswitch-with-enum-bit-fields fix where I used the unlowered
> type so that we're able to get hold of the enum type.  The problem with that
> is with ordinary bit-fields: we'll get the underlying type (e.g. long int),
> but subsequent perform_integral_promotions promotes that to int, see
> cp_perform_integral_promotions.  Fixed by using the type of the condition in
> case we're not dealing with an enum bit-field, i.e. do what we've been doing
> before the -Wswitch fix, which ought to make this fix very safe.
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
>
> 2015-03-27  Marek Polacek  
>
> PR c++/65556
> * semantics.c (finish_switch_cond): If the unlowered type is not an
> enum, use the type of the condition.
>
> * c-c++-common/pr65556.c: New test.
>

The new test is failing for me on x86-32 and x32:

https://gcc.gnu.org/ml/gcc-regression/2015-03/msg00392.html

-- 
H.J.


Re: C++ PATCH for c++/65556 (ICE with switch and bit-fields)

2015-03-27 Thread H.J. Lu
On Fri, Mar 27, 2015 at 7:38 AM, Marek Polacek  wrote:
> In this testcase we were crashing while trying to gimplify a switch, because
> the types of the switch condition and case constants didn't match.  This ICE
> started with my -Wswitch-with-enum-bit-fields fix where I used the unlowered
> type so that we're able to get hold of the enum type.  The problem with that
> is with ordinary bit-fields: we'll get the underlying type (e.g. long int),
> but subsequent perform_integral_promotions promotes that to int, see
> cp_perform_integral_promotions.  Fixed by using the type of the condition in
> case we're not dealing with an enum bit-field, i.e. do what we've been doing
> before the -Wswitch fix, which ought to make this fix very safe.
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
>
> 2015-03-27  Marek Polacek  
>
> PR c++/65556
> * semantics.c (finish_switch_cond): If the unlowered type is not an
> enum, use the type of the condition.
>
> * c-c++-common/pr65556.c: New test.
>
> diff --git gcc/cp/semantics.c gcc/cp/semantics.c
> index f325e41..74af7e8 100644
> --- gcc/cp/semantics.c
> +++ gcc/cp/semantics.c
> @@ -1165,6 +1165,8 @@ finish_switch_cond (tree cond, tree switch_stmt)
> }
>/* We want unlowered type here to handle enum bit-fields.  */
>orig_type = unlowered_expr_type (cond);
> +  if (TREE_CODE (orig_type) != ENUMERAL_TYPE)
> +   orig_type = TREE_TYPE (cond);
>if (cond != error_mark_node)
> {
>   /* Warn if the condition has boolean value.  */
> diff --git gcc/testsuite/c-c++-common/pr65556.c 
> gcc/testsuite/c-c++-common/pr65556.c
> index e69de29..c6729a1 100644
> --- gcc/testsuite/c-c++-common/pr65556.c
> +++ gcc/testsuite/c-c++-common/pr65556.c
> @@ -0,0 +1,23 @@
> +/* PR c++/65556 */
> +/* { dg-do compile } */
> +
> +struct S
> +{
> +  long l: 1;
> +  long l2: 41;
> +  unsigned long ul: 1;
> +  unsigned long ul2: 41;


This won't work with 32-bit long.

-- 
H.J.


Re: [PATCH] fortran/65429 -- don't dereference a null pointer

2015-03-27 Thread Tobias Burnus

Steve Kargl wrote:

The following patch avoids the dereferencing of
a null pointer, which led to an ICE.  The patch
here is a slight variation on the patch submitted
by drikosev at otenet dot gr.  The testcase is a
slight variation on the code submitted by FX.

Built and regression tested on x86_64-*-freebsd.
OK to commit?


OK. However, could you additionally add "if (len(s) /= 5) call abort" to 
the test, just to make sure. (It works, I tried it :-)


Thanks for the patch!

Tobias


2015-03-27  Steven G. Kargl  

PR fortran/65429
* decl.c (add_init_expr_to_sym): Do not dereference a null pointer.

2015-03-27  Steven G. Kargl  

 PR fortran/65429
* pr65429.f90: New test.


Re: [PATCH] fortran/65429 -- don't dereference a null pointer

2015-03-27 Thread Dominique Dhumieres
Steve,

AFAICT your test succeeds without your patch and does not test that the ICE
reported by FX is gone (indeed it is with your patch).

TIA

Dominique


Re: [PATCH] fortran/65429 -- don't dereference a null pointer

2015-03-27 Thread Steve Kargl
On Sat, Mar 28, 2015 at 01:01:57AM +0100, Dominique Dhumieres wrote:
> 
> AFAICT your test succeeds without your patch and does not test that the ICE
> reported by FX is gone (indeed it is with your patch).
> 

Yeah, I thought about that, but did not pursue it, yet.
It is a zero-size string issue because FX's initialization
is empty.  I'll play a little bit tomorrow with the
testcase case.

-- 
Steve


[patch, libfortran] Bug 65596 - [4.9,5.0 Regression] NAMELIST bug with f2003: reads too far

2015-03-27 Thread Jerry DeLisle
At first glance this looked like only a regression in 4.9.  While searching for 
the regression I noticed an error in unit.c (probably a copy/paste error). Upon 
correcting that obvious error, the regression found in 4.9 also appeared in 5.0.


The fix is simple and obvious and I have regression tested on 4.9 and 5.0.

I will commit in the next few days, giving others a chance to review.

New test case attached. I used STOP rather than abort just to change things up a 
bit if the case fails. (yes I could have used -fall-intrinsics)


Regards

Jerry

2015-03-27 Jerry DeLisle  

PR libgfortran/65596
* io/transfer.c (data_transfer_init): If in namelist mode and
delimiter is not specified, set it to DELIM_QUOTE, independent
of -std.
* io/unit.c (init_units): Set flags.delim to the correct
initial value of DELIM_UNSPECIFIED.



Index: io/transfer.c
===
--- io/transfer.c	(revision 221744)
+++ io/transfer.c	(working copy)
@@ -2675,8 +2675,7 @@ data_transfer_init (st_parameter_dt *dtp, int read
   if (dtp->u.p.current_unit->delim_status == DELIM_UNSPECIFIED)
 {
   if (ionml && dtp->u.p.current_unit->flags.delim == DELIM_UNSPECIFIED)
-	dtp->u.p.current_unit->delim_status =
-	  compile_options.allow_std & GFC_STD_GNU ? DELIM_QUOTE : DELIM_NONE;
+	dtp->u.p.current_unit->delim_status = DELIM_QUOTE;
   else
 	dtp->u.p.current_unit->delim_status = dtp->u.p.current_unit->flags.delim;
 }
Index: io/unit.c
===
--- io/unit.c	(revision 221744)
+++ io/unit.c	(working copy)
@@ -608,7 +608,7 @@ init_units (void)
   u->flags.position = POSITION_ASIS;
   u->flags.sign = SIGN_SUPPRESS;
   u->flags.decimal = DECIMAL_POINT;
-  u->flags.delim = DECIMAL_UNSPECIFIED;
+  u->flags.delim = DELIM_UNSPECIFIED;
   u->flags.encoding = ENCODING_DEFAULT;
   u->flags.async = ASYNC_NO;
   u->flags.round = ROUND_UNSPECIFIED;
! { dg-do run }
! { dg-options "-std=f2003 -fall-intrinsics" }
! PR65596 Namelist reads too far.
integer ,parameter :: CL=80
integer ,parameter :: AL=4

character(CL) :: mode
character(CL) :: cats(AL)
character(CL) :: dogs(AL)
character(CL) :: rslt(AL)
integer   :: ierr, k

namelist / theList / cats, dogs, mode

open(27,status="scratch")

write(27,'(A)')  "&theList"
write(27,'(A)')  " mode  = 'on'"
write(27,'(A)')  " dogs  = 'Rover',"
write(27,'(A)')  " 'Spot'"
write(27,'(A)')  " cats  = 'Fluffy',"
write(27,'(A)')  " 'Hairball'"
write(27,'(A)') "/"
rewind(27)

mode= 'off'
cats(:) = ''
dogs(:) = ''

read (27, nml=theList, iostat=ierr)

if (ierr .ne. 0) call abort

rslt = ['Rover   ','Spot','','']
if (any(dogs.ne.rslt)) call abort

rslt = ['Fluffy  ','Hairball','','']
if (any(cats.ne.rslt)) call abort

close(27)

contains

subroutine abort()
  close(27)
  stop 500
end subroutine abort

end


Re: [PATCH] gcc/config/c6x/c6x.md: Remove "clobber (match_scratch ...)" in "movmisalign_store".

2015-03-27 Thread Chen Gang
On 3/27/15 21:03, Bernd Schmidt wrote:
> On 03/27/2015 01:05 AM, Chen Gang wrote:
>> For misalignment memory access, c6x gcc will cause issue, so need remove
>> "clobber (match_scratch ...)" which will be symmetric with "movmisalign
>> _load", then pass compiling and generate correct assembly code.
>>
> 
>> * config/c6x/c6x.md (movmisalign_store): Remove "clobber
>> (match_scratch ...)".
> 
> No, that just will make the compiler confuse loads and stores. I've committed 
> the following to fix it (I thought I'd done so a year ago, but probably it 
> was one of those commit against an out-of-date tree situations and it didn't 
> go through).
> 

OK, thanks. Your patch is OK to me. And I shall try to find another c6x
patches within this month (2015-03-31).


Thanks.
-- 
Chen Gang

Open, share, and attitude like air, water, and life which God blessed


[PATCH] gcc/config/c6x/c6x.h: Handle default case for switch statement in TARGET_CPU_CPP_BUILTINS().

2015-03-27 Thread Chen Gang
The related warning:

  g++ -c  -DIN_GCC_FRONTEND -g -O2 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  
-fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing 
-Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual 
-pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings 
-fno-common  -DHAVE_CONFIG_H -I. -Ic-family -I../../gcc-c6x/gcc 
-I../../gcc-c6x/gcc/c-family -I../../gcc-c6x/gcc/../include 
-I../../gcc-c6x/gcc/../libcpp/include  -I../../gcc-c6x/gcc/../libdecnumber 
-I../../gcc-c6x/gcc/../libdecnumber/dpd -I../libdecnumber 
-I../../gcc-c6x/gcc/../libbacktrace   -o c-family/c-cppbuiltin.o -MT 
c-family/c-cppbuiltin.o -MMD -MP -MF c-family/.deps/c-cppbuiltin.TPo 
../../gcc-c6x/gcc/c-family/c-cppbuiltin.c
  In file included from ./tm.h:16:0,
   from ../../gcc-c6x/gcc/c-family/c-cppbuiltin.c:23:
  ../../gcc-c6x/gcc/c-family/c-cppbuiltin.c: In function ‘void 
c_cpp_builtins(cpp_reader*)’:
  ../../gcc-c6x/gcc/config/c6x/c6x.h:85:14: warning: enumeration value 
‘unk_isa’ not handled in switch [-Wswitch]
 switch (c6x_arch)\
^../../gcc-c6x/gcc/c-family/c-cppbuiltin.c:1243:3: note: in 
expansion of macro ‘TARGET_CPU_CPP_BUILTINS’
 TARGET_CPU_CPP_BUILTINS ();
 ^

2015-03-28  Chen Gang  

* config/c6x/c6x.h (TARGET_CPU_CPP_BUILTINS): Handle default
case for switch statement.
---
 gcc/config/c6x/c6x.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/config/c6x/c6x.h b/gcc/config/c6x/c6x.h
index 58a7ac6..b4810be 100644
--- a/gcc/config/c6x/c6x.h
+++ b/gcc/config/c6x/c6x.h
@@ -109,6 +109,9 @@ extern c6x_cpu_t c6x_arch;
  builtin_define ("_TMS320C6400_PLUS"); \
  builtin_define ("_TMS320C6400");  \
  break;\
+   \
+   default:\
+ break;\
}   \
 } while (0)
 
-- 
1.9.3


Re: [Patch, libstdc++/65420] Use constexpr variables as regex_constans flags

2015-03-27 Thread Tim Shen
On Fri, Mar 27, 2015 at 12:44 PM, Jonathan Wakely  wrote:
> I forgot to say that for a { dg-do compile } test you don't need a
> 'test' variable and don't need to #include ,

Committed.


-- 
Regards,
Tim Shen
commit a1b32eec28442e38b830078ce3a9c142b1072647
Author: Tim Shen 
Date:   Fri Mar 27 20:38:53 2015 +

PR libstdc++/65420
* include/bits/regex_constants.h: Use constexpr variables for flags.
* testsuite/28_regex/constants/constexpr.cc: New testcase.

diff --git a/libstdc++-v3/include/bits/regex_constants.h 
b/libstdc++-v3/include/bits/regex_constants.h
index 1ef5a43..e2c7631 100644
--- a/libstdc++-v3/include/bits/regex_constants.h
+++ b/libstdc++-v3/include/bits/regex_constants.h
@@ -77,88 +77,97 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* elements @c ECMAScript, @c basic, @c extended, @c awk, @c grep, @c egrep
* %set.
*/
-  enum syntax_option_type : unsigned int
-  {
-/**
- * Specifies that the matching of regular expressions against a character
- * sequence shall be performed without regard to case.
- */
-icase  = 1 << _S_icase,
-
-/**
- * Specifies that when a regular expression is matched against a character
- * container sequence, no sub-expression matches are to be stored in the
- * supplied match_results structure.
- */
-nosubs = 1 << _S_nosubs,
-
-/**
- * Specifies that the regular expression engine should pay more attention 
to
- * the speed with which regular expressions are matched, and less to the
- * speed with which regular expression objects are constructed. Otherwise
- * it has no detectable effect on the program output.
- */
-optimize   = 1 << _S_optimize,
-
-/**
- * Specifies that character ranges of the form [a-b] should be locale
- * sensitive.
- */
-collate= 1 << _S_collate,
-
-/**
- * Specifies that the grammar recognized by the regular expression engine 
is
- * that used by ECMAScript in ECMA-262 [Ecma International, ECMAScript
- * Language Specification, Standard Ecma-262, third edition, 1999], as
- * modified in section [28.13].  This grammar is similar to that defined
- * in the PERL scripting language but extended with elements found in the
- * POSIX regular expression grammar.
- */
-ECMAScript = 1 << _S_ECMAScript,
-
-/**
- * Specifies that the grammar recognized by the regular expression engine 
is
- * that used by POSIX basic regular expressions in IEEE Std 1003.1-2001,
- * Portable Operating System Interface (POSIX), Base Definitions and
- * Headers, Section 9, Regular Expressions [IEEE, Information Technology --
- * Portable Operating System Interface (POSIX), IEEE Standard 1003.1-2001].
- */
-basic  = 1 << _S_basic,
-
-/**
- * Specifies that the grammar recognized by the regular expression engine 
is
- * that used by POSIX extended regular expressions in IEEE Std 1003.1-2001,
- * Portable Operating System Interface (POSIX), Base Definitions and
- * Headers, Section 9, Regular Expressions.
- */
-extended   = 1 << _S_extended,
-
-/**
- * Specifies that the grammar recognized by the regular expression engine 
is
- * that used by POSIX utility awk in IEEE Std 1003.1-2001.  This option is
- * identical to syntax_option_type extended, except that C-style escape
- * sequences are supported.  These sequences are:
- * , \\a, \\b, \\f, \\n, \\r, \\t , \\v, \\&apos,, &apos,,
- * and \\ddd (where ddd is one, two, or three octal digits).
- */
-awk= 1 << _S_awk,
-
-/**
- * Specifies that the grammar recognized by the regular expression engine 
is
- * that used by POSIX utility grep in IEEE Std 1003.1-2001.  This option is
- * identical to syntax_option_type basic, except that newlines are treated
- * as whitespace.
- */
-grep   = 1 << _S_grep,
-
-/**
- * Specifies that the grammar recognized by the regular expression engine 
is
- * that used by POSIX utility grep when given the -E option in
- * IEEE Std 1003.1-2001.  This option is identical to syntax_option_type
- * extended, except that newlines are treated as whitespace.
- */
-egrep  = 1 << _S_egrep,
-  };
+  enum syntax_option_type : unsigned int { };
+
+  /**
+   * Specifies that the matching of regular expressions against a character
+   * sequence shall be performed without regard to case.
+   */
+  constexpr syntax_option_type icase =
+static_cast(1 << _S_icase);
+
+  /**
+   * Specifies that when a regular expression is matched against a character
+   * container sequence, no sub-expression matches are to be stored in the
+   * supplied match_results structure.
+   */
+  constexpr syntax_option_type nosubs =
+static_cast(1 << _S_nosubs);
+
+  /**
+   * Specifies that the regular expression engine should pay more attention to
+   * the speed with which regular expressions a

Re: [PATCH] gcc/config/c6x/c6x.md: Remove "clobber (match_scratch ...)" in "movmisalign_store".

2015-03-27 Thread Chen Gang
On 3/28/15 09:32, Chen Gang wrote:
> On 3/27/15 21:03, Bernd Schmidt wrote:
>> On 03/27/2015 01:05 AM, Chen Gang wrote:
>>> For misalignment memory access, c6x gcc will cause issue, so need remove
>>> "clobber (match_scratch ...)" which will be symmetric with "movmisalign
>>> _load", then pass compiling and generate correct assembly code.
>>>
>>
>>> * config/c6x/c6x.md (movmisalign_store): Remove "clobber
>>> (match_scratch ...)".
>>
>> No, that just will make the compiler confuse loads and stores. I've 
>> committed the following to fix it (I thought I'd done so a year ago, but 
>> probably it was one of those commit against an out-of-date tree situations 
>> and it didn't go through).
>>
> 
> OK, thanks. Your patch is OK to me. And I shall try to find another c6x
> patches within this month (2015-03-31).
> 

I have reported the related bug 65510, please continue for it, if I need
to continue, please let me know.

Thanks.
-- 
Chen Gang

Open, share, and attitude like air, water, and life which God blessed