[09/12] Remove all but one use of default_hashmap_traits

2015-06-23 Thread Richard Sandiford
After the previous patches in the series, there are three remaining hash
traits that use the key to represent empty and deleted entries.  This patch
makes them use simple_hashmap_traits.


gcc/
* ipa-icf.h (symbol_compare_hash): New class.
(symbol_compare_hashmap_traits): Use it.
* mem-stats.h (mem_alloc_description::mem_location_hash): New class.
(mem_alloc_description::mem_alloc_hashmap_traits): Use it.
(mem_alloc_description::reverse_mem_map_t): Remove redundant
default_hashmap_traits.
* sanopt.c (sanopt_tree_triplet_hash): New class.
(sanopt_tree_triplet_map_traits): Use it.

Index: gcc/ipa-icf.h
===
--- gcc/ipa-icf.h   2015-06-23 15:52:24.937095524 +0100
+++ gcc/ipa-icf.h   2015-06-23 15:52:24.929095617 +0100
@@ -87,10 +87,10 @@ enum sem_item_type
 
 /* Hash traits for symbol_compare_collection map.  */
 
-struct symbol_compare_hashmap_traits: default_hashmap_traits
+struct symbol_compare_hash : nofree_ptr_hash symbol_compare_collection
 {
   static hashval_t
-  hash (const symbol_compare_collection *v)
+  hash (value_type v)
   {
 inchash::hash hstate;
 hstate.add_int (v-m_references.length ());
@@ -107,8 +107,7 @@ struct symbol_compare_hashmap_traits: de
   }
 
   static bool
-  equal_keys (const symbol_compare_collection *a,
- const symbol_compare_collection *b)
+  equal (value_type a, value_type b)
   {
 if (a-m_references.length () != b-m_references.length ()
|| a-m_interposables.length () != b-m_interposables.length ())
@@ -126,6 +125,8 @@ struct symbol_compare_hashmap_traits: de
 return true;
   }
 };
+typedef simple_hashmap_traits symbol_compare_hash
+  symbol_compare_hashmap_traits;
 
 
 /* Semantic item usage pair.  */
Index: gcc/mem-stats.h
===
--- gcc/mem-stats.h 2015-06-23 15:52:24.937095524 +0100
+++ gcc/mem-stats.h 2015-06-23 15:52:24.929095617 +0100
@@ -238,10 +238,10 @@ struct mem_usage_pair
 class mem_alloc_description
 {
 public:
-  struct mem_alloc_hashmap_traits: default_hashmap_traits
+  struct mem_location_hash : nofree_ptr_hash mem_location
   {
 static hashval_t
-hash (const mem_location *l)
+hash (value_type l)
 {
inchash::hash hstate;
 
@@ -253,18 +253,18 @@ struct mem_usage_pair
 }
 
 static bool
-equal_keys (const mem_location *l1, const mem_location *l2)
+equal (value_type l1, value_type l2)
 {
   return l1-m_filename == l2-m_filename
 l1-m_function == l2-m_function
 l1-m_line == l2-m_line;
 }
   };
+  typedef simple_hashmap_traitsmem_location_hash mem_alloc_hashmap_traits;
 
   /* Internal class type definitions.  */
   typedef hash_map mem_location *, T *, mem_alloc_hashmap_traits mem_map_t;
-  typedef hash_map const void *, mem_usage_pairT, default_hashmap_traits
-reverse_mem_map_t;
+  typedef hash_map const void *, mem_usage_pairT  reverse_mem_map_t;
   typedef hash_map const void *, std::pairT *, size_t  
reverse_object_map_t;
   typedef std::pair mem_location *, T * mem_list_t;
 
Index: gcc/sanopt.c
===
--- gcc/sanopt.c2015-06-23 15:52:24.937095524 +0100
+++ gcc/sanopt.c2015-06-23 15:52:24.929095617 +0100
@@ -109,8 +109,11 @@ struct sanopt_tree_triplet
 
 /* Traits class for tree triplet hash maps below.  */
 
-struct sanopt_tree_triplet_map_traits : default_hashmap_traits
+struct sanopt_tree_triplet_hash : typed_noop_remove sanopt_tree_triplet
 {
+  typedef sanopt_tree_triplet value_type;
+  typedef sanopt_tree_triplet compare_type;
+
   static inline hashval_t
   hash (const sanopt_tree_triplet ref)
   {
@@ -122,41 +125,39 @@ struct sanopt_tree_triplet_map_traits :
   }
 
   static inline bool
-  equal_keys (const sanopt_tree_triplet ref1, const sanopt_tree_triplet ref2)
+  equal (const sanopt_tree_triplet ref1, const sanopt_tree_triplet ref2)
   {
 return operand_equal_p (ref1.t1, ref2.t1, 0)
operand_equal_p (ref1.t2, ref2.t2, 0)
operand_equal_p (ref1.t3, ref2.t3, 0);
   }
 
-  templatetypename T
   static inline void
-  mark_deleted (T e)
+  mark_deleted (sanopt_tree_triplet ref)
   {
-e.m_key.t1 = reinterpret_castT * (1);
+ref.t1 = reinterpret_casttree (1);
   }
 
-  templatetypename T
   static inline void
-  mark_empty (T e)
+  mark_empty (sanopt_tree_triplet ref)
   {
-e.m_key.t1 = NULL;
+ref.t1 = NULL;
   }
 
-  templatetypename T
   static inline bool
-  is_deleted (T e)
+  is_deleted (const sanopt_tree_triplet ref)
   {
-return e.m_key.t1 == (void *) 1;
+return ref.t1 == (void *) 1;
   }
 
-  templatetypename T
   static inline bool
-  is_empty (T e)
+  is_empty (const sanopt_tree_triplet ref)
   {
-return e.m_key.t1 == NULL;
+return ref.t1 == NULL;
   }
 };
+typedef simple_hashmap_traits 

Re: [gomp4.1] Add new versions of GOMP_target{,_data,_update} and GOMP_target_enter_exit_data

2015-06-23 Thread Jakub Jelinek
On Tue, Jun 23, 2015 at 05:54:48PM +0300, Ilya Verbin wrote:
 On Tue, Jun 23, 2015 at 13:51:39 +0200, Jakub Jelinek wrote:
   +  /* Set dd on target to 0 for the further check.  */
   +  #pragma omp target map(always to: dd)
   + { dd; }
  
  This reminds me that:
if (ctx-region_type == ORT_TARGET  !(n-value  GOVD_SEEN))
  remove = true;
  in gimplify.c is not what we want, if it is has GOMP_MAP_KIND_ALWAYS,
  then we shouldn't remove it even when it is not mentioned inside of the
  region's body, because it then has side-effects.
 
 OK for gomp-4_1-branch?
 
 
 gcc/
   * gimplify.c (gimplify_adjust_omp_clauses): Don't remove map clause if
   it has map-type-modifier always.
 libgomp/
   * testsuite/libgomp.c/target-11.c (main): Remove dd from target region.

GOMP_MAP_RELEASE uses the GOMP_MAP_FLAG_ALWAYS for something different from
always, because always release and always delete is not meaningful.
But as neither release nor delete can appear on map clause in target region,
it doesn't matter (at least for now).
So the patch is ok, thanks.

Jakub


[committed] Use abort in parloops-exit-first-loop-alt-{3,4}.c

2015-06-23 Thread Tom de Vries

Hi,

committed attached patch as trivial.

Thanks,
- Tom
Use abort in parloops-exit-first-loop-alt-{3,4}.c

2015-06-23  Tom de Vries  t...@codesourcery.com

	* testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c (main): Use
	abort.
	* testsuite/libgomp.c/parloops-exit-first-loop-alt-4.c (main): Same.
---
 libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c | 9 -
 libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-4.c | 6 +-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c
index 43b9194..cb5bf9c 100644
--- a/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c
+++ b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c
@@ -3,6 +3,8 @@
 
 /* Variable bound, reduction.  */
 
+#include stdlib.h
+
 #define N 4000
 
 unsigned int *a;
@@ -25,9 +27,14 @@ main (void)
   unsigned int res;
   unsigned int array[N];
   int i;
+
   for (i = 0; i  N; ++i)
 array[i] = i % 7;
   a = array[0];
+
   res = f (N);
-  return !(res == 11995);
+  if (res != 11995)
+abort ();
+
+  return 0;
 }
diff --git a/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-4.c b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-4.c
index 8599a89..ac420fa 100644
--- a/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-4.c
+++ b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-4.c
@@ -3,6 +3,8 @@
 
 /* Constant bound, reduction.  */
 
+#include stdlib.h
+
 #define N 4000
 
 unsigned int *a;
@@ -29,5 +31,7 @@ main (void)
 array[i] = i % 7;
   a = array[0];
   res = f ();
-  return !(res == 11995);
+  if (res != 11995)
+abort ();
+  return 0;
 }
-- 
1.9.1



[03/12] Move decl hasher to header file

2015-06-23 Thread Richard Sandiford
Like the previous patch, but for decl hashers.  There's only one copy
of this so far, but the idea seems general.


gcc/
* tree-hash-traits.h (tree_decl_hash): New class.
* tree-ssa-strlen.c: Include tree-hash-traits.h.
(stridxlist_hash_traits): Use tree_decl_hash.

Index: gcc/tree-hash-traits.h
===
--- gcc/tree-hash-traits.h  2015-06-23 15:45:22.993947116 +0100
+++ gcc/tree-hash-traits.h  2015-06-23 15:45:22.989947161 +0100
@@ -39,4 +39,18 @@ tree_operand_hash::equal_keys (const_tre
   return operand_equal_p (t1, t2, 0);
 }
 
+/* Hasher for tree decls.  Pointer equality is enough here, but the DECL_UID
+   is a better hash than the pointer value and gives a predictable traversal
+   order.  */
+struct tree_decl_hash : ggc_ptr_hash tree_node
+{
+  static inline hashval_t hash (tree);
+};
+
+inline hashval_t
+tree_decl_hash::hash (tree t)
+{
+  return DECL_UID (t);
+}
+
 #endif
Index: gcc/tree-ssa-strlen.c
===
--- gcc/tree-ssa-strlen.c   2015-06-23 15:45:22.993947116 +0100
+++ gcc/tree-ssa-strlen.c   2015-06-23 15:45:22.989947161 +0100
@@ -73,6 +73,7 @@ the Free Software Foundation; either ver
 #include ipa-ref.h
 #include cgraph.h
 #include ipa-chkp.h
+#include tree-hash-traits.h
 
 /* A vector indexed by SSA_NAME_VERSION.  0 means unknown, positive value
is an index into strinfo vector, negative value stands for
@@ -155,20 +156,7 @@ struct decl_stridxlist_map
   struct stridxlist list;
 };
 
-/* stridxlist hashtable helpers.  */
-
-struct stridxlist_hash_traits : default_hashmap_traits
-{
-  static inline hashval_t hash (tree);
-};
-
-/* Hash a from tree in a decl_stridxlist_map.  */
-
-inline hashval_t
-stridxlist_hash_traits::hash (tree item)
-{
-  return DECL_UID (item);
-}
+typedef simple_hashmap_traits tree_decl_hash stridxlist_hash_traits;
 
 /* Hash table for mapping decls to a chained list of offset - idx
mappings.  */



[06/12] Consolidate string hashers

2015-06-23 Thread Richard Sandiford
This patch replaces various string hashers with a single copy
in hash-traits.h.


gcc/
* hash-traits.h (string_hash, nofree_string_hash): New classes.
* genmatch.c (capture_id_map_hasher): Use nofree_string_hash.
* passes.c (pass_registry_hasher): Likewise.
* config/alpha/alpha.c (string_traits): Likewise.
* config/i386/winnt.c (i386_find_on_wrapper_list): Likewise.
* config/m32c/m32c.c (pragma_traits): Likewise.
* config/mep/mep.c (pragma_traits): Likewise.

gcc/java/
* jcf-io.c (memoized_class_lookups): Use nofree_string_hash.
(find_class): Likewise.

Index: gcc/hash-traits.h
===
--- gcc/hash-traits.h   2015-06-23 15:48:30.751788389 +0100
+++ gcc/hash-traits.h   2015-06-23 15:48:30.743788520 +0100
@@ -121,6 +121,27 @@ pointer_hash Type::is_empty (Type *e)
   return e == NULL;
 }
 
+/* Hasher for const char * strings, using string rather than pointer
+   equality.  */
+
+struct string_hash : pointer_hash const char
+{
+  static inline hashval_t hash (const char *);
+  static inline bool equal (const char *, const char *);
+};
+
+inline hashval_t
+string_hash::hash (const char *id)
+{
+  return htab_hash_string (id);
+}
+
+inline bool
+string_hash::equal (const char *id1, const char *id2)
+{
+  return strcmp (id1, id2) == 0;
+}
+
 /* Remover and marker for entries in gc memory.  */
 
 templatetypename T
@@ -190,6 +211,11 @@ struct ggc_ptr_hash : pointer_hash T,
 template typename T
 struct ggc_cache_ptr_hash : pointer_hash T, ggc_cache_remove T * {};
 
+/* Traits for string elements that should not be freed when an element
+   is deleted.  */
+
+struct nofree_string_hash : string_hash, typed_noop_remove const char * {};
+
 template typename T struct default_hash_traits;
 
 template typename T
Index: gcc/genmatch.c
===
--- gcc/genmatch.c  2015-06-23 15:48:30.751788389 +0100
+++ gcc/genmatch.c  2015-06-23 15:48:30.743788520 +0100
@@ -392,26 +392,7 @@ get_operator (const char *id)
   return 0;
 }
 
-
-/* Helper for the capture-id map.  */
-
-struct capture_id_map_hasher : default_hashmap_traits
-{
-  static inline hashval_t hash (const char *);
-  static inline bool equal_keys (const char *, const char *);
-};
-
-inline hashval_t
-capture_id_map_hasher::hash (const char *id)
-{
-  return htab_hash_string (id);
-}
-
-inline bool
-capture_id_map_hasher::equal_keys (const char *id1, const char *id2)
-{
-  return strcmp (id1, id2) == 0;
-}
+typedef simple_hashmap_traitsnofree_string_hash capture_id_map_hasher;
 
 typedef hash_mapconst char *, unsigned, capture_id_map_hasher cid_map_t;
 
Index: gcc/passes.c
===
--- gcc/passes.c2015-06-23 15:48:30.751788389 +0100
+++ gcc/passes.c2015-06-23 15:48:30.747788453 +0100
@@ -861,29 +861,7 @@ pass_manager::register_dump_files (opt_p
   while (pass);
 }
 
-/* Helper for pass_registry hash table.  */
-
-struct pass_registry_hasher : default_hashmap_traits
-{
-  static inline hashval_t hash (const char *);
-  static inline bool equal_keys (const char *, const char *);
-};
-
-/* Pass registry hash function.  */
-
-inline hashval_t
-pass_registry_hasher::hash (const char *name)
-{
-  return htab_hash_string (name);
-}
-
-/* Hash equal function  */
-
-inline bool
-pass_registry_hasher::equal_keys (const char *s1, const char *s2)
-{
-  return !strcmp (s1, s2);
-}
+typedef simple_hashmap_traitsnofree_string_hash pass_registry_hasher;
 
 static hash_mapconst char *, opt_pass *, pass_registry_hasher
   *name_to_pass_map;
Index: gcc/config/alpha/alpha.c
===
--- gcc/config/alpha/alpha.c2015-06-23 15:48:30.751788389 +0100
+++ gcc/config/alpha/alpha.c2015-06-23 15:48:30.747788453 +0100
@@ -4808,13 +4808,7 @@ alpha_multipass_dfa_lookahead (void)
 
 struct GTY(()) alpha_links;
 
-struct string_traits : default_hashmap_traits
-{
-  static bool equal_keys (const char *const a, const char *const b)
-  {
-return strcmp (a, b) == 0;
-  }
-};
+typedef simple_hashmap_traits nofree_string_hash string_traits;
 
 struct GTY(()) machine_function
 {
Index: gcc/config/i386/winnt.c
===
--- gcc/config/i386/winnt.c 2015-06-23 15:48:30.751788389 +0100
+++ gcc/config/i386/winnt.c 2015-06-23 15:48:30.739788568 +0100
@@ -709,29 +709,6 @@ i386_pe_record_stub (const char *name)
 
 #ifdef CXX_WRAP_SPEC_LIST
 
-/* Hashtable helpers.  */
-
-struct wrapped_symbol_hasher : nofree_ptr_hash const char
-{
-  static inline hashval_t hash (const char *);
-  static inline bool equal (const char *, const char *);
-  static inline void remove (const char *);
-};
-
-inline hashval_t
-wrapped_symbol_hasher::hash (const char *v)
-{
-  return htab_hash_string (v);
-}
-
-/*  Hash table equality 

[05/12] Move TREE_HASH hasher to header file

2015-06-23 Thread Richard Sandiford
One more tree hasher, this time based on TREE_HASH.


gcc/
* tree-hash-traits.h (tree_hash): New class.
* except.c: Include tree-hash-traits.h.
(tree_hash_traits): Use tree_hash.

Index: gcc/tree-hash-traits.h
===
--- gcc/tree-hash-traits.h  2015-06-23 15:47:41.132358999 +0100
+++ gcc/tree-hash-traits.h  2015-06-23 15:47:41.128359041 +0100
@@ -67,4 +67,16 @@ tree_ssa_name_hash::hash (tree t)
   return SSA_NAME_VERSION (t);
 }
 
+/* Hasher for general trees, based on their TREE_HASH.  */
+struct tree_hash : ggc_ptr_hash tree_node
+{
+  static hashval_t hash (tree);
+};
+
+inline hashval_t
+tree_hash::hash (tree t)
+{
+  return TREE_HASH (t);
+}
+
 #endif
Index: gcc/except.c
===
--- gcc/except.c2015-06-23 15:47:41.132358999 +0100
+++ gcc/except.c2015-06-23 15:47:41.128359041 +0100
@@ -161,14 +161,11 @@ Software Foundation; either version 3, o
 #include tree-pass.h
 #include cfgloop.h
 #include builtins.h
+#include tree-hash-traits.h
 
 static GTY(()) int call_site_base;
 
-struct tree_hash_traits : default_hashmap_traits
-{
-  static hashval_t hash (tree t) { return TREE_HASH (t); }
-};
-
+struct tree_hash_traits : simple_hashmap_traits tree_hash {};
 static GTY (()) hash_maptree, tree, tree_hash_traits *type_to_runtime_map;
 
 /* Describe the SjLj_Function_Context structure.  */



Re: [PATCH] c/66516 - missing diagnostic on taking the address of a builtin function

2015-06-23 Thread Martin Sebor

On 06/23/2015 04:29 AM, Jakub Jelinek wrote:

On Tue, Jun 23, 2015 at 12:18:30PM +0200, Marek Polacek wrote:

Is it intended that programs be able to take the address of
the builtins that correspond to libc functions and make calls
to the underlying libc functions via such pointers? (If so,
the patch will need some tweaking.)


I don't think so, at least clang doesn't allow e.g.
size_t (*fp) (const char *) = __builtin_strlen;


Well, clang is irrelevant here, __builtin_strlen etc. is a GNU
extension, so it matters what we decide about it.  As this used to work
for decades (if the builtin function has a libc fallback), suddenly
rejecting it could break various programs that e.g. just
#define strlen __builtin_strlen
or similar.  Can't we really reject it just for the functions
that don't have a unique fallback?


Let me look into it.

Martin


Remove redundant AND from count reduction loop

2015-06-23 Thread Richard Sandiford
We vectorise:

int
f (int *a, int n)
{
  int count = 0;
  for (int i = 0; i  n; ++i)
if (a[i]  255)
  count += 1;
  return count;
}

using an add reduction of a VEC_COND_EXPR COND, {1, 1, ...}, {0, 0, ...}.
This leads to the main loop having an AND with a loop invariant {1, 1, ...}.
E.g. on aarch64:

moviv2.4s, 0x1
.L4:
lsl x5, x4, 4
add x4, x4, 1
cmp w2, w4
ldr q1, [x0, x5]
cmgev1.4s, v3.4s, v1.4s
and v1.16b, v2.16b, v1.16b
add v0.4s, v0.4s, v1.4s
bhi .L4

This patch converts an ADD of that VEC_COND_EXPR into a SUB of COND:

.L4:
lsl x5, x4, 4
add x4, x4, 1
cmp w2, w4
ldr q1, [x0, x5]
cmgev1.4s, v2.4s, v1.4s
sub v0.4s, v0.4s, v1.4s
bhi .L4

At the moment the simplification is done during forwprop4, after the last
dce pass, and so the VEC_COND_EXPR survives until expand.  Richi says
this a known problem.  Of course, the expression gets deleted by
rtl dce, but it means that a scan-tree-dump of the *.optimized output
can't easily tell that the optimisation has triggered.  I've therefore
added a scan-assembler test instead.

Bootstrapped  regression-tested on x86_64-linux-gnu.  Also tested
on aarch64-elf.  OK to install?

Thanks,
Richard


gcc/
* match.pd: Add patterns for vec_conds between -1 and 0, and
between 1 and 0.

gcc/testsuite/
* gcc.target/aarch64/vect-add-sub-cond.c: New test.

Index: gcc/match.pd
===
--- gcc/match.pd2015-06-23 11:42:23.644645975 +0100
+++ gcc/match.pd2015-06-23 11:42:23.760644655 +0100
@@ -973,6 +973,36 @@ along with GCC; see the file COPYING3.
   (cnd @0 @2 @1)))
 
 
+/* Vector comparisons are defined to produce all-one or all-zero results.  */
+(simplify
+ (vec_cond @0 integer_all_onesp@1 integer_zerop@2)
+ (if (tree_nop_conversion_p (type, TREE_TYPE (@0)))
+   (convert @0)))
+
+/* We could instead convert all instances of the vec_cond to negate,
+   but that isn't necessarily a win on its own.  */
+(simplify
+ (plus:c @3 (vec_cond @0 integer_each_onep@1 integer_zerop@2))
+ (if (tree_nop_conversion_p (type, TREE_TYPE (@0)))
+  (minus @3 (convert @0
+
+(simplify
+ (plus:c @3 (view_convert_expr
+(vec_cond @0 integer_each_onep@1 integer_zerop@2)))
+ (if (tree_nop_conversion_p (type, TREE_TYPE (@0)))
+  (minus @3 (convert @0
+
+(simplify
+ (minus @3 (vec_cond @0 integer_each_onep@1 integer_zerop@2))
+ (if (tree_nop_conversion_p (type, TREE_TYPE (@0)))
+  (plus @3 (convert @0
+
+(simplify
+ (minus @3 (view_convert_expr
+   (vec_cond @0 integer_each_onep@1 integer_zerop@2)))
+ (if (tree_nop_conversion_p (type, TREE_TYPE (@0)))
+  (plus @3 (convert @0
+
 /* Simplifications of comparisons.  */
 
 /* We can simplify a logical negation of a comparison to the
Index: gcc/testsuite/gcc.target/aarch64/vect-add-sub-cond.c
===
--- /dev/null   2015-06-02 17:27:28.541944012 +0100
+++ gcc/testsuite/gcc.target/aarch64/vect-add-sub-cond.c2015-06-23 
12:06:27.120203685 +0100
@@ -0,0 +1,94 @@
+/* Make sure that vector comaprison results are not unnecessarily ANDed
+   with vectors of 1.  */
+/* { dg-do compile } */
+/* { dg-options -O2 -ftree-vectorize } */
+
+#define COUNT1(X) if (X) count += 1
+#define COUNT2(X) if (X) count -= 1
+#define COUNT3(X) count += (X)
+#define COUNT4(X) count -= (X)
+
+#define COND1(X) (X)
+#define COND2(X) ((X) ? 1 : 0)
+#define COND3(X) ((X) ? -1 : 0)
+#define COND4(X) ((X) ? 0 : 1)
+#define COND5(X) ((X) ? 0 : -1)
+
+#define TEST_LT(X, Y) ((X)  (Y))
+#define TEST_LE(X, Y) ((X) = (Y))
+#define TEST_GT(X, Y) ((X)  (Y))
+#define TEST_GE(X, Y) ((X) = (Y))
+#define TEST_EQ(X, Y) ((X) == (Y))
+#define TEST_NE(X, Y) ((X) != (Y))
+
+#define COUNT_LOOP(ID, TYPE, CMP_ARRAY, TEST, COUNT) \
+  TYPE \
+  reduc_##ID (__typeof__ (CMP_ARRAY[0]) x) \
+  { \
+TYPE count = 0; \
+for (unsigned int i = 0; i  1024; ++i) \
+  COUNT (TEST (CMP_ARRAY[i], x)); \
+return count; \
+  }
+
+#define COND_LOOP(ID, ARRAY, CMP_ARRAY, TEST, COND) \
+  void \
+  plus_##ID (__typeof__ (CMP_ARRAY[0]) x) \
+  { \
+for (unsigned int i = 0; i  1024; ++i) \
+  ARRAY[i] += COND (TEST (CMP_ARRAY[i], x)); \
+  } \
+  void \
+  plusc_##ID (void) \
+  { \
+for (unsigned int i = 0; i  1024; ++i) \
+  ARRAY[i] += COND (TEST (CMP_ARRAY[i], 10)); \
+  } \
+  void \
+  minus_##ID (__typeof__ (CMP_ARRAY[0]) x) \
+  { \
+for (unsigned int i = 0; i  1024; ++i) \
+  ARRAY[i] -= COND (TEST (CMP_ARRAY[i], x)); \
+  } \
+  void \
+  minusc_##ID (void) \
+  { \
+for (unsigned int i = 0; i  1024; ++i) \
+  ARRAY[i] += COND (TEST (CMP_ARRAY[i], 1)); \
+  }
+
+#define ALL_LOOPS(ID, ARRAY, CMP_ARRAY, TEST) \
+  typedef __typeof__(ARRAY[0]) ID##_type; \
+  COUNT_LOOP (ID##_1, 

Re: [Patch SRA] Fix PR66119 by calling get_move_ratio in SRA

2015-06-23 Thread James Greenhalgh

On Tue, Jun 23, 2015 at 09:52:01AM +0100, Jakub Jelinek wrote:
 On Tue, Jun 23, 2015 at 09:18:52AM +0100, James Greenhalgh wrote:
  This patch fixes the issue by always calling get_move_ratio in the SRA
  code, ensuring that an up-to-date value is used.
 
  Unfortunately, this means we have to use 0 as a sentinel value for
  the parameter - indicating no user override of the feature - and
  therefore cannot use it to disable scalarization. However, there
  are other ways to disable scalarazation (-fno-tree-sra) so this is not
  a great loss.

 You can handle even that.


snip

   enum compiler_param param
 = optimize_function_for_size_p (cfun)
   ? PARAM_SRA_MAX_SCALARIZATION_SIZE_SIZE
   : PARAM_SRA_MAX_SCALARIZATION_SIZE_SPEED;
   unsigned max_scalarization_size = PARAM_VALUE (param) * BITS_PER_UNIT;
   if (!max_scalarization_size  !global_options_set.x_param_values[param])

 Then it will handle explicit --param sra-max-scalarization-size-Os*=0
 differently from implicit 0.

Ah hah! OK, I've respun the patch removing this extra justification in
the documentation and reshuffling the logic a little.

 OT, shouldn't max_scalarization_size be at least unsigned HOST_WIDE_INT,
 so that it doesn't overflow for larger values (0x4000 etc.)?
 Probably need some cast in the multiplication to avoid UB in the compiler.

I've increased the size of max_scalarization_size to a UHWI in this spin.

Bootstrapped and tested on AArch64 and x86-64 with no issues and checked
to see the PR is fixed.

OK for trunk, and gcc-5 in a few days?

Thanks,
James

---
gcc/

2015-06-23  James Greenhalgh  james.greenha...@arm.com

PR tree-optimization/66119
* toplev.c (process_options): Don't set up default values for
the sra_max_scalarization_size_{speed,size} parameters.
* tree-sra (analyze_all_variable_accesses): If no values
have been set for the sra_max_scalarization_size_{speed,size}
parameters, call get_move_ratio to get target defaults.

diff --git a/gcc/toplev.c b/gcc/toplev.c
index 2f43a89..902bfc7 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1301,20 +1301,6 @@ process_options (void)
  so we can correctly initialize debug output.  */
   no_backend = lang_hooks.post_options (main_input_filename);
 
-  /* Set default values for parameters relation to the Scalar Reduction
- of Aggregates passes (SRA and IP-SRA).  We must do this here, rather
- than in opts.c:default_options_optimization as historically these
- tuning heuristics have been based on MOVE_RATIO, which on some
- targets requires other symbols from the backend.  */
-  maybe_set_param_value
-(PARAM_SRA_MAX_SCALARIZATION_SIZE_SPEED,
- get_move_ratio (true) * UNITS_PER_WORD,
- global_options.x_param_values, global_options_set.x_param_values);
-  maybe_set_param_value
-(PARAM_SRA_MAX_SCALARIZATION_SIZE_SIZE,
- get_move_ratio (false) * UNITS_PER_WORD,
- global_options.x_param_values, global_options_set.x_param_values);
-
   /* Some machines may reject certain combinations of options.  */
   targetm.target_option.override ();
 
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 8e34244..5f573f6 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -2549,11 +2549,20 @@ analyze_all_variable_accesses (void)
   bitmap tmp = BITMAP_ALLOC (NULL);
   bitmap_iterator bi;
   unsigned i;
-  unsigned max_scalarization_size
-= (optimize_function_for_size_p (cfun)
-	? PARAM_VALUE (PARAM_SRA_MAX_SCALARIZATION_SIZE_SIZE)
-	: PARAM_VALUE (PARAM_SRA_MAX_SCALARIZATION_SIZE_SPEED))
-  * BITS_PER_UNIT;
+  bool optimize_speed_p = !optimize_function_for_size_p (cfun);
+
+  enum compiler_param param = optimize_speed_p
+			? PARAM_SRA_MAX_SCALARIZATION_SIZE_SPEED
+			: PARAM_SRA_MAX_SCALARIZATION_SIZE_SIZE;
+
+  /* If the user didn't set PARAM_SRA_MAX_SCALARIZATION_SIZE_...,
+ fall back to a target default.  */
+  unsigned HOST_WIDE_INT max_scalarization_size
+= global_options_set.x_param_values[param]
+  ? PARAM_VALUE (param)
+  : get_move_ratio (optimize_speed_p) * UNITS_PER_WORD;
+
+  max_scalarization_size *= BITS_PER_UNIT;
 
   EXECUTE_IF_SET_IN_BITMAP (candidate_bitmap, 0, i, bi)
 if (bitmap_bit_p (should_scalarize_away_bitmap, i)


[10/12] Add helper class for valued-based empty and deleted slots

2015-06-23 Thread Richard Sandiford
part_traits in cfgexpand.c needs to use the value rather than the key to
represent empty and deleted slots.  What it's doing is pretty generic,
so this patch adds a helper class to hash-map-traits.h.


gcc/
* hash-map-traits.h (unbounded_hashmap_traits): New class.
(unbounded_int_hashmap_traits): Likewise.
* cfgexpand.c (part_traits): Use unbounded_int_hashmap_traits.

Index: gcc/hash-map-traits.h
===
--- gcc/hash-map-traits.h   2015-06-23 15:54:04.515950631 +0100
+++ gcc/hash-map-traits.h   2015-06-23 15:54:04.511950679 +0100
@@ -174,4 +174,84 @@ simple_hashmap_traits H::mark_deleted
   H::mark_deleted (entry.m_key);
 }
 
+/* Implement traits for a hash_map with values of type Value for cases
+   in which the key cannot represent empty and deleted slots.  Instead
+   record empty and deleted entries in Value.  Derived classes must
+   implement the hash and equal_keys functions.  */
+
+template typename Value
+struct unbounded_hashmap_traits
+{
+  template typename T static inline void remove (T );
+  template typename T static inline bool is_empty (const T );
+  template typename T static inline bool is_deleted (const T );
+  template typename T static inline void mark_empty (T );
+  template typename T static inline void mark_deleted (T );
+};
+
+template typename Value
+template typename T
+inline void
+unbounded_hashmap_traits Value::remove (T entry)
+{
+  default_hash_traits Value::remove (entry.m_value);
+}
+
+template typename Value
+template typename T
+inline bool
+unbounded_hashmap_traits Value::is_empty (const T entry)
+{
+  return default_hash_traits Value::is_empty (entry.m_value);
+}
+
+template typename Value
+template typename T
+inline bool
+unbounded_hashmap_traits Value::is_deleted (const T entry)
+{
+  return default_hash_traits Value::is_deleted (entry.m_value);
+}
+
+template typename Value
+template typename T
+inline void
+unbounded_hashmap_traits Value::mark_empty (T entry)
+{
+  default_hash_traits Value::mark_empty (entry.m_value);
+}
+
+template typename Value
+template typename T
+inline void
+unbounded_hashmap_traits Value::mark_deleted (T entry)
+{
+  default_hash_traits Value::mark_deleted (entry.m_value);
+}
+
+/* Implement traits for a hash_map from integer type Key to Value in
+   cases where Key has no spare values for recording empty and deleted
+   slots.  */
+
+template typename Key, typename Value
+struct unbounded_int_hashmap_traits : unbounded_hashmap_traits Value
+{
+  static inline hashval_t hash (Key);
+  static inline bool equal_keys (Key, Key);
+};
+
+template typename Key, typename Value
+inline hashval_t
+unbounded_int_hashmap_traits Key, Value::hash (Key k)
+{
+  return k;
+}
+
+template typename Key, typename Value
+inline bool
+unbounded_int_hashmap_traits Key, Value::equal_keys (Key k1, Key k2)
+{
+  return k1 == k2;
+}
+
 #endif // HASH_MAP_TRAITS_H
Index: gcc/cfgexpand.c
===
--- gcc/cfgexpand.c 2015-06-23 15:54:04.515950631 +0100
+++ gcc/cfgexpand.c 2015-06-23 15:54:04.511950679 +0100
@@ -612,25 +612,7 @@ stack_var_cmp (const void *a, const void
   return 0;
 }
 
-struct part_traits : default_hashmap_traits
-{
-  templatetypename T
-static bool
-is_deleted (T e)
-{ return e.m_value == reinterpret_castvoid * (1); }
-
-  templatetypename T static bool is_empty (T e) { return e.m_value == NULL; 
}
-  templatetypename T
-static void
-mark_deleted (T e)
-{ e.m_value = reinterpret_castT (1); }
-
-  templatetypename T
-static void
-mark_empty (T e)
-  { e.m_value = NULL; }
-};
-
+struct part_traits : unbounded_int_hashmap_traits size_t, bitmap {};
 typedef hash_mapsize_t, bitmap, part_traits part_hashmap;
 
 /* If the points-to solution *PI points to variables that are in a partition



Re: [gomp4.1] Add new versions of GOMP_target{,_data,_update} and GOMP_target_enter_exit_data

2015-06-23 Thread Ilya Verbin
On Tue, Jun 23, 2015 at 13:51:39 +0200, Jakub Jelinek wrote:
  +  /* Set dd on target to 0 for the further check.  */
  +  #pragma omp target map(always to: dd)
  +   { dd; }
 
 This reminds me that:
   if (ctx-region_type == ORT_TARGET  !(n-value  GOVD_SEEN))
 remove = true;
 in gimplify.c is not what we want, if it is has GOMP_MAP_KIND_ALWAYS,
 then we shouldn't remove it even when it is not mentioned inside of the
 region's body, because it then has side-effects.

OK for gomp-4_1-branch?


gcc/
* gimplify.c (gimplify_adjust_omp_clauses): Don't remove map clause if
it has map-type-modifier always.
libgomp/
* testsuite/libgomp.c/target-11.c (main): Remove dd from target region.


diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 9b2347a..74fe60b 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -6870,7 +6870,8 @@ gimplify_adjust_omp_clauses (gimple_seq *pre_p, tree 
*list_p)
  if (!DECL_P (decl))
break;
  n = splay_tree_lookup (ctx-variables, (splay_tree_key) decl);
- if (ctx-region_type == ORT_TARGET  !(n-value  GOVD_SEEN))
+ if (ctx-region_type == ORT_TARGET  !(n-value  GOVD_SEEN)
+  !(OMP_CLAUSE_MAP_KIND (c)  GOMP_MAP_FLAG_ALWAYS))
remove = true;
  else if (DECL_SIZE (decl)
TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST
diff --git a/libgomp/testsuite/libgomp.c/target-11.c 
b/libgomp/testsuite/libgomp.c/target-11.c
index 4562d88..0fd183b 100644
--- a/libgomp/testsuite/libgomp.c/target-11.c
+++ b/libgomp/testsuite/libgomp.c/target-11.c
@@ -13,7 +13,7 @@ int main ()
 
   /* Set dd on target to 0 for the further check.  */
   #pragma omp target map(always to: dd)
-   { dd; }
+   ;
 
   dd = 1;
   #pragma omp target map(tofrom: aa) map(always to: bb) \


  -- Ilya


[02/12] Move tree operand hashers to a new header file

2015-06-23 Thread Richard Sandiford
There were three tree operand hashers, so move them to their own
header file.

The typedefs in this and subsequent patches are temporary and
get removed in patch 12.


gcc/
* tree-hash-traits.h: New file.
(tree_operand_hash): New class.
* sanopt.c: Include tree-hash-traits.h.
(sanopt_tree_map_traits): Use tree_operand_hash.
* tree-if-conv.c: Include tree-hash-traits.h.
(phi_args_hash_traits): Use tree_operand_hash.
* tree-ssa-uncprop.c: Include tree-hash-traits.h.
(val_ssa_equiv_hash_traits): Use tree_operand_hash.

Index: gcc/tree-hash-traits.h
===
--- /dev/null   2015-06-02 17:27:28.541944012 +0100
+++ gcc/tree-hash-traits.h  2015-06-23 15:44:07.966809173 +0100
@@ -0,0 +1,42 @@
+/* Traits for hashing trees.
+   Copyright (C) 2014-2015 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+http://www.gnu.org/licenses/.  */
+
+#ifndef tree_hash_traits_h
+#define tree_hash_traits_h
+
+/* Hash for trees based on operand_equal_p.  */
+struct tree_operand_hash : ggc_ptr_hash tree_node
+{
+  static inline hashval_t hash (const_tree);
+  static inline bool equal_keys (const_tree, const_tree);
+};
+
+inline hashval_t
+tree_operand_hash::hash (const_tree t)
+{
+  return iterative_hash_expr (t, 0);
+}
+
+inline bool
+tree_operand_hash::equal_keys (const_tree t1, const_tree t2)
+{
+  return operand_equal_p (t1, t2, 0);
+}
+
+#endif
Index: gcc/sanopt.c
===
--- gcc/sanopt.c2015-06-23 15:44:07.970809082 +0100
+++ gcc/sanopt.c2015-06-23 15:44:07.962809243 +0100
@@ -50,6 +50,7 @@ Software Foundation; either version 3, o
 #include ubsan.h
 #include params.h
 #include tree-ssa-operands.h
+#include tree-hash-traits.h
 
 
 /* This is used to carry information about basic blocks.  It is
@@ -98,20 +99,7 @@ maybe_get_single_definition (tree t)
   return NULL_TREE;
 }
 
-/* Traits class for tree hash maps below.  */
-
-struct sanopt_tree_map_traits : default_hashmap_traits
-{
-  static inline hashval_t hash (const_tree ref)
-  {
-return iterative_hash_expr (ref, 0);
-  }
-
-  static inline bool equal_keys (const_tree ref1, const_tree ref2)
-  {
-return operand_equal_p (ref1, ref2, 0);
-  }
-}; 
+typedef simple_hashmap_traits tree_operand_hash sanopt_tree_map_traits;
 
 /* Tree triplet for vptr_check_map.  */
 struct sanopt_tree_triplet
Index: gcc/tree-if-conv.c
===
--- gcc/tree-if-conv.c  2015-06-23 15:44:07.970809082 +0100
+++ gcc/tree-if-conv.c  2015-06-23 15:44:07.966809173 +0100
@@ -135,6 +135,7 @@ Software Foundation; either version 3, o
 #include expr.h
 #include insn-codes.h
 #include optabs.h
+#include tree-hash-traits.h
 
 /* List of basic blocks in if-conversion-suitable order.  */
 static basic_block *ifc_bbs;
@@ -1594,27 +1595,9 @@ convert_scalar_cond_reduction (gimple re
   return rhs;
 }
 
-/* Helpers for PHI arguments hashtable map.  */
+typedef simple_hashmap_traits tree_operand_hash phi_args_hash_traits;
 
-struct phi_args_hash_traits : default_hashmap_traits
-{
-  static inline hashval_t hash (tree);
-  static inline bool equal_keys (tree, tree);
-};
-
-inline hashval_t
-phi_args_hash_traits::hash (tree value)
-{
-  return iterative_hash_expr (value, 0);
-}
-
-inline bool
-phi_args_hash_traits::equal_keys (tree value1, tree value2)
-{
-  return operand_equal_p (value1, value2, 0);
-}
-
-  /* Produce condition for all occurrences of ARG in PHI node.  */
+/* Produce condition for all occurrences of ARG in PHI node.  */
 
 static tree
 gen_phi_arg_condition (gphi *phi, vecint *occur,
Index: gcc/tree-ssa-uncprop.c
===
--- gcc/tree-ssa-uncprop.c  2015-06-23 15:44:07.970809082 +0100
+++ gcc/tree-ssa-uncprop.c  2015-06-23 15:44:07.966809173 +0100
@@ -50,6 +50,7 @@ the Free Software Foundation; either ver
 #include domwalk.h
 #include tree-pass.h
 #include tree-ssa-propagate.h
+#include tree-hash-traits.h
 
 /* The basic structure describing an equivalency created by traversing
an edge.  Traversing the edge effectively means that we can assume
@@ -294,25 +295,11 @@ struct equiv_hash_elt
 
 /* Value to ssa name equivalence hashtable helpers.  */
 
-struct val_ssa_equiv_hash_traits : 

[04/12] Move ssa_name hasher to header file

2015-06-23 Thread Richard Sandiford
Another tree hasher, this time for SSA names.  Again there's only one copy
at the moment, but the idea seems general.


gcc/
* tree-hash-traits.h (tree_ssa_name_hasher): New class.
* sese.c: Include tree-hash-traits.h.
(rename_map_hasher): Use tree_ssa_name_hasher.

Index: gcc/tree-hash-traits.h
===
--- gcc/tree-hash-traits.h  2015-06-23 15:46:11.453390373 +0100
+++ gcc/tree-hash-traits.h  2015-06-23 15:46:11.449390427 +0100
@@ -53,4 +53,18 @@ tree_decl_hash::hash (tree t)
   return DECL_UID (t);
 }
 
+/* Hash for SSA_NAMEs in the same function.  Pointer equality is enough
+   here, but the SSA_NAME_VERSION is a better hash than the pointer
+   value and gives a predictable traversal order.  */
+struct tree_ssa_name_hash : ggc_ptr_hash tree_node
+{
+  static inline hashval_t hash (tree);
+};
+
+inline hashval_t
+tree_ssa_name_hash::hash (tree t)
+{
+  return SSA_NAME_VERSION (t);
+}
+
 #endif
Index: gcc/sese.c
===
--- gcc/sese.c  2015-06-23 15:46:11.453390373 +0100
+++ gcc/sese.c  2015-06-23 15:46:11.449390427 +0100
@@ -63,6 +63,7 @@ the Free Software Foundation; either ver
 #include value-prof.h
 #include sese.h
 #include tree-ssa-propagate.h
+#include tree-hash-traits.h
 
 /* Helper function for debug_rename_map.  */
 
@@ -78,22 +79,7 @@ debug_rename_map_1 (tree_node *const ol
   return true;
 }
 
-
-/* Hashtable helpers.  */
-
-struct rename_map_hasher : default_hashmap_traits
-{
-  static inline hashval_t hash (tree);
-};
-
-/* Computes a hash function for database element ELT.  */
-
-inline hashval_t
-rename_map_hasher::hash (tree old_name)
-{
-  return SSA_NAME_VERSION (old_name);
-}
-
+typedef simple_hashmap_traitstree_ssa_name_hash rename_map_hasher;
 typedef hash_maptree, tree, rename_map_hasher rename_map_type;
 
 



[12/12] Simplify uses of hash_map

2015-06-23 Thread Richard Sandiford
At this point all hash_map traits know what kind of key they're
dealing with, so we can make that a traits typedef, like it is for
hash_table traits.  Then, if we make the default hash traits for
T be T, we can use hash_table-style traits as the first template
parameter to hash_map, without the need for a third.  That is, if
foo_hash hashes elements of type foo_type:

  typedef simple_hashmap_traits foo_hash foo_traits;
  hash_map foo_type, value_type, foo_traits x;

becomes just:

  hash_map foo_hash, value_type x;

just like a hash_table of foo_types would be:

  hash_table foo_hash y;

This patch makes that simplification.


gcc/
* hash-map-traits.h (simple_hashmap_traits::key_type): New typedef.
(unbounded_int_hashmap_traits::key_type): Likewise.
* hash-map.h (hash_map): Get the key type from the traits.
* hash-traits.h (default_hash_traits): By default, inherit from the
template parameter.
* alias.c (alias_set_traits): Delete.
(alias_set_entry_d::children): Use alias_set_hash as the first
template parameter.
(record_alias_subset): Update accordingly.
* except.c (tree_hash_traits): Delete.
(type_to_runtime_map): Use tree_hash as the first template parameter.
(init_eh): Update accordingly.
* genmatch.c (capture_id_map_hasher): Delete.
(cid_map_t): Use nofree_string_hash as first template parameter.
* ipa-icf.h (symbol_compare_hashmap_traits): Delete.
* ipa-icf.c (sem_item_optimizer::subdivide_classes_by_sensitive_refs):
Use symbol_compare_hash as the first template parameter in
subdivide_hash_map.
* mem-stats.h (mem_usage_pair::mem_alloc_hashmap_traits): Delete.
(mem_usage_pair::mem_map_t): Use mem_location_hash as the first
template parameter.
* passes.c (pass_registry_hasher): Delete.
(name_to_pass_map): Use nofree_string_hash as the first template
parameter.
(register_pass_name): Update accordingly.
* sanopt.c (sanopt_tree_map_traits): Delete.
(sanopt_tree_triplet_map_traits): Delete.
(sanopt_ctx::asan_check_map): Use tree_operand_hash as the first
template parameter.
(sanopt_ctx::vptr_check_map): Use sanopt_tree_triplet_hash as
the first template parameter.
* sese.c (rename_map_hasher): Delete.
(rename_map_type): Use tree_ssa_name_hash as the first template
parameter.
* symbol-summary.h (function_summary::summary_hashmap_traits): Delete.
(function_summary::m_map): Use map_hash as the first template
parameter.
(function_summary::release): Update accordingly.
* tree-if-conv.c (phi_args_hash_traits): Delete.
(predicate_scalar_phi): Use tree_operand_hash as the first template
parameter to phi_arg_map.
* tree-inline.h (dependence_hasher): Delete.
(copy_body_data::dependence_map): Use dependence_hash as the first
template parameter.
* tree-inline.c (remap_dependence_clique): Update accordingly.
* tree-ssa-strlen.c (stridxlist_hash_traits): Delete.
(decl_to_stridxlist_htab): Use tree_decl_hash as the first template
parameter.
(addr_stridxptr): Update accordingly.
* value-prof.c (profile_id_traits): Delete.
(cgraph_node_map): Use profile_id_hash as the first template
parameter.
(init_node_map): Update accordingly.
* config/alpha/alpha.c (string_traits): Delete.
(machine_function::links): Use nofree_string_hash as the first
template parameter.
(alpha_use_linkage, alpha_write_linkage): Update accordingly.
* config/m32c/m32c.c (pragma_traits): Delete.
(pragma_htab): Use nofree_string_hash as the first template parameter.
(m32c_note_pragma_address): Update accordingly.
* config/mep/mep.c (pragma_traits): Delete.
(pragma_htab): Use nofree_string_hash as the first template parameter.
(mep_note_pragma_flag): Update accordingly.
* config/mips/mips.c (mips16_flip_traits): Delete.
(mflip_mips16_htab): Use nofree_string_hash as the first template
parameter.
(mflip_mips16_use_mips16_p): Update accordingly.
(local_alias_traits): Delete.
(mips16_local_aliases): Use nofree_string_hash as the first template
parameter.
(mips16_local_alias): Update accordingly.

Index: gcc/hash-map-traits.h
===
--- gcc/hash-map-traits.h   2015-06-23 15:56:38.990174759 +0100
+++ gcc/hash-map-traits.h   2015-06-23 15:56:38.986174805 +0100
@@ -31,9 +31,9 @@ #define HASH_MAP_TRAITS_H
 template typename H
 struct simple_hashmap_traits
 {
-  static inline hashval_t hash (const typename H::value_type );
-  static inline bool equal_keys (const typename H::value_type ,
-const typename 

[PATCH] Make muser-mode the default for LEON3

2015-06-23 Thread Daniel Cederman
The muser-mode flag causes the CASA instruction for LEON3 to use the
user mode ASI. This is the correct behavior for almost all LEON3 targets.
For this reason it makes sense to make user mode the default. This patch
adds a flag for supervisor mode that can be used on the very few LEON3 targets
that requires CASA to use the supervisor ASI.

gcc/ChangeLog:

2015-06-22  Daniel Cederman  ceder...@gaisler.com

* config/sparc/sparc.opt: Add supervisor mode flag (-msv-mode) and
  make user mode the default
* config/sparc/sync.md: Only use supervisor ASI for CASA when in
  supervisor mode
* doc/invoke.texi: Document msv-mode flag
---
 gcc/config/sparc/sparc.opt |  8 ++--
 gcc/config/sparc/sync.md   |  6 +++---
 gcc/doc/invoke.texi| 13 -
 3 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/gcc/config/sparc/sparc.opt b/gcc/config/sparc/sparc.opt
index 93d24a6..5c7f546 100644
--- a/gcc/config/sparc/sparc.opt
+++ b/gcc/config/sparc/sparc.opt
@@ -113,9 +113,13 @@ mrelax
 Target
 Optimize tail call instructions in assembler and linker
 
+msv-mode
+Target RejectNegative Report Mask(SV_MODE)
+Generate code that can only run in supervisor mode
+
 muser-mode
-Target Report Mask(USER_MODE)
-Do not generate code that can only run in supervisor mode
+Target RejectNegative Report InverseMask(SV_MODE)
+Do not generate code that can only run in supervisor mode (default)
 
 mcpu=
 Target RejectNegative Joined Var(sparc_cpu_and_features) 
Enum(sparc_processor_type) Init(PROCESSOR_V7)
diff --git a/gcc/config/sparc/sync.md b/gcc/config/sparc/sync.md
index 7d00b10..2fabff5 100644
--- a/gcc/config/sparc/sync.md
+++ b/gcc/config/sparc/sync.md
@@ -222,10 +222,10 @@
  UNSPECV_CAS))]
   TARGET_LEON3
 {
-  if (TARGET_USER_MODE)
-return casa\t%1 0xa, %2, %0; /* ASI for user data space.  */
-  else
+  if (TARGET_SV_MODE)
 return casa\t%1 0xb, %2, %0; /* ASI for supervisor data space.  */
+  else
+return casa\t%1 0xa, %2, %0; /* ASI for user data space.  */
 }
   [(set_attr type multi)])
 
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index b99ab1c..211e8e9 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -1008,7 +1008,7 @@ See RS/6000 and PowerPC Options.
 -mhard-quad-float  -msoft-quad-float @gol
 -mstack-bias  -mno-stack-bias @gol
 -munaligned-doubles  -mno-unaligned-doubles @gol
--muser-mode  -mno-user-mode @gol
+-muser-mode  -msv-mode @gol
 -mv8plus  -mno-v8plus  -mvis  -mno-vis @gol
 -mvis2  -mno-vis2  -mvis3  -mno-vis3 @gol
 -mcbcond -mno-cbcond @gol
@@ -21300,13 +21300,16 @@ Specifying this option avoids some rare compatibility 
problems with code
 generated by other compilers.  It is not the default because it results
 in a performance loss, especially for floating-point code.
 
+@item -msv-mode
+@opindex msv-mode
+Generate code that can only run in supervisor mode.  This is relevant
+only for the @code{casa} instruction emitted for the LEON3 processor.
+
 @item -muser-mode
-@itemx -mno-user-mode
 @opindex muser-mode
-@opindex mno-user-mode
 Do not generate code that can only run in supervisor mode.  This is relevant
-only for the @code{casa} instruction emitted for the LEON3 processor.  The
-default is @option{-mno-user-mode}.
+only for the @code{casa} instruction emitted for the LEON3 processor.  This
+is the default.
 
 @item -mno-faster-structs
 @itemx -mfaster-structs
-- 
2.4.3



[PATCH 1/2] Add mask to specify which LEON3 targets support CASA

2015-06-23 Thread Daniel Cederman
Not all LEON3 support the CASA instruction. This patch provides a mask
that can be used to specify which LEON3 targets that support CASA.

gcc/ChangeLog:

2015-06-22  Daniel Cederman  ceder...@gaisler.com

* config/sparc/sparc.c (sparc_option_override): Mark CPU targets
  leon3 and leon3v7 as supporting the CASA instruction
* config/sparc/sparc.opt: Add mask specifying that the LEON3
  supports the CASA instruction (MASK_LEON3_CASA)
* config/sparc/sync.md: Only generate CASA for V9 and targets
  with the MASK_LEON3_CASA mask
---
 gcc/config/sparc/sparc.c   | 4 ++--
 gcc/config/sparc/sparc.opt | 3 +++
 gcc/config/sparc/sync.md   | 6 +++---
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index 995a769..205e3cb 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -1280,8 +1280,8 @@ sparc_option_override (void)
 { supersparc,MASK_ISA, MASK_V8 },
 { hypersparc,MASK_ISA, MASK_V8|MASK_FPU },
 { leon,  MASK_ISA, MASK_V8|MASK_LEON|MASK_FPU },
-{ leon3, MASK_ISA, MASK_V8|MASK_LEON3|MASK_FPU },
-{ leon3v7,   MASK_ISA, MASK_LEON3|MASK_FPU },
+{ leon3, MASK_ISA, MASK_V8|MASK_LEON3|MASK_FPU|MASK_LEON_CASA },
+{ leon3v7,   MASK_ISA, MASK_LEON3|MASK_FPU|MASK_LEON_CASA },
 { sparclite, MASK_ISA, MASK_SPARCLITE },
 /* The Fujitsu MB86930 is the original sparclite chip, with no FPU.  */
 { f930,  MASK_ISA|MASK_FPU, MASK_SPARCLITE },
diff --git a/gcc/config/sparc/sparc.opt b/gcc/config/sparc/sparc.opt
index 5c7f546..e6caa95 100644
--- a/gcc/config/sparc/sparc.opt
+++ b/gcc/config/sparc/sparc.opt
@@ -228,6 +228,9 @@ Mask(LEON)
 Mask(LEON3)
 ;; Generate code for LEON3
 
+Mask(LEON_CASA)
+;; Generate CAS instruction for LEON
+
 Mask(SPARCLITE)
 ;; Generate code for SPARClite
 
diff --git a/gcc/config/sparc/sync.md b/gcc/config/sparc/sync.md
index 2fabff5..8e1baee 100644
--- a/gcc/config/sparc/sync.md
+++ b/gcc/config/sparc/sync.md
@@ -181,7 +181,7 @@
(match_operand:SI 5 const_int_operand ) ;; is_weak
(match_operand:SI 6 const_int_operand ) ;; mod_s
(match_operand:SI 7 const_int_operand )];; mod_f
-  (TARGET_V9 || TARGET_LEON3)
+  (TARGET_V9 || TARGET_LEON_CASA)
 (MODEmode != DImode || TARGET_ARCH64 || TARGET_V8PLUS)
 {
   sparc_expand_compare_and_swap (operands);
@@ -197,7 +197,7 @@
 [(match_operand:I48MODE 2 register_operand )
  (match_operand:I48MODE 3 register_operand )]
 UNSPECV_CAS))])]
-  TARGET_V9 || TARGET_LEON3
+  TARGET_V9 || TARGET_LEON_CASA
   )
 
 (define_insn *atomic_compare_and_swapmode_1
@@ -220,7 +220,7 @@
  [(match_operand:SI 2 register_operand r)
   (match_operand:SI 3 register_operand 0)]
  UNSPECV_CAS))]
-  TARGET_LEON3
+  TARGET_LEON_CASA
 {
   if (TARGET_SV_MODE)
 return casa\t%1 0xb, %2, %0; /* ASI for supervisor data space.  */
-- 
2.4.3



C++ PATCH for c++/66501 (wrong code with array move assignment)

2015-06-23 Thread Jason Merrill
build_vec_init was assuming that if a class has a trivial copy 
assignment, then an array assignment is trivial.  But overload 
resolution might not choose the copy assignment operator.  So this patch 
changes build_vec_init to check for any non-trivial assignment operator.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit 2f1cd98c72127d70e198ed99c67cc5d031f052b6
Author: Jason Merrill ja...@redhat.com
Date:   Mon Jun 22 15:13:58 2015 -0400

	PR c++/66501
	* class.c (type_has_nontrivial_assignment): New.
	* init.c (build_vec_init): Use it.
	* cp-tree.h: Declare it.
	* method.c (trivial_fn_p): Templates aren't trivial.

diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 9da532e..88f1022 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -5136,6 +5136,24 @@ type_has_non_user_provided_default_constructor (tree t)
   return false;
 }
 
+/* Return true if TYPE has some non-trivial assignment operator.  */
+
+bool
+type_has_nontrivial_assignment (tree type)
+{
+  gcc_assert (TREE_CODE (type) != ARRAY_TYPE);
+  if (CLASS_TYPE_P (type))
+for (tree fns
+	   = lookup_fnfields_slot_nolazy (type, ansi_assopname (NOP_EXPR));
+	 fns; fns = OVL_NEXT (fns))
+  {
+	tree fn = OVL_CURRENT (fns);
+	if (!trivial_fn_p (fn))
+	  return true;
+  }
+  return false;
+}
+
 /* TYPE is being used as a virtual base, and has a non-trivial move
assignment.  Return true if this is due to there being a user-provided
move assignment in TYPE or one of its subobjects; if there isn't, then
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index b53aa90..8eb7474 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -5295,6 +5295,7 @@ extern tree in_class_defaulted_default_constructor (tree);
 extern bool user_provided_p			(tree);
 extern bool type_has_user_provided_constructor  (tree);
 extern bool type_has_non_user_provided_default_constructor (tree);
+extern bool type_has_nontrivial_assignment	(tree);
 extern bool vbase_has_user_provided_move_assign (tree);
 extern tree default_init_uninitialized_part (tree);
 extern bool trivial_default_constructor_is_constexpr (tree);
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index fc30fef..08c6c0e 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -3460,8 +3460,7 @@ build_vec_init (tree base, tree maxindex, tree init,
TREE_CODE (atype) == ARRAY_TYPE
TREE_CONSTANT (maxindex)
(from_array == 2
-	  ? (!CLASS_TYPE_P (inner_elt_type)
-	 || !TYPE_HAS_COMPLEX_COPY_ASSIGN (inner_elt_type))
+	  ? !type_has_nontrivial_assignment (inner_elt_type)
 	  : !TYPE_NEEDS_CONSTRUCTING (type))
((TREE_CODE (init) == CONSTRUCTOR
 	   /* Don't do this if the CONSTRUCTOR might contain something
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index 79e4bbc..da03c36 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -476,6 +476,8 @@ type_set_nontrivial_flag (tree ctype, special_function_kind sfk)
 bool
 trivial_fn_p (tree fn)
 {
+  if (TREE_CODE (fn) == TEMPLATE_DECL)
+return false;
   if (!DECL_DEFAULTED_FN (fn))
 return false;
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-array1.C b/gcc/testsuite/g++.dg/cpp0x/rv-array1.C
new file mode 100644
index 000..9075764
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/rv-array1.C
@@ -0,0 +1,55 @@
+// PR c++/66501
+// { dg-do run { target c++11 } }
+
+int total_size;
+
+struct Object
+{
+  int size = 0;
+
+  Object () = default;
+
+  ~Object () {
+total_size -= size;
+  }
+
+  Object (const Object ) = delete;
+  Object  operator= (const Object ) = delete;
+
+  Object (Object  b) {
+size = b.size;
+b.size = 0;
+  }
+
+  Object  operator= (Object  b) {
+if (this !=  b) {
+  total_size -= size;
+  size = b.size;
+  b.size = 0;
+}
+return * this;
+  }
+
+  void grow () {
+size ++;
+total_size ++;
+  }
+};
+
+struct Container {
+  Object objects[2];
+};
+
+int main (void)
+{
+  Container container;
+
+  // grow some objects in the container
+  for (auto  object : container.objects)
+object.grow ();
+
+  // now empty it
+  container = Container ();
+
+  return total_size;
+}


[01/12] Add hash_map traits that use existing hash_table-like traits

2015-06-23 Thread Richard Sandiford
This patch defines a class that converts hash_table-style traits into
hash_map traits.  It can be used as the default traits for all hash_maps
that don't specify their own traits (i.e. this patch does work on its own).

By the end of the series this class replaces default_hashmap_traits.


gcc/
* hash-map-traits.h: Include hash-traits.h.
(simple_hashmap_traits): New class.
* mem-stats.h (hash_map): Change the default traits to
simple_hashmap_traitsdefault_hash_traitsKey .

Index: gcc/hash-map-traits.h
===
--- gcc/hash-map-traits.h   2015-06-23 15:42:24.132002236 +0100
+++ gcc/hash-map-traits.h   2015-06-23 15:42:24.128002280 +0100
@@ -23,6 +23,8 @@ #define HASH_MAP_TRAITS_H
 /* Bacause mem-stats.h uses default hashmap traits, we have to
put the class to this separate header file.  */
 
+#include hash-traits.h
+
 /* implement default behavior for traits when types allow it.  */
 
 struct default_hashmap_traits
@@ -101,4 +103,75 @@ struct default_hashmap_traits
 }
 };
 
+/* Implement hash_map traits for a key with hash traits H.  Empty and
+   deleted map entries are represented as empty and deleted keys.  */
+
+template typename H
+struct simple_hashmap_traits
+{
+  static inline hashval_t hash (const typename H::value_type );
+  static inline bool equal_keys (const typename H::value_type ,
+const typename H::value_type );
+  template typename T static inline void remove (T );
+  template typename T static inline bool is_empty (const T );
+  template typename T static inline bool is_deleted (const T );
+  template typename T static inline void mark_empty (T );
+  template typename T static inline void mark_deleted (T );
+};
+
+template typename H
+inline hashval_t
+simple_hashmap_traits H::hash (const typename H::value_type h)
+{
+  return H::hash (h);
+}
+
+template typename H
+inline bool
+simple_hashmap_traits H::equal_keys (const typename H::value_type k1,
+  const typename H::value_type k2)
+{
+  return H::equal (k1, k2);
+}
+
+template typename H
+template typename T
+inline void
+simple_hashmap_traits H::remove (T entry)
+{
+  H::remove (entry.m_key);
+}
+
+template typename H
+template typename T
+inline bool
+simple_hashmap_traits H::is_empty (const T entry)
+{
+  return H::is_empty (entry.m_key);
+}
+
+template typename H
+template typename T
+inline bool
+simple_hashmap_traits H::is_deleted (const T entry)
+{
+  return H::is_deleted (entry.m_key);
+}
+
+template typename H
+template typename T
+inline void
+simple_hashmap_traits H::mark_empty (T entry)
+{
+  H::mark_empty (entry.m_key);
+}
+
+template typename H
+template typename T
+inline void
+simple_hashmap_traits H::mark_deleted (T entry)
+{
+  H::mark_deleted (entry.m_key);
+}
+
 #endif // HASH_MAP_TRAITS_H
Index: gcc/mem-stats.h
===
--- gcc/mem-stats.h 2015-06-23 15:42:24.132002236 +0100
+++ gcc/mem-stats.h 2015-06-23 15:42:24.128002280 +0100
@@ -3,7 +3,7 @@ #define GCC_MEM_STATS_H
 
 /* Forward declaration.  */
 templatetypename Key, typename Value,
-typename Traits = default_hashmap_traits
+typename Traits = simple_hashmap_traitsdefault_hash_traitsKey  
 class hash_map;
 
 #define LOCATION_LINE_EXTRA_SPACE 30



[07/12] Use new string hasher for MIPS

2015-06-23 Thread Richard Sandiford
Use the string hasher from patch 6 for MIPS.  I split this out because
local_alias_traits doesn't actually need to use SYMBOL_REF rtxes as
the map keys, since the only data used is the symbol name.


gcc/
* config/mips/mips.c (mips16_flip_traits): Use it.
(local_alias_traits, mips16_local_aliases): Convert from a map of
rtxes to a map of symbol names.
(mips16_local_alias): Update accordingly.

Index: gcc/config/mips/mips.c
===
--- gcc/config/mips/mips.c  2015-06-23 15:49:32.187081876 +0100
+++ gcc/config/mips/mips.c  2015-06-23 15:49:32.183081933 +0100
@@ -1265,15 +1265,7 @@ static int mips_register_move_cost (mach
 static unsigned int mips_function_arg_boundary (machine_mode, const_tree);
 static machine_mode mips_get_reg_raw_mode (int regno);
 
-struct mips16_flip_traits : default_hashmap_traits
-{
-  static hashval_t hash (const char *s) { return htab_hash_string (s); }
-  static bool
-  equal_keys (const char *a, const char *b)
-  {
-return !strcmp (a, b);
-  }
-};
+struct mips16_flip_traits : simple_hashmap_traits nofree_string_hash {};
 
 /* This hash table keeps track of implicit mips16 and nomips16 attributes
for -mflip_mips16.  It maps decl names onto a boolean mode setting.  */
@@ -6601,30 +6593,13 @@ mips_load_call_address (enum mips_call_t
 }
 }
 
-struct local_alias_traits : default_hashmap_traits
-{
-  static hashval_t hash (rtx);
-  static bool equal_keys (rtx, rtx);
-};
+struct local_alias_traits : simple_hashmap_traits nofree_string_hash {};
 
 /* Each locally-defined hard-float MIPS16 function has a local symbol
associated with it.  This hash table maps the function symbol (FUNC)
to the local symbol (LOCAL). */
-static GTY (()) hash_maprtx, rtx, local_alias_traits *mips16_local_aliases;
-
-/* Hash table callbacks for mips16_local_aliases.  */
-
-hashval_t
-local_alias_traits::hash (rtx func)
-{
-  return htab_hash_string (XSTR (func, 0));
-}
-
-bool
-local_alias_traits::equal_keys (rtx func1, rtx func2)
-{
-  return rtx_equal_p (func1, func2);
-}
+static GTY (()) hash_mapconst char *, rtx, local_alias_traits
+  *mips16_local_aliases;
 
 /* FUNC is the symbol for a locally-defined hard-float MIPS16 function.
Return a local alias for it, creating a new one if necessary.  */
@@ -6635,23 +6610,23 @@ mips16_local_alias (rtx func)
   /* Create the hash table if this is the first call.  */
   if (mips16_local_aliases == NULL)
 mips16_local_aliases
-  = hash_maprtx, rtx, local_alias_traits::create_ggc (37);
+  = hash_mapconst char *, rtx, local_alias_traits::create_ggc (37);
 
   /* Look up the function symbol, creating a new entry if need be.  */
   bool existed;
-  rtx *slot = mips16_local_aliases-get_or_insert (func, existed);
+  const char *func_name = XSTR (func, 0);
+  rtx *slot = mips16_local_aliases-get_or_insert (func_name, existed);
   gcc_assert (slot != NULL);
 
   if (!existed)
 {
-  const char *func_name, *local_name;
   rtx local;
 
   /* Create a new SYMBOL_REF for the local symbol.  The choice of
 __fn_local_* is based on the __fn_stub_* names that we've
 traditionally used for the non-MIPS16 stub.  */
   func_name = targetm.strip_name_encoding (XSTR (func, 0));
-  local_name = ACONCAT ((__fn_local_, func_name, NULL));
+  const char *local_name = ACONCAT ((__fn_local_, func_name, NULL));
   local = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (local_name));
   SYMBOL_REF_FLAGS (local) = SYMBOL_REF_FLAGS (func) | SYMBOL_FLAG_LOCAL;
 



[08/12] Add common traits for integer hash keys

2015-06-23 Thread Richard Sandiford
Several places define hash traits for integers, using particular integer
values as empty and deleted markers.  This patch defines them in terms
of a single int_hash class.

I also needed to extend gengtype to accept + in template arguments.


gcc/
* gengtype-parse.c (require_template_declaration): Allow '+' in
template parameters.  Consolidate cases.
* hash-traits.h (int_hash): New class.
* alias.c (alias_set_hash): New structure.
(alias_set_traits): Use it.
* symbol-summary.h (function_summary::map_hash): New class.
(function_summary::summary_hashmap_traits): Use it.
* tree-inline.h (dependence_hash): New class.
(dependence_hasher): Use it.
* tree-ssa-reassoc.c (oecount_hasher): Use int_hash.
* value-prof.c (profile_id_hash): New class.
(profile_id_traits): Use it.

Index: gcc/gengtype-parse.c
===
--- gcc/gengtype-parse.c2015-06-23 15:50:56.686110247 +0100
+++ gcc/gengtype-parse.c2015-06-23 15:50:56.678110339 +0100
@@ -274,17 +274,13 @@ require_template_declaration (const char
  str = concat (str, enum , (char *) 0);
  continue;
}
-  if (token () == NUM)
+  if (token () == NUM
+ || token () == ':'
+ || token () == '+')
{
  str = concat (str, advance (), (char *) 0);
  continue;
}
-  if (token () == ':')
-   {
- advance ();
- str = concat (str, :, (char *) 0);
- continue;
-   }
   if (token () == '')
{
  advance ();
Index: gcc/hash-traits.h
===
--- gcc/hash-traits.h   2015-06-23 15:50:56.686110247 +0100
+++ gcc/hash-traits.h   2015-06-23 15:50:56.674110387 +0100
@@ -57,6 +57,68 @@ typed_noop_remove Type::remove (Type 
 }
 
 
+/* Hasher for integer type Type in which Empty is a spare value that can be
+   used to mark empty slots.  If Deleted != Empty then Deleted is another
+   spare value that can be used for deleted slots; if Deleted == Empty then
+   hash table entries cannot be deleted.  */
+
+template typename Type, Type Empty, Type Deleted = Empty
+struct int_hash : typed_noop_remove Type
+{
+  typedef Type value_type;
+  typedef Type compare_type;
+
+  static inline hashval_t hash (value_type);
+  static inline bool equal (value_type existing, value_type candidate);
+  static inline void mark_deleted (Type );
+  static inline void mark_empty (Type );
+  static inline bool is_deleted (Type);
+  static inline bool is_empty (Type);
+};
+
+template typename Type, Type Empty, Type Deleted
+inline hashval_t
+int_hash Type, Empty, Deleted::hash (value_type x)
+{
+  return x;
+}
+
+template typename Type, Type Empty, Type Deleted
+inline bool
+int_hash Type, Empty, Deleted::equal (value_type x, value_type y)
+{
+  return x == y;
+}
+
+template typename Type, Type Empty, Type Deleted
+inline void
+int_hash Type, Empty, Deleted::mark_deleted (Type x)
+{
+  gcc_assert (Empty != Deleted);
+  x = Deleted;
+}
+
+template typename Type, Type Empty, Type Deleted
+inline void
+int_hash Type, Empty, Deleted::mark_empty (Type x)
+{
+  x = Empty;
+}
+
+template typename Type, Type Empty, Type Deleted
+inline bool
+int_hash Type, Empty, Deleted::is_deleted (Type x)
+{
+  return Empty != Deleted  x == Deleted;
+}
+
+template typename Type, Type Empty, Type Deleted
+inline bool
+int_hash Type, Empty, Deleted::is_empty (Type x)
+{
+  return x == Empty;
+}
+
 /* Pointer hasher based on pointer equality.  Other types of pointer hash
can inherit this and override the hash and equal functions with some
other form of equality (such as string equality).  */
Index: gcc/alias.c
===
--- gcc/alias.c 2015-06-23 15:50:56.686110247 +0100
+++ gcc/alias.c 2015-06-23 15:50:56.678110339 +0100
@@ -143,31 +143,8 @@ Software Foundation; either version 3, o
However, this is no actual entry for alias set zero.  It is an
error to attempt to explicitly construct a subset of zero.  */
 
-struct alias_set_traits : default_hashmap_traits
-{
-  templatetypename T
-  static bool
-  is_empty (T e)
-  {
-return e.m_key == INT_MIN;
-  }
-
-  templatetypename  T
-  static bool
-  is_deleted (T e)
-  {
-return e.m_key == (INT_MIN + 1);
-  }
-
-  templatetypename T static void mark_empty (T e) { e.m_key = INT_MIN; }
-
-  templatetypename T
-  static void
-  mark_deleted (T e)
-  {
-e.m_key = INT_MIN + 1;
-  }
-};
+struct alias_set_hash : int_hash int, INT_MIN, INT_MIN + 1 {};
+struct alias_set_traits : simple_hashmap_traits alias_set_hash {};
 
 struct GTY(()) alias_set_entry_d {
   /* The alias set number, as stored in MEM_ALIAS_SET.  */
Index: gcc/symbol-summary.h
===
--- gcc/symbol-summary.h2015-06-23 15:50:56.686110247 

Re: [PATCH] Add CFI entries for ARM Linux idiv0 / ldiv0

2015-06-23 Thread Ramana Radhakrishnan



On 16/06/15 22:25, James Lemke wrote:

A divide by zero exception was not giving a proper traceback for LINUX
ARM_EABI.  The attached patch fixes the problem on trunk (and several
local branches).

Tested on gcc-trunk for arm-none-linux-gnueabi.

OK to commit?

2015-06-16  James Lemke  jwle...@codesourcery.com

libgcc/config/arm/
* lib1funcs.S (aeabi_idiv0, aeabi_ldiv0): Add CFI entries for
Linux ARM_EABI.


s/for Linux ARM EABI//

given you handle both __ARM_EABI__ and the not __ARM_EABI__ targets in 
the source.


This is OK if no regressions.

Thanks,
Ramana


[00/12] Share hash traits between hash_table and hash_map

2015-06-23 Thread Richard Sandiford
Following on from: https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01066.html
this series unifies the key hashing traits for hash_maps in all but one case
(which needs to use the values rather than keys to represent deleted and
empty entries).

It also consolidates the various tree, integer and string hashers
so that there's only one copy of each.

This series is a net reduction of 121 lines, despite using the more
verbose out-of-class function definitions and having new copyright
notices.  The series linked above is a net reduction of 419 lines.

Series bootstrapped  regression-tested on x86_64-linux-gnu.
Also tested with config-list.mk.

Thanks,
Richard



[gomp4.1] Taskloop C++ random access iterator support

2015-06-23 Thread Jakub Jelinek
Hi!

I've committed following patch to add support for C++ random access
iterators in taskloop constructs.

2015-06-23  Jakub Jelinek  ja...@redhat.com

* tree.h (OMP_CLAUSE_PRIVATE_TASKLOOP_IV,
OMP_CLAUSE_LASTPRIVATE_TASKLOOP_IV): Define.
* gimplify.c (gimplify_omp_for): Handle gimplification of
OMP_TASKLOOP with C++ random access iterator clauses.
* omp-low.c (scan_sharing_clauses): Ignore
OMP_CLAUSE_SHARED with OMP_CLAUSE_SHARED_FIRSTPRIVATE if
it is a global var outside of the outer taskloop for.
(lower_lastprivate_clauses): Handle
OMP_CLAUSE_LASTPRIVATE_TASKLOOP_IV lastprivate if the
decl is global outside of outer taskloop for.
(lower_send_clauses): Look beyond the outer taskloop for.
gcc/cp/
* semantics.c (handle_omp_for_class_iterator): Handle
OMP_TASKLOOP class iterators.
(finish_omp_for): Adjust handle_omp_for_class_iterator
caller.
libgomp/
* testsuite/libgomp.c++/taskloop-6.C: New test.
* testsuite/libgomp.c++/taskloop-7.C: New test.
* testsuite/libgomp.c++/taskloop-8.C: New test.
* testsuite/libgomp.c++/taskloop-9.C: New test.

--- gcc/tree.h.jj   2015-06-17 21:02:00.0 +0200
+++ gcc/tree.h  2015-06-22 15:19:37.501110534 +0200
@@ -1356,6 +1356,12 @@ extern void protected_set_expr_location
 #define OMP_CLAUSE_PRIVATE_OUTER_REF(NODE) \
   TREE_PRIVATE (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_PRIVATE))
 
+/* True if a PRIVATE clause is for a C++ class IV on taskloop construct
+   (thus should be private on the outer taskloop and firstprivate on
+   task).  */
+#define OMP_CLAUSE_PRIVATE_TASKLOOP_IV(NODE) \
+  TREE_PROTECTED (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_PRIVATE))
+
 /* True on a LASTPRIVATE clause if a FIRSTPRIVATE clause for the same
decl is present in the chain.  */
 #define OMP_CLAUSE_LASTPRIVATE_FIRSTPRIVATE(NODE) \
@@ -1367,6 +1373,12 @@ extern void protected_set_expr_location
 #define OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ(NODE) \
   (OMP_CLAUSE_CHECK (NODE))-omp_clause.gimple_reduction_init
 
+/* True if a LASTPRIVATE clause is for a C++ class IV on taskloop construct
+   (thus should be lastprivate on the outer taskloop and firstprivate on
+   task).  */
+#define OMP_CLAUSE_LASTPRIVATE_TASKLOOP_IV(NODE) \
+  TREE_PROTECTED (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_LASTPRIVATE))
+
 /* True on a SHARED clause if a FIRSTPRIVATE clause for the same
decl is present in the chain (this can happen only for taskloop
with FIRSTPRIVATE/LASTPRIVATE on it originally.  */
--- gcc/gimplify.c.jj   2015-06-18 15:16:18.0 +0200
+++ gcc/gimplify.c  2015-06-23 10:03:28.908079507 +0200
@@ -7230,7 +7230,8 @@ gimplify_omp_for (tree *expr_p, gimple_s
{
  TREE_OPERAND (t, 1)
= get_initialized_tmp_var (TREE_OPERAND (t, 1),
-  pre_p, NULL);
+  gimple_seq_empty_p (for_pre_body)
+  ? pre_p : for_pre_body, NULL);
  tree c = build_omp_clause (input_location,
 OMP_CLAUSE_FIRSTPRIVATE);
  OMP_CLAUSE_DECL (c) = TREE_OPERAND (t, 1);
@@ -7250,7 +7251,9 @@ gimplify_omp_for (tree *expr_p, gimple_s
 
  if (!is_gimple_constant (*tp))
{
- *tp = get_initialized_tmp_var (*tp, pre_p, NULL);
+ gimple_seq *seq = gimple_seq_empty_p (for_pre_body)
+   ? pre_p : for_pre_body;
+ *tp = get_initialized_tmp_var (*tp, seq, NULL);
  tree c = build_omp_clause (input_location,
 OMP_CLAUSE_FIRSTPRIVATE);
  OMP_CLAUSE_DECL (c) = *tp;
@@ -7683,7 +7686,6 @@ gimplify_omp_for (tree *expr_p, gimple_s
  {
  /* These clauses are allowed on task, move them there.  */
  case OMP_CLAUSE_SHARED:
- case OMP_CLAUSE_PRIVATE:
  case OMP_CLAUSE_FIRSTPRIVATE:
  case OMP_CLAUSE_DEFAULT:
  case OMP_CLAUSE_IF:
@@ -7694,6 +7696,26 @@ gimplify_omp_for (tree *expr_p, gimple_s
*gtask_clauses_ptr = c;
gtask_clauses_ptr = OMP_CLAUSE_CHAIN (c);
break;
+ case OMP_CLAUSE_PRIVATE:
+   if (OMP_CLAUSE_PRIVATE_TASKLOOP_IV (c))
+ {
+   /* We want private on outer for and firstprivate
+  on task.  */
+   *gtask_clauses_ptr
+ = build_omp_clause (OMP_CLAUSE_LOCATION (c),
+ OMP_CLAUSE_FIRSTPRIVATE);
+   OMP_CLAUSE_DECL (*gtask_clauses_ptr) = OMP_CLAUSE_DECL (c);
+   lang_hooks.decls.omp_finish_clause (*gtask_clauses_ptr, NULL);
+   gtask_clauses_ptr = OMP_CLAUSE_CHAIN (*gtask_clauses_ptr);
+   *gforo_clauses_ptr = c;
+  

[11/12] Remove default_hashmap_traits

2015-06-23 Thread Richard Sandiford
The previous patches removed all uses of default_hashmap_traits,
so this patch deletes the definition.


gcc/
* hash-map-traits.h (default_hashmap_traits): Delete.

Index: gcc/hash-map-traits.h
===
--- gcc/hash-map-traits.h   2015-06-23 15:55:43.054817986 +0100
+++ gcc/hash-map-traits.h   2015-06-23 15:55:43.050818009 +0100
@@ -25,84 +25,6 @@ #define HASH_MAP_TRAITS_H
 
 #include hash-traits.h
 
-/* implement default behavior for traits when types allow it.  */
-
-struct default_hashmap_traits
-{
-  /* Hashes the passed in key.  */
-
-  templatetypename T
-  static hashval_t
-  hash (T *p)
-{
-  return uintptr_t (p)  3;
-}
-
-  /* If the value converts to hashval_t just use it.  */
-
-  templatetypename T static hashval_t hash (T v) { return v; }
-
-  /* Return true if the two keys passed as arguments are equal.  */
-
-  templatetypename T
-  static bool
-  equal_keys (const T a, const T b)
-{
-  return a == b;
-}
-
-  /* Called to dispose of the key and value before marking the entry as
- deleted.  */
-
-  templatetypename T static void remove (T v) { v.~T (); }
-
-  /* Mark the passed in entry as being deleted.  */
-
-  templatetypename T
-  static void
-  mark_deleted (T e)
-{
-  mark_key_deleted (e.m_key);
-}
-
-  /* Mark the passed in entry as being empty.  */
-
-  templatetypename T
-  static void
-  mark_empty (T e)
-{
-  mark_key_empty (e.m_key);
-}
-
-  /* Return true if the passed in entry is marked as deleted.  */
-
-  templatetypename T
-  static bool
-  is_deleted (T e)
-{
-  return e.m_key == (void *)1;
-}
-
-  /* Return true if the passed in entry is marked as empty.  */
-
-  templatetypename T static bool is_empty (T e) { return e.m_key == NULL; }
-
-private:
-  templatetypename T
-  static void
-  mark_key_deleted (T *k)
-{
-  k = reinterpret_castT * (1);
-}
-
-  templatetypename T
-  static void
-  mark_key_empty (T *k)
-{
-  k = static_castT * (0);
-}
-};
-
 /* Implement hash_map traits for a key with hash traits H.  Empty and
deleted map entries are represented as empty and deleted keys.  */
 




Re: [patch] Delete temporary response file

2015-06-23 Thread Jeff Law

On 06/22/2015 11:37 AM, Eric Botcazou wrote:

Hi,

when you pass a response file at link time and you use the GNU linker, then
collect2 creates another, temporary response file and passes it to the linker.
But it fails to delete the file after it is done.  This can easily be seen
with the following manipulation:

eric@polaris:~/build/gcc/native cat t.c
int main (void) { return 0; }
eric@polaris:~/build/gcc/native cat t.resp
-L/usr/lib64
eric@polaris:~/build/gcc/native gcc -c t.c
eric@polaris:~/build/gcc/native export TMPDIR=$PWD
eric@polaris:~/build/gcc/native gcc -o t t.o @t.resp
eric@polaris:~/build/gcc/native ls cc*
ccVSQ6W5

The problem is that do_wait is not invoked by tlink_execute, only collect_wait
is, so the cleanup code present therein is never invoked.

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


2015-06-22  Tristan Gingold  ging...@adacore.com

* collect2.c (collect_wait): Unlink the response file here instead of...
(do_wait): ...here.
(utils_cleanup): ...and here.

OK.
jeff


Re: [PATCH] Make muser-mode the default for LEON3

2015-06-23 Thread Sebastian Huber
Instead of introducing a new option which may conflict with an existing 
one, is it not possible to simply use -mno-user-mode?


On 23/06/15 14:22, Daniel Cederman wrote:

The muser-mode flag causes the CASA instruction for LEON3 to use the
user mode ASI. This is the correct behavior for almost all LEON3 targets.
For this reason it makes sense to make user mode the default. This patch
adds a flag for supervisor mode that can be used on the very few LEON3 targets
that requires CASA to use the supervisor ASI.

gcc/ChangeLog:

2015-06-22  Daniel Cederman  ceder...@gaisler.com

* config/sparc/sparc.opt: Add supervisor mode flag (-msv-mode) and
  make user mode the default
* config/sparc/sync.md: Only use supervisor ASI for CASA when in
  supervisor mode
* doc/invoke.texi: Document msv-mode flag


--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



Re: [AArch64] Implement -fpic for -mcmodel=small

2015-06-23 Thread Jiong Wang

Marcus Shawcroft writes:

 On 20 May 2015 at 11:21, Jiong Wang jiong.w...@arm.com wrote:

 gcc/
   * config/aarch64/aarch64.md: (ldr_got_small_mode): Support new GOT 
 relocation
   modifiers.
   (ldr_got_small_sidi): Ditto.
   * config/aarch64/iterators.md (got_modifier): New mode iterator.
   * config/aarch64/aarch64-otps.h (aarch64_code_model): New model.
   * config/aarch64/aarch64.c (aarch64_load_symref_appropriately): Support 
 -fpic.
   (aarch64_rtx_costs): Add costs for new instruction sequences.
   (initialize_aarch64_code_model): Initialize new model.
   (aarch64_classify_symbol): Recognize new model.
   (aarch64_asm_preferred_eh_data_format): Support new model.
   (aarch64_load_symref_appropriately): Generate new instruction sequences 
 for -fpic.
   (TARGET_USE_PSEUDO_PIC_REG): New definition.
   (aarch64_use_pseudo_pic_reg): New function.

 gcc/testsuite/
   * gcc.target/aarch64/pic-small.c: New testcase.


 Rather than thread tests against aarch64_cmodel throughout the
 existing code can we instead extend classify_symbol with a new symbol
 classification?

Yes, we can. As -fPIC/-fpic allow 4G/32K GOT table size, we may name
corresponding symbol classification as SYMBOL_GOT_4G,
SYMBOL_GOT_32K.

But can we let this patch go in and create a another patch to improve
this? there are several other TLS patches may needs rebase if we change
this immedaitely.

Thanks

--
Regards,
Jiong



C++ PATCH for c++/65879 (error on member function of nested class of anonymous class)

2015-06-23 Thread Jason Merrill
It doesn't make sense to complain about a function using its own 
enclosing class.  There were two problems here:


1) The function should have been marked as internal because its class is 
internal.

2) We shouldn't bother looking at 'this' for no-linkage types.

Tested x86_64-pc-linux-gnu, applying to trunk.  Applying #2 to 5 and 4.9 
as well.
commit 6ad33315431b2e6dc2664a36f0a3b308a9eafd40
Author: Jason Merrill ja...@redhat.com
Date:   Mon Jun 22 16:07:13 2015 -0400

	PR c++/65879
	* decl.c (grokfndecl): Check the linkage of ctype, not just
	TYPE_ANONYMOUS_P.
	* tree.c (no_linkage_check): Skip the 'this' pointer.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index d14ffe2..a8fc1a5 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -7794,7 +7794,7 @@ grokfndecl (tree ctype,
 
   /* Members of anonymous types and local classes have no linkage; make
  them internal.  If a typedef is made later, this will be changed.  */
-  if (ctype  (TYPE_ANONYMOUS_P (ctype)
+  if (ctype  (!TREE_PUBLIC (TYPE_MAIN_DECL (ctype))
 		|| decl_function_context (TYPE_MAIN_DECL (ctype
 publicp = 0;
 
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index a9c9214..bc8428d 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -2299,14 +2299,14 @@ no_linkage_check (tree t, bool relaxed_p)
   return no_linkage_check (TYPE_PTRMEM_CLASS_TYPE (t), relaxed_p);
 
 case METHOD_TYPE:
-  r = no_linkage_check (TYPE_METHOD_BASETYPE (t), relaxed_p);
-  if (r)
-	return r;
-  /* Fall through.  */
 case FUNCTION_TYPE:
   {
-	tree parm;
-	for (parm = TYPE_ARG_TYPES (t);
+	tree parm = TYPE_ARG_TYPES (t);
+	if (TREE_CODE (t) == METHOD_TYPE)
+	  /* The 'this' pointer isn't interesting; a method has the same
+	 linkage (or lack thereof) as its enclosing class.  */
+	  parm = TREE_CHAIN (parm);
+	for (;
 	 parm  parm != void_list_node;
 	 parm = TREE_CHAIN (parm))
 	  {
diff --git a/gcc/testsuite/g++.dg/abi/anon2.C b/gcc/testsuite/g++.dg/abi/anon2.C
index cee9237..396edd3 100644
--- a/gcc/testsuite/g++.dg/abi/anon2.C
+++ b/gcc/testsuite/g++.dg/abi/anon2.C
@@ -23,9 +23,9 @@ namespace N2 {
 typedef struct { } B;
 struct C {
   // { dg-final { scan-assembler-not .weak\(_definition\)?\[ \t\]_?_ZN2N23._31C3fn1ENS0_1BE { target c++11 } } }
-  static void fn1 (B) { } // { dg-error no linkage  { target { ! c++11 } } }
+  static void fn1 (B) { }
   // { dg-final { scan-assembler-not .weak\(_definition\)?\[ \t\]_?_ZN2N23._31C3fn2ES1_ { target c++11 } } }
-  static void fn2 (C) { } // { dg-error no linkage  { target { ! c++11 } } }
+  static void fn2 (C) { }
 };
   } const D;
 
diff --git a/gcc/testsuite/g++.dg/other/anon7.C b/gcc/testsuite/g++.dg/other/anon7.C
new file mode 100644
index 000..12c1ab2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/anon7.C
@@ -0,0 +1,10 @@
+// PR c++/65879
+
+static struct
+{
+  void f();
+  struct Inner
+  {
+void g();
+  };
+} x;


Re: [PATCH] Make muser-mode the default for LEON3

2015-06-23 Thread Daniel Cederman



On 2015-06-23 14:34, Jakub Jelinek wrote:

On Tue, Jun 23, 2015 at 02:22:34PM +0200, Daniel Cederman wrote:

The muser-mode flag causes the CASA instruction for LEON3 to use the
user mode ASI. This is the correct behavior for almost all LEON3 targets.
For this reason it makes sense to make user mode the default. This patch
adds a flag for supervisor mode that can be used on the very few LEON3 targets
that requires CASA to use the supervisor ASI.


Why are you adding a new option and without deprecation removing a
previously accepted (at least since 4.8) option?
For just changing the default, you really don't need to add a new option
or remove -mno-user-mode, just change the default, which can be done
e.g. by checking if the bit has been explicitly set and if not, use the
desired default, or if you want to change the Mask() name, just
make it InverseMask, but keep the options as they are.

Jakub



How does one check if the bit has been explicitly set? It was not 
obvious to me, which is why I took a similar approach to a patch I found 
for another CPU target. If it is possible to change the default without 
adding another flag then that is obviously better and I will update my 
patch.


Best regards,
Daniel Cederman



[c-family PATCH] Fix for -Wlogical-op

2015-06-23 Thread Marek Polacek
While looking at something else I noticed that we're using == for
INTEGER_CSTs comparison.  That isn't going to work well, so use
tree_int_cst_equal instead.  Because of that we weren't diagnosing
the following test.

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

2015-06-23  Marek Polacek  pola...@redhat.com

* c-common.c (warn_logical_operator): Use tree_int_cst_equal
when comparing INTEGER_CSTs.

* c-c++-common/Wlogical-op-3.c: New test.

diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c
index c39a36d..9fcd9d6 100644
--- gcc/c-family/c-common.c
+++ gcc/c-family/c-common.c
@@ -1838,7 +1838,8 @@ warn_logical_operator (location_t location, enum 
tree_code code, tree type,
}
   /* Or warn if the operands have exactly the same range, e.g.
 A  0  A  0.  */
-  else if (low0 == low1  high0 == high1)
+  else if (tree_int_cst_equal (low0, low1)
+   tree_int_cst_equal (high0, high1))
{
  if (or_op)
warning_at (location, OPT_Wlogical_op,
diff --git gcc/testsuite/c-c++-common/Wlogical-op-3.c 
gcc/testsuite/c-c++-common/Wlogical-op-3.c
index e69de29..83b5df4 100644
--- gcc/testsuite/c-c++-common/Wlogical-op-3.c
+++ gcc/testsuite/c-c++-common/Wlogical-op-3.c
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options -Wlogical-op } */
+
+void
+fn1 (int a)
+{
+  const int x = a;
+  if (x  x) {} /* { dg-warning logical .and. of equal expressions } */
+  if (x  (int) x) {} /* { dg-warning logical .and. of equal expressions } 
*/
+  if ((int) x  x) {} /* { dg-warning logical .and. of equal expressions } 
*/
+  if ((int) x  (int) x) {} /* { dg-warning logical .and. of equal 
expressions } */
+}
+
+void
+fn2 (int a)
+{
+  const int x = a;
+  if (x || x) {} /* { dg-warning logical .or. of equal expressions } */
+  if (x || (int) x) {} /* { dg-warning logical .or. of equal expressions } */
+  if ((int) x || x) {} /* { dg-warning logical .or. of equal expressions } */
+  if ((int) x || (int) x) {} /* { dg-warning logical .or. of equal 
expressions } */
+}

Marek


Re: [AArch64] Implement -fpic for -mcmodel=small

2015-06-23 Thread Marcus Shawcroft
On 23 June 2015 at 14:02, Jiong Wang jiong.w...@arm.com wrote:

 Marcus Shawcroft writes:

 On 20 May 2015 at 11:21, Jiong Wang jiong.w...@arm.com wrote:

 gcc/
   * config/aarch64/aarch64.md: (ldr_got_small_mode): Support new GOT 
 relocation
   modifiers.
   (ldr_got_small_sidi): Ditto.
   * config/aarch64/iterators.md (got_modifier): New mode iterator.
   * config/aarch64/aarch64-otps.h (aarch64_code_model): New model.
   * config/aarch64/aarch64.c (aarch64_load_symref_appropriately): Support 
 -fpic.
   (aarch64_rtx_costs): Add costs for new instruction sequences.
   (initialize_aarch64_code_model): Initialize new model.
   (aarch64_classify_symbol): Recognize new model.
   (aarch64_asm_preferred_eh_data_format): Support new model.
   (aarch64_load_symref_appropriately): Generate new instruction sequences 
 for -fpic.
   (TARGET_USE_PSEUDO_PIC_REG): New definition.
   (aarch64_use_pseudo_pic_reg): New function.

 gcc/testsuite/
   * gcc.target/aarch64/pic-small.c: New testcase.


 Rather than thread tests against aarch64_cmodel throughout the
 existing code can we instead extend classify_symbol with a new symbol
 classification?

 Yes, we can. As -fPIC/-fpic allow 4G/32K GOT table size, we may name
 corresponding symbol classification as SYMBOL_GOT_4G,
 SYMBOL_GOT_32K.

 But can we let this patch go in and create a another patch to improve
 this? there are several other TLS patches may needs rebase if we change
 this immedaitely.

We can wait for a proper solution that fits with the code already in place.


Re: RFA: Add support for -fstack-usage to various ports

2015-06-23 Thread Jeff Law

On 06/23/2015 06:56 AM, Nick Clifton wrote:

Hi Guys,

   The patch below adds support for the -fstack-usage option to the BFIN,
   FT32, H8300, IQ2000 and M32C ports.  It also adjusts the expected
   output in the gcc.dg/stack-usage-1.c test for the V850 and MN10300 to
   match the actual results generated by these toolchains.

   Tested with no regressions on bfin-elf, ft32-elf, h8300-elf,
   iq2000-elf, m32c-elf, mn10300-elf and v850-elf toolchains.

   OK to apply ?

Cheers
   Nick

gcc/ChangeLog
2015-06-23  Nick Clifton  ni...@redhat.com

* config/bfin/bfin.c (bfin_expand_prologue): Set
current_function_static_stack_size if flag_stack_usage_info is
 set.
* config/ft32/ft32.c (ft32_expand_prologue): Likewise.
* config/h8300/h8300.c (h8300_expand_prologue): Likewise.
* config/iq2000/iq2000.c (iq2000_expand_prologue): Likewise.
* config/m32c/m32c.c (m32c_emit_prologue): Likewise.

gcc/testsuite/ChangeLog
2015-06-23  Nick Clifton  ni...@redhat.com

* gcc.dg/stack-usage-1.c: Add SIZE values for V850, MN10300,
H8300 and M32R targets.

OK.
jeff



Re: [PATCH] Make muser-mode the default for LEON3

2015-06-23 Thread Daniel Cederman



On 2015-06-23 14:58, Jakub Jelinek wrote:

On Tue, Jun 23, 2015 at 02:48:45PM +0200, Daniel Cederman wrote:

How does one check if the bit has been explicitly set? It was not obvious to


if (TARGET_USER_MODE_P (target_flags_explicit))


me, which is why I took a similar approach to a patch I found for another
CPU target. If it is possible to change the default without adding another
flag then that is obviously better and I will update my patch.


Or you can just change the default target_flags, supposedly with
TargetVariable
int target_flags = MASK_USER_MODE
in the opt file, there are really many possibilities.

Jakub



Thanks! I went with your suggestion in the previous mail and removed the 
new -msv-mode option and inversed the user mode mask.


Best regards,
Daniel Cederman


Re: [PATCH] Make muser-mode the default for LEON3

2015-06-23 Thread Jakub Jelinek
On Tue, Jun 23, 2015 at 02:22:34PM +0200, Daniel Cederman wrote:
 The muser-mode flag causes the CASA instruction for LEON3 to use the
 user mode ASI. This is the correct behavior for almost all LEON3 targets.
 For this reason it makes sense to make user mode the default. This patch
 adds a flag for supervisor mode that can be used on the very few LEON3 targets
 that requires CASA to use the supervisor ASI.

Why are you adding a new option and without deprecation removing a
previously accepted (at least since 4.8) option?
For just changing the default, you really don't need to add a new option
or remove -mno-user-mode, just change the default, which can be done
e.g. by checking if the bit has been explicitly set and if not, use the
desired default, or if you want to change the Mask() name, just
make it InverseMask, but keep the options as they are.

Jakub


Re: [c-family PATCH] Fix for -Wlogical-op

2015-06-23 Thread Jeff Law

On 06/23/2015 07:12 AM, Marek Polacek wrote:

While looking at something else I noticed that we're using == for
INTEGER_CSTs comparison.  That isn't going to work well, so use
tree_int_cst_equal instead.  Because of that we weren't diagnosing
the following test.

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

2015-06-23  Marek Polacek  pola...@redhat.com

* c-common.c (warn_logical_operator): Use tree_int_cst_equal
when comparing INTEGER_CSTs.

* c-c++-common/Wlogical-op-3.c: New test.

OK.
jeff



RFA: Add support for -fstack-usage to various ports

2015-06-23 Thread Nick Clifton
Hi Guys,

  The patch below adds support for the -fstack-usage option to the BFIN,
  FT32, H8300, IQ2000 and M32C ports.  It also adjusts the expected
  output in the gcc.dg/stack-usage-1.c test for the V850 and MN10300 to
  match the actual results generated by these toolchains.

  Tested with no regressions on bfin-elf, ft32-elf, h8300-elf,
  iq2000-elf, m32c-elf, mn10300-elf and v850-elf toolchains.

  OK to apply ?

Cheers
  Nick

gcc/ChangeLog
2015-06-23  Nick Clifton  ni...@redhat.com

* config/bfin/bfin.c (bfin_expand_prologue): Set
current_function_static_stack_size if flag_stack_usage_info is
set. 
* config/ft32/ft32.c (ft32_expand_prologue): Likewise.
* config/h8300/h8300.c (h8300_expand_prologue): Likewise.
* config/iq2000/iq2000.c (iq2000_expand_prologue): Likewise.
* config/m32c/m32c.c (m32c_emit_prologue): Likewise.

gcc/testsuite/ChangeLog
2015-06-23  Nick Clifton  ni...@redhat.com

* gcc.dg/stack-usage-1.c: Add SIZE values for V850, MN10300,
H8300 and M32R targets.

Index: gcc/config/bfin/bfin.c
===
--- gcc/config/bfin/bfin.c  (revision 224834)
+++ gcc/config/bfin/bfin.c  (working copy)
@@ -1090,6 +1090,9 @@
   tree attrs = TYPE_ATTRIBUTES (TREE_TYPE (current_function_decl));
   bool all = lookup_attribute (saveall, attrs) != NULL_TREE;
 
+  if (flag_stack_usage_info)
+current_function_static_stack_size = frame_size;
+
   if (fkind != SUBROUTINE)
 {
   expand_interrupt_handler_prologue (spreg, fkind, all);
Index: gcc/config/ft32/ft32.c
===
--- gcc/config/ft32/ft32.c  (revision 224834)
+++ gcc/config/ft32/ft32.c  (working copy)
@@ -456,6 +456,9 @@
 
   ft32_compute_frame ();
 
+  if (flag_stack_usage_info)
+current_function_static_stack_size = cfun-machine-size_for_adjusting_sp;
+
   if (!must_link ()  (cfun-machine-callee_saved_reg_size == 4))
 {
   insn =
Index: gcc/config/h8300/h8300.c
===
--- gcc/config/h8300/h8300.c(revision 224834)
+++ gcc/config/h8300/h8300.c(working copy)
@@ -896,6 +896,12 @@
 
   /* Leave room for locals.  */
   h8300_emit_stack_adjustment (-1, round_frame_size (get_frame_size ()), true);
+
+  if (flag_stack_usage_info)
+current_function_static_stack_size
+  = round_frame_size (get_frame_size ())
+  + (__builtin_popcount (saved_regs) * UNITS_PER_WORD)
+  + (frame_pointer_needed ? UNITS_PER_WORD : 0);
 }
 
 /* Return nonzero if we can use rts for the function currently being
Index: gcc/config/iq2000/iq2000.c
===
--- gcc/config/iq2000/iq2000.c  (revision 224834)
+++ gcc/config/iq2000/iq2000.c  (working copy)
@@ -2072,6 +2072,9 @@
}
 }
 
+  if (flag_stack_usage_info)
+current_function_static_stack_size = cfun-machine-total_size;
+
   emit_insn (gen_blockage ());
 }
 
Index: gcc/config/m32c/m32c.c
===
--- gcc/config/m32c/m32c.c  (revision 224834)
+++ gcc/config/m32c/m32c.c  (working copy)
@@ -4123,6 +4123,9 @@
!m32c_function_needs_enter ())
 cfun-machine-use_rts = 1;
 
+  if (flag_stack_usage_info)
+current_function_static_stack_size = frame_size;
+  
   if (frame_size  254)
 {
   extra_frame_size = frame_size - 254;
Index: gcc/config/m32r/m32r.c
===
--- gcc/config/m32r/m32r.c  (revision 224834)
+++ gcc/config/m32r/m32r.c  (working copy)
@@ -1665,6 +1665,9 @@
   if (! current_frame_info.initialized)
 m32r_compute_frame_size (get_frame_size ());
 
+  if (flag_stack_usage_info)
+current_function_static_stack_size = current_frame_info.total_size;
+
   gmask = current_frame_info.gmask;
 
   /* These cases shouldn't happen.  Catch them now.  */
Index: gcc/testsuite/gcc.dg/stack-usage-1.c
===
--- gcc/testsuite/gcc.dg/stack-usage-1.c(revision 224834)
+++ gcc/testsuite/gcc.dg/stack-usage-1.c(working copy)
@@ -81,6 +81,14 @@
 #  define SIZE 254
 #elif defined (__nios2__)
 #  define SIZE 252
+#elif defined (__v850__)
+#define SIZE 260
+#elif defined (__mn10300__)
+#define SIZE 252
+#elif defined (__H8300SX__) || defined (__H8300S__) || defined (__H8300H__) || 
defined (__H8300__) 
+#define SIZE 252
+#elif defined (__M32R__)
+#define SIZE 252
 #else
 #  define SIZE 256
 #endif


[PATCH] Make muser-mode the default for LEON3

2015-06-23 Thread Daniel Cederman
The muser-mode flag causes the CASA instruction for LEON3 to use the
user mode ASI. This is the correct behavior for almost all LEON3 targets.
For this reason it makes sense to make user mode the default.

gcc/ChangeLog:

2015-06-23  Daniel Cederman  ceder...@gaisler.com

* config/sparc/sparc.opt: Rename mask from USER_MODE to SV_MODE
  and make it inverse to change default
* config/sparc/sync.md: Only use supervisor ASI for CASA when in
  supervisor mode
* doc/invoke.texi: Document change of default
---
 gcc/config/sparc/sparc.opt | 4 ++--
 gcc/config/sparc/sync.md   | 6 +++---
 gcc/doc/invoke.texi| 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/gcc/config/sparc/sparc.opt b/gcc/config/sparc/sparc.opt
index 93d24a6..85bf0bd 100644
--- a/gcc/config/sparc/sparc.opt
+++ b/gcc/config/sparc/sparc.opt
@@ -114,8 +114,8 @@ Target
 Optimize tail call instructions in assembler and linker
 
 muser-mode
-Target Report Mask(USER_MODE)
-Do not generate code that can only run in supervisor mode
+Target Report InverseMask(SV_MODE)
+Do not generate code that can only run in supervisor mode (default)
 
 mcpu=
 Target RejectNegative Joined Var(sparc_cpu_and_features) 
Enum(sparc_processor_type) Init(PROCESSOR_V7)
diff --git a/gcc/config/sparc/sync.md b/gcc/config/sparc/sync.md
index 7d00b10..2fabff5 100644
--- a/gcc/config/sparc/sync.md
+++ b/gcc/config/sparc/sync.md
@@ -222,10 +222,10 @@
  UNSPECV_CAS))]
   TARGET_LEON3
 {
-  if (TARGET_USER_MODE)
-return casa\t%1 0xa, %2, %0; /* ASI for user data space.  */
-  else
+  if (TARGET_SV_MODE)
 return casa\t%1 0xb, %2, %0; /* ASI for supervisor data space.  */
+  else
+return casa\t%1 0xa, %2, %0; /* ASI for user data space.  */
 }
   [(set_attr type multi)])
 
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index b99ab1c..86b2a73 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -21305,8 +21305,8 @@ in a performance loss, especially for floating-point 
code.
 @opindex muser-mode
 @opindex mno-user-mode
 Do not generate code that can only run in supervisor mode.  This is relevant
-only for the @code{casa} instruction emitted for the LEON3 processor.  The
-default is @option{-mno-user-mode}.
+only for the @code{casa} instruction emitted for the LEON3 processor.  This
+is the default.
 
 @item -mno-faster-structs
 @itemx -mfaster-structs
-- 
2.4.3



[PATCH 2/2] Add leon3r0 and leon3r0v7 CPU targets

2015-06-23 Thread Daniel Cederman
Early variants of LEON3, revision 0, do not support the CASA instruction.
This patch adds two new targets, leon3r0 and leon3r0v7, that are equivalent
to leon3 and leon3v7, except that they do not support CASA.

gcc/ChangeLog:

2015-06-22  Daniel Cederman  ceder...@gaisler.com

* config.gcc: Add leon3r0[v7] targets
* config/sparc/leon.md: Add leon3r0[v7] to FPU timing
* config/sparc/sparc-opts.h (enum processor_type): Add leon3r0[v7] 
targets
* config/sparc/sparc.c (sparc_option_override): Add leon3r0[v7] as 
targets
  without CASA support
* config/sparc/sparc.h: Add leon3r0[v7] targets
* config/sparc/sparc.md: Add leon3r0[v7] targets
* config/sparc/sparc.opt: Add leon3r0[v7] targets
* doc/invoke.texi: Add leon3r0[v7] targets
---
 gcc/config.gcc|  6 ++
 gcc/config/sparc/leon.md  | 14 +++---
 gcc/config/sparc/sparc-opts.h |  2 ++
 gcc/config/sparc/sparc.c  |  4 
 gcc/config/sparc/sparc.h  | 44 ---
 gcc/config/sparc/sparc.md |  2 ++
 gcc/config/sparc/sparc.opt|  6 ++
 gcc/doc/invoke.texi   | 22 +++---
 8 files changed, 59 insertions(+), 41 deletions(-)

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 805638d..b10a1c9 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -3322,10 +3322,7 @@ if test x$with_cpu = x ; then
  with_cpu=leon
  ;;
*-leon[3-9]*)
- with_cpu=leon3
- ;;
-   *-leon[3-9]v7*)
- with_cpu=leon3v7
+ with_cpu=`echo ${target} | sed 's/.*-\(leon[a-z0-9]*\).*$/\1/'`
  ;;
*)
  with_cpu=`echo ${target} | sed 's/-.*$//'`
@@ -4198,6 +4195,7 @@ case ${target} in
 | sparc | sparcv9 | sparc64 \
| v7 | cypress \
| v8 | supersparc | hypersparc | leon | leon3 | leon3v7 
\
+   | leon3r0 | leon3r0v7 \
| sparclite | f930 | f934 | sparclite86x \
| sparclet | tsc701 \
| v9 | ultrasparc | ultrasparc3 | niagara | niagara2 \
diff --git a/gcc/config/sparc/leon.md b/gcc/config/sparc/leon.md
index aca92fc..3441a74 100644
--- a/gcc/config/sparc/leon.md
+++ b/gcc/config/sparc/leon.md
@@ -29,11 +29,11 @@
 
 ;; Use a double reservation to work around the load pipeline hazard on UT699.
 (define_insn_reservation leon3_load 1
-  (and (eq_attr cpu leon3,leon3v7) (eq_attr type load,sload))
+  (and (eq_attr cpu leon3,leon3v7,leon3r0,leon3r0v7) (eq_attr type 
load,sload))
   leon_memory*2)
 
 (define_insn_reservation leon_store 2
-  (and (eq_attr cpu leon,leon3,leon3v7) (eq_attr type store))
+  (and (eq_attr cpu leon,leon3,leon3v7,leon3r0,leon3r0v7) (eq_attr type 
store))
   leon_memory*2)
 
 ;; This describes Gaisler Research's FPU
@@ -44,21 +44,21 @@
 (define_cpu_unit grfpu_ds grfpu)
 
 (define_insn_reservation leon_fp_alu 4
-  (and (eq_attr cpu leon,leon3,leon3v7) (eq_attr type fp,fpcmp,fpmul))
+  (and (eq_attr cpu leon,leon3,leon3v7,leon3r0,leon3r0v7) (eq_attr type 
fp,fpcmp,fpmul))
   grfpu_alu, nothing*3)
 
 (define_insn_reservation leon_fp_divs 16
-  (and (eq_attr cpu leon,leon3,leon3v7) (eq_attr type fpdivs))
+  (and (eq_attr cpu leon,leon3,leon3v7,leon3r0,leon3r0v7) (eq_attr type 
fpdivs))
   grfpu_ds*14, nothing*2)
 
 (define_insn_reservation leon_fp_divd 17
-  (and (eq_attr cpu leon,leon3,leon3v7) (eq_attr type fpdivd))
+  (and (eq_attr cpu leon,leon3,leon3v7,leon3r0,leon3r0v7) (eq_attr type 
fpdivd))
   grfpu_ds*15, nothing*2)
 
 (define_insn_reservation leon_fp_sqrts 24
-  (and (eq_attr cpu leon,leon3,leon3v7) (eq_attr type fpsqrts))
+  (and (eq_attr cpu leon,leon3,leon3v7,leon3r0,leon3r0v7) (eq_attr type 
fpsqrts))
   grfpu_ds*22, nothing*2)
 
 (define_insn_reservation leon_fp_sqrtd 25
-  (and (eq_attr cpu leon,leon3,leon3v7) (eq_attr type fpsqrtd))
+  (and (eq_attr cpu leon,leon3,leon3v7,leon3r0,leon3r0v7) (eq_attr type 
fpsqrtd))
   grfpu_ds*23, nothing*2)
diff --git a/gcc/config/sparc/sparc-opts.h b/gcc/config/sparc/sparc-opts.h
index 7679d0d..24a2b64 100644
--- a/gcc/config/sparc/sparc-opts.h
+++ b/gcc/config/sparc/sparc-opts.h
@@ -30,6 +30,8 @@ enum processor_type {
   PROCESSOR_SUPERSPARC,
   PROCESSOR_HYPERSPARC,
   PROCESSOR_LEON,
+  PROCESSOR_LEON3R0,
+  PROCESSOR_LEON3R0V7,
   PROCESSOR_LEON3,
   PROCESSOR_LEON3V7,
   PROCESSOR_SPARCLITE,
diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index 205e3cb..862e88d 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -1280,6 +1280,8 @@ sparc_option_override (void)
 { supersparc,MASK_ISA, MASK_V8 },
 { hypersparc,MASK_ISA, MASK_V8|MASK_FPU },
 { leon,  MASK_ISA, MASK_V8|MASK_LEON|MASK_FPU },
+{ leon3r0,   MASK_ISA, MASK_V8|MASK_LEON3|MASK_FPU },
+{ leon3r0v7, MASK_ISA, MASK_LEON3|MASK_FPU },
 { leon3, MASK_ISA, 

[PATCH] Use leon3 target for native LEON on Linux

2015-06-23 Thread Daniel Cederman
Linux requires LEON version 3 or above with CASA support.

gcc/ChangeLog:

2015-06-23  Daniel Cederman  ceder...@gaisler.com

* config/sparc/driver-sparc.c: map /proc/cpuinfo with CPU LEON
  to leon3
---
 gcc/config/sparc/driver-sparc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/config/sparc/driver-sparc.c b/gcc/config/sparc/driver-sparc.c
index 778de2c..5969735 100644
--- a/gcc/config/sparc/driver-sparc.c
+++ b/gcc/config/sparc/driver-sparc.c
@@ -73,6 +73,7 @@ static const struct cpu_names {
   { UltraSparc T2,   niagara2 },
   { UltraSparc T3,   niagara3 },
   { UltraSparc T4,   niagara4 },
+  { LEON,leon3 },
 #endif
   { NULL,  NULL }
   };
-- 
2.4.3



Re: [PATCH][ARM] PR/65711: Don't pass '-dynamic-linker' when '-shared' is used

2015-06-23 Thread Ludovic Courtès
Jakub Jelinek ja...@redhat.com skribis:

 On Tue, Jun 23, 2015 at 11:30:25AM +0200, Ludovic Courtès wrote:
 Ramana Radhakrishnan ramana@googlemail.com skribis:
 
  On Thu, Apr 23, 2015 at 9:29 AM, Ludovic Courtès l...@gnu.org wrote:
  As discussed at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65711.
 
  Patch is for both 4.8 and 4.9 (possibly 5.1 too, I haven’t checked.)
 
 
  OK for trunk. This is also ok for all release branches if no
  objections in 24 hours.
 
 [...]
 
  gcc/
  2015-04-23  Ludovic Courtès  l...@gnu.org
 
  PR 65711
  * config/arm/linux-elf.h (LINUX_TARGET_LINK_SPEC): Move
  '-dynamic-linker' within %{!shared: ...}.
 
 Committed to gcc-4_8-branch, gcc-4_9-branch, gcc-5-branch, and trunk.
 Please let me know if there’s anything I missed.

 See richi's mail.  4.8 branch has already been closed, and 4.9 branch
 is frozen, so you should have asked for RM permission.

Noted.  That part of the process was not clear to me, apologies.

 Also, in the ChangeLog entries, one should write it in the form
 PR component/bugno,
 so
   PR target/65711
 in your case.

OK.

Thanks,
Ludo’.


[gomp4] Additional testing for deviceptr clause.

2015-06-23 Thread James Norris

Hi!

The following patch adds additional testing of the deviceptr
clause.

Patch applied to gomp-4_0-branch.

Thanks!
Jim
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/deviceptr-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/deviceptr-1.c
index e271a37..e62c315 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/deviceptr-1.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/deviceptr-1.c
@@ -28,5 +28,26 @@ int main (void)
 abort ();
 #endif
 
+  a_1 = a_2 = 0;
+
+#pragma acc data deviceptr (a)
+#pragma acc parallel copyout (a_1, a_2)
+  {
+a_1 = a;
+a_2 = a;
+  }
+
+  if (a != A)
+abort ();
+  if (a_1 != a)
+abort ();
+#if ACC_MEM_SHARED
+  if (a_2 != a)
+abort ();
+#else
+  if (a_2 == a)
+abort ();
+#endif
+
   return 0;
 }


Re: [PATCH] Make muser-mode the default for LEON3

2015-06-23 Thread Jakub Jelinek
On Tue, Jun 23, 2015 at 02:48:45PM +0200, Daniel Cederman wrote:
 How does one check if the bit has been explicitly set? It was not obvious to

if (TARGET_USER_MODE_P (target_flags_explicit))

 me, which is why I took a similar approach to a patch I found for another
 CPU target. If it is possible to change the default without adding another
 flag then that is obviously better and I will update my patch.

Or you can just change the default target_flags, supposedly with
TargetVariable
int target_flags = MASK_USER_MODE
in the opt file, there are really many possibilities.

Jakub


Re: [PATCH] Expand PIC calls without PLT with -fno-plt

2015-06-23 Thread Jeff Law

On 06/23/2015 02:29 AM, Ramana Radhakrishnan wrote:


If you try disabling the REG_EQUAL note generation [*], you'll probably find a
performance regression on arm32 (and probably on aarch64 as well?
we only


IMHO disabling the REG_EQUAL note generation is the wrong way to go about this.

Agreed.


Irrespective of combine, as a first step we should fix the predicates
and the call expanders to prevent this sort of replacement in the
backends. Tightening the predicates in the call patterns will achieve
the same for you and then we can investigate the use of GOT_PREL. My
recollection of this is that you need to work out when it's more
beneficial to use GOT_PREL over GOT but it's been a while since I
looked in that area.

Also agreed.  This is primarily a backend issue with the call patterns.

This is similar to the situation on the PA with the 32bit SOM runtime 
where direct and indirect calls have different calling conventions. 
Those different calling conventions combined with the early loading of 
the parameter registers in effect restricts us from being able to 
transform an indirect call into a direct call (combine) or vice-versa (cse).


The way we handled this was to split the calls into two patterns, one 
for direct one for indirect and tightening their predicates appropriately.


Jeff



[nvptx] add select

2015-06-23 Thread Nathan Sidwell
I've committed this PTX patch to add support for the selp instruction.  It's 
pretty much a direct implementation of 'r = a ? b : c'.  This is sufficient for 
combine(?) to generate selp instructions such as:


selp.u32%r22, %r25, %r26, %r28;
selp.u32%r22, %r25, 4, %r27;
selp.f32%r22, %r25, %r26, %r28;
selp.f32%r22, %r25, 0f40a0, %r27;

Approved by Bernd off list.
--
Nathan Sidwell - Director, Sourcery Services - Mentor Embedded
2015-06-22  Nathan Sidwell  nat...@codesourcery.com

	* config/nvptx/nvptx.md (sel_truemode, sel_falsemode): New
	conditional selects.
	(setcc_intmode, setcc_floatmode): Reformat.

Index: config/nvptx/nvptx.md
===
--- config/nvptx/nvptx.md	(revision 224757)
+++ config/nvptx/nvptx.md	(working copy)
@@ -873,35 +873,71 @@
   
   %.\\tselp%t0 %0,-1,0,%1;)
 
+(define_insn sel_truemode
+  [(set (match_operand:HSDIM 0 nvptx_register_operand =R)
+(if_then_else:HSDIM
+	  (ne (match_operand:BI 1 nvptx_register_operand R) (const_int 0))
+	  (match_operand:HSDIM 2 nvptx_nonmemory_operand Ri)
+	  (match_operand:HSDIM 3 nvptx_nonmemory_operand Ri)))]
+  
+  %.\\tselp%t0\\t%0, %2, %3, %1;)
+
+(define_insn sel_truemode
+  [(set (match_operand:SDFM 0 nvptx_register_operand =R)
+(if_then_else:SDFM
+	  (ne (match_operand:BI 1 nvptx_register_operand R) (const_int 0))
+	  (match_operand:SDFM 2 nvptx_nonmemory_operand RF)
+	  (match_operand:SDFM 3 nvptx_nonmemory_operand RF)))]
+  
+  %.\\tselp%t0\\t%0, %2, %3, %1;)
+
+(define_insn sel_falsemode
+  [(set (match_operand:HSDIM 0 nvptx_register_operand =R)
+(if_then_else:HSDIM
+	  (eq (match_operand:BI 1 nvptx_register_operand R) (const_int 0))
+	  (match_operand:HSDIM 2 nvptx_nonmemory_operand Ri)
+	  (match_operand:HSDIM 3 nvptx_nonmemory_operand Ri)))]
+  
+  %.\\tselp%t0\\t%0, %3, %2, %1;)
+
+(define_insn sel_falsemode
+  [(set (match_operand:SDFM 0 nvptx_register_operand =R)
+(if_then_else:SDFM
+	  (eq (match_operand:BI 1 nvptx_register_operand R) (const_int 0))
+	  (match_operand:SDFM 2 nvptx_nonmemory_operand RF)
+	  (match_operand:SDFM 3 nvptx_nonmemory_operand RF)))]
+  
+  %.\\tselp%t0\\t%0, %3, %2, %1;)
+
 (define_insn setcc_intmode
   [(set (match_operand:SI 0 nvptx_register_operand =R)
 	(match_operator:SI 1 nvptx_comparison_operator
-			   [(match_operand:HSDIM 2 nvptx_register_operand R)
-			(match_operand:HSDIM 3 nvptx_nonmemory_operand Ri)]))]
+	  [(match_operand:HSDIM 2 nvptx_register_operand R)
+	   (match_operand:HSDIM 3 nvptx_nonmemory_operand Ri)]))]
   
   %.\\tset%t0%c1 %0,%2,%3;)
 
 (define_insn setcc_intmode
   [(set (match_operand:SI 0 nvptx_register_operand =R)
 	(match_operator:SI 1 nvptx_float_comparison_operator
-			   [(match_operand:SDFM 2 nvptx_register_operand R)
-			(match_operand:SDFM 3 nvptx_nonmemory_operand RF)]))]
+	   [(match_operand:SDFM 2 nvptx_register_operand R)
+	(match_operand:SDFM 3 nvptx_nonmemory_operand RF)]))]
   
   %.\\tset%t0%c1 %0,%2,%3;)
 
 (define_insn setcc_floatmode
   [(set (match_operand:SF 0 nvptx_register_operand =R)
 	(match_operator:SF 1 nvptx_comparison_operator
-			   [(match_operand:HSDIM 2 nvptx_register_operand R)
-			(match_operand:HSDIM 3 nvptx_nonmemory_operand Ri)]))]
+	   [(match_operand:HSDIM 2 nvptx_register_operand R)
+	(match_operand:HSDIM 3 nvptx_nonmemory_operand Ri)]))]
   
   %.\\tset%t0%c1 %0,%2,%3;)
 
 (define_insn setcc_floatmode
   [(set (match_operand:SF 0 nvptx_register_operand =R)
 	(match_operator:SF 1 nvptx_float_comparison_operator
-			   [(match_operand:SDFM 2 nvptx_register_operand R)
-			(match_operand:SDFM 3 nvptx_nonmemory_operand RF)]))]
+	   [(match_operand:SDFM 2 nvptx_register_operand R)
+	(match_operand:SDFM 3 nvptx_nonmemory_operand RF)]))]
   
   %.\\tset%t0%c1 %0,%2,%3;)
 


Re: RFA: FT32: Fix building gcc.

2015-06-23 Thread Jeff Law

On 06/23/2015 06:10 AM, Nicholas Clifton wrote:

Hi Guys,

   It seems that the FT32 port of GCC does not have a maintainer at the
   moment.  Nevertheless I have a patch to fix a couple of build time
   problems compiling gcc for the FT32.  Is this OK to apply ?

Cheers
   Nick

gcc/ChangeLog
2015-06-23  Nick Clifton  ni...@redhat.com

 * config/ft32/ft32.c: Include emit-rtl.h for the definition of
 crtl.
 (ft32_print_operand): Cast the result of INTVAL in order to make
 sure that the correct value is printed.
 * config/ft32/ft32.h (STACK_GROWS_DOWNWARD): Define to an
 integer.
James Bowman is the maintainer, though that isn't reflected in the 
MAINTAINERS file.


OK for the trunk.

jeff



[PATCH] Fix PR66636

2015-06-23 Thread Richard Biener

The following fixes an ICE with 188.ammp and AVX2.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2015-06-23  Richard Biener  rguent...@suse.de

PR tree-optimization/66636
* tree-vect-stmts.c (vectorizable_store): Properly compute the
def type for further defs for strided stores.

* gcc.dg/vect/pr66636.c: New testcase.

Index: gcc/tree-vect-stmts.c
===
*** gcc/tree-vect-stmts.c   (revision 224834)
--- gcc/tree-vect-stmts.c   (working copy)
*** vectorizable_store (gimple stmt, gimple_
*** 5365,5371 
  if (slp)
vec_oprnd = vec_oprnds[j];
  else
!   vec_oprnd = vect_get_vec_def_for_stmt_copy (dt, vec_oprnd);
}
  
  for (i = 0; i  nstores; i++)
--- 5365,5375 
  if (slp)
vec_oprnd = vec_oprnds[j];
  else
!   {
! vect_is_simple_use (vec_oprnd, NULL, loop_vinfo,
! bb_vinfo, def_stmt, def, dt);
! vec_oprnd = vect_get_vec_def_for_stmt_copy (dt, 
vec_oprnd);
!   }
}
  
  for (i = 0; i  nstores; i++)
Index: gcc/testsuite/gcc.dg/vect/pr66636.c
===
*** gcc/testsuite/gcc.dg/vect/pr66636.c (revision 0)
--- gcc/testsuite/gcc.dg/vect/pr66636.c (working copy)
***
*** 0 
--- 1,29 
+ /* { dg-additional-options -mavx2 { target avx_runtime } } */
+ 
+ #include tree-vect.h
+ 
+ extern void abort (void);
+ 
+ struct X { double x; double y; };
+ 
+ void foo (struct X *x, double px, int s)
+ {
+   int i;
+   for (i = 0; i  256; ++i)
+ {
+   x[i*s].x = px;
+   x[i*s].y = i + px;
+ }
+ }
+ 
+ int main()
+ {
+   struct X x[512];
+   int i;
+   check_vect ();
+   foo (x, 1., 2);
+   if (x[0].x != 1. || x[0].y != 1.
+   || x[510].x != 1. || x[510].y != 256.)
+ abort ();
+   return 0;
+ }


Fwd: [PATCH] Add CFI entries for ARM Linux idiv0 / ldiv0

2015-06-23 Thread James Lemke

Ping..


 Forwarded Message 
Subject: [PATCH] Add CFI entries for ARM Linux idiv0 / ldiv0
Date: Tue, 16 Jun 2015 17:25:49 -0400
From: James Lemke jwle...@codesourcery.com
To: gcc-patches@gcc.gnu.org

A divide by zero exception was not giving a proper traceback for LINUX
ARM_EABI.  The attached patch fixes the problem on trunk (and several
local branches).

Tested on gcc-trunk for arm-none-linux-gnueabi.

OK to commit?

--
Jim Lemke, GNU Tools Sourcerer
Mentor Graphics / CodeSourcery
Orillia, Ontario



2015-06-16  James Lemke  jwle...@codesourcery.com

	libgcc/config/arm/
	* lib1funcs.S (aeabi_idiv0, aeabi_ldiv0): Add CFI entries for
	Linux ARM_EABI.

Index: libgcc/config/arm/lib1funcs.S
===
--- libgcc/config/arm/lib1funcs.S	(revision 224523)
+++ libgcc/config/arm/lib1funcs.S	(working copy)
@@ -1336,23 +1336,30 @@ LSYM(Lover12):
 #define SIGFPE	8
 
 #ifdef __ARM_EABI__
+	cfi_start	__aeabi_ldiv0, LSYM(Lend_aeabi_ldiv0)
 	WEAK aeabi_idiv0
 	WEAK aeabi_ldiv0
 	ARM_FUNC_START aeabi_idiv0
 	ARM_FUNC_START aeabi_ldiv0
+	do_push	{r1, lr}
+98:	cfi_push 98b - __aeabi_ldiv0, 0xe, -0x4, 0x8
 #else
+	cfi_start	__div0, LSYM(Lend_div0)
 	ARM_FUNC_START div0
+	do_push	{r1, lr}
+98:	cfi_push 98b - __div0, 0xe, -0x4, 0x8
 #endif
 
-	do_push	{r1, lr}
 	mov	r0, #SIGFPE
 	bl	SYM(raise) __PLT__
-	RETLDM	r1
+	RETLDM	r1 unwind=98b
 
 #ifdef __ARM_EABI__
+	cfi_end	LSYM(Lend_aeabi_ldiv0)
 	FUNC_END aeabi_ldiv0
 	FUNC_END aeabi_idiv0
 #else
+	cfi_end	LSYM(Lend_div0)
 	FUNC_END div0
 #endif
 	



Re: [gomp4] Generate sequential loop for OpenACC loop directive inside kernels

2015-06-23 Thread Chung-Lin Tang
On 2015/6/16 05:05 PM, Tom de Vries wrote:
 On 16/06/15 10:59, Chung-Lin Tang wrote:
 This patch adjusts omp-low.c:expand_omp_for_generic() to expand to a 
 sequential
 loop form (without the OMP runtime calls), used for loop directives inside
 OpenACC kernels constructs. Tom mentions that this allows the kernels 
 parallelization
 to work when '#pragma acc loop' makes the front-ends create OMP_FOR, which 
 the
 loop analysis phases don't understand.

 Tested and committed to gomp-4_0-branch.

 
 Hi Chung-Lin,
 
 can you commit a test-case to exercise the code?
 
 Thanks,
 - Tom

Just committed the attached testcase patch to gomp-4_0-branch.

Chung-Lin

2015-06-23  Chung-Lin Tang  clt...@codesourcery.com

gcc/testsuite/
* c-c++-common/goacc/kernels-loop.c (ACC_LOOP): Add #ifndef/#define.
(main): Tag loops inside kernels construct with '#pragma ACC_LOOP'.
* c-c++-common/goacc/kernels-loop-2.c: Likewise.
* c-c++-common/goacc/kernels-loop-3.c: Likewise.
* c-c++-common/goacc/kernels-loop-n.c: Likewise.
* c-c++-common/goacc/kernels-loop-acc-loop.c: New test.
* c-c++-common/goacc/kernels-loop-2-acc-loop.c: New test.
* c-c++-common/goacc/kernels-loop-3-acc-loop.c: New test.
* c-c++-common/goacc/kernels-loop-n-acc-loop.c: New test.

Index: gcc/testsuite/c-c++-common/goacc/kernels-loop-3-acc-loop.c
===
--- gcc/testsuite/c-c++-common/goacc/kernels-loop-3-acc-loop.c	(revision 0)
+++ gcc/testsuite/c-c++-common/goacc/kernels-loop-3-acc-loop.c	(revision 0)
@@ -0,0 +1,20 @@
+/* { dg-additional-options -O2 } */
+/* { dg-additional-options -ftree-parallelize-loops=32 } */
+/* { dg-additional-options -fdump-tree-parloops_oacc_kernels-all } */
+/* { dg-additional-options -fdump-tree-optimized } */
+
+/* Check that loops with '#pragma acc loop' tagged gets properly parallelized.  */
+#define ACC_LOOP acc loop
+#include kernels-loop-3.c
+
+/* Check that only one loop is analyzed, and that it can be parallelized.  */
+/* { dg-final { scan-tree-dump-times SUCCESS: may be parallelized 1 parloops_oacc_kernels } } */
+/* { dg-final { scan-tree-dump-not FAILED: parloops_oacc_kernels } } */
+
+/* Check that the loop has been split off into a function.  */
+/* { dg-final { scan-tree-dump-times (?n);; Function .*main._omp_fn.0 1 optimized } } */
+
+/* { dg-final { scan-tree-dump-times (?n)pragma omp target oacc_parallel.*num_gangs\\(32\\) 1 parloops_oacc_kernels } } */
+
+/* { dg-final { cleanup-tree-dump parloops_oacc_kernels } } */
+/* { dg-final { cleanup-tree-dump optimized } } */
Index: gcc/testsuite/c-c++-common/goacc/kernels-loop-2.c
===
--- gcc/testsuite/c-c++-common/goacc/kernels-loop-2.c	(revision 224836)
+++ gcc/testsuite/c-c++-common/goacc/kernels-loop-2.c	(working copy)
@@ -8,6 +8,10 @@
 #define N (1024 * 512)
 #define COUNTERTYPE unsigned int
 
+#ifndef ACC_LOOP
+#define ACC_LOOP
+#endif
+
 int
 main (void)
 {
@@ -21,18 +25,21 @@ main (void)
 
 #pragma acc kernels copyout (a[0:N])
   {
+#pragma ACC_LOOP
 for (COUNTERTYPE i = 0; i  N; i++)
   a[i] = i * 2;
   }
 
 #pragma acc kernels copyout (b[0:N])
   {
+#pragma ACC_LOOP
 for (COUNTERTYPE i = 0; i  N; i++)
   b[i] = i * 4;
   }
 
 #pragma acc kernels copyin (a[0:N], b[0:N]) copyout (c[0:N])
   {
+#pragma ACC_LOOP
 for (COUNTERTYPE ii = 0; ii  N; ii++)
   c[ii] = a[ii] + b[ii];
   }
Index: gcc/testsuite/c-c++-common/goacc/kernels-loop.c
===
--- gcc/testsuite/c-c++-common/goacc/kernels-loop.c	(revision 224836)
+++ gcc/testsuite/c-c++-common/goacc/kernels-loop.c	(working copy)
@@ -8,6 +8,10 @@
 #define N (1024 * 512)
 #define COUNTERTYPE unsigned int
 
+#ifndef ACC_LOOP
+#define ACC_LOOP
+#endif
+
 int
 main (void)
 {
@@ -27,6 +31,7 @@ main (void)
 
 #pragma acc kernels copyin (a[0:N], b[0:N]) copyout (c[0:N])
   {
+#pragma ACC_LOOP
 for (COUNTERTYPE ii = 0; ii  N; ii++)
   c[ii] = a[ii] + b[ii];
   }
Index: gcc/testsuite/c-c++-common/goacc/kernels-loop-2-acc-loop.c
===
--- gcc/testsuite/c-c++-common/goacc/kernels-loop-2-acc-loop.c	(revision 0)
+++ gcc/testsuite/c-c++-common/goacc/kernels-loop-2-acc-loop.c	(revision 0)
@@ -0,0 +1,23 @@
+/* { dg-additional-options -O2 } */
+/* { dg-additional-options -ftree-parallelize-loops=32 } */
+/* { dg-additional-options -fdump-tree-parloops_oacc_kernels-all } */
+/* { dg-additional-options -fdump-tree-optimized } */
+
+/* Check that loops with '#pragma acc loop' tagged gets properly parallelized.  */
+#define ACC_LOOP acc loop
+#include kernels-loop-2.c
+
+/* Check that only three loops are analyzed, and that all can be
+   parallelized.  */
+/* { dg-final { scan-tree-dump-times SUCCESS: may be parallelized 3 parloops_oacc_kernels } } */
+/* { dg-final { 

C++ PATCH for c++/66542 (missing error with deleted dtor and static variable)

2015-06-23 Thread Jason Merrill
In expand_static_init we were diagnosing a deleted dtor if there was 
also no initializer, but not if there was, and nothing later on was 
diagnosing it either.  Fixed thus.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit 78593d02fb6af72a8f97e52cbfbbe9f49b29e9db
Author: Jason Merrill ja...@redhat.com
Date:   Mon Jun 22 14:00:30 2015 -0400

	PR c++/66542
	* decl.c (expand_static_init): Make sure the destructor is callable
	here even if we have an initializer.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index c934ff9..d14ffe2 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -7163,12 +7163,12 @@ expand_static_init (tree decl, tree init)
   gcc_assert (TREE_STATIC (decl));
 
   /* Some variables require no dynamic initialization.  */
-  if (!init
-   TYPE_HAS_TRIVIAL_DESTRUCTOR (TREE_TYPE (decl)))
+  if (TYPE_HAS_TRIVIAL_DESTRUCTOR (TREE_TYPE (decl)))
 {
   /* Make sure the destructor is callable.  */
   cxx_maybe_build_cleanup (decl, tf_warning_or_error);
-  return;
+  if (!init)
+	return;
 }
 
   if (DECL_THREAD_LOCAL_P (decl)  DECL_GNU_TLS_P (decl)
diff --git a/gcc/testsuite/g++.dg/cpp0x/deleted12.C b/gcc/testsuite/g++.dg/cpp0x/deleted12.C
new file mode 100644
index 000..770bb9c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/deleted12.C
@@ -0,0 +1,10 @@
+// PR c++/66542
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+  A() {}
+  ~A() = delete;		// { dg-message declared here }
+};
+
+static A a;			// { dg-error deleted }


[PATCH 2/3][AArch64 nofp] Clarify docs for +nofp/-mgeneral-regs-only

2015-06-23 Thread Alan Lawrence

James Greenhalgh wrote:



-Generate code which uses only the general registers.
+Generate code which uses only the general registers.  Equivalent to feature


The ARMARM uses general-purpose registers to refer to these registers,
we should match that style.

s/Equivalent to feature/This is equivalent to the feature/


Done.


-Feature modifiers used with @option{-march} and @option{-mcpu} can be one
-the following:
+Feature modifiers used with @option{-march} and @option{-mcpu} can be any of
+the following, or their inverses @option{no@var{feature}}:


s/inverses/inverse/


The grammar is quite difficult here, so have gone for and their inverses as 
the set of possibilities definitely includes 3 inverses.


 
+As stated above, @option{crypto} implies @option{simd} implies @option{fp}.


Drop the As stated above.


To my eye, beginning a sentence in lowercase looks very odd in pdf, and still a 
bit odd in html. Have changed to That is...?


Tested with make pdf  make html.

gcc/ChangeLog (unchanged):

* doc/invoke.texi: Clarify AArch64 feature modifiers (no)fp, (no)simd
and (no)crypto.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index d8e982c3aa338819df3785696c493a66c1f5b674..0579bf2ecf993bb56987e0bb9686925537ab61e3 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -12359,7 +12359,10 @@ Generate big-endian code.  This is the default when GCC is configured for an
 
 @item -mgeneral-regs-only
 @opindex mgeneral-regs-only
-Generate code which uses only the general registers.
+Generate code which uses only the general-purpose registers.  This is equivalent
+to feature modifier @option{nofp} of @option{-march} or @option{-mcpu}, except
+that @option{-mgeneral-regs-only} takes precedence over any conflicting feature
+modifier regardless of sequence.
 
 @item -mlittle-endian
 @opindex mlittle-endian
@@ -12498,20 +12501,22 @@ over the appropriate part of this option.
 @subsubsection @option{-march} and @option{-mcpu} Feature Modifiers
 @cindex @option{-march} feature modifiers
 @cindex @option{-mcpu} feature modifiers
-Feature modifiers used with @option{-march} and @option{-mcpu} can be one
-the following:
+Feature modifiers used with @option{-march} and @option{-mcpu} can be any of
+the following and their inverses @option{no@var{feature}}:
 
 @table @samp
 @item crc
 Enable CRC extension.
 @item crypto
-Enable Crypto extension.  This implies Advanced SIMD is enabled.
+Enable Crypto extension.  This also enables Advanced SIMD and floating-point
+instructions.
 @item fp
-Enable floating-point instructions.
+Enable floating-point instructions.  This is on by default for all possible
+values for options @option{-march} and @option{-mcpu}.
 @item simd
-Enable Advanced SIMD instructions.  This implies floating-point instructions
-are enabled.  This is the default for all current possible values for options
-@option{-march} and @option{-mcpu=}.
+Enable Advanced SIMD instructions.  This also enables floating-point
+instructions.  This is on by default for all possible values for options
+@option{-march} and @option{-mcpu}.
 @item lse
 Enable Large System Extension instructions.
 @item pan
@@ -12522,6 +12527,10 @@ Enable Limited Ordering Regions support.
 Enable ARMv8.1 Advanced SIMD instructions.
 @end table
 
+That is, @option{crypto} implies @option{simd} implies @option{fp}.
+Conversely, @option{nofp} (or equivalently, @option{-mgeneral-regs-only})
+implies @option{nosimd} implies @option{nocrypto}.
+
 @node Adapteva Epiphany Options
 @subsection Adapteva Epiphany Options
 


[PATCH 1/3][AArch64 nofp] Fix ICEs with +nofp/-mgeneral-regs-only and improve error messages

2015-06-23 Thread Alan Lawrence

James Greenhalgh wrote:

Submissions on this list should be one patch per mail, it makes
tracking review easier.


OK here's a respin of the first, I've added a third patch after I found another 
route to get to an ICE.



+void
+aarch64_err_no_fpadvsimd (machine_mode mode, const char *msg)
+{
+  const char *mc = FLOAT_MODE_P (mode) ? floating point : vector;


GCC coding conventions, this should be
floating-point (https://gcc.gnu.org/codingconventions.html).


Done.


+  if (!TARGET_FLOAT
+   fndecl  TREE_PUBLIC (fndecl)
+   fntype  fntype != error_mark_node)
+{
+  const_tree args, type = TREE_TYPE (fntype);
+  machine_mode mode; /* To pass pointer as argument; never used.  */
+  int nregs; /* Likewise.  */


Do these need annotations to avoid errors in a Werror build? I don't see
any mention of what testing this patch has been through?


Dropped the args, added ATTRIBUTE_UNUSED to the others - the attribute isn't 
necessary at the moment but might become so if inlining became more aggressive.


This version has been bootstrapped on aarch64 linux.


-  if (cum-aapcs_nvrn  0)
-   sorry (%qs and floating point or vector arguments,
-  -mgeneral-regs-only);
+  gcc_assert (cum-aapcs_nvrn == 0);


This promotes an error to an ICE? Can we really never get to this
point through the error control flow


Indeed - the new checks in init_cumulative_args and aarch64_layout_arg mean we 
never get here. (If said new checks were sorry(), we would still get here, but 
since they are error() we do not.)



@@ -7920,9 +7941,7 @@ aarch64_setup_incoming_varargs (cumulative_args_t cum_v, 
machine_mode mode,
 
   if (!TARGET_FLOAT)

 {
-  if (local_cum.aapcs_nvrn  0)
-   sorry (%qs and floating point or vector arguments,
-  -mgeneral-regs-only);
+  gcc_assert (local_cum.aapcs_nvrn == 0);


As above?


Similarly because of change from sorry() - error().


diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
index 11123d6..99cefec 100644
--- a/gcc/config/aarch64/aarch64.md
+++ b/gcc/config/aarch64/aarch64.md
@@ -981,10 +981,7 @@
   
   
 if (!TARGET_FLOAT)
- {
-   sorry (\%qs and floating point code\, \-mgeneral-regs-only\);
-   FAIL;
- }
+  aarch64_err_no_fpadvsimd (MODEmode, \code\);


You've dropped the FAIL?


(*2)

This usually gets called from emit_move_insn_1, via a call to emit_insn 
(GEN_FCN...). If we FAIL, we return NULL, and emit_insn then returns whatever 
insn was last in the BB; if we don't FAIL, we return a move to a general 
register (which is still a valid bit of RTL!). So either seems valid, but 
keeping the FAIL generates fewer instances of the error message, which can 
already get quite numerous. So reinstated FAIL. (Also changed  quotes to {} 
braces.)


Bootstrap + check-gcc on aarch64-none-linux-gnu.

(ChangeLog's identical to v1)

gcc/ChangeLog:

* config/aarch64/aarch64-protos.h (aarch64_err_no_fpadvsimd): New.

* config/aarch64/aarch64.md (movmode/GPF, movtf): Use
aarch64_err_no_fpadvsimd.

* config/aarch64/aarch64.c (aarch64_err_no_fpadvsimd): New.
(aarch64_layout_arg, aarch64_init_cumulative_args): Use
aarch64_err_no_fpadvsimd if !TARGET_FLOAT and we need FP regs.
(aarch64_expand_builtin_va_start, aarch64_setup_incoming_varargs):
Turn error into assert, test TARGET_FLOAT.
(aarch64_gimplify_va_arg_expr): Use aarch64_err_no_fpadvsimd, test
TARGET_FLOAT.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/mgeneral-regs_1.c: New file.
* gcc.target/aarch64/mgeneral-regs_2.c: New file.
* gcc.target/aarch64/nofp_1.c: New file.
diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
index 965a11b7bee188819796e2b17017a87dca80..ac92c5924a4cfc5941fe8eeb31281e18bd21a5a0 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -259,6 +259,7 @@ unsigned aarch64_dbx_register_number (unsigned);
 unsigned aarch64_trampoline_size (void);
 void aarch64_asm_output_labelref (FILE *, const char *);
 void aarch64_elf_asm_named_section (const char *, unsigned, tree);
+void aarch64_err_no_fpadvsimd (machine_mode, const char *);
 void aarch64_expand_epilogue (bool);
 void aarch64_expand_mov_immediate (rtx, rtx);
 void aarch64_expand_prologue (void);
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index a79bb6a96572799181a5bff3c3818e294f87cb7a..3193a15970e5524e0f3a8a5505baea5582e55731 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -522,6 +522,16 @@ static const char * const aarch64_condition_codes[] =
   hi, ls, ge, lt, gt, le, al, nv
 };
 
+void
+aarch64_err_no_fpadvsimd (machine_mode mode, const char *msg)
+{
+  const char *mc = FLOAT_MODE_P (mode) ? floating-point : vector;
+  if (TARGET_GENERAL_REGS_ONLY)
+error (%qs is incompatible with %s %s, -mgeneral-regs-only, mc, 

Re: *Ping* patch, fortran] Warn about constant integer divisions

2015-06-23 Thread Jerry DeLisle
On 06/23/2015 01:36 AM, Janne Blomqvist wrote:
 On Sun, Jun 21, 2015 at 4:57 PM, Thomas Koenig tkoe...@netcologne.de wrote:
 *ping*

 https://gcc.gnu.org/ml/gcc-patches/2015-06/msg00966.html


 Hello world,

 the attached patch emits a warning for constant integer division.
 While correct according to the standard, I cannot really think
 of a legitimate reason why people would want to write 3/5 where
 they could have written 0 , so my preference would be to put
 this under -Wconversion (like in the attached patch).

 However, I am open to discussion on that.  It is easy enough to
 change.

 Regression-tested.  Opinions?  Comments?  Would somebody rather
 have -Wconversion-extra?  OK for trunk?
 
 I'm a bit uncomfortable about this. IIRC I have code where I'm
 iterating over some kind of grid, and I'm using integer division and
 relying on truncation to calculate array indices. I can certainly
 imagine that others have used it as well, and even that it's not a
 particularly uncommon pattern.
 
 Furthermore, I think it's confusing that you have it under
 -Wconversion, as there is no type conversion going on.
 -Winteger-truncation maybe?
 
 Any other opinions?
 

I am not sure it is worth warning about. I don't think it justifies its own
compilation warning option. I have no objection to -Wconversion, 3/5 being
converted to zero in a sense. It would help users catch a missing decimal point
when they meant 3./5

Regards,

Jerry

Jerry


[PATCH] backport FreeBSD add functionality to build PIE executables

2015-06-23 Thread Andreas Tobler

Hi all,

I'm going to commit this patch to 5.1 in the next days unless someone 
objects.


The patch is in my 5.1 tree since a longer time and I regularly post 
results.


Thanks,
Andreas

2015-06-22  Andreas Tobler  andre...@gcc.gnu.org

Backport from mainline
2015-05-18  Andreas Tobler  andre...@gcc.gnu.org

* config/freebsd-spec.h (FBSD_STARTFILE_SPEC): Add the bits to build
pie executables.
(FBSD_ENDFILE_SPEC): Likewise.
* config/i386/freebsd.h (STARTFILE_SPEC): Remove and use the one from
config/freebsd-spec.h.
(ENDFILE_SPEC): Likewise.

2015-06-22  Andreas Tobler  andre...@gcc.gnu.org

Backport from mainline
2015-05-12  Andreas Tobler  andre...@gcc.gnu.org

* lib/target-supports.exp (check_effective_target_pie): Add *-*-freebsd*
to the family of pie capable targets.

Index: config/freebsd-spec.h
===
--- config/freebsd-spec.h   (revision 224751)
+++ config/freebsd-spec.h   (working copy)
@@ -66,8 +66,9 @@
   %{!shared: \
  %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
   %{!p:%{profile:gcrt1.o%s} \
-%{!profile:crt1.o%s \
-   crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}
+%{!profile: \
+%{pie: Scrt1.o%s;:crt1.o%s} \
+   crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}
 
 /* Provide a ENDFILE_SPEC appropriate for FreeBSD.  Here we tack on
the magical crtend.o file (see crtstuff.c) which provides part of 
@@ -76,7 +77,7 @@
`crtn.o'.  */
 
 #define FBSD_ENDFILE_SPEC \
-  %{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s
+  %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s
 
 /* Provide a LIB_SPEC appropriate for FreeBSD as configured and as
required by the user-land thread model.  Before __FreeBSD_version
Index: config/i386/freebsd.h
===
--- config/i386/freebsd.h   (revision 224751)
+++ config/i386/freebsd.h   (working copy)
@@ -59,29 +59,16 @@
 #define SUBTARGET_EXTRA_SPECS \
   { fbsd_dynamic_linker, FBSD_DYNAMIC_LINKER }
 
-/* Provide a STARTFILE_SPEC appropriate for FreeBSD.  Here we add
-   the magical crtbegin.o file (see crtstuff.c) which provides part 
-   of the support for getting C++ file-scope static object constructed 
-   before entering `main'.  */
-   
-#undef STARTFILE_SPEC
-#define STARTFILE_SPEC \
-  %{!shared: \
- %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
-  %{!p:%{profile:gcrt1.o%s} \
-%{!profile:crt1.o%s \
-   crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}
+/* Use the STARTFILE_SPEC from config/freebsd-spec.h.  */
 
-/* Provide a ENDFILE_SPEC appropriate for FreeBSD.  Here we tack on
-   the magical crtend.o file (see crtstuff.c) which provides part of 
-   the support for getting C++ file-scope static object constructed 
-   before entering `main', followed by a normal finalizer file, 
-   `crtn.o'.  */
+#undef  STARTFILE_SPEC
+#define STARTFILE_SPEC FBSD_STARTFILE_SPEC
 
-#undef ENDFILE_SPEC
-#define ENDFILE_SPEC \
-  %{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s
+/* Use the ENDFILE_SPEC from config/freebsd-spec.h.  */
 
+#undef  ENDFILE_SPEC
+#define ENDFILE_SPEC FBSD_ENDFILE_SPEC
+
 /* Provide a LINK_SPEC appropriate for FreeBSD.  Here we provide support
for the special GCC options -static and -shared, which allow us to
link things in one of these three modes by applying the appropriate
Index: testsuite/lib/target-supports.exp
===
--- testsuite/lib/target-supports.exp   (revision 224751)
+++ testsuite/lib/target-supports.exp   (working copy)
@@ -952,6 +952,7 @@
 
 proc check_effective_target_pie { } {
 if { [istarget *-*-darwin\[912\]*]
+|| [istarget *-*-freebsd*]
 || [istarget *-*-linux*]
 || [istarget *-*-gnu*] } {
return 1;


Re: [PATCH] Add CFI entries for ARM Linux idiv0 / ldiv0

2015-06-23 Thread James Lemke



Tested on gcc-trunk for arm-none-linux-gnueabi.

OK to commit?



2015-06-16  James Lemke  jwle...@codesourcery.com

libgcc/config/arm/
* lib1funcs.S (aeabi_idiv0, aeabi_ldiv0): Add CFI entries for
Linux ARM_EABI.


s/for Linux ARM EABI//

given you handle both __ARM_EABI__ and the not __ARM_EABI__ targets in
the source.

This is OK if no regressions.


I saw no regressions for arm-none-linux-gnueabi.
However, I don't have access to a non-eabi linux target.
Shall I commit with the non-eabi portions or remove them?
Jim.

--
Jim Lemke, GNU Tools Sourcerer
Mentor Graphics / CodeSourcery
Orillia, Ontario


Re: [PATCH][testsuite] Fix TORTURE_OPTIONS overriding

2015-06-23 Thread James Greenhalgh

On Thu, Jun 18, 2015 at 11:10:01AM +0100, Richard Biener wrote:

 Currently when doing

 make check-gcc RUNTESTFLAGS=TORTURE_OPTIONS=\\\{ -O3 } { -O2 }\\\
 dg-torture.exp

 you get -O3 and -O2 but also the two LTO torture option combinations.
 That's undesired (those are the most expensive anyway).  The following
 patch avoids this by setting LTO_TORTURE_OPTIONS only when
 TORTURE_OPTIONS isn't specified.

 Tested with and without TORTURE_OPTIONS for C and fortran tortures.

 Seems the instruction in c-torture.exp how to override TORTURE_OPTIONS
 is off, RUNTESTFLAGS=TORTURE_OPTIONS=\\\{ { -O3 } { -O2 } }\\\
 certainly doesn't do what it should.

This patch causes issues for ARM and AArch64 cross multilib
testing. There are two issues, one is that we now clobber
gcc_force_conventional_output after setting it in the conditional this patch
moved (hits all targets, see the new x86-64 failures like pr61848.c).

The other is that we no longer protect environment settings before calling
check_effective_target_lto, which results in our cross --specs files no
longer being on the path.

I've fixed these issues by rearranging the file again, but I'm not
sure if what I've done is sensible and does not cause other issues. This
seems to bring back the tests I'd lost overnight, and doesn't cause
issues elsewhere.

I've run some cross-tests to ensure this brings back the missing tests,
and a full x86-64 testrun to make sure I haven't dropped any from there.

OK for trunk?

Thanks,
James

---
2015-06-23  James Greenhalgh  james.greenha...@arm.com

* lib/c-torture.exp: Don't call check_effective_target_lto
before setting up environment correctly.
* lib/gcc-dg.exp: Likewise, and protect
gcc_force_conventional_output.

diff --git a/gcc/testsuite/lib/c-torture.exp b/gcc/testsuite/lib/c-torture.exp
index 607e7d0..c88c439 100644
--- a/gcc/testsuite/lib/c-torture.exp
+++ b/gcc/testsuite/lib/c-torture.exp
@@ -21,6 +21,20 @@ load_lib file-format.exp
 load_lib target-libpath.exp
 load_lib target-utils.exp
 
+global GCC_UNDER_TEST
+if ![info exists GCC_UNDER_TEST] {
+set GCC_UNDER_TEST [find_gcc]
+}
+
+global orig_environment_saved
+
+# This file may be sourced, so don't override environment settings
+# that have been previously setup.
+if { $orig_environment_saved == 0 } {
+append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
+set_ld_library_path_env_vars
+}
+
 # The default option list can be overridden by
 # TORTURE_OPTIONS={ list1 } ... { listN }
 
@@ -68,20 +82,6 @@ if [info exists ADDITIONAL_TORTURE_OPTIONS] {
 	[concat $C_TORTURE_OPTIONS $ADDITIONAL_TORTURE_OPTIONS]
 }
 
-global GCC_UNDER_TEST
-if ![info exists GCC_UNDER_TEST] {
-set GCC_UNDER_TEST [find_gcc]
-}
-
-global orig_environment_saved
-
-# This file may be sourced, so don't override environment settings
-# that have been previously setup.
-if { $orig_environment_saved == 0 } {
-append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
-set_ld_library_path_env_vars
-}
-
 #
 # c-torture-compile -- runs the Tege C-torture test
 #
diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 00ca0c5..d463f81 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -46,6 +46,19 @@ if ![info exists GCC_UNDER_TEST] {
 set GCC_UNDER_TEST [find_gcc]
 }
 
+# This file may be sourced, so don't override environment settings
+# that have been previously setup.
+if { $orig_environment_saved == 0 } {
+append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
+set_ld_library_path_env_vars
+}
+
+# Some torture-options cause intermediate code output, unusable for
+# testing using e.g. scan-assembler.  In this variable are the options
+# how to force it, when needed.
+global gcc_force_conventional_output
+set gcc_force_conventional_output 
+
 set LTO_TORTURE_OPTIONS 
 if [info exists TORTURE_OPTIONS] {
 set DG_TORTURE_OPTIONS $TORTURE_OPTIONS
@@ -92,19 +105,6 @@ if [info exists ADDITIONAL_TORTURE_OPTIONS] {
 
 global orig_environment_saved
 
-# This file may be sourced, so don't override environment settings
-# that have been previously setup.
-if { $orig_environment_saved == 0 } {
-append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
-set_ld_library_path_env_vars
-}
-
-# Some torture-options cause intermediate code output, unusable for
-# testing using e.g. scan-assembler.  In this variable are the options
-# how to force it, when needed.
-global gcc_force_conventional_output
-set gcc_force_conventional_output 
-
 # Deduce generated files from tool flags, return finalcode string
 proc schedule-cleanups { opts } {
 global additional_sources


[PATCH 3/3][AArch64 nofp] Fix another ICE with +nofp/-mgeneral-regs-only

2015-06-23 Thread Alan Lawrence
This fixes another ICE, obtained with the attached testcase - yes, there was a 
way to get hold of a float, without passing an argument or going through 
movsf/movdf!


Bootstrapped + check-gcc on aarch64-none-linux-gnu.

gcc/ChangeLog:

* config/aarch64/aarch64.md (optabfcvt_targetGPF:mode2):
Condition on TARGET_FLOAT.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/mgeneral-regs_3.c: New.
diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
index 99cefece8093791ccf17cb071a4e9997bda8fd89..bcaafda5ea46f136dc90f34aa8f2dfaddabd09f5 100644
--- a/gcc/config/aarch64/aarch64.md
+++ b/gcc/config/aarch64/aarch64.md
@@ -4106,7 +4106,7 @@
 (define_insn optabfcvt_targetGPF:mode2
   [(set (match_operand:GPF 0 register_operand =w,w)
 (FLOATUORS:GPF (match_operand:FCVT_TARGET 1 register_operand w,r)))]
-  
+  TARGET_FLOAT
   @
su_optabcvtf\t%GPF:s0, %s1
su_optabcvtf\t%GPF:s0, %w11
diff --git a/gcc/testsuite/gcc.target/aarch64/mgeneral-regs_3.c b/gcc/testsuite/gcc.target/aarch64/mgeneral-regs_3.c
new file mode 100644
index ..225d9eaa45530d88315a146f3fae72d86fe66373
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/mgeneral-regs_3.c
@@ -0,0 +1,11 @@
+/* { dg-options -mgeneral-regs-only -O2 } */
+
+extern void abort (void);
+
+int
+test (int i, ...)
+{
+  float f = (float) i; /* { dg-error '-mgeneral-regs-only' is incompatible with floating point code } */
+  if (f != f) abort ();
+  return 2;
+}


Re: [PATCH] [ARM] Post-indexed addressing for NEON memory access

2015-06-23 Thread Ramana Radhakrishnan
On Fri, Jun 19, 2015 at 7:04 PM, Charles Baylis
charles.bay...@linaro.org wrote:
 On 18 June 2014 at 11:06, Ramana Radhakrishnan
 ramana@googlemail.com wrote:
 On Tue, Jun 17, 2014 at 4:03 PM, Charles Baylis
 charles.bay...@linaro.org wrote:
 Your mention of larger vector modes prompted me to check that the
 patch has the desired result with them. In fact, the costs are
 estimated incorrectly which means the post_modify pattern is not used.
 The attached patch fixes that. (used in combination with my original
 patch)


 2014-06-15  Charles Baylis  charles.ba...@linaro.org

 * config/arm/arm.c (arm_new_rtx_costs): Reduce cost for mem with
 embedded side effects.

 I'm not too thrilled with putting in more special cases that are not
 table driven in there. Can you file a PR with some testcases that show
 this so that we don't forget and CC me on it please ?

 I created https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61551 at the time.

 I've come back to look at this again and would like to fix it in this
 release cycle. I still don't really understand what you mean by
 table-driven in this context. Do you still hold this view, and if so,
 could you describe what you'd like to see instead of this patch?

By table-driven I mean something similar to the existing rtx_costs
infrastructure with a walker and a data structure holding costs for
each addressing mode which are tweakable on a per-core basis.

Thus for example I'd expect this to be on a per access mode basis
along with different costs with respect to post_inc, reg indirect,
pre_inc etc. that were in a data structure and then a worker function
that peeled rtx's to obtain the appropriate cost from said
data-structure.



Ramana


[PATCH] backport Contribute FreeBSD unwind support (x86_64 and x86)

2015-06-23 Thread Andreas Tobler

Hi all,

the next one. I'm going to commit this patch to 5.1 in the next days.

Also in my tree, test results posted for amd64/i386-*-freebsd11.0

Thanks,

Andreas


2015-06-22  Andreas Tobler  andre...@gcc.gnu.org

Backport from mainline
2015-05-27  John Marino gnu...@marino.st

* config.host (i[34567]86-*-freebsd*, x86_64-*-freebsd*): Set
md_unwind_header
* config/i386/freebsd-unwind.h: New.
Index: config/i386/freebsd-unwind.h
===
--- config/i386/freebsd-unwind.h(revision 0)
+++ config/i386/freebsd-unwind.h(working copy)
@@ -0,0 +1,173 @@
+/* DWARF2 EH unwinding support for FreeBSD: AMD x86-64 and x86.
+   Copyright (C) 2015 Free Software Foundation, Inc.
+   Contributed by John Marino gnu...@marino.st
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+http://www.gnu.org/licenses/.  */
+
+/* Do code reading to identify a signal frame, and set the frame
+   state data appropriately.  See unwind-dw2.c for the structs. */
+
+#include sys/types.h
+#include signal.h
+#include sys/ucontext.h
+#include machine/sigframe.h
+
+#define REG_NAME(reg)  sf_uc.uc_mcontext.mc_## reg
+
+#ifdef __x86_64__
+#define MD_FALLBACK_FRAME_STATE_FOR x86_64_freebsd_fallback_frame_state
+
+static _Unwind_Reason_Code
+x86_64_freebsd_fallback_frame_state
+(struct _Unwind_Context *context, _Unwind_FrameState *fs)
+{
+  struct sigframe *sf;
+  long new_cfa;
+
+  /* Prior to FreeBSD 9, the signal trampoline was located immediately
+ before the ps_strings.  To support non-executable stacks on AMD64,
+ the sigtramp was moved to a shared page for FreeBSD 9.  Unfortunately
+ this means looking frame patterns again (sys/amd64/amd64/sigtramp.S)
+ rather than using the robust and convenient KERN_PS_STRINGS trick.
+
+ pc + 00:  lea 0x10(%rsp),%rdi
+ pc + 05:  pushq   $0x0
+ pc + 17:  mov $0x1a1,%rax
+ pc + 14:  syscall
+
+ If we can't find this pattern, we're at the end of the stack.
+  */
+
+  if (!(   *(unsigned int *)(context-ra)  == 0x247c8d48
+ *(unsigned int *)(context-ra +  4) == 0x48006a10
+ *(unsigned int *)(context-ra +  8) == 0x01a1c0c7
+ *(unsigned int *)(context-ra + 12) == 0x050f ))
+return _URC_END_OF_STACK;
+
+  sf = (struct sigframe *) context-cfa;
+  new_cfa = sf-REG_NAME(rsp);
+  fs-regs.cfa_how = CFA_REG_OFFSET;
+  /* Register 7 is rsp  */
+  fs-regs.cfa_reg = 7;
+  fs-regs.cfa_offset = new_cfa - (long) context-cfa;
+
+  /* The SVR4 register numbering macros aren't usable in libgcc.  */
+  fs-regs.reg[0].how = REG_SAVED_OFFSET;
+  fs-regs.reg[0].loc.offset = (long)sf-REG_NAME(rax) - new_cfa;
+  fs-regs.reg[1].how = REG_SAVED_OFFSET;
+  fs-regs.reg[1].loc.offset = (long)sf-REG_NAME(rdx) - new_cfa;
+  fs-regs.reg[2].how = REG_SAVED_OFFSET;
+  fs-regs.reg[2].loc.offset = (long)sf-REG_NAME(rcx) - new_cfa;
+  fs-regs.reg[3].how = REG_SAVED_OFFSET;
+  fs-regs.reg[3].loc.offset = (long)sf-REG_NAME(rbx) - new_cfa;
+  fs-regs.reg[4].how = REG_SAVED_OFFSET;
+  fs-regs.reg[4].loc.offset = (long)sf-REG_NAME(rsi) - new_cfa;
+  fs-regs.reg[5].how = REG_SAVED_OFFSET;
+  fs-regs.reg[5].loc.offset = (long)sf-REG_NAME(rdi) - new_cfa;
+  fs-regs.reg[6].how = REG_SAVED_OFFSET;
+  fs-regs.reg[6].loc.offset = (long)sf-REG_NAME(rbp) - new_cfa;
+  fs-regs.reg[8].how = REG_SAVED_OFFSET;
+  fs-regs.reg[8].loc.offset = (long)sf-REG_NAME(r8) - new_cfa;
+  fs-regs.reg[9].how = REG_SAVED_OFFSET;
+  fs-regs.reg[9].loc.offset = (long)sf-REG_NAME(r9) - new_cfa;
+  fs-regs.reg[10].how = REG_SAVED_OFFSET;
+  fs-regs.reg[10].loc.offset = (long)sf-REG_NAME(r10) - new_cfa;
+  fs-regs.reg[11].how = REG_SAVED_OFFSET;
+  fs-regs.reg[11].loc.offset = (long)sf-REG_NAME(r11) - new_cfa;
+  fs-regs.reg[12].how = REG_SAVED_OFFSET;
+  fs-regs.reg[12].loc.offset = (long)sf-REG_NAME(r12) - new_cfa;
+  fs-regs.reg[13].how = REG_SAVED_OFFSET;
+  fs-regs.reg[13].loc.offset = (long)sf-REG_NAME(r13) - new_cfa;
+  fs-regs.reg[14].how = REG_SAVED_OFFSET;
+  fs-regs.reg[14].loc.offset = (long)sf-REG_NAME(r14) - new_cfa;
+  fs-regs.reg[15].how = REG_SAVED_OFFSET;
+  

PING: Re: [patch] PR debug/66482: Do not ICE in gen_formal_parameter_die

2015-06-23 Thread Aldy Hernandez

On 06/12/2015 10:07 AM, Aldy Hernandez wrote:

Hi.

This is now a P2, as it is causing a secondary target bootstrap to fail 
(s390).


Aldy


Sigh.  I must say my head is spinning with this testcase and what we do
with it (-O3), even prior to the debug-early work:

void f(int p) {}
int g() {
   void f(int p);
   g();
   return 0;
}

The inliner recursively inlines this function up to a certain depth, but
the useless inlining gets cleaned up shortly afterwards.  However, the
BLOCK_SOURCE_LOCATION are still set throughout which is technically
correct.

Eventually late dwarf gets a hold of all this and we end up calling
dwarf2out_abstract_function to build debug info for the abstract
instance of a function for which we have already generated a DIE for.
Basically, a similar issue to what we encountered for template parameter
packs.  Or at least, that's my understanding, because as I've said, I
admit to being slightly confused here.

Since technically this is all going away when we remove
dwarf2out_abstract_function, I suggest we remove the assert and avoid
sudden death.  It's not like the we generated useful debugging for this
testcase anyhow.

Aldy




Re: [PATCH] libgomp sysctl check

2015-06-23 Thread Jakub Jelinek
On Tue, Jun 23, 2015 at 07:36:22PM +0200, Andreas Tobler wrote:
 Hi all,
 
 this patch fixes a long standing bug in the libgomp configury.
 The initial patch was correct, but the commit I did was wrong.
 
 Ok for trunk?
 
 Thanks,
 
 Andreas
 
 2015-06-23  Andreas Tobler  andre...@gcc.gnu.org
 
   * configure.ac: Fix check for header sys/sysctl.h
 * configure: Regenerate.
 * config.h.in: Likewise.

The last 2 lines are weidly indented (should be one tab before *),
the first line lacks full stop at the end.
Ok with those changes.

 --- configure.ac  (revision 224759)
 +++ configure.ac  (working copy)
 @@ -170,7 +170,7 @@
  AC_STDC_HEADERS
  AC_HEADER_TIME
  ACX_HEADER_STRING
 -AC_CHECK_HEADERS(pthread.h unistd.h semaphore.h sys/loadavg.h sys/time.h
 sys/time.h)
 +AC_CHECK_HEADERS(pthread.h unistd.h semaphore.h sys/loadavg.h sys/sysctl.h
 sys/time.h)
 
  GCC_HEADER_STDINT(gstdint.h)

Jakub


[PATCH] backport libjava signal handling for FreeBSD (amd64/i386)

2015-06-23 Thread Andreas Tobler

Hi again,

number three.

This one is also on my list to be committed to 5.1.

Results on the usual place.

Thanks,
Andreas

2015-06-22  Andreas Tobler  andre...@gcc.gnu.org

Backport from mainline
2015-05-28  Andreas Tobler  andre...@gcc.gnu.org

* configure.host: Add bits for FreeBSD amd64 and i386.
* configure.ac: Add signal handler for FreeBSD (amd64/i386)
* configure: Regenerate.
* include/freebsd-signal.h: New file.

2015-05-26  Andreas Tobler  andre...@gcc.gnu.org

* testsuite/libjava.jni/jni.exp (gcj_jni_get_cxxflags_invocation): Add
libiconv for FreeBSD to cxxflags.


Index: configure
===
--- configure   (revision 224751)
+++ configure   (working copy)
@@ -24442,6 +24442,9 @@
  powerpc*-*-aix*)
 SIGNAL_HANDLER=include/aix-signal.h
 ;;
+ i?86-*-freebsd* | x86_64-*-freebsd*)
+SIGNAL_HANDLER=include/freebsd-signal.h
+;;
  *)
 SIGNAL_HANDLER=include/default-signal.h
 ;;
Index: configure.ac
===
--- configure.ac(revision 224751)
+++ configure.ac(working copy)
@@ -1755,6 +1755,9 @@
  powerpc*-*-aix*)
 SIGNAL_HANDLER=include/aix-signal.h
 ;;
+ i?86-*-freebsd* | x86_64-*-freebsd*)
+SIGNAL_HANDLER=include/freebsd-signal.h
+;;
  *)
 SIGNAL_HANDLER=include/default-signal.h
 ;;
Index: configure.host
===
--- configure.host  (revision 224751)
+++ configure.host  (working copy)
@@ -338,6 +338,8 @@
;;
   *-*-freebsd*)
slow_pthread_self=
+   can_unwind_signal=yes
+   DIVIDESPEC=-fuse-divide-subroutine
;;
   *-mingw*)
 libgcj_flags=${libgcj_flags} -fno-omit-frame-pointer
Index: include/freebsd-signal.h
===
--- include/freebsd-signal.h(revision 0)
+++ include/freebsd-signal.h(working copy)
@@ -0,0 +1,48 @@
+/* freebsd-signal.h - Catch runtime signals and turn them into exceptions,
+   on a FreeBSD system.  */
+
+/* Copyright (C) 2015 Free Software Foundation
+
+   This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License.  Please consult the file LIBGCJ_LICENSE for
+details.  */
+
+/* This file is really more of a specification.  The rest of the system
+   should be arranged so that this Just Works.  */
+
+#ifndef JAVA_SIGNAL_H
+# define JAVA_SIGNAL_H 1
+
+#include sys/types.h
+#include sys/signal.h
+
+# define HANDLE_SEGV 1
+# define HANDLE_FPE  1
+
+# define SIGNAL_HANDLER(_name) \
+  static void _name (int _dummy __attribute__ ((unused)))
+
+# define MAKE_THROW_FRAME(_exception)
+
+# define INIT_SEGV \
+  do { \
+struct sigaction sa;   \
+sa.sa_handler = catch_segv;\
+sigemptyset (sa.sa_mask); \
+sa.sa_flags = SA_NODEFER;  \
+sigaction (SIGBUS, sa, NULL); \
+sigaction (SIGSEGV, sa, NULL);\
+} while (0)
+
+# define INIT_FPE  \
+  do { \
+struct sigaction sa;   \
+sa.sa_handler = catch_fpe; \
+sigemptyset (sa.sa_mask); \
+sa.sa_flags = SA_NODEFER;  \
+sigaction (SIGFPE, sa, NULL); \
+} while (0)
+
+#endif /* JAVA_SIGNAL_H */
Index: testsuite/libjava.jni/jni.exp
===
--- testsuite/libjava.jni/jni.exp   (revision 224751)
+++ testsuite/libjava.jni/jni.exp   (working copy)
@@ -274,6 +274,11 @@
 eval lappend cxxflags -shared-libgcc -lgcj $libiconv
   }
 
+  # FreeBSD needs -liconv linked, otherwise we get some unresolved.
+  if { [istarget *-*-freebsd*] } {
+eval lappend cxxflags $libiconv
+  }
+
   # Make sure libgcc unwinder is used on 64-bit Solaris 10+/x86 rather than
   # the libc one.
   if { [istarget *-*-solaris*] } {


[PATCH] libgomp sysctl check

2015-06-23 Thread Andreas Tobler

Hi all,

this patch fixes a long standing bug in the libgomp configury.
The initial patch was correct, but the commit I did was wrong.

Ok for trunk?

Thanks,

Andreas

2015-06-23  Andreas Tobler  andre...@gcc.gnu.org

* configure.ac: Fix check for header sys/sysctl.h
* configure: Regenerate.
* config.h.in: Likewise.

Index: configure.ac
===
--- configure.ac(revision 224759)
+++ configure.ac(working copy)
@@ -170,7 +170,7 @@
 AC_STDC_HEADERS
 AC_HEADER_TIME
 ACX_HEADER_STRING
-AC_CHECK_HEADERS(pthread.h unistd.h semaphore.h sys/loadavg.h 
sys/time.h sys/time.h)
+AC_CHECK_HEADERS(pthread.h unistd.h semaphore.h sys/loadavg.h 
sys/sysctl.h sys/time.h)


 GCC_HEADER_STDINT(gstdint.h)



Re: [PATCH] Add CFI entries for ARM Linux idiv0 / ldiv0

2015-06-23 Thread Ramana Radhakrishnan
On Tue, Jun 23, 2015 at 5:18 PM, James Lemke jwle...@codesourcery.com wrote:

 Tested on gcc-trunk for arm-none-linux-gnueabi.

 OK to commit?


 2015-06-16  James Lemke  jwle...@codesourcery.com

 libgcc/config/arm/
 * lib1funcs.S (aeabi_idiv0, aeabi_ldiv0): Add CFI entries for
 Linux ARM_EABI.


 s/for Linux ARM EABI//

 given you handle both __ARM_EABI__ and the not __ARM_EABI__ targets in
 the source.

 This is OK if no regressions.


 I saw no regressions for arm-none-linux-gnueabi.
 However, I don't have access to a non-eabi linux target.
 Shall I commit with the non-eabi portions or remove them?
 Jim.

I have no access to a non-EABI arm target to test this, not sure if
there are any intree anymore (probably vxworks ?) .  It looks sane on
a read - just apply it and look after regressions if anything gets
reported in bugzilla.


regards
Ramana



 --
 Jim Lemke, GNU Tools Sourcerer
 Mentor Graphics / CodeSourcery
 Orillia, Ontario


Re: [PATCH] Add CFI entries for ARM Linux idiv0 / ldiv0

2015-06-23 Thread James Lemke

On 06/23/2015 12:22 PM, Ramana Radhakrishnan wrote:

I have no access to a non-EABI arm target to test this, not sure if
there are any intree anymore (probably vxworks ?) .  It looks sane on
a read - just apply it and look after regressions if anything gets
reported in bugzilla.


Thanks Ramana.  I will change the CL entry as you suggested.
Jim.

--
Jim Lemke, GNU Tools Sourcerer
Mentor Graphics / CodeSourcery
Orillia, Ontario


Re: [PATCH] backport FreeBSD add functionality to build PIE executables

2015-06-23 Thread Jakub Jelinek
On Tue, Jun 23, 2015 at 07:26:09PM +0200, Andreas Tobler wrote:
 Hi all,
 
 I'm going to commit this patch to 5.1 in the next days unless someone
 objects.
 
 The patch is in my 5.1 tree since a longer time and I regularly post
 results.

Note, Richard announced plan to do 5.2-rc2 on July, 3rd, so either you
should do that before, or after 5.2 is released (general comment for all the
patches).  Or you'd need an exception when the branch is frozen.

Jakub


Re: [PATCH] backport FreeBSD add functionality to build PIE executables

2015-06-23 Thread Andreas Tobler

On 23.06.15 19:50, Jakub Jelinek wrote:

On Tue, Jun 23, 2015 at 07:26:09PM +0200, Andreas Tobler wrote:

Hi all,

I'm going to commit this patch to 5.1 in the next days unless someone
objects.

The patch is in my 5.1 tree since a longer time and I regularly post
results.


Note, Richard announced plan to do 5.2-rc2 on July, 3rd, so either you
should do that before, or after 5.2 is released (general comment for all the
patches).  Or you'd need an exception when the branch is frozen.


With 'in the next days' I meant to say 26.6 latest. Is this early enough?

I'm ready to commit right now, but I wanted to give people some time to 
object :)


Thank you!

Andreas




Re: [PATCH/RFC]: unittesting v2: as a plugin (was Re: [PATCH 00/17] RFC: Addding a unit testing framework to gcc)

2015-06-23 Thread Jeff Law

On 06/17/2015 01:48 PM, David Malcolm wrote:

On Thu, 2015-06-11 at 00:18 +0200, Jakub Jelinek wrote:

I wrote a custom formatter for the output (class deja_gnu_printer within
unittests-plugin.c) which generates lines like this on stderr:

PASS: ggc_test.tree_marking
PASS: ggc_test.custom_struct
PASS: ggc_test.finalization
PASS: ggc_test.inheritance
PASS: ggc_test.chain_next

These get detected on stderr by some new logic inside
testsuite/lib/prune.exp, which prefixes them with
[testname-for-summary], and emitting them at the Tcl level, so they end
up in the .log and .sum files as lines like this:

PASS: c-c++-common/torture/run-unittests-plugin.c   -O0   ggc_test.tree_marking
PASS: c-c++-common/torture/run-unittests-plugin.c   -O0   ggc_test.custom_struct
PASS: c-c++-common/torture/run-unittests-plugin.c   -O0   ggc_test.finalization
PASS: c-c++-common/torture/run-unittests-plugin.c   -O0   ggc_test.inheritance
PASS: c-c++-common/torture/run-unittests-plugin.c   -O0   ggc_test.chain_next

(if doing it for all testcase output is an issue, perhaps this prune.exp
logic could be made conditional, so that we only do it for testcases
using the plugin, or that contain a dg command)
Yea, this is roughly what I was expecting -- you don't have access to 
the .log/.sum files from within the test, so you have to scan the output 
from the test and emit the pass/fail/xfail/whatever messages.


Presumably there's a mechanism for mark expected failures in the gtest 
framework that we can turn into XFAIL/XPASS as needed.  What about the 
UNSUPPORTED result -- perhaps useful if a test depends on some attribute 
of the target.




This works, and means there's no extra external dependency, and I was
able to bootstrap with this.  I ran into an issue with make check: the
plugin is linked against the previous stage's libstdc++, but make
check doesn't seem to set up LD_LIBRARY_PATH to point at a fresh
libstdc++ and uses the system copy, leading to
cc1: error: cannot load plugin ../../unittests_plugin.so
/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required
by ../../unittests_plugin.so)

on this Fedora 20 box.  Manually setting LD_LIBRARY_PATH to point at the
built libstdc++ fixes it.
You might look at the libstdc++ testsuite.  It has to arrange to get the 
just built library used for testing.


Jeff


Re: [PATCH 00/17] RFC: Addding a unit testing framework to gcc

2015-06-23 Thread Mike Stump
On Jun 10, 2015, at 10:16 AM, David Malcolm dmalc...@redhat.com wrote:
 It doesn't have an output formatter for the DejaGnu format, but I guess
 I could write one.  The gtest standard output format is IMHO superior to
 DejaGnu's since it tells you start-of-test/end-of-test on separate
 lines, so you can see which test killed things in the event of total
 failure,

dejagnu is superior, total failure isn’t allowed.  We treat it as a bug to be 
fixed in the framework, not a bug to be fixed in the tool under test.

Re: [PATCH] libgomp sysctl check

2015-06-23 Thread Andreas Tobler

On 23.06.15 19:47, Jakub Jelinek wrote:

On Tue, Jun 23, 2015 at 07:36:22PM +0200, Andreas Tobler wrote:

Hi all,

this patch fixes a long standing bug in the libgomp configury.
The initial patch was correct, but the commit I did was wrong.

Ok for trunk?

Thanks,

Andreas

2015-06-23  Andreas Tobler  andre...@gcc.gnu.org

* configure.ac: Fix check for header sys/sysctl.h
 * configure: Regenerate.
 * config.h.in: Likewise.


The last 2 lines are weidly indented (should be one tab before *),
the first line lacks full stop at the end.
Ok with those changes.


Committed with issues fixed.

Thanks,
Andreas






Move target-def.h includes after main include block

2015-06-23 Thread Richard Sandiford
This moves target-def.h includes to the end of the include list, so that
the file sees the same header files as the targetm initialisation itself.
I've left a gap to emphasise that the placement is deliberate.

This is a prerequisite for the patch I'm about to post.  It probably doesn't
make much sense otherwise.

Bootstrapped  regression-tested on x86_64-linux-gnu.  Also tested with
config-list.mk.  OK to install if the later patch is?

Thanks,
Richard


gcc/
* config/aarch64/aarch64.c, config/alpha/alpha.c, config/arm/arm.c,
config/avr/avr.c, config/bfin/bfin.c, config/c6x/c6x.c,
config/cr16/cr16.c, config/cris/cris.c, config/fr30/fr30.c,
config/frv/frv.c, config/ft32/ft32.c, config/h8300/h8300.c,
config/i386/i386.c, config/ia64/ia64.c, config/iq2000/iq2000.c,
config/lm32/lm32.c, config/m32c/m32c.c, config/m32r/m32r.c,
config/m68k/m68k.c, config/mcore/mcore.c, config/mep/mep.c,
config/microblaze/microblaze.c, config/mips/mips.c, config/mmix/mmix.c,
config/mn10300/mn10300.c, config/moxie/moxie.c, config/msp430/msp430.c,
config/nds32/nds32.c, config/nios2/nios2.c, config/nvptx/nvptx.c,
config/pa/pa.c, config/pdp11/pdp11.c, config/rl78/rl78.c,
config/rs6000/rs6000.c, config/rx/rx.c, config/s390/s390.c,
config/sh/sh.c, config/sparc/sparc.c, config/spu/spu.c,
config/stormy16/stormy16.c, config/tilegx/tilegx.c,
config/tilepro/tilepro.c, config/v850/v850.c, config/vax/vax.c,
config/visium/visium.c, config/xtensa/xtensa.c: Move target-def.h
includes to end.

Index: gcc/config/aarch64/aarch64.c
===
--- gcc/config/aarch64/aarch64.c2015-06-22 14:02:15.009537962 +0100
+++ gcc/config/aarch64/aarch64.c2015-06-22 14:06:21.254220624 +0100
@@ -58,7 +58,6 @@
 #include reload.h
 #include toplev.h
 #include target.h
-#include target-def.h
 #include targhooks.h
 #include tm_p.h
 #include recog.h
@@ -83,6 +82,8 @@
 #include sched-int.h
 #include cortex-a57-fma-steering.h
 
+#include target-def.h
+
 /* Defined for convenience.  */
 #define POINTER_BYTES (POINTER_SIZE / BITS_PER_UNIT)
 
Index: gcc/config/alpha/alpha.c
===
--- gcc/config/alpha/alpha.c2015-06-22 14:04:24.083139746 +0100
+++ gcc/config/alpha/alpha.c2015-06-22 14:06:21.255220580 +0100
@@ -54,7 +54,6 @@ the Free Software Foundation; either ver
 #include diagnostic-core.h
 #include tm_p.h
 #include target.h
-#include target-def.h
 #include common/common-target.h
 #include debug.h
 #include langhooks.h
@@ -90,6 +89,8 @@ the Free Software Foundation; either ver
 #include builtins.h
 #include rtl-iter.h
 
+#include target-def.h
+
 /* Specify which cpu to schedule for.  */
 enum processor_type alpha_tune;
 
Index: gcc/config/arm/arm.c
===
--- gcc/config/arm/arm.c2015-06-22 14:03:56.691808537 +0100
+++ gcc/config/arm/arm.c2015-06-22 14:06:21.258220450 +0100
@@ -69,7 +69,6 @@
 #include tm_p.h
 #include target.h
 #include sched-int.h
-#include target-def.h
 #include debug.h
 #include langhooks.h
 #include df.h
@@ -85,6 +84,8 @@
 #include rtl-iter.h
 #include sched-int.h
 
+#include target-def.h
+
 /* Forward definitions of types.  */
 typedef struct minipool_nodeMnode;
 typedef struct minipool_fixup   Mfix;
Index: gcc/config/avr/avr.c
===
--- gcc/config/avr/avr.c2015-06-22 14:02:15.138533308 +0100
+++ gcc/config/avr/avr.c2015-06-22 14:06:21.260220363 +0100
@@ -56,7 +56,6 @@
 #include langhooks.h
 #include tm_p.h
 #include target.h
-#include target-def.h
 #include params.h
 #include dominance.h
 #include cfg.h
@@ -72,6 +71,8 @@
 #include context.h
 #include tree-pass.h
 
+#include target-def.h
+
 /* Maximal allowed offset for an address in the LD command */
 #define MAX_LD_OFFSET(MODE) (64 - (signed)GET_MODE_SIZE (MODE))
 
Index: gcc/config/bfin/bfin.c
===
--- gcc/config/bfin/bfin.c  2015-06-22 14:02:15.148532947 +0100
+++ gcc/config/bfin/bfin.c  2015-06-22 14:06:21.261220320 +0100
@@ -41,7 +41,6 @@
 #include except.h
 #include function.h
 #include target.h
-#include target-def.h
 #include expmed.h
 #include dojump.h
 #include explow.h
@@ -77,6 +76,8 @@
 #include dumpfile.h
 #include builtins.h
 
+#include target-def.h
+
 /* A C structure for machine-specific, per-function data.
This is added to the cfun structure.  */
 struct GTY(()) machine_function
Index: gcc/config/c6x/c6x.c
===
--- gcc/config/c6x/c6x.c2015-06-22 14:02:15.155532695 +0100
+++ gcc/config/c6x/c6x.c2015-06-22 14:06:21.261220320 +0100
@@ -70,7 +70,6 @@
 #include cgraph.h
 #include langhooks.h
 #include target.h

Re: [C/C++ PATCH] PR c++/66572. Fix Wlogical-op false positive

2015-06-23 Thread Marek Polacek
On Sat, Jun 20, 2015 at 03:02:06AM +0300, Mikhail Maltsev wrote:
 -  /* We do not warn for constants because they are typical of macro
 - expansions that test for features.  */
 -  if (CONSTANT_CLASS_P (op_left) || CONSTANT_CLASS_P (op_right))
 +  /* We do not warn for literal constants because they are typical of macro
 + expansions that test for features.  Likewise, we do not warn for
 + const-qualified and constexpr variables which are initialized by 
 constant
 + expressions, because they can come from e.g. type_traits or similar 
 user
 + code.  */
 +  if (TREE_CONSTANT (op_left) || TREE_CONSTANT (op_right))
  return;

That looks wrong, because with TREE_CONSTANT we'd warn in C but not in C++
for the following:

const int a = 4;
void
f (void)
{
  const int b = 4;
  static const int c = 5;
  if (a  a) {}
  if (b  b) {}
  if (c  c) {}
}

Note that const-qualified types are checked using TYPE_READONLY.

But I'm not even sure that the warning in the original testcase in the PR
is bogus; you won't get any warning when using e.g.
  foounsigned, signed();
in main().

Marek


Re: [PATCH] backport FreeBSD add functionality to build PIE executables

2015-06-23 Thread Jakub Jelinek
On Tue, Jun 23, 2015 at 07:58:48PM +0200, Andreas Tobler wrote:
 On 23.06.15 19:50, Jakub Jelinek wrote:
 On Tue, Jun 23, 2015 at 07:26:09PM +0200, Andreas Tobler wrote:
 Hi all,
 
 I'm going to commit this patch to 5.1 in the next days unless someone
 objects.
 
 The patch is in my 5.1 tree since a longer time and I regularly post
 results.
 
 Note, Richard announced plan to do 5.2-rc2 on July, 3rd, so either you
 should do that before, or after 5.2 is released (general comment for all the
 patches).  Or you'd need an exception when the branch is frozen.
 
 With 'in the next days' I meant to say 26.6 latest. Is this early enough?

26.6.  3.7., so sure, it is ok ;)

Jakub


Add .def file for public target instructions

2015-06-23 Thread Richard Sandiford
[A fair bit later than promised, sorry...]

Mikhail posted a patch to make genflags generate the default HAVE_foo
and gen_foo definitions that have recently been added to defaults.h:

  https://gcc.gnu.org/ml/gcc-patches/2015-06/msg00723.html

I agree it'd be a good idea to generate this kind of thing automatically,
but I think we should take the opportunity to move the interface to the
target structure.  I.e.:

  HAVE_foo - targetm.have_foo ()
  gen_foo - targetm.gen_foo ()

This should move us closer to the pipedream goal of supporting multiple
targets at once.  It should also mean that only the target code depends
on insn-flags.h.

The patch just moves return and simple_return as an example.  I have more
locally (in order to test other code paths), but they're just an obvious
extension of this one.

The patch relies on the hashing changes in:

  https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01066.html
  https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01564.html

and on this trivial patch:

  https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01604.html

It seems a bit heavyweight when you just look at these two instructions,
but I think it'll be a saving in the end.

Bootstrapped  regression-tested on x86_64-linux-gnu.  Also tested
via config-list.mk.  OK to install?

Thanks,
Richard


gcc/
* Makefile.in (TARGET_DEF): Add target-insns.def.
(.PRECIOUS, simple_rtl_generated_h): Add insn-target-def.h.
(build/gentarget-def.o): New rule.
(genprogrtl): Add target-def.
* target-insns.def, gentarget-def.c: New files.
* target.def: Add targetm.have_* and targetm.gen_* hooks,
based on the contents of target-insns.def.
* defaults.h (HAVE_simple_return, gen_simple_return): Delete.
(HAVE_return, gen_return): Delete.
* target-def.h: Include insn-target-def.h.
* cfgrtl.c (force_nonfallthru_and_redirect): Use targetm interface
instead of direct calls.  Rely on them to do the appropriate assertions.
* function.c (gen_return_pattern): Likewise.  Return an rtx_insn *.
(convert_jumps_to_returns): Use targetm interface instead of
direct calls.
(thread_prologue_and_epilogue_insns): Likewise.
* reorg.c (find_end_label, dbr_schedule): Likewise.
* shrink-wrap.h (SHRINK_WRAPPING_ENABLED): Likewise.
* shrink-wrap.c (convert_to_simple_return): Likewise.
(try_shrink_wrapping): Use SHRINK_WRAPPING_ENABLED.

Index: gcc/Makefile.in
===
--- gcc/Makefile.in 2015-06-22 14:03:10.985503368 +0100
+++ gcc/Makefile.in 2015-06-22 14:04:26.689971484 +0100
@@ -866,7 +866,7 @@ DUMPFILE_H = $(srcdir)/../libcpp/include
 VEC_H = vec.h statistics.h $(GGC_H)
 HASH_TABLE_H = $(HASHTAB_H) hash-table.h
 EXCEPT_H = except.h $(HASHTAB_H)
-TARGET_DEF = target.def target-hooks-macros.h
+TARGET_DEF = target.def target-hooks-macros.h target-insns.def
 C_TARGET_DEF = c-family/c-target.def target-hooks-macros.h
 COMMON_TARGET_DEF = common/common-target.def target-hooks-macros.h
 TARGET_H = $(TM_H) target.h $(TARGET_DEF) insn-modes.h insn-codes.h
@@ -2078,7 +2078,8 @@ $(common_out_object_file): $(common_out_
 .PRECIOUS: insn-config.h insn-flags.h insn-codes.h insn-constants.h \
   insn-emit.c insn-recog.c insn-extract.c insn-output.c insn-peep.c \
   insn-attr.h insn-attr-common.h insn-attrtab.c insn-dfatab.c \
-  insn-latencytab.c insn-preds.c gimple-match.c generic-match.c
+  insn-latencytab.c insn-preds.c gimple-match.c generic-match.c \
+  insn-target-def.h
 
 # Dependencies for the md file.  The first time through, we just assume
 # the md file itself and the generated dependency file (in order to get
@@ -2099,7 +2100,7 @@ s-mddeps: $(md_file) $(MD_INCLUDES) buil
 # the target file.
 
 simple_rtl_generated_h = insn-attr.h insn-attr-common.h insn-codes.h \
- insn-config.h insn-flags.h
+ insn-config.h insn-flags.h insn-target-def.h
 
 simple_rtl_generated_c = insn-automata.c insn-emit.c \
  insn-extract.c insn-output.c \
@@ -2498,6 +2499,9 @@ build/genextract.o : genextract.c $(RTL_
   $(SYSTEM_H) coretypes.h $(GTM_H) errors.h $(READ_MD_H) gensupport.h
 build/genflags.o : genflags.c $(RTL_BASE_H) $(OBSTACK_H) $(BCONFIG_H)  \
   $(SYSTEM_H) coretypes.h $(GTM_H) errors.h $(READ_MD_H) gensupport.h
+build/gentarget-def.o : gentarget-def.c $(BCONFIG_H) $(SYSTEM_H)   \
+  coretypes.h $(GTM_H) $(RTL_BASE_H) errors.h $(READ_MD_H) gensupport.h
\
+  $(HASH_TABLE_H) target-insns.def
 build/gengenrtl.o : gengenrtl.c $(BCONFIG_H) $(SYSTEM_H) rtl.def
 
 # The gengtype generator program is special: Two versions are built.
@@ -2562,7 +2566,7 @@ build/genmatch.o : genmatch.c $(BCONFIG_
 
 # All these programs use the RTL reader ($(BUILD_RTL)).
 genprogrtl = attr attr-common attrtab automata codes conditions config emit \
-extract flags opinit output peep preds 

Re: [PATCH 00/17] RFC: Addding a unit testing framework to gcc

2015-06-23 Thread Jeff Law

On 06/10/2015 11:16 AM, David Malcolm wrote:

On Wed, 2015-06-10 at 17:34 +0200, Jakub Jelinek wrote:

On Wed, Jun 10, 2015 at 11:24:41AM -0400, David Malcolm wrote:

I picked the Google Test framework:
   http://code.google.com/p/googletest/


I must say I'm not very excited about using this, it won't integrate
very well with dejagnu


Why is that a goal?  I've been using DejaGnu's unittesting API for
testing the jit, and it is... suboptimal, to put it mildly.
Everyone on the project is already using dejagnu.  Adding another 
framework means everyone has to learn new ways of doing the same thing. 
 I think Jakub touched on multilibs, flag passing, result parsing, etc. 
   Note these things are embedded in the daily practices of many 
developers, build bots and even within our Makefiles for parallization 
of testing.


I'd be less likely to object if the google test framework was wrapped by 
dejagnu and had those low level things wired up properly.  I'd also be 
less likely to object if we converted *everything* to googletest.  The 
former is most likely orders of magnitude easier :-)






whether talking about results (will it provide
some *.log/*.sum file with FAIL/XFAIL/PASS/XPASS etc. lines?),


It doesn't have an output formatter for the DejaGnu format, but I guess
I could write one.  The gtest standard output format is IMHO superior to
DejaGnu's since it tells you start-of-test/end-of-test on separate
lines, so you can see which test killed things in the event of total
failure, and the per-test timings (which can be disabled if you want to
do diffs).
You can still get all that output if you wrap googletest with dejagnu -- 
that low level information would go into the .log file and the .sum 
would just have the pass, fail, xfail, xpass, etc messages.






  choosing
what options to use, e.g. global
RUNTESTFLAGS='--target_board=unix/\{-m32,-m64\}'
to test everything twice for 32-bit and 64-bit, will that run just
all unittests twice the same?,


Fair enough; yes, as written, RUNTESTFLAGS is ignored; it will run
everything once.  However we could express such a loop directly in the
main of the
But using the syntax above is already well known by developers and 
build/test bots.  I'm not keen to change it.



And note, I *hate* dejagnu.

Jeff


Re: [PATCH 1/3] Refactor entry point to -Wmisleading-indentation

2015-06-23 Thread Patrick Palka
On Mon, Jun 22, 2015 at 2:56 PM, Patrick Palka patr...@parcs.ath.cx wrote:
 On Mon, Jun 22, 2015 at 1:29 PM, Jeff Law l...@redhat.com wrote:
 On 06/09/2015 11:31 AM, Patrick Palka wrote:

 This patch refactors the entry point of -Wmisleading-indentation from:

void
warn_for_misleading_indentation (location_t guard_loc,
 location_t body_loc,
 location_t next_stmt_loc,
 enum cpp_ttype next_tok_type,
 const char *guard_kind);

 to

struct token_indent_info
{
  location_t location;
  cpp_ttype type;
  rid keyword;
};

void
warn_for_misleading_indentation (const token_indent_info guard_tinfo,
 const token_indent_info body_tinfo,
 const token_indent_info next_tinfo);

 The purpose of this refactoring is to expose more information to the
 -Wmisleading-indentation implementation to allow for more advanced
 heuristics and for better coverage.

 (I decided to keep the usage of const references because nobody
 seems to mind.  Also I added a new header file, c-indentation.h.)

 gcc/c-family/ChangeLog:

 * c-indentation.h (struct token_indent_info): Define.
 (get_token_indent_info): Define.
 (warn_for_misleading_information): Declare.
 * c-common.h (warn_for_misleading_information): Remove.
 * c-identation.c (warn_for_misleading_indentation):
 Change declaration to take three token_indent_infos.  Adjust
 accordingly.
 * c-identation.c (should_warn_for_misleading_indentation):
 Likewise.  Bail out early if the body is a compound statement.
 (guard_tinfo_to_string): Define.

 gcc/c/ChangeLog:

 * c-parser.c (c_parser_if_body): Take token_indent_info
 argument. Call warn_for_misleading_indentation even when the
 body is a semicolon.  Extract token_indent_infos corresponding
 to the guard, body and next tokens.  Adjust call to
 warn_for_misleading_indentation accordingly.
 (c_parser_else_body): Likewise.
 (c_parser_if_statement): Likewise.
 (c_parser_while_statement): Likewise.
 (c_parser_for_statement): Likewise.

 gcc/cp/ChangeLog:

 * parser.c (cp_parser_selection_statement): Move handling of
 semicolon body to ...
 (cp_parser_implicitly_scoped_statement): .. here.  Call
 warn_for_misleading_indentation even when the body is a
 semicolon.  Extract token_indent_infos corresponding to the
 guard, body and next tokens.  Adjust call to
 warn_for_misleading_indentation accordingly.  Take
 token_indent_info argument.
 (cp_parser_already_scoped_statement): Likewise.
 (cp_parser_selection_statement, cp_parser_iteration_statement):
 Extract a token_indent_info corresponding to the guard token.

 The only question in my mind is bootstrap  regression testing.  From
 reading the thread for the earlier version of this patch I got the
 impression you had bootstrapped and regression tested earlier versions.

 If you could confirm that you've bootstrapped and regression tested this
 version it'd be appreciated.  You can do it on the individual patches or the
 set as a whole.

 I think I successfully bootstrapped + regtested this exact version but
 I'm not sure.  I was going to do so again before committing anyway.
 I will fire off a build tonight and confirm the results tomorrow.

Bootstrap + regtest on x86_64-linux-gnu was successful with no new regressions.



 Jeff




Re: [PATCH 03/17] Add test-cfg.c to gcc/unittests

2015-06-23 Thread Jeff Law

On 06/10/2015 09:24 AM, David Malcolm wrote:

gcc/unittests/ChangeLog:
* test-cfg.c: New file.
---
  gcc/unittests/test-cfg.c | 319 +++
  1 file changed, 319 insertions(+)
  create mode 100644 gcc/unittests/test-cfg.c
So this one would be a great place to check that the dominator code does 
something sensible if there's unreachable nodes in the CFG or the 
post-dominator code does something sensible with infinite loops, etc.


I don't necessarily expect you to do this, just pointing it out.

Just a nit, I noticed this included rtl.h, which seems a bit odd.  Are 
those #includes relatively minimal or are they in need to cleanup?


Jeff


Re: pr66345.c size_t assumption bug

2015-06-23 Thread Jeff Law

On 06/08/2015 06:58 PM, DJ Delorie wrote:

The testcase for pr 66345 assumes size_t is unsigned long instead of
using the real type, which causes failures on some 16-bit targets.
Ok?




Also, I note that some tests check for __SIZE_TYPE__ as I do below,
and others use it unconditionally as a replacement for size_t.  Is
there a convention?
I doubt there's a well defined convention.  Particularly for the torture 
tests, many of which are very very old.




* gcc.dg/torture/pr66345.c: Fix assumption about size_t type.

OK.

jeff




Re: New type-based pool allocator code miscompiled due to aliasing issue?

2015-06-23 Thread Pat Haugen

On 06/18/2015 06:10 AM, Richard Biener wrote:

You are right that we should call ::new just for classes that have 
m_ignore_type_size == false.
I've come up with following patch, that I tested slightly:

diff --git a/gcc/alloc-pool.h b/gcc/alloc-pool.h
index 1785df5..7da5f7a 100644
--- a/gcc/alloc-pool.h
+++ b/gcc/alloc-pool.h
@@ -412,8 +412,16 @@ pool_allocatorT::allocate ()
  #endif
VALGRIND_DISCARD (VALGRIND_MAKE_MEM_UNDEFINED (header, size));

+  T *ptr = (T *)header;
+
/* Call default constructor.  */
-  return (T *)(header);
+  if (!m_ignore_type_size)
+{
+  memset (header + sizeof (T), 0, m_extra_size);
+  return ::new (ptr) T;
+}
+  else
+return ptr;
  }

  /* Puts PTR back on POOL's free list.  */

Would it be suitable?

Suitable with the memset removed, yes.
What's the status of this patch? I have a couple spec regression testers 
that have been unable to build GCC due to this issue, specifically the 
sched-deps.c change. The above patch (with memset removed) does result 
in a successful build.


Thanks,
Pat



[committed] Remove bogus target-def.h includes

2015-06-23 Thread Richard Sandiford
target-def.h should only be included by files that want to initialise targetm.
This patch removes unnecessary includes for other files.

Bootstrapped  regression-tested on x86_64-linux-gnu.  Also tested with
config-list.mk.  Applied as obvious.

Thanks,
Richard


gcc/c-family/
* c-common.c: Don't include target-def.h.

gcc/
* df-scan.c: Don't include target-def.h.
* targhooks.c: Likewise.
* config/arm/arm-c.c: Likewise.
* config/i386/i386-c.c: Likewise.
* config/nds32/nds32-cost.c: Likewise.
* config/nds32/nds32-fp-as-gp.c: Likewise.
* config/nds32/nds32-intrinsic.c: Likewise.
* config/nds32/nds32-isr.c: Likewise.
* config/nds32/nds32-md-auxiliary.c: Likewise.
* config/nds32/nds32-memory-manipulation.c: Likewise.
* config/nds32/nds32-pipelines-auxiliary.c: Likewise.
* config/nds32/nds32-predicates.c: Likewise.

Index: gcc/c-family/c-common.c
===
--- gcc/c-family/c-common.c 2015-06-22 14:04:01.749581305 +0100
+++ gcc/c-family/c-common.c 2015-06-22 14:04:25.488049064 +0100
@@ -52,7 +52,6 @@ #define GCC_C_COMMON_C
 #include function.h
 #include ipa-ref.h
 #include cgraph.h
-#include target-def.h
 #include gimplify.h
 #include wide-int-print.h
 #include gimple-expr.h
Index: gcc/df-scan.c
===
--- gcc/df-scan.c   2015-06-22 14:03:11.056500735 +0100
+++ gcc/df-scan.c   2015-06-22 14:04:25.486049193 +0100
@@ -45,7 +45,6 @@ Software Foundation; either version 3, o
 #include dumpfile.h
 #include tree.h
 #include target.h
-#include target-def.h
 #include df.h
 #include emit-rtl.h  /* FIXME: Can go away once crtl is moved to rtl.h.  */
 
Index: gcc/targhooks.c
===
--- gcc/targhooks.c 2015-06-22 14:03:11.056500735 +0100
+++ gcc/targhooks.c 2015-06-22 14:04:25.486049193 +0100
@@ -72,7 +72,6 @@ Software Foundation; either version 3, o
 #include diagnostic-core.h
 #include target.h
 #include tm_p.h
-#include target-def.h
 #include regs.h
 #include reload.h
 #include insn-codes.h
Index: gcc/config/arm/arm-c.c
===
--- gcc/config/arm/arm-c.c  2015-06-22 14:03:11.056500735 +0100
+++ gcc/config/arm/arm-c.c  2015-06-22 14:04:25.488049064 +0100
@@ -27,7 +27,6 @@
 #include tm_p.h
 #include c-family/c-common.h
 #include target.h
-#include target-def.h
 #include c-family/c-pragma.h
 
 /* Output C specific EABI object attributes.  These can not be done in
Index: gcc/config/i386/i386-c.c
===
--- gcc/config/i386/i386-c.c2015-06-22 14:03:11.056500735 +0100
+++ gcc/config/i386/i386-c.c2015-06-22 14:04:25.489048999 +0100
@@ -29,7 +29,6 @@ the Free Software Foundation; either ver
 #include flags.h
 #include c-family/c-common.h
 #include target.h
-#include target-def.h
 #include cpplib.h
 #include c-family/c-pragma.h
 
Index: gcc/config/nds32/nds32-cost.c
===
--- gcc/config/nds32/nds32-cost.c   2015-06-22 14:03:11.056500735 +0100
+++ gcc/config/nds32/nds32-cost.c   2015-06-22 14:04:25.489048999 +0100
@@ -64,7 +64,6 @@
 #include tm-constrs.h
 #include optabs.h/* For GEN_FCN.  */
 #include target.h
-#include target-def.h
 #include langhooks.h /* For add_builtin_function().  */
 #include builtins.h
 
Index: gcc/config/nds32/nds32-fp-as-gp.c
===
--- gcc/config/nds32/nds32-fp-as-gp.c   2015-06-22 14:03:11.056500735 +0100
+++ gcc/config/nds32/nds32-fp-as-gp.c   2015-06-22 14:04:25.489048999 +0100
@@ -64,7 +64,6 @@
 #include tm-constrs.h
 #include optabs.h/* For GEN_FCN.  */
 #include target.h
-#include target-def.h
 #include langhooks.h /* For add_builtin_function().  */
 #include builtins.h
 
Index: gcc/config/nds32/nds32-intrinsic.c
===
--- gcc/config/nds32/nds32-intrinsic.c  2015-06-22 14:03:11.056500735 +0100
+++ gcc/config/nds32/nds32-intrinsic.c  2015-06-22 14:04:25.489048999 +0100
@@ -64,7 +64,6 @@
 #include tm-constrs.h
 #include optabs.h/* For GEN_FCN.  */
 #include target.h
-#include target-def.h
 #include langhooks.h /* For add_builtin_function().  */
 #include builtins.h
 
Index: gcc/config/nds32/nds32-isr.c
===
--- gcc/config/nds32/nds32-isr.c2015-06-22 14:03:11.056500735 +0100
+++ gcc/config/nds32/nds32-isr.c2015-06-22 14:04:25.490048935 +0100
@@ -64,7 +64,6 @@
 #include tm-constrs.h
 #include optabs.h/* For GEN_FCN.  */
 #include target.h
-#include target-def.h
 #include langhooks.h /* For add_builtin_function().  */
 

Re: [PATCH 02/17] Add test-bitmap.c to gcc/unittests

2015-06-23 Thread Jeff Law

On 06/10/2015 09:24 AM, David Malcolm wrote:

gcc/unittests/ChangeLog:
* test-bitmap.c: New file.
---
  gcc/unittests/test-bitmap.c | 117 
  1 file changed, 117 insertions(+)
  create mode 100644 gcc/unittests/test-bitmap.c

diff --git a/gcc/unittests/test-bitmap.c b/gcc/unittests/test-bitmap.c
new file mode 100644
index 000..38adff3
--- /dev/null
+++ b/gcc/unittests/test-bitmap.c
So...  We have a long standing issue that we can't iterate on a bitmap 
that is changing.  I can't recall if it's bits going from set to unset 
that causes a problem or vice-versa or both.


There's been talk of putting some sanity checking in the bitmap code to 
detect this error.  A unit testing framework of this nature would be a 
great way to verify that sanity checking worked.


More generally a unit testing framework would allow us to build a suite 
that does a positive test on our sanity checking.  ie, set up the 
invalid state and see if the sanity checking bits complain -- things we 
can't do from a source file.


Anyway, the test itself seems like a reasonable start, we just have to 
settle the framework issues.



Jeff



Re: Do not take address of empty string front

2015-06-23 Thread François Dumont
On 22/06/2015 17:10, Jonathan Wakely wrote:
 On 20/06/15 12:59 +0100, Jonathan Wakely wrote:
 On 20/06/15 12:03 +0200, François Dumont wrote:
 Hi

   2 experimental tests are failing in debug mode because
 __do_str_codecvt is sometimes taking address of string front() and
 back() even if empty. It wasn't use so not a big issue but it still
 seems better to avoid. I propose to rather use string begin() to get
 buffer address.

 But derefencing begin() is still undefined for an empty string.
 Shouldn't that fail for debug mode too? Why change one form of
 undefined behaviour that we diagnose to another form that we don't
 diagnose?

 It would be better if that function didn't do any work when the input
 range is empty:

 --- a/libstdc++-v3/include/bits/locale_conv.h
 +++ b/libstdc++-v3/include/bits/locale_conv.h
 @@ -58,6 +58,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_OutStr __outstr, const _Codecvt __cvt, _State
 __state,
size_t __count, _Fn __fn)
{
 +  if (__first == __last)
 +   {
 + __outstr.clear();
 + return true;
 +   }
 +

Shouldn't it also set __count to 0 to make clear that nothing has been
converted.

  size_t __outchars = 0;
  auto __next = __first;
  const auto __maxlen = __cvt.max_length() + 1;

 This makes that change, and also moves wstring_convert into the
 ABI-tagged __cxx11 namespace, and fixes a copypaste error in the
 exception thrown from wbuffer_convert.

 Tested powerpc64le-linux, committed to trunk.

 François, your changes to add extra checks in std::string are still
 useful separately.

Ok I will take care of this part.

François



Re: [PATCH][RFC] Add FRE in pass_vectorize

2015-06-23 Thread Jeff Law

On 06/10/2015 08:02 AM, Richard Biener wrote:


The following patch adds FRE after vectorization which is needed
for IVOPTs to remove redundant PHI nodes (well, I'm testing a
patch for FRE that will do it already there).

Redundant or degenerates which should be propagated?

I believe Alan Lawrence has run into similar issues (unpropagated 
degenerates) with his changes to make loop header copying more 
aggressive.  Threading will also create them.  The phi-only propagator 
may be the solution.  It ought to be cheaper than FRE.





The patch also makes FRE preserve loop-closed SSA form and thus
make it suitable for use in the loop pipeline.
Loop optimizations will tend to create opportunities for redundancy 
elimination, so the ability to use FRE in the loop pipeline seems like a 
good thing.  We ran into this in RTL land, so I'm not surprised to see 
it occurring in the gimple optimizers and thus I'm not opposed to 
running FRE in the loop pipeline.






With the placement in the vectorizer sub-pass FRE will effectively
be enabled by -O3 only (well, or if one requests loop vectorization).
I've considered placing it after complete_unroll instead but that
would enable it at -O1 already.  I have no strong opinion on the
exact placement, but it should help all passes between vectorizing
and ivopts for vectorized loops.
For -O3/vectorization it seems like a no-brainer.  -O1 less so.  IIRC we 
conditionalize -frerun-cse-after-loop on -O2 which seems more 
appropriate than doing it with -O1.




Any other suggestions on pass placement?  I can of course key
that FRE run on -O3 explicitely.  Not sure if we at this point
want to start playing fancy games like setting a property
when a pass (likely) generated redundancies that are worth
fixing up and then key FRE on that one (it gets harder and
less predictable what transforms are run on code).
RTL CSE is bloody expensive and so many times I wanted the ability to 
know a bit about what the loop optimizer had done (or not done) so that 
I could conditionally skip the second CSE pass.   We never built that, 
but it's something I've wanted for decades.


Jeff



Re: Remove redundant AND from count reduction loop

2015-06-23 Thread Marc Glisse

On Tue, 23 Jun 2015, Richard Sandiford wrote:


+/* Vector comparisons are defined to produce all-one or all-zero results.  */
+(simplify
+ (vec_cond @0 integer_all_onesp@1 integer_zerop@2)
+ (if (tree_nop_conversion_p (type, TREE_TYPE (@0)))
+   (convert @0)))


I am trying to understand why the test tree_nop_conversion_p is the right 
one (at least for the transformations not using VIEW_CONVERT_EXPR). By 
definition of VEC_COND_EXPR, type and TREE_TYPE (@0) are both integer 
vector types of the same size and number of elements. It thus seems like a 
conversion is always fine. For vectors, tree_nop_conversion_p apparently 
only checks that they have the same mode (quite often VOIDmode I guess).



+/* We could instead convert all instances of the vec_cond to negate,
+   but that isn't necessarily a win on its own.  */
+(simplify
+ (plus:c @3 (vec_cond @0 integer_each_onep@1 integer_zerop@2))
+ (if (tree_nop_conversion_p (type, TREE_TYPE (@0)))
+  (minus @3 (convert @0
+
+(simplify
+ (plus:c @3 (view_convert_expr


Aren't we suppose to drop _expr in match.pd?


+(vec_cond @0 integer_each_onep@1 integer_zerop@2)))
+ (if (tree_nop_conversion_p (type, TREE_TYPE (@0)))
+  (minus @3 (convert @0
+
+(simplify
+ (minus @3 (vec_cond @0 integer_each_onep@1 integer_zerop@2))
+ (if (tree_nop_conversion_p (type, TREE_TYPE (@0)))
+  (plus @3 (convert @0
+
+(simplify
+ (minus @3 (view_convert_expr
+   (vec_cond @0 integer_each_onep@1 integer_zerop@2)))
+ (if (tree_nop_conversion_p (type, TREE_TYPE (@0)))
+  (plus @3 (convert @0
+
/* Simplifications of comparisons.  */

/* We can simplify a logical negation of a comparison to the
Index: gcc/testsuite/gcc.target/aarch64/vect-add-sub-cond.c
===
--- /dev/null   2015-06-02 17:27:28.541944012 +0100
+++ gcc/testsuite/gcc.target/aarch64/vect-add-sub-cond.c2015-06-23 
12:06:27.120203685 +0100
@@ -0,0 +1,94 @@
+/* Make sure that vector comaprison results are not unnecessarily ANDed
+   with vectors of 1.  */
+/* { dg-do compile } */
+/* { dg-options -O2 -ftree-vectorize } */
+
+#define COUNT1(X) if (X) count += 1
+#define COUNT2(X) if (X) count -= 1
+#define COUNT3(X) count += (X)
+#define COUNT4(X) count -= (X)
+
+#define COND1(X) (X)
+#define COND2(X) ((X) ? 1 : 0)
+#define COND3(X) ((X) ? -1 : 0)
+#define COND4(X) ((X) ? 0 : 1)
+#define COND5(X) ((X) ? 0 : -1)
+
+#define TEST_LT(X, Y) ((X)  (Y))
+#define TEST_LE(X, Y) ((X) = (Y))
+#define TEST_GT(X, Y) ((X)  (Y))
+#define TEST_GE(X, Y) ((X) = (Y))
+#define TEST_EQ(X, Y) ((X) == (Y))
+#define TEST_NE(X, Y) ((X) != (Y))
+
+#define COUNT_LOOP(ID, TYPE, CMP_ARRAY, TEST, COUNT) \
+  TYPE \
+  reduc_##ID (__typeof__ (CMP_ARRAY[0]) x) \
+  { \
+TYPE count = 0; \
+for (unsigned int i = 0; i  1024; ++i) \
+  COUNT (TEST (CMP_ARRAY[i], x)); \
+return count; \
+  }
+
+#define COND_LOOP(ID, ARRAY, CMP_ARRAY, TEST, COND) \
+  void \
+  plus_##ID (__typeof__ (CMP_ARRAY[0]) x) \
+  { \
+for (unsigned int i = 0; i  1024; ++i) \
+  ARRAY[i] += COND (TEST (CMP_ARRAY[i], x)); \
+  } \
+  void \
+  plusc_##ID (void) \
+  { \
+for (unsigned int i = 0; i  1024; ++i) \
+  ARRAY[i] += COND (TEST (CMP_ARRAY[i], 10)); \
+  } \
+  void \
+  minus_##ID (__typeof__ (CMP_ARRAY[0]) x) \
+  { \
+for (unsigned int i = 0; i  1024; ++i) \
+  ARRAY[i] -= COND (TEST (CMP_ARRAY[i], x)); \
+  } \
+  void \
+  minusc_##ID (void) \
+  { \
+for (unsigned int i = 0; i  1024; ++i) \
+  ARRAY[i] += COND (TEST (CMP_ARRAY[i], 1)); \
+  }
+
+#define ALL_LOOPS(ID, ARRAY, CMP_ARRAY, TEST) \
+  typedef __typeof__(ARRAY[0]) ID##_type; \
+  COUNT_LOOP (ID##_1, ID##_type, CMP_ARRAY, TEST, COUNT1) \
+  COUNT_LOOP (ID##_2, ID##_type, CMP_ARRAY, TEST, COUNT2) \
+  COUNT_LOOP (ID##_3, ID##_type, CMP_ARRAY, TEST, COUNT3) \
+  COUNT_LOOP (ID##_4, ID##_type, CMP_ARRAY, TEST, COUNT4) \
+  COND_LOOP (ID##_1, ARRAY, CMP_ARRAY, TEST, COND1) \
+  COND_LOOP (ID##_2, ARRAY, CMP_ARRAY, TEST, COND2) \
+  COND_LOOP (ID##_3, ARRAY, CMP_ARRAY, TEST, COND3) \
+  COND_LOOP (ID##_4, ARRAY, CMP_ARRAY, TEST, COND4) \
+  COND_LOOP (ID##_5, ARRAY, CMP_ARRAY, TEST, COND5)
+
+signed int asi[1024] __attribute__ ((aligned (16)));
+unsigned int aui[1024] __attribute__ ((aligned (16)));
+signed long long asl[1024] __attribute__ ((aligned (16)));
+unsigned long long aul[1024] __attribute__ ((aligned (16)));
+float af[1024] __attribute__ ((aligned (16)));
+double ad[1024] __attribute__ ((aligned (16)));
+
+ALL_LOOPS (si_si, aui, asi, TEST_LT)
+ALL_LOOPS (ui_si, aui, asi, TEST_LE)
+ALL_LOOPS (si_ui, aui, asi, TEST_GT)
+ALL_LOOPS (ui_ui, aui, asi, TEST_GE)
+ALL_LOOPS (sl_sl, asl, asl, TEST_NE)
+ALL_LOOPS (ul_ul, aul, aul, TEST_NE)
+ALL_LOOPS (si_f, asi, af, TEST_LE)
+ALL_LOOPS (ui_f, aui, af, TEST_GT)
+ALL_LOOPS (sl_d, asl, ad, TEST_GE)
+ALL_LOOPS (ul_d, aul, ad, TEST_GT)
+
+/* { dg-final { scan-assembler-not \tand\t } } */
+/* { dg-final { scan-assembler-not 

[PATCH/AARCH64] Update ThunderX schedule model

2015-06-23 Thread Andrew Pinski
Hi,
  This patch updates the schedule model to be more accurate and model
SIMD and fp instructions that I had missed out when I had the last
patch.

OK?  Bootstrapped and tested on aarch64-linux-gnu with no regeessions.

Thanks,
Andrew Pinski

ChangeLog:

 * config/aarch64/thunderx.md (thunderx_shift): Add rbit and rev.
(thunderx_crc32): New reservation.
(thunderx_fmov): Add fcsel, ffarithd and ffariths.
(thunderx_fabs): New reservation.
(thunderx_fcsel): New reservation.
(thunderx_fcmp): New reservation.
(thunderx_fsqrtd): Correct latency.
(thunderx_frint): Add f_cvt.
(thunderx_f_cvt): Remove f_cvt.
(thunderx_simd_fp_store): Add neon_store1_one_lane
and neon_store1_one_lane_q.
(thunderx_neon_ld1): New reservation.
(thunderx_neon_move): Add neon_dup.
neon_ins, neon_from_gp, neon_to_gp,
neon_abs, neon_neg,
neon_fp_neg_s, and neon_fp_abs_s.
(thunderx_neon_move_q): Add neon_dup_q,
neon_ins_q, neon_from_gp_q, neon_to_gp_q,
neon_abs_q, neon_neg_q,
neon_fp_neg_s_q, neon_fp_neg_d_q,
neon_fp_abs_s_q, and neon_fp_abs_d_q.
(thunderx_neon_add): Add neon_arith_acc, neon_rev, neon_fp_abd_s,
neon_fp_abd_d, and neon_fp_reduc_minmax_s.
(thunderx_neon_add_q): Add neon_fp_abd_s_q, neon_fp_abd_d_q,
neon_arith_acc_q, neon_rev_q,
neon_fp_reduc_minmax_s_q, and neon_fp_reduc_minmax_d_q.
(thunderx_neon_mult): New reservation.
(thunderx_neon_mult_q): New reservation.
(thunderx_crypto_aese): New reservation.
(thunderx_crypto_aesmc): New reservation.
(bypasses): Add bypass to thunderx_neon_mult_q.
(thunderx_tbl): New reservation.
(thunderx_tblq): New reservation.
Index: config/aarch64/thunderx.md
===
--- config/aarch64/thunderx.md  (revision 224856)
+++ config/aarch64/thunderx.md  (working copy)
@@ -39,7 +39,7 @@ (define_insn_reservation thunderx_add
 
 (define_insn_reservation thunderx_shift 1
   (and (eq_attr tune thunderx)
-   (eq_attr type bfm,extend,shift_imm,shift_reg))
+   (eq_attr type bfm,extend,shift_imm,shift_reg,rbit,rev))
   thunderx_pipe0 | thunderx_pipe1)
 
 
@@ -66,12 +66,18 @@ (define_insn_reservation thunderx_mul
(eq_attr type mul,muls,mla,mlas,clz,smull,umull,smlal,umlal))
   thunderx_pipe1 + thunderx_mult)
 
-;; Multiply high instructions take an extra cycle and cause the muliply unit to
-;; be busy for an extra cycle.
+;; crcb,crch,crcw is 4 cycles and can only happen on pipe 1
 
-;(define_insn_reservation thunderx_mul_high 5
+(define_insn_reservation thunderx_crc32 4
+  (and (eq_attr tune thunderx)
+   (eq_attr type crc))
+  thunderx_pipe1 + thunderx_mult)
+
+;; crcx is 5 cycles and only happen on pipe 1
+;(define_insn_reservation thunderx_crc64 5
 ;  (and (eq_attr tune thunderx)
-;   (eq_attr type smull,umull))
+;   (eq_attr type crc)
+;   (eq_attr mode DI))
 ;  thunderx_pipe1 + thunderx_mult)
 
 (define_insn_reservation thunderx_div32 22
@@ -97,6 +103,11 @@ (define_insn_reservation thunderx_store
(eq_attr type store2))
   thunderx_pipe0 + thunderx_pipe1)
 
+;; Prefetch are single issued
+;(define_insn_reservation thunderx_prefetch 1
+;  (and (eq_attr tune thunderx)
+;   (eq_attr type prefetch))
+;  thunderx_pipe0 + thunderx_pipe1)
 
 ;; loads (and load pairs) from L1 take 3 cycles in pipe 0
 (define_insn_reservation thunderx_load 3
@@ -121,10 +132,21 @@ (define_insn_reservation thunderx_fcons
(eq_attr type fconsts,fconstd))
   thunderx_pipe1)
 
-;; Moves between fp are 2 cycles including min/max/select/abs/neg
+;; Moves between fp are 2 cycles including min/max
 (define_insn_reservation thunderx_fmov 2
   (and (eq_attr tune thunderx)
-   (eq_attr type fmov,f_minmaxs,f_minmaxd,fcsel,ffarithd,ffariths))
+   (eq_attr type fmov,f_minmaxs,f_minmaxd))
+  thunderx_pipe1)
+
+;; ABS, and NEG are 1 cycle
+(define_insn_reservation thunderx_fabs 1
+  (and (eq_attr tune thunderx)
+   (eq_attr type ffariths,ffarithd))
+  thunderx_pipe1)
+
+(define_insn_reservation thunderx_fcsel 3
+  (and (eq_attr tune thunderx)
+   (eq_attr type fcsel))
   thunderx_pipe1)
 
 (define_insn_reservation thunderx_fmovgpr 2
@@ -132,6 +154,11 @@ (define_insn_reservation thunderx_fmovg
(eq_attr type f_mrc, f_mcr))
   thunderx_pipe1)
 
+(define_insn_reservation thunderx_fcmp 3
+  (and (eq_attr tune thunderx)
+   (eq_attr type fcmps,fcmpd))
+  thunderx_pipe1)
+
 (define_insn_reservation thunderx_fmul 6
   (and (eq_attr tune thunderx)
(eq_attr type fmacs,fmacd,fmuls,fmuld))
@@ -152,21 +179,21 @@ (define_insn_reservation thunderx_fsqrt
(eq_attr type fsqrts))
   thunderx_pipe1 + thunderx_divide, thunderx_divide*13)
 
-(define_insn_reservation thunderx_fsqrtd 28
+(define_insn_reservation thunderx_fsqrtd 31
   (and (eq_attr tune thunderx)
(eq_attr type fsqrtd))
-  thunderx_pipe1 + thunderx_divide, thunderx_divide*31)
+  thunderx_pipe1 + thunderx_divide, thunderx_divide*27)
 
 ;; The rounding conversion inside fp is 4 cycles
 (define_insn_reservation thunderx_frint 4
   (and (eq_attr tune 

Re: [01/13] Move hash traits to their own header file

2015-06-23 Thread Jeff Law

On 06/16/2015 02:43 AM, Richard Sandiford wrote:

This patch just moves the traits classes to their own header file,
hash-traits.h.

gcc/
* hash-table.h: Include hash-traits.h.
(typed_free_remove, typed_noop_remove, pointer_hash, ggc_hasher)
(ggc_cache_hasher): Move to...
* hash-traits.h: ...this new file.

This is fine.

In fact, I think that we probably should just have a policy that moving 
bits like this into a new file should be considered obviously OK after 
the usual bootstrap and regression test.


jeff




Re: [03/13] Make ggc_cached_hasher inherit from ggc_hasher

2015-06-23 Thread Jeff Law

On 06/16/2015 02:52 AM, Richard Sandiford wrote:

Most of ggc_cache_hasher is duplicated from ggc_hasher.  This patch
gets the same functionality via inheritance.  It also brings the
ggc_hasher functions in line with ggc_cache_hasher by making remove()
and ggc_mx() take references rather than pointers.  This seems more
consistent with the idea that elements don't need to be pointers and
could be some gc-ed structure instead.

gcc/
* hash-traits.h (ggc_hasher::remove): Take a reference parameter.
(ggc_hasher::ggc_mx): Likewise.
(ggc_cache_hasher): Inherit from ggc_hasher.  Remove definitions
that duplicate ggc_hasher ones.

OK.
jeff



Re: [04/13] Add {mark,is}_{empty,deleted} to pointer_hash

2015-06-23 Thread Jeff Law

On 06/16/2015 02:53 AM, Richard Sandiford wrote:

This patch just adds the standard pointer handling of empty and deleted
entries.  As the series goes on, more and more traits classes will inherit
these definitions, to the point where we can require the functions to exist.

gcc/
* hash-traits.h (pointer_hash::mark_deleted, pointer_hash::mark_empty)
(pointer_hash::is_deleted, pointer_hash::is_empty): New functions.

OK.
jeff



Re: [PATCH/RFC] Make loop-header-copying more aggressive, rerun before tree-if-conversion

2015-06-23 Thread Jeff Law

On 06/19/2015 11:38 AM, Alan Lawrence wrote:

Jeff Law wrote:

On 05/22/2015 09:42 AM, Alan Lawrence wrote:

This patch does so (and makes slightly less conservative, to tackle the
example above). I found I had to make this a separate pass, so that the
phi nodes were cleaned up at the end of the pass before running
tree_if_conversion.

What PHI node cleanup needs to be done?  I don't doubt something's
needed, but would like to understand the cleanup -- depending on what
needs to be done, it may be the case that we can cleanup on-the-fly or
it may point at a general issue we should be resolving prior to
running tree_if_conversion.


If I change pass_ch_vect to return 0 rather than TODO_update_cfg, my
testcase gives:
Thanks.  Does running the phi-only propagator after the loop header 
copying help?  At first glance it would seem that it ought to propagate 
the values of those degenerate PHIs then eliminate those PHIs.


It was written to cleanup after jump threading which has a tendency to 
create very similar code to what you've shown below and to do so very 
quickly.



/* A very simple pass to eliminate degenerate PHI nodes from the
   IL.  This is meant to be fast enough to be able to be run several
   times in the optimization pipeline.

   Certain optimizations, particularly those which duplicate blocks
   or remove edges from the CFG can create or expose PHIs which are
   trivial copies or constant initializations.

   While we could pick up these optimizations in DOM or with the
   combination of copy-prop and CCP, those solutions are far too
   heavy-weight for our needs.

   This implementation has two phases so that we can efficiently
   eliminate the first order degenerate PHIs and second order
   degenerate PHIs.

   The first phase performs a dominator walk to identify and eliminate
   the vast majority of the degenerate PHIs.  When a degenerate PHI
   is identified and eliminated any affected statements or PHIs
   are put on a worklist.

   The second phase eliminates degenerate PHIs and trivial copies
   or constant initializations using the worklist.  This is how we
   pick up the secondary optimization opportunities with minimal
   cost.  */


I agree this isn't (/cannot be) totally definitive, so if you are not
sufficiently reassured - would you be if I called loop_optimizer_init
(LOOPS_NORMAL | LOOPS_HAVE_RECORDED_EXITS) at the end of pass_ch_vect,
redoing the setup done in pass_tree_loop_init::execute?
As I mentioned, I didn't have anything specific in mind, just a general 
concern.   No way to be totally definitive here.  I think you've done 
suitable due diligence.





Patch v2 at https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01355.html .
Thanks.  It's in the queue again.  Two weeks of PTO has made that queue 
much deeper than I'd like, but I'm making progress :-)


jeff



Re: [00/13] Share hash traits between hash_table and hash_set

2015-06-23 Thread Jeff Law

On 06/16/2015 02:42 AM, Richard Sandiford wrote:

At the moment we need separate traits classes for hash_table, hash_set
and hash_map.  I think that's a sign that we don't have the right
abstraction.

You're probably right.



The aim of this series is to unify the traits for hash_table and hash_set.
If that's OK, I'll look at adding default hash_map traits for the common
case in which the deleted/empty information is stored in the key rather
than the value and where hash_table traits could be used.

There were various things I needed to change along the way:

- Our one generic hasher, pointer_hash, inherits from typed_noop_remove.
   In other words, it's specifically for cases where the pointer isn't
   freed when an entry is deleted.  That seems a bit arbitrary.  I think
   we should separate out the hashing and the removing aspects.
Seems wise.  Certainly doesn't feel right that hashing and removing are 
tied together like this (/me scurries off to see if this was my doing...)








   Also, typed_noop_remove and typed_free_remove don't provide hashing typedefs,
   but the ggc equivalents ggc_hasher and ggc_cache_hasher do.  If we separate
   the hashing and removing aspects, the typedefs belong to the hashing side.

Right.



   Much of the awkwardness here is due to not having proper object
   construction and destruction.  If we had that, the memory management
   would be an integral part of the element type rather than being part
   of the traits.  So I don't think adding a template parameter for the
   element remover would necessarily be forward progress.

It's a common theme in GCC.



- handle_cache_entry is too tied to the internals.  The generic
   implementation is:

 static void
 handle_cache_entry (T e)
 {
   if (e != HTAB_EMPTY_ENTRY  e != HTAB_DELETED_ENTRY  !ggc_marked_p 
(e))
e = static_castT (HTAB_DELETED_ENTRY);
 }

   and a typical override looks like:

 void
 pad_type_hasher::handle_cache_entry (pad_type_hash *t)
 {
   extern void gt_ggc_mx (pad_type_hash *);
   if (t == HTAB_EMPTY_ENTRY || t == HTAB_DELETED_ENTRY)
return;
   else if (ggc_marked_p (t-type))
gt_ggc_mx (t);
   else
t = static_castpad_type_hash * (HTAB_DELETED_ENTRY);
 }

   In particular, this bypasses the normal remove() function, so we never
   update m_n_deleted.

   ISTM the (single) caller should be checking for empty and deleted items
   first and handling any deletion itself.  All we want to know from the
   traits is which of the following applies:

   - the entry should be deleted
   - the entry should be kept and needs to be marked
   - the entry should be kept and is already marked (an optimisation of
 the previous case).

   The patch adds a keep_cache_entry function to provide this information.
Seems like this is a result of having the memory management being part 
of the traits rather than the element.


Thanks for the detailed overview...  Onward to the patches.

jeff


Re: [02/13] Replace handle_cache_entry with new interface

2015-06-23 Thread Jeff Law

On 06/16/2015 02:45 AM, Richard Sandiford wrote:

As described in the covering note, this patch replaces handle_cache_entry
with a new function keep_cache_entry.  It also ensures that elements are
deleted using the proper function, so that m_n_deleted is updated.

I couldn't tell whether the unusual name of the function
(gt_cleare_cache) is deliberate or not, but I left it be.

Short-hand for clear_entry or something similar?




gcc/ada/
* gcc-interface/decl.c (value_annotation_hasher::handle_cache_entry):
Delete.
(value_annotation_hasher::keep_cache_entry): New function.
* gcc-interface/utils.c (pad_type_hasher::handle_cache_entry):
Delete.
(pad_type_hasher::keep_cache_entry): New function.

gcc/
* hash-table.h (hash_table): Add gt_cleare_cache as a friend.
(gt_cleare_cache): Check here for deleted and empty entries.
Replace handle_cache_entry with a call to keep_cache_entry.
* hash-traits.h (ggc_cache_hasher::handle_cache_entry): Delete.
(ggc_cache_hasher::keep_cache_entry): New function.
* trans-mem.c (tm_wrapper_hasher::handle_cache_entry): Delete.
(tm_wrapper_hasher::keep_cache_entry): New function.
* tree.h (tree_decl_map_cache_hasher::handle_cache_entry): Delete.
(tree_vec_map_cache_hasher::keep_cache_entry): New function.
* tree.c (type_cache_hasher::handle_cache_entry): Delete.
(type_cache_hasher::keep_cache_entry): New function.
(tree_vec_map_cache_hasher::handle_cache_entry): Delete.
(tree_vec_map_cache_hasher::keep_cache_entry): New function.
* ubsan.c (tree_type_map_cache_hasher::handle_cache_entry): Delete.
(tree_type_map_cache_hasher::keep_cache_entry): New function.
* varasm.c (tm_clone_hasher::handle_cache_entry): Delete.
(tm_clone_hasher::keep_cache_entry): New function.
* config/i386/i386.c (dllimport_hasher::handle_cache_entry): Delete.
(dllimport_hasher::keep_cache_entry): New function.
So for all the keep_cache_entry functions, I guess they're trivial 
enough that a function comment probably isn't needed.  Presumably no 
good way to share the trivial implementation?


OK for the trunk.

jeff


Re: [05/13] Add nofree_ptr_hash

2015-06-23 Thread Jeff Law

On 06/16/2015 02:55 AM, Richard Sandiford wrote:

This patch stops pointer_hash from inheriting typed_noop_remove and
instead creates a new class nofree_ptr_hash that inherits from both.
It then updates all uses of typed_noop_remove (which are all pointers)
and pointer_hash so that they use this new class instead.

gcc/
* hash-table.h: Update comments.
* hash-traits.h (pointer_hash): Don't inherit from typed_noop_remove.
(nofree_ptr_hash): New class.
* asan.c (asan_mem_ref_hasher): Inherit from nofree_ptr_hash rather
than typed_noop_remove.  Remove redudant typedefs.
* attribs.c (attribute_hasher): Likewise.
* cfg.c (bb_copy_hasher): Likewise.
* cselib.c (cselib_hasher): Likewise.
* dse.c (invariant_group_base_hasher): Likewise.
* dwarf2cfi.c (trace_info_hasher): Likewise.
* dwarf2out.c (macinfo_entry_hasher): Likewise.
(comdat_type_hasher, loc_list_hasher): Likewise.
* gcse.c (pre_ldst_expr_hasher): Likewise.
* genmatch.c (id_base): Likewise.
* genrecog.c (test_pattern_hasher): Likewise.
* gimple-ssa-strength-reduction.c (cand_chain_hasher): Likewise.
* haifa-sched.c (delay_i1_hasher): Likewise.
* hard-reg-set.h (simplifiable_subregs_hasher): Likewise.
* ipa-icf.h (congruence_class_group_hash): Likewise.
* ipa-profile.c (histogram_hash): Likewise.
* ira-color.c (allocno_hard_regs_hasher): Likewise.
* lto-streamer.h (string_slot_hasher): Likewise.
* lto-streamer.c (tree_entry_hasher): Likewise.
* plugin.c (event_hasher): Likewise.
* postreload-gcse.c (expr_hasher): Likewise.
* store-motion.c (st_expr_hasher): Likewise.
* tree-sra.c (uid_decl_hasher): Likewise.
* tree-ssa-coalesce.c (coalesce_pair_hasher): Likewise.
(ssa_name_var_hash): Likewise.
* tree-ssa-live.c (tree_int_map_hasher): Likewise.
* tree-ssa-loop-im.c (mem_ref_hasher): Likewise.
* tree-ssa-pre.c (pre_expr_d): Likewise.
* tree-ssa-sccvn.c (vn_nary_op_hasher): Likewise.
* vtable-verify.h (registration_hasher): Likewise.
* vtable-verify.c (vtbl_map_hasher): Likewise.
* config/arm/arm.c (libcall_hasher): Likewise.
* config/i386/winnt.c (wrapped_symbol_hasher): Likewise.
* config/ia64/ia64.c (bundle_state_hasher): Likewise.
* config/sol2.c (comdat_entry_hasher): Likewise.
* fold-const.c (fold): Use nofree_ptr_hash instead of pointer_hash.
(print_fold_checksum, fold_checksum_tree): Likewise.
(debug_fold_checksum, fold_build1_stat_loc): Likewise.
(fold_build2_stat_loc, fold_build3_stat_loc): Likewise.
(fold_build_call_array_loc): Likewise.
* tree-ssa-ccp.c (gimple_htab): Likewise.
* tree-browser.c (tree_upper_hasher): Inherit from nofree_ptr_hash
rather than pointer_type.

gcc/c/
* c-decl.c (detect_field_duplicates_hash): Use nofree_ptr_hash
instead of pointer_hash.
(detect_field_duplicates): Likewise.

gcc/cp/
* class.c (fixed_type_or_null_ref_ht): Inherit from nofree_ptr_hash
rather than pointer_hash.
(fixed_type_or_null): Use nofree_ptr_hash instead of pointer_hash.
* semantics.c (nrv_data): Likewise.
* tree.c (verify_stmt_tree_r, verify_stmt_tree): Likewise.

gcc/java/
* jcf-io.c (charstar_hash): Inherit from nofree_ptr_hash rather
than typed_noop_remove.  Remove redudant typedefs.

gcc/lto/
* lto.c (tree_scc_hasher): Inherit from nofree_ptr_hash rather
than typed_noop_remove.  Remove redudant typedefs.

gcc/objc/
* objc-act.c (decl_name_hash): Inherit from nofree_ptr_hash rather
than typed_noop_remove.  Remove redudant typedefs.

libcc1/
* plugin.cc (string_hasher): Inherit from nofree_ptr_hash rather
than typed_noop_remove.  Remove redudant typedefs.
(plugin_context): Use nofree_ptr_hash rather than pointer_hash.
(plugin_context::mark): Likewise.
So are we allowing multiple inheritance in GCC?  It seems like that's 
what we've got for nofree_ptr_hash.  Is there a better way to achieve 
what you're trying to do, or do you think this use ought to fall under 
some kind of exception?




Index: gcc/haifa-sched.c
===
--- gcc/haifa-sched.c   2015-06-16 09:53:47.338092692 +0100
+++ gcc/haifa-sched.c   2015-06-16 09:53:47.322092878 +0100
@@ -614,9 +614,8 @@ struct delay_pair

  /* Helpers for delay hashing.  */

-struct delay_i1_hasher : typed_noop_remove delay_pair
+struct delay_i1_hasher : nofree_ptr_hash delay_pair
  {
-  typedef delay_pair *value_type;
typedef void *compare_type;
static inline hashval_t hash (const delay_pair *);
static inline bool equal (const delay_pair *, const void *);
Did you keep compare_type intentionally?  Similarly for the changes in 

Re: [gomp4.1] Add new versions of GOMP_target{,_data,_update} and GOMP_target_enter_exit_data

2015-06-23 Thread Jakub Jelinek
On Tue, Jun 23, 2015 at 02:40:43PM +0300, Ilya Verbin wrote:
 On Sat, Jun 20, 2015 at 00:35:14 +0300, Ilya Verbin wrote:
  Given that a mapped variable in 4.1 can have different kinds across nested 
  data
  regions, we need to store map-type not only for each var, but also for each
  structured mapping.  Here is my WIP patch, is it sane? :)
  Attached testcase works OK on the device with non-shared memory.
 
 A bit updated version with a fix for GOMP_MAP_TO_PSET.
 make check-target-libgomp passed.

Ok, thanks.

 include/gcc/
   * gomp-constants.h (GOMP_MAP_ALWAYS_TO_P,
   GOMP_MAP_ALWAYS_FROM_P): Define.
 libgomp/
   * libgomp.h (struct target_var_desc): New.
   (struct target_mem_desc): Replace array of splay_tree_key with array of
   target_var_desc.
   (struct splay_tree_key_s): Move copy_from to target_var_desc.
   * oacc-mem.c (gomp_acc_remove_pointer): Use copy_from from
   target_var_desc.
   * oacc-parallel.c (GOACC_parallel): Use copy_from from target_var_desc.
   * target.c (gomp_map_vars_existing): Copy data to device if map-type is
   'always to' or 'always tofrom'.
   (gomp_map_vars): Use key from target_var_desc.  Set copy_from and
   always_copy_from.
   (gomp_copy_from_async): Use key and copy_from from target_var_desc.
   (gomp_unmap_vars): Copy data from device if always_copy_from is set.
   (gomp_offload_image_to_device): Do not use copy_from.
   * testsuite/libgomp.c/target-11.c: New test.

 +  /* Set dd on target to 0 for the further check.  */
 +  #pragma omp target map(always to: dd)
 + { dd; }

This reminds me that:
  if (ctx-region_type == ORT_TARGET  !(n-value  GOVD_SEEN))
remove = true;
in gimplify.c is not what we want, if it is has GOMP_MAP_KIND_ALWAYS,
then we shouldn't remove it even when it is not mentioned inside of the
region's body, because it then has side-effects.

Jakub


RFA: FT32: Fix building gcc.

2015-06-23 Thread Nicholas Clifton

Hi Guys,

  It seems that the FT32 port of GCC does not have a maintainer at the
  moment.  Nevertheless I have a patch to fix a couple of build time
  problems compiling gcc for the FT32.  Is this OK to apply ?

Cheers
  Nick

gcc/ChangeLog
2015-06-23  Nick Clifton  ni...@redhat.com

* config/ft32/ft32.c: Include emit-rtl.h for the definition of
crtl.
(ft32_print_operand): Cast the result of INTVAL in order to make
sure that the correct value is printed.
* config/ft32/ft32.h (STACK_GROWS_DOWNWARD): Define to an
integer.

Index: gcc/config/ft32/ft32.c
===
--- gcc/config/ft32/ft32.c  (revision 224834)
+++ gcc/config/ft32/ft32.c  (working copy)
@@ -59,8 +59,8 @@
 #include basic-block.h
 #include df.h
 #include builtins.h
+#include emit-rtl.h

-
 #include stdint.h

 #define LOSE_AND_RETURN(msgid, x)   \
@@ -199,7 +199,7 @@
   return;

 case 'm':
-  fprintf (file, %d, -INTVAL(x));
+  fprintf (file, %ld, (long) (- INTVAL(x)));
   return;

 case 'd':   // a DW spec, from an integer 
alignment (for BLKmode insns)

Index: gcc/config/ft32/ft32.h
===
--- gcc/config/ft32/ft32.h  (revision 224834)
+++ gcc/config/ft32/ft32.h  (working copy)
@@ -248,7 +248,7 @@

 /* Define this macro if pushing a word onto the stack moves the stack
pointer to a smaller address.  */
-#define STACK_GROWS_DOWNWARD
+#define STACK_GROWS_DOWNWARD 1

 #define INITIAL_FRAME_POINTER_OFFSET(DEPTH) (DEPTH) = 0



Re: [C++ Patch] PR 65811

2015-06-23 Thread Jason Merrill

OK.

Jason


Re: [PATCH][ARM] PR/65711: Don't pass '-dynamic-linker' when '-shared' is used

2015-06-23 Thread Richard Biener
On Mon, May 18, 2015 at 9:09 PM, Ludovic Courtès l...@gnu.org wrote:
 Ramana Radhakrishnan ramana@googlemail.com skribis:

 On Thu, Apr 23, 2015 at 9:29 AM, Ludovic Courtès l...@gnu.org wrote:
 As discussed at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65711.

 Patch is for both 4.8 and 4.9 (possibly 5.1 too, I haven’t checked.)


 OK for trunk. This is also ok for all release branches if no
 objections in 24 hours.

 OK, thank you.

 I haven’t applied for write-after-approval so perhaps you should commit
 it yourself?

So you just committed to the already closed 4.8 branch.  Please always
check gcc.gnu.org/ for branch status.

Richard.

 Ludo’.


Re: [PATCH] Check dominator info in compute_dominance_frontiers

2015-06-23 Thread Richard Biener
On Mon, Jun 22, 2015 at 7:10 PM, Tom de Vries tom_devr...@mentor.com wrote:
 On 22/06/15 13:47, Richard Biener wrote:

 (eventually also for the case where we
 end up only computing the fast-query stuff).


 Like this?
 ...
 diff --git a/gcc/dominance.c b/gcc/dominance.c
 index 9c66ca2..58fc6fd 100644
 --- a/gcc/dominance.c
 +++ b/gcc/dominance.c
 @@ -679,6 +679,12 @@ calculate_dominance_info (enum cdi_direction dir)
free_dom_info (di);
dom_computed[dir_index] = DOM_NO_FAST_QUERY;
  }
 +  else
 +{
 +#if ENABLE_CHECKING
 +  verify_dominators (CDI_DOMINATORS);
 +#endif
 +}

compute_dom_fast_query (dir);

Yeah.

Richard.

 ...

 Thanks,
 - Tom


Re: [PATCH][ARM] PR/65711: Don't pass '-dynamic-linker' when '-shared' is used

2015-06-23 Thread Jakub Jelinek
On Tue, Jun 23, 2015 at 11:30:25AM +0200, Ludovic Courtès wrote:
 Ramana Radhakrishnan ramana@googlemail.com skribis:
 
  On Thu, Apr 23, 2015 at 9:29 AM, Ludovic Courtès l...@gnu.org wrote:
  As discussed at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65711.
 
  Patch is for both 4.8 and 4.9 (possibly 5.1 too, I haven’t checked.)
 
 
  OK for trunk. This is also ok for all release branches if no
  objections in 24 hours.
 
 [...]
 
  gcc/
  2015-04-23  Ludovic Courtès  l...@gnu.org
 
  PR 65711
  * config/arm/linux-elf.h (LINUX_TARGET_LINK_SPEC): Move
  '-dynamic-linker' within %{!shared: ...}.
 
 Committed to gcc-4_8-branch, gcc-4_9-branch, gcc-5-branch, and trunk.
 Please let me know if there’s anything I missed.

See richi's mail.  4.8 branch has already been closed, and 4.9 branch
is frozen, so you should have asked for RM permission.
Also, in the ChangeLog entries, one should write it in the form
PR component/bugno,
so
PR target/65711
in your case.

Jakub


Re: [Ping, Patch, fortran, 64674, v3] [OOP] ICE in ASSOCIATE with class array

2015-06-23 Thread Andre Vehreschild
Hi Paul,

thanks for the review. Submitted as r224827.

Regards,
Andre
-- 
Andre Vehreschild * Email: vehre ad gmx dot de 
Index: gcc/testsuite/gfortran.dg/associate_18.f08
===
--- gcc/testsuite/gfortran.dg/associate_18.f08	(Revision 0)
+++ gcc/testsuite/gfortran.dg/associate_18.f08	(Revision 224827)
@@ -0,0 +1,80 @@
+! { dg-do run }
+!
+! Contributed by Antony Lewis  ant...@cosmologist.info
+!Andre Vehreschild  ve...@gcc.gnu.org
+! Check that associating array-sections/scalars is working
+! with class arrays.
+!
+
+program associate_18
+  Type T
+integer :: map = 1
+  end Type T
+
+  class(T), allocatable :: av(:)
+  class(T), allocatable :: am(:,:)
+  class(T), pointer :: pv(:)
+  class(T), pointer :: pm(:,:)
+
+  integer :: iv(5) = 17
+  integer :: im(4,5) = 23
+  integer :: expect(20) = 23
+  integer :: c
+
+  allocate(av(2))
+  associate(i = av(1))
+i%map = 2
+  end associate
+  if (any (av%map /= [2,1])) call abort()
+  deallocate(av)
+
+  allocate(am(3,4))
+  associate(pam = am(2:3, 2:3))
+pam%map = 7
+pam(1,2)%map = 8
+  end associate
+  if (any (reshape(am%map, [12]) /= [1,1,1, 1,7,7, 1,8,7, 1,1,1])) call abort()
+  deallocate(am)
+
+  allocate(pv(2))
+  associate(i = pv(1))
+i%map = 2
+  end associate
+  if (any (pv%map /= [2,1])) call abort()
+  deallocate(pv)
+
+  allocate(pm(3,4))
+  associate(ppm = pm(2:3, 2:3))
+ppm%map = 7
+ppm(1,2)%map = 8
+  end associate
+  if (any (reshape(pm%map, [12]) /= [1,1,1, 1,7,7, 1,8,7, 1,1,1])) call abort()
+  deallocate(pm)
+
+  associate(i = iv(1))
+i = 7
+  end associate
+  if (any (iv /= [7, 17, 17, 17, 17])) call abort()
+
+  associate(pam = im(2:3, 2:3))
+pam = 9
+pam(1,2) = 10
+do c = 1, 2
+pam(2, c) = 0
+end do
+  end associate
+  if (any (reshape(im, [20]) /= [23,23,23,23, 23,9,0,23, 
+23,10,0,23, 23,23,23,23, 23,23,23,23])) call abort()
+
+  expect(2:3) = 9
+  do c = 1, 5
+im = 23
+associate(pam = im(:, c))
+  pam(2:3) = 9
+end associate
+if (any (reshape(im, [20]) /= expect)) call abort()
+! Shift expect
+expect = [expect(17:), expect(:16)]
+  end do
+end program
+
Index: gcc/testsuite/ChangeLog
===
--- gcc/testsuite/ChangeLog	(Revision 224826)
+++ gcc/testsuite/ChangeLog	(Arbeitskopie)
@@ -1,3 +1,8 @@
+2015-06-23  Andre Vehreschild  ve...@gmx.de
+
+	PR fortran/64674
+	* gfortran.dg/associate_18.f08: New test.
+
 2015-06-23  Uros Bizjak  ubiz...@gmail.com
 
 	PR target/66560
Index: gcc/fortran/parse.c
===
--- gcc/fortran/parse.c	(Revision 224826)
+++ gcc/fortran/parse.c	(Arbeitskopie)
@@ -3958,6 +3958,8 @@
   for (a = new_st.ext.block.assoc; a; a = a-next)
 {
   gfc_symbol* sym;
+  gfc_ref *ref;
+  gfc_array_ref *array_ref;
 
   if (gfc_get_sym_tree (a-name, NULL, a-st, false))
 	gcc_unreachable ();
@@ -3974,6 +3976,84 @@
 	 for parsing component references on the associate-name
 	 in case of association to a derived-type.  */
   sym-ts = a-target-ts;
+
+  /* Check if the target expression is array valued.  This can not always
+	 be done by looking at target.rank, because that might not have been
+	 set yet.  Therefore traverse the chain of refs, looking for the last
+	 array ref and evaluate that.  */
+  array_ref = NULL;
+  for (ref = a-target-ref; ref; ref = ref-next)
+	if (ref-type == REF_ARRAY)
+	  array_ref = ref-u.ar;
+  if (array_ref || a-target-rank)
+	{
+	  gfc_array_spec *as;
+	  int dim, rank = 0;
+	  if (array_ref)
+	{
+	  /* Count the dimension, that have a non-scalar extend.  */
+	  for (dim = 0; dim  array_ref-dimen; ++dim)
+		if (array_ref-dimen_type[dim] != DIMEN_ELEMENT
+		 !(array_ref-dimen_type[dim] == DIMEN_UNKNOWN
+			  array_ref-end[dim] == NULL
+			  array_ref-start[dim] != NULL))
+		  ++rank;
+	}
+	  else
+	rank = a-target-rank;
+	  /* When the rank is greater than zero then sym will be an array.  */
+	  if (sym-ts.type == BT_CLASS)
+	{
+	  if ((!CLASS_DATA (sym)-as  rank != 0)
+		  || (CLASS_DATA (sym)-as
+		   CLASS_DATA (sym)-as-rank != rank))
+		{
+		  /* Don't just (re-)set the attr and as in the sym.ts,
+		 because this modifies the target's attr and as.  Copy the
+		 data and do a build_class_symbol.  */
+		  symbol_attribute attr = CLASS_DATA (a-target)-attr;
+		  int corank = gfc_get_corank (a-target);
+		  gfc_typespec type;
+
+		  if (rank || corank)
+		{
+		  as = gfc_get_array_spec ();
+		  as-type = AS_DEFERRED;
+		  as-rank = rank;
+		  as-corank = corank;
+		  attr.dimension = rank ? 1 : 0;
+		  attr.codimension = corank ? 1 : 0;
+		}
+		  else
+		{
+		  as = NULL;
+		  attr.dimension = attr.codimension = 0;
+		}
+		  attr.class_ok = 0;
+		  type = CLASS_DATA (sym)-ts;
+		  if 

Re: [PATCH][ARM] PR/65711: Don't pass '-dynamic-linker' when '-shared' is used

2015-06-23 Thread Ludovic Courtès
Ramana Radhakrishnan ramana@googlemail.com skribis:

 On Thu, Apr 23, 2015 at 9:29 AM, Ludovic Courtès l...@gnu.org wrote:
 As discussed at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65711.

 Patch is for both 4.8 and 4.9 (possibly 5.1 too, I haven’t checked.)


 OK for trunk. This is also ok for all release branches if no
 objections in 24 hours.

[...]

 gcc/
 2015-04-23  Ludovic Courtès  l...@gnu.org

 PR 65711
 * config/arm/linux-elf.h (LINUX_TARGET_LINK_SPEC): Move
 '-dynamic-linker' within %{!shared: ...}.

Committed to gcc-4_8-branch, gcc-4_9-branch, gcc-5-branch, and trunk.
Please let me know if there’s anything I missed.

Thanks,
Ludo’.


Re: [i386, PATCH, 3/3] IA MCU psABI support: testsuite.

2015-06-23 Thread Kirill Yukhin
Hello,
This patch introduces tests for new psABI.

gcc/testsuite/
* gcc.target/i386/iamcu/abi-iamcu.exp: New file.
* gcc.target/i386/iamcu/args.h: Likewise.
* gcc.target/i386/iamcu/asm-support.S: Likewise.
* gcc.target/i386/iamcu/defines.h: Likewise.
* gcc.target/i386/iamcu/macros.h: Likewise.
* gcc.target/i386/iamcu/test_3_element_struct_and_unions.c: Likewise.
* gcc.target/i386/iamcu/test_basic_64bit_returning.c: Likewise.
* gcc.target/i386/iamcu/test_basic_alignment.c: Likewise.
* gcc.target/i386/iamcu/test_basic_array_size_and_align.c: Likewise.
* gcc.target/i386/iamcu/test_basic_returning.c: Likewise.
* gcc.target/i386/iamcu/test_basic_sizes.c: Likewise.
* gcc.target/i386/iamcu/test_basic_struct_size_and_align.c: Likewise.
* gcc.target/i386/iamcu/test_basic_union_size_and_align.c: Likewise.
* gcc.target/i386/iamcu/test_bitfields.c: Likewise.
* gcc.target/i386/iamcu/test_complex_returning.c: Likewise.
* gcc.target/i386/iamcu/test_passing_floats.c: Likewise.
* gcc.target/i386/iamcu/test_passing_integers.c: Likewise.
* gcc.target/i386/iamcu/test_passing_structs.c: Likewise.
* gcc.target/i386/iamcu/test_passing_structs_and_unions.c: Likewise.
* gcc.target/i386/iamcu/test_passing_unions.c: Likewise.
* gcc.target/i386/iamcu/test_struct_returning.c: Likewise.
* gcc.target/i386/iamcu/test_varargs.c: Likewise.

New tests pass, when run on for 32b target.
Is it ok for trunk?

--
Thanks, K

diff --git a/gcc/testsuite/gcc.target/i386/iamcu/abi-iamcu.exp 
b/gcc/testsuite/gcc.target/i386/iamcu/abi-iamcu.exp
new file mode 100644
index 000..b5b3261
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/iamcu/abi-iamcu.exp
@@ -0,0 +1,42 @@
+# Copyright (C) 2015 Free Software Foundation, Inc.
+
+# This program 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 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# http://www.gnu.org/licenses/.
+
+# The Intel MCU psABI testsuite needs one additional assembler file for
+# most testcases.  For simplicity we will just link it into each test.
+
+load_lib c-torture.exp
+load_lib target-supports.exp
+load_lib torture-options.exp
+
+if { (![istarget x86_64-*-linux*]  ![istarget i?86-*-linux*])
+ || ![is-effective-target ia32] } then {
+  return
+}
+
+
+torture-init
+set-torture-options $C_TORTURE_OPTIONS
+set additional_flags -miamcu -W -Wall -Wno-abi
+
+foreach src [lsort [glob -nocomplain $srcdir/$subdir/test_*.c]] {
+if {[runtest_file_p $runtests $src]} {
+   c-torture-execute [list $src \
+   $srcdir/$subdir/asm-support.S] \
+   $additional_flags
+}
+}
+
+torture-finish
diff --git a/gcc/testsuite/gcc.target/i386/iamcu/args.h 
b/gcc/testsuite/gcc.target/i386/iamcu/args.h
new file mode 100644
index 000..f8abde4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/iamcu/args.h
@@ -0,0 +1,77 @@
+#ifndef INCLUDED_ARGS_H
+#define INCLUDED_ARGS_H
+
+/* This defines the calling sequences for integers and floats.  */
+#define I0 eax
+#define I1 edx
+#define I2 ecx
+
+typedef unsigned int size_t;
+
+extern void (*callthis)(void);
+extern unsigned long eax,ebx,ecx,edx,esi,edi,esp,ebp;
+extern unsigned long sret_eax;
+extern volatile unsigned long volatile_var;
+extern void snapshot (void);
+extern void snapshot_ret (void);
+extern void *iamcu_memset (void *, int, size_t);
+#define WRAP_CALL(N) \
+  (callthis = (void (*)()) (N), (typeof (N)) snapshot)
+#define WRAP_RET(N) \
+  (callthis = (void (*)()) (N), (typeof (N)) snapshot_ret)
+
+/* Clear all scratch integer registers.  */
+#define clear_int_hardware_registers \
+  asm __volatile__ (xor %%eax, %%eax\n\t \
+   xor %%edx, %%edx\n\t \
+   xor %%ecx, %%ecx\n\t \
+   ::: eax, edx, ecx);
+
+/* Clear all scratch integer registers, excluding the one used to return
+   aggregate.  */
+#define clear_non_sret_int_hardware_registers \
+  asm __volatile__ (xor %%edx, %%ebx\n\t \
+   xor %%ecx, %%ecx\n\t \
+   ::: edx, ecx);
+
+/* This is the list of registers available for passing arguments. Not all of
+   these are used or even really available.  */
+struct IntegerRegisters
+{
+  unsigned long eax, ebx, ecx, edx, esi, edi;
+};
+
+/* Implemented in scalarargs.c  */
+extern struct IntegerRegisters iregs, iregbits;
+extern 

  1   2   >