Re: Calculate TYPE_CANONICAL only for types that can be accessed in memory

2015-05-24 Thread H.J. Lu
On Fri, May 22, 2015 at 5:00 AM, Jan Hubicka hubi...@ucw.cz wrote:
 Now we have it spelled out 4 times ... makes sense to create a new
 macro for it?  (though I cannot think of a good name...
 UNACCESSIBLE_TYPE_P ()?)

 Yep, actually I already made that version of patch yesterday but then got
 hooked by beers.  This is better version (also with more sensible comments).
 I will commit it at afternoon if you have no further comments.


 * lto.c (hash_canonical_type): Be sure we hash only types that
 need alias set.
 (gimple_register_canonical_type_1): Do not produce canonical
 types for types that do not need alias sets.
 * tree.c (gimple_canonical_types_compatible_p): Sanity check that
 we do not try to compute canonical type for type that does not need
 alias set.
 (verify_type): Drop FIXME for METHOD_TYPE, update FIXME for
 FUNCITON_TYPE.
 * tree.h (type_with_alias_set_p): New.

This caused:

https://gcc.gnu.org/ml/gcc-cvs/2015-05/msg00948.html

H.J.


Re: Move ABS detection from fold-const.c to match.pd

2015-05-24 Thread Marc Glisse


I forgot to mention I optimistically tried to write something like this:

(match
 (negated_value_for_comparison @0)
 (negate @0))
(match
 (negated_value_for_comparison (negate @0))
 @0)
(match
 (negated_value_for_comparison (minus @0 @1))
 (if (!HONOR_SIGN_DEPENDENT_ROUNDING (type))
  (minus @1 @0))

without success. There is already a comment for logical_inverted_value 
about related limitations in genmatch.


--
Marc Glisse


Re: [RFC / CFT] PR c++/66192 - Remove TARGET_RELAXED_ORDERING and use load acquires.

2015-05-24 Thread Uros Bizjak
Hello!

 This patch removes the special casing for targets with relaxed memory 
 ordering and handles
 guard accesses with equivalent atomic load acquire operations. In this 
 process we change the
 algorithm to load the guard variable with an atomic load that has ACQUIRE 
 semantics. I'm not
 terribly familiar with the C++ front-end so I'm not sure I've used the 
 appropriate interfaces for
 doing something like this.

 This then means that on targets which have weak memory models, the fast path 
 is inlined and can
 directly use a load-acquire instruction where available (and yay! one more 
 hook gone).

 Currently bootstrapping and regression testing on AArch64 and ARM (prior to 
 the commit that
 caused PR66241). If this goes in then I'm happy to withdraw part of the 
 patches to trunk for
 AArch64 / ARM that defines TARGET_RELAXED_ORDERING and only propose those 
 hunks to
 the branches.

 I'd also request the other target maintainers CC'd to help by testing this on 
 their platforms as I
 do not have access to all of them.

The patch works OK on alphaev68-linux-gnu [1].

[1] https://gcc.gnu.org/ml/gcc-testresults/2015-05/msg03008.html

Uros.


Re: Calculate TYPE_CANONICAL only for types that can be accessed in memory

2015-05-24 Thread H.J. Lu
On Sun, May 24, 2015 at 5:49 AM, H.J. Lu hjl.to...@gmail.com wrote:
 On Fri, May 22, 2015 at 5:00 AM, Jan Hubicka hubi...@ucw.cz wrote:
 Now we have it spelled out 4 times ... makes sense to create a new
 macro for it?  (though I cannot think of a good name...
 UNACCESSIBLE_TYPE_P ()?)

 Yep, actually I already made that version of patch yesterday but then got
 hooked by beers.  This is better version (also with more sensible comments).
 I will commit it at afternoon if you have no further comments.


 * lto.c (hash_canonical_type): Be sure we hash only types that
 need alias set.
 (gimple_register_canonical_type_1): Do not produce canonical
 types for types that do not need alias sets.
 * tree.c (gimple_canonical_types_compatible_p): Sanity check that
 we do not try to compute canonical type for type that does not need
 alias set.
 (verify_type): Drop FIXME for METHOD_TYPE, update FIXME for
 FUNCITON_TYPE.
 * tree.h (type_with_alias_set_p): New.

 This caused:

 https://gcc.gnu.org/ml/gcc-cvs/2015-05/msg00948.html

I meant:

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


-- 
H.J.


Re: [Patch, fortran] PR66257 [5/6 regression] elemental typebound calls rejected as actual argument

2015-05-24 Thread Paul Richard Thomas
Hi Mikael,

Yes, that's fine for 5 and 6.

Thanks for the patch.

Paul


On 23 May 2015 at 23:35, Mikael Morin mikael.mo...@sfr.fr wrote:
 Hello,

 For PR 63727, a check was introduced, rejecting procedure pointer
 components used as actual arguments:
 foo(obj%proc_comp)
 but it had the side effect of also rejecting
 foo(obj%proc_comp(arg))

 Fixed by the attached patch.
 Tested on x86_64-linux. OK for 6/5 ?

 Mikael






-- 
Outside of a dog, a book is a man's best friend. Inside of a dog it's
too dark to read.

Groucho Marx


Simplify -x0 to x0

2015-05-24 Thread Marc Glisse

Hello,

I noticed we were only doing this transformation for floats and not for 
integers, so I took the chance to move it to match.pd. Regtested on 
ppc64le-redhat-linux.


2015-05-25  Marc Glisse  marc.gli...@inria.fr

* match.pd (swapped_tcc_comparison): New operator list.
(-A CMP -B): New simplification.
* fold-const.c (fold_comparison): Remove corresponding code.

--
Marc GlisseIndex: gcc/fold-const.c
===
--- gcc/fold-const.c(revision 223630)
+++ gcc/fold-const.c(working copy)
@@ -9176,38 +9176,25 @@ fold_comparison (location_t loc, enum tr
 
   if (TYPE_PRECISION (TREE_TYPE (targ1))  TYPE_PRECISION (newtype))
newtype = TREE_TYPE (targ1);
 
   /* Fold (double)float1 CMP (double)float2 into float1 CMP float2.  */
   if (TYPE_PRECISION (newtype)  TYPE_PRECISION (TREE_TYPE (arg0)))
return fold_build2_loc (loc, code, type,
fold_convert_loc (loc, newtype, targ0),
fold_convert_loc (loc, newtype, targ1));
 
-  /* (-a) CMP (-b) - b CMP a  */
-  if (TREE_CODE (arg0) == NEGATE_EXPR
-  TREE_CODE (arg1) == NEGATE_EXPR)
-   return fold_build2_loc (loc, code, type, TREE_OPERAND (arg1, 0),
-   TREE_OPERAND (arg0, 0));
-
   if (TREE_CODE (arg1) == REAL_CST)
{
  REAL_VALUE_TYPE cst;
  cst = TREE_REAL_CST (arg1);
 
- /* (-a) CMP CST - a swap(CMP) (-CST)  */
- if (TREE_CODE (arg0) == NEGATE_EXPR)
-   return fold_build2_loc (loc, swap_tree_comparison (code), type,
-   TREE_OPERAND (arg0, 0),
-   build_real (TREE_TYPE (arg1),
-   real_value_negate (cst)));
-
  /* IEEE doesn't distinguish +0 and -0 in comparisons.  */
  /* a CMP (-0) - a CMP 0  */
  if (REAL_VALUE_MINUS_ZERO (cst))
return fold_build2_loc (loc, code, type, arg0,
build_real (TREE_TYPE (arg1), dconst0));
 
  /* x != NaN is always true, other ops are always false.  */
  if (REAL_VALUE_ISNAN (cst)
   ! HONOR_SNANS (arg1))
{
Index: gcc/match.pd
===
--- gcc/match.pd(revision 223630)
+++ gcc/match.pd(working copy)
@@ -31,20 +31,22 @@ along with GCC; see the file COPYING3.
CONSTANT_CLASS_P
tree_expr_nonnegative_p)
 
 /* Operator lists.  */
 (define_operator_list tcc_comparison
   lt   le   eq ne ge   gt   unordered ordered   unlt unle ungt unge uneq ltgt)
 (define_operator_list inverted_tcc_comparison
   ge   gt   ne eq lt   le   ordered   unordered ge   gt   le   lt   ltgt uneq)
 (define_operator_list inverted_tcc_comparison_with_nans
   unge ungt ne eq unlt unle ordered   unordered ge   gt   le   lt   ltgt uneq)
+(define_operator_list swapped_tcc_comparison
+  gt   ge   eq ne le   lt   unordered ordered   ungt unge unlt unle uneq ltgt)
 
 
 /* Simplifications of operations with one constant operand and
simplifications to constants or single values.  */
 
 (for op (plus pointer_plus minus bit_ior bit_xor)
   (simplify
 (op @0 integer_zerop)
 (non_lvalue @0)))
 
@@ -973,20 +975,38 @@ along with GCC; see the file COPYING3.
  (bit_and (ordered @0 @0) (ordered @1 @1))
  (if (types_match (@0, @1))
   (ordered @0 @1)))
 (simplify
  (bit_ior:c (unordered @0 @0) (unordered:c@2 @0 @1))
  @2)
 (simplify
  (bit_and:c (ordered @0 @0) (ordered:c@2 @0 @1))
  @2)
 
+/* -A CMP -B - B CMP A.  */
+(for cmp (tcc_comparison)
+ scmp (swapped_tcc_comparison)
+ (simplify
+  (cmp (negate @0) (negate @1))
+  (if (FLOAT_TYPE_P (TREE_TYPE (@0))
+   || (ANY_INTEGRAL_TYPE_P (TREE_TYPE (@0))
+   TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0
+   (scmp @0 @1)))
+ (simplify
+  (cmp (negate @0) CONSTANT_CLASS_P@1)
+  (if (FLOAT_TYPE_P (TREE_TYPE (@0))
+   || (ANY_INTEGRAL_TYPE_P (TREE_TYPE (@0))
+   TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0
+   (with { tree tem = fold_unary (NEGATE_EXPR, TREE_TYPE (@0), @1); }
+(if (tem  !TREE_OVERFLOW (tem))
+ (scmp @0 { tem; }))
+
 /* Simplification of math builtins.  */
 
 (define_operator_list LOG BUILT_IN_LOGF BUILT_IN_LOG BUILT_IN_LOGL)
 (define_operator_list EXP BUILT_IN_EXPF BUILT_IN_EXP BUILT_IN_EXPL)
 (define_operator_list LOG2 BUILT_IN_LOG2F BUILT_IN_LOG2 BUILT_IN_LOG2L)
 (define_operator_list EXP2 BUILT_IN_EXP2F BUILT_IN_EXP2 BUILT_IN_EXP2L)
 (define_operator_list LOG10 BUILT_IN_LOG10F BUILT_IN_LOG10 BUILT_IN_LOG10L)
 (define_operator_list EXP10 BUILT_IN_EXP10F BUILT_IN_EXP10 BUILT_IN_EXP10L)
 (define_operator_list POW BUILT_IN_POWF BUILT_IN_POW BUILT_IN_POWL)
 (define_operator_list POW10 BUILT_IN_POW10F BUILT_IN_POW10 BUILT_IN_POW10L)


Move ABS detection from fold-const.c to match.pd

2015-05-24 Thread Marc Glisse

Hello,

I don't think this pattern is done in the branch. Here I am trying to 
match what is done in fold-const, but the idea is that we can later add an 
extra block where we replace (cmp (minus @2 @3) zerop) with (cmp @2 @3), 
maybe with some adjustments (convert? all over the place), to help with 
PR 64450 / PR 61734.


I didn't exactly match the code in fold-const.c, among other things 
because I didn't feel like calling operand_equal_for_comparison_p, and 
strip_nops can translate to quite heavy patterns. Except for a few 
irrelevant cases (where I simplify more), this seems to generate the same 
.original dumps in the cases I tried. But I am not claiming this is the 
best way to arrange that code, better ideas are welcome.


I don't understand the old code handling unsigned, but I couldn't find a 
case where the new code (doing nothing special for unsigned) generated a 
different .original dump. The last pattern had a strange mix of requiring 
integer_zerop and talking about signed zero and NaN, I didn't try to 
preserve that. The change to genmatch is for zerop, which doesn't try to 
valueize anything.


I had a few issues with the machinery. First, genmatch was generating 
a switch with duplicate cases (miraculously, replacing 'cond' with an 
iteration on 'cnd' worked around it). Second, (plus @0 (negate@0 @1)) is 
treated as (plus @0 @0), the pattern on the second occurence of the 
capture is silently ignored.


Regtested on ppc64le-redhat-linux.

2015-05-25  Marc Glisse  marc.gli...@inria.fr

* genmatch.c (write_predicate): Add ATTRIBUTE_UNUSED.
* match.pd (A op 0 ? A : -A, A op 0 ? A : 0): New simplifications.
* fold-const.c (fold_cond_expr_with_comparison): Remove
corresponding code.

--
Marc GlisseIndex: gcc/fold-const.c
===
--- gcc/fold-const.c(revision 223630)
+++ gcc/fold-const.c(working copy)
@@ -4875,112 +4875,25 @@ merge_ranges (int *pin_p, tree *plow, tr
Return a folded expression whose code is not a COND_EXPR
anymore, or NULL_TREE if no folding opportunity is found.  */
 
 static tree
 fold_cond_expr_with_comparison (location_t loc, tree type,
tree arg0, tree arg1, tree arg2)
 {
   enum tree_code comp_code = TREE_CODE (arg0);
   tree arg00 = TREE_OPERAND (arg0, 0);
   tree arg01 = TREE_OPERAND (arg0, 1);
-  tree arg1_type = TREE_TYPE (arg1);
   tree tem;
 
   STRIP_NOPS (arg1);
   STRIP_NOPS (arg2);
 
-  /* If we have A op 0 ? A : -A, consider applying the following
- transformations:
-
- A == 0? A : -Asame as -A
- A != 0? A : -Asame as A
- A = 0? A : -Asame as abs (A)
- A  0?  A : -Asame as abs (A)
- A = 0? A : -Asame as -abs (A)
- A  0?  A : -Asame as -abs (A)
-
- None of these transformations work for modes with signed
- zeros.  If A is +/-0, the first two transformations will
- change the sign of the result (from +0 to -0, or vice
- versa).  The last four will fix the sign of the result,
- even though the original expressions could be positive or
- negative, depending on the sign of A.
-
- Note that all these transformations are correct if A is
- NaN, since the two alternatives (A and -A) are also NaNs.  */
-  if (!HONOR_SIGNED_ZEROS (element_mode (type))
-   (FLOAT_TYPE_P (TREE_TYPE (arg01))
- ? real_zerop (arg01)
- : integer_zerop (arg01))
-   ((TREE_CODE (arg2) == NEGATE_EXPR
-   operand_equal_p (TREE_OPERAND (arg2, 0), arg1, 0))
-/* In the case that A is of the form X-Y, '-A' (arg2) may
-   have already been folded to Y-X, check for that. */
- || (TREE_CODE (arg1) == MINUS_EXPR
-  TREE_CODE (arg2) == MINUS_EXPR
-  operand_equal_p (TREE_OPERAND (arg1, 0),
- TREE_OPERAND (arg2, 1), 0)
-  operand_equal_p (TREE_OPERAND (arg1, 1),
- TREE_OPERAND (arg2, 0), 0
-switch (comp_code)
-  {
-  case EQ_EXPR:
-  case UNEQ_EXPR:
-   tem = fold_convert_loc (loc, arg1_type, arg1);
-   return pedantic_non_lvalue_loc (loc,
-   fold_convert_loc (loc, type,
- negate_expr (tem)));
-  case NE_EXPR:
-  case LTGT_EXPR:
-   return pedantic_non_lvalue_loc (loc, fold_convert_loc (loc, type, 
arg1));
-  case UNGE_EXPR:
-  case UNGT_EXPR:
-   if (flag_trapping_math)
- break;
-   /* Fall through.  */
-  case GE_EXPR:
-  case GT_EXPR:
-   if (TYPE_UNSIGNED (TREE_TYPE (arg1)))
- arg1 = fold_convert_loc (loc, signed_type_for
-  (TREE_TYPE (arg1)), arg1);
-   tem = fold_build1_loc (loc, ABS_EXPR, TREE_TYPE (arg1), arg1);
-   return pedantic_non_lvalue_loc (loc, fold_convert_loc (loc, type, tem));
-  case UNLE_EXPR:
-  case 

[PATCH v3 2/4] libcc1: set debug compile: Display GCC driver filename

2015-05-24 Thread Jan Kratochvil
Hi,

GDB currently searches for /usr/bin/ARCH-OS-gcc and chooses one but it does not
display which one.  It cannot, GCC method set_arguments() does not yet know
whether 'set debug compile' is enabled or not.


Jan


include/ChangeLog
2015-05-24  Jan Kratochvil  jan.kratoch...@redhat.com

* gcc-interface.h (enum gcc_base_api_version): Add comment to
GCC_FE_VERSION_1.
(struct gcc_base_vtable): Rename compile to compile_v0.  Update comment
for compile.  New methods set_verbose and compile.

libcc1/ChangeLog
2015-05-24  Jan Kratochvil  jan.kratoch...@redhat.com

* libcc1.cc: Include intl.h.
(struct libcc1): Add field verbose.
(libcc1::libcc1): Initialize it.
(libcc1_set_verbose): New function.
(libcc1_set_arguments): Print messages for VERBOSE.
(libcc1_compile): Remove parameter verbose.  Use VERBOSE from SELF.
(libcc1_compile_v0): New function.
(vtable): Use libcc1_compile_v0 and add libcc1_compile and
libcc1_set_verbose.
---
 include/gcc-interface.h |   33 ++---
 libcc1/libcc1.cc|   38 +-
 2 files changed, 59 insertions(+), 12 deletions(-)

diff --git a/include/gcc-interface.h b/include/gcc-interface.h
index dcfa6ce..0b409d0 100644
--- a/include/gcc-interface.h
+++ b/include/gcc-interface.h
@@ -45,6 +45,8 @@ struct gcc_base_context;
 enum gcc_base_api_version
 {
   GCC_FE_VERSION_0 = 0,
+
+  /* Deprecated method compile_v0.  Added method set_verbose and compile.  */
   GCC_FE_VERSION_1 = 1,
 };
 
@@ -94,18 +96,35 @@ struct gcc_base_vtable
  const char *message),
  void *datum);
 
-  /* Perform the compilation.  FILENAME is the name of the resulting
- object file.  VERBOSE can be set to cause GCC to print some
- information as it works.  Returns true on success, false on
- error.  */
+  /* Deprecated GCC_FE_VERSION_0 variant of the GCC_FE_VERSION_1
+ compile method.  GCC_FE_VERSION_0 version verbose parameter has
+ been replaced by the set_verbose method.  */
 
-  int /* bool */ (*compile) (struct gcc_base_context *self,
-const char *filename,
-int /* bool */ verbose);
+  int /* bool */ (*compile_v0) (struct gcc_base_context *self,
+   const char *filename,
+   int /* bool */ verbose);
 
   /* Destroy this object.  */
 
   void (*destroy) (struct gcc_base_context *self);
+
+  /* VERBOSE can be set to non-zero to cause GCC to print some
+ information as it works.  Calling this method overrides its
+ possible previous calls.
+
+ This method is only available since GCC_FE_VERSION_1.  */
+
+  void (*set_verbose) (struct gcc_base_context *self,
+  int /* bool */ verbose);
+
+  /* Perform the compilation.  FILENAME is the name of the resulting
+ object file.  Either set_triplet_regexp or set_driver_filename must
+ be called before.  Returns true on success, false on error. 
+
+ This method is only available since GCC_FE_VERSION_1.  */
+
+  int /* bool */ (*compile) (struct gcc_base_context *self,
+const char *filename);
 };
 
 /* The GCC object.  */
diff --git a/libcc1/libcc1.cc b/libcc1/libcc1.cc
index 99a0fa1..6fda5b9 100644
--- a/libcc1/libcc1.cc
+++ b/libcc1/libcc1.cc
@@ -38,6 +38,7 @@ along with GCC; see the file COPYING3.  If not see
 #include xregex.h
 #include findcomp.hh
 #include compiler-name.h
+#include intl.h
 
 struct libcc1;
 
@@ -66,6 +67,9 @@ struct libcc1 : public gcc_c_context
 
   std::vectorstd::string args;
   std::string source_file;
+
+  /* Non-zero as an equivalent to gcc driver option -v.  */
+  bool verbose;
 };
 
 // A local subclass of connection that holds a back-pointer to the
@@ -97,7 +101,8 @@ libcc1::libcc1 (const gcc_base_vtable *v,
 print_function (NULL),
 print_datum (NULL),
 args (),
-source_file ()
+source_file (),
+verbose (false)
 {
   base.ops = v;
   c_ops = cv;
@@ -306,6 +311,14 @@ make_regexp (const char *triplet_regexp, const char 
*compiler)
   return buf.str ();
 }
 
+static void
+libcc1_set_verbose (struct gcc_base_context *s, int /* bool */ verbose)
+{
+  libcc1 *self = (libcc1 *) s;
+
+  self-verbose = verbose != 0;
+}
+
 static char *
 libcc1_set_arguments (struct gcc_base_context *s,
  const char *triplet_regexp,
@@ -316,6 +329,10 @@ libcc1_set_arguments (struct gcc_base_context *s,
   int code;
 
   std::string rx = make_regexp (triplet_regexp, COMPILER_NAME);
+  // Simulate fnotice by fprintf.
+  if (self-verbose)
+fprintf (stderr, _(searching for compiler matching regex %s\n),
+rx.c_str());
   code = regcomp (triplet, rx.c_str (), REG_EXTENDED | REG_NOSUB);
   if (code != 0)
 {
@@ -341,6 +358,8 @@ libcc1_set_arguments (struct gcc_base_context 

[PATCH v3 1/4] libcc1: Introduce GCC_FE_VERSION_1

2015-05-24 Thread Jan Kratochvil
Hi,

the libcc1 API change formerly approved for GCC was rejected by GDB, therefore
here is a new API + its implementation.


Jan


include/ChangeLog
2015-05-24  Jan Kratochvil  jan.kratoch...@redhat.com

* gcc-interface.h (enum gcc_base_api_version): Add GCC_FE_VERSION_1.

libcc1/ChangeLog
2015-05-24  Jan Kratochvil  jan.kratoch...@redhat.com

* libcc1.cc (vtable): Update to GCC_FE_VERSION_1.
(gcc_c_fe_context): Accept also GCC_FE_VERSION_1.
---
 include/gcc-interface.h |3 ++-
 libcc1/libcc1.cc|5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/gcc-interface.h b/include/gcc-interface.h
index 34010f2..dcfa6ce 100644
--- a/include/gcc-interface.h
+++ b/include/gcc-interface.h
@@ -44,7 +44,8 @@ struct gcc_base_context;
 
 enum gcc_base_api_version
 {
-  GCC_FE_VERSION_0 = 0
+  GCC_FE_VERSION_0 = 0,
+  GCC_FE_VERSION_1 = 1,
 };
 
 /* The operations defined by the GCC base API.  This is the vtable for
diff --git a/libcc1/libcc1.cc b/libcc1/libcc1.cc
index 7d7d2c1..99a0fa1 100644
--- a/libcc1/libcc1.cc
+++ b/libcc1/libcc1.cc
@@ -504,7 +504,7 @@ libcc1_destroy (struct gcc_base_context *s)
 
 static const struct gcc_base_vtable vtable =
 {
-  GCC_FE_VERSION_0,
+  GCC_FE_VERSION_1,
   libcc1_set_arguments,
   libcc1_set_source_file,
   libcc1_set_print_callback,
@@ -523,7 +523,8 @@ struct gcc_c_context *
 gcc_c_fe_context (enum gcc_base_api_version base_version,
  enum gcc_c_api_version c_version)
 {
-  if (base_version != GCC_FE_VERSION_0 || c_version != GCC_C_FE_VERSION_0)
+  if ((base_version != GCC_FE_VERSION_0  base_version != GCC_FE_VERSION_1)
+  || c_version != GCC_C_FE_VERSION_0)
 return NULL;
 
   return new libcc1 (vtable, c_vtable);



[PATCH v3 3/4] libcc1: Add 'set compile-gcc'

2015-05-24 Thread Jan Kratochvil
Hi,

GDB currently searches for /usr/bin/ARCH-OS-gcc and chooses one but one cannot
override which one.  GDB would provide new option 'set compile-gcc'.


Jan


include/ChangeLog
2015-05-24  Jan Kratochvil  jan.kratoch...@redhat.com

* gcc-interface.h (enum gcc_base_api_version): Update comment for
GCC_FE_VERSION_1.
(struct gcc_base_vtable): Rename set_arguments to set_arguments_v0.
Add set_arguments, set_triplet_regexp and set_driver_filename.

libcc1/ChangeLog
2015-05-24  Jan Kratochvil  jan.kratoch...@redhat.com

* libcc1.cc (libcc1): Add class compiler with field compilerp, class
compiler_triplet_regexp and class compiler_driver_filename.
(libcc1::libcc1): Initialize compilerp.
(libcc1::~libcc1): Delete compilerp.
(libcc1::compiler::find, libcc1::compiler_triplet_regexp::find)
(libcc1::compiler_driver_filename::find): New methods.
(libcc1_set_arguments): Remove parameter triplet_regexp.
(libcc1_set_triplet_regexp, libcc1_set_driver_filename)
(libcc1_set_arguments_v0): New functions.
(vtable): Use libcc1_set_arguments_v0, add libcc1_set_arguments,
libcc1_set_triplet_regexp and libcc1_set_driver_filename.
---
 include/gcc-interface.h |   61 -
 libcc1/libcc1.cc|  139 ++-
 2 files changed, 172 insertions(+), 28 deletions(-)

diff --git a/include/gcc-interface.h b/include/gcc-interface.h
index 0b409d0..1c66c3b 100644
--- a/include/gcc-interface.h
+++ b/include/gcc-interface.h
@@ -46,7 +46,9 @@ enum gcc_base_api_version
 {
   GCC_FE_VERSION_0 = 0,
 
-  /* Deprecated method compile_v0.  Added method set_verbose and compile.  */
+  /* Deprecated methods set_arguments_v0 and compile_v0.  Added methods
+ set_arguments, set_triplet_regexp, set_driver_filename, set_verbose and
+ compile.  */
   GCC_FE_VERSION_1 = 1,
 };
 
@@ -67,20 +69,12 @@ struct gcc_base_vtable
 
   unsigned int version;
 
-  /* Set the compiler's command-line options for the next compilation.
- TRIPLET_REGEXP is a regular expression that is used to match the
- configury triplet prefix to the compiler.
- The arguments are copied by GCC.  ARGV need not be
- NULL-terminated.  The arguments must be set separately for each
- compilation; that is, after a compile is requested, the
- previously-set arguments cannot be reused.
-
- This returns NULL on success.  On failure, returns a malloc()d
- error message.  The caller is responsible for freeing it.  */
+  /* Deprecated GCC_FE_VERSION_0 variant of the GCC_FE_VERSION_1
+ methods set_triplet_regexp and set_arguments.  */
 
-  char *(*set_arguments) (struct gcc_base_context *self,
- const char *triplet_regexp,
- int argc, char **argv);
+  char *(*set_arguments_v0) (struct gcc_base_context *self,
+const char *triplet_regexp,
+int argc, char **argv);
 
   /* Set the file name of the program to compile.  The string is
  copied by the method implementation, but the caller must
@@ -125,6 +119,45 @@ struct gcc_base_vtable
 
   int /* bool */ (*compile) (struct gcc_base_context *self,
 const char *filename);
+
+  /* Set the compiler's command-line options for the next compilation.
+ The arguments are copied by GCC.  ARGV need not be
+ NULL-terminated.  The arguments must be set separately for each
+ compilation; that is, after a compile is requested, the
+ previously-set arguments cannot be reused.
+
+ This returns NULL on success.  On failure, returns a malloc()d
+ error message.  The caller is responsible for freeing it.
+
+ This method is only available since GCC_FE_VERSION_1.  */
+
+  char *(*set_arguments) (struct gcc_base_context *self,
+ int argc, char **argv);
+
+  /* Set TRIPLET_REGEXP as a regular expression that is used to match
+ the configury triplet prefix to the compiler.  Calling this method
+ overrides possible previous call of itself or set_driver_filename.
+
+ This returns NULL on success.  On failure, returns a malloc()d
+ error message.  The caller is responsible for freeing it.
+
+ This method is only available since GCC_FE_VERSION_1.  */
+
+  char *(*set_triplet_regexp) (struct gcc_base_context *self,
+  const char *triplet_regexp);
+
+  /* DRIVER_FILENAME should be filename of the gcc compiler driver
+ program.  It will be searched in PATH components like
+ TRIPLET_REGEXP.  Calling this method overrides possible previous
+ call of itself or set_triplet_regexp.
+
+ This returns NULL on success.  On failure, returns a malloc()d
+ error message.  The caller is responsible for freeing it.
+
+ This method is only available since GCC_FE_VERSION_1.  */
+
+  char *(*set_driver_filename) (struct 

Re: [Patch, fortran] PR66079 - [6 Regression] memory leak with source allocation in internal subprogram

2015-05-24 Thread Andre Vehreschild
Hi Paul,

thanks for the answers. I did not want to be nasty, but was just wondering, if
I only I had those problems. Given furthermore, that reviews are sparse lately,
I thought it might help, when a glitch was removed before a reviewer put his
head into it :-)

I am curious though, why we loose memory with the second point I mentioned. Do
you have an easy example for that?

Regards,
Andre

PS: No hurry needed. I just started with investigation about what is needed for
submodules and am already encountering first questions marks with the example
in the F2008 standard (section C.8 I think). Just to let you know.

On Sat, 23 May 2015 21:40:08 +0200
Paul Richard Thomas paul.richard.tho...@gmail.com wrote:

 Dear Andre,
 
 To answer your fist question - no, it doesn't. I was working with my
 laptop, which is over slow when it comes to
 updating. I should have realised that since you are working in this
 area that there might be a problem. I discovered it when I did an
 update on my workstation this afternoon. Of course the fixes are
 trivial.
 
 As to your second question about the chunk that avoids creating an
 expr3. Yes, I am aware of the consequences. I am perfectly happy to
 insert a TODO that saying that we should effect all the good things
 that happen when the standard assignment is used in another block of
 code. Alternatively, we could make a temporary variable to which the
 expr3 is assigned that is used latter in the assignment to the
 allocated variables.  For the moment though, repeating evaluation of
 expressions seems like a small price to pay for avoiding memory
 leakage.
 
 Cheers
 
 Paul
 
 
 
 On 23 May 2015 at 19:52, Andre Vehreschild ve...@gmx.de wrote:
  Hi Paul,
 
  does this patch apply to current trunk cleanly? I get an issue with the last
  hunk, because all of the prerequisites are gone since r223445. The string
  copy is completely handled by the trans_assignment at the bottom of the if
  (code-expr3) block. Therefore I doubt the patches last hunk is needed any
  longer.
 
  Do you have an example why this hunk is needed?
 
  Index: gcc/fortran/trans-stmt.c
  ===
  *** gcc/fortran/trans-stmt.c(revision 223233)
  --- gcc/fortran/trans-stmt.c(working copy)
  *** gfc_trans_allocate (gfc_code * code)
  *** 5200,5206 
  }
/* else expr3 = NULL_TREE set above.  */
  }
  ! else
  {
/* In all other cases evaluate the expr3 and create a
   temporary.  */
  --- 5200,5207 
  }
/* else expr3 = NULL_TREE set above.  */
  }
  ! else if (!(code-expr3-ts.type == BT_DERIVED
  ! code-expr3-ts.u.derived-attr.alloc_comp))
  {
/* In all other cases evaluate the expr3 and create a
   temporary.  */
 
  When I get the code right, than all derived-typed source= expressions that
  have an allocatable component will not be prepared for copy to the
  allocated object. This also means, that functions returning an object of
  such a type are called multiple times. Once for each object to allocate. Is
  this really desired?
 
  I am sorry, that I have to say that, but the check2305.diff file does not
  bring the testcase with it.
 
  Regards,
  Andre
 
 
  On Sat, 23 May 2015 14:48:53 +0200
  Paul Richard Thomas paul.richard.tho...@gmail.com wrote:
 
  Dear All,
 
  This patch started out fixing a single source of memory leak and then
  went on to fix various other issues that I found upon investigation.
 
  The fortran ChangeLog entry is sufficiently descripive that I do not
  think that there is a need to say more.
 
  Bootstrapped and regtested on x86_64/FC21 - OK for trunk?
 
  I am rather sure that some of the issues go further back than 6.0. I
  will investigate what should be fixed for 5.2.
 
  Cheers
 
  Paul
 
  2015-05-23  Paul Thomas  pa...@gcc.gnu.org
 
  PR fortran/66079
  * trans-expr.c (gfc_conv_procedure_call): Allocatable scalar
  function results must be freed and nullified after use. Create
  a temporary to hold the result to prevent duplicate calls.
  * trans-stmt.c (gfc_trans_allocate): Prevent memory leaks by
  not evaluating expr3 for scalar derived types with allocatable
  components. Fixed character length allocatable results and
  dummies need to be dereferenced. Also, if al_len is NULL use
  memsz for the string copy.
 
  2015-05-23  Paul Thomas  pa...@gcc.gnu.org
 
  PR fortran/66079
  * gfortran.dg/allocatable_scalar_13.f90: New test
 
 
  --
  Andre Vehreschild * Email: vehre ad gmx dot de
 
 
 


-- 
Andre Vehreschild * Email: vehre ad gmx dot de 


[PATCH v3 4/4] libcc1: 'set debug compile': Display absolute GCC driver filename

2015-05-24 Thread Jan Kratochvil
Hi,

already approved, maybe it could be already checked in outside of the series:
https://gcc.gnu.org/ml/gcc-patches/2015-04/msg01298.html

With the patches so far after
(gdb) set debug compile 1
one would get:
searching for compiler matching regex 
^(x86_64|i.86)(-[^-]*)?-linux(-gnu)?-gcc$
found compiler x86_64-unknown-linux-gnu-gcc
But I believe it is more readable to see:
searching for compiler matching regex 
^(x86_64|i.86)(-[^-]*)?-linux(-gnu)?-gcc$
found compiler /usr/bin/x86_64-unknown-linux-gnu-gcc

I do not think the change will have functionality impact, although the filename
gets used even for executing the command.


Jan


libcc1/ChangeLog
2015-05-24  Jan Kratochvil  jan.kratoch...@redhat.com

* findcomp.cc: Include system.h.
(search_dir): Return absolute filename.
---
 libcc1/findcomp.cc |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libcc1/findcomp.cc b/libcc1/findcomp.cc
index f02b1df..5d49e29 100644
--- a/libcc1/findcomp.cc
+++ b/libcc1/findcomp.cc
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
 #include libiberty.h
 #include xregex.h
 #include findcomp.hh
+#include system.h
 
 class scanner
 {
@@ -68,7 +69,7 @@ search_dir (const regex_t regexp, const std::string dir, 
std::string *result)
 {
   if (regexec (regexp, filename, 0, NULL, 0) == 0)
{
- *result = filename;
+ *result = dir + DIR_SEPARATOR + filename;
  return true;
}
 }



Teach gimple_canonical_types_compatible_p about incomplete types

2015-05-24 Thread Jan Hubicka
Richard,
here is next patch of the series.  It adds all the logic for defining type
equivalence that globs all complete types together in order to make incomplete
type equivalent to every complete variant.

Effect of recursing on pointers
===

This is, of course, intended for hashing pointers, but I did not bundle it
here.  When used in the obvious way to hash pointers (not included in this
patch), the number of distinct canonical types in Firefox increase by 50%:

[WPA] GIMPLE canonical type table: size 32749, 21596 elements, 1637039 
searches, 222326 collisions (ratio: 0.135810)
[WPA] GIMPLE canonical type pointer-map: 21596 elements, 2271778 searches
to:
[WPA] GIMPLE canonical type table: size 65521, 32680 elements, 1637039 
searches, 475073 collisions (ratio: 0.290203)
[WPA] GIMPLE canonical type pointer-map: 32680 elements, 2303368 searches   

I also noticed the increase in collision ratio; it is still not bad and we
can strenghten the hash little bit incrementally.

Here is a testcase where we improve:

truct a
{
  int a; int *b;
};
struct a *ptr;
void test (void);
void linker_error (void);

struct b
{
  int a; short *b;
};
struct b *ptr2;
inline void
test()
{
  ptr2-a=2;
}

void
main()
{
  asm (:=r(ptr));
  asm (:=r(ptr2));
  while (1) {
  ptr-a=1;
  test();
  if (ptr-a != 1)
linker_error ();
   }
}

with -fno-early-inlining we are able to disambiguate ptr-a from ptr2-a
because we disambiguate struct a from struct b. For some reason we don't do
that if I move the secon ASM statement to test() that looks like missed
optimization.

Now the change does not really translate to great increase of disambiguations
for Firefox (it seems more in noise). The reason is the pointer_type globbing
in alias.c.

Globbing pointer types in alias.c
=

This code seemed very odd to me, but after some tought it does make sense for
C/C++.  It seemed to me that if we want to support alias of two different
pointers of same type but different qualification, we must make it part of the
TYPE_CANONICAL construction because that effectively unifies the compound types
build from them.  This is (fortunately) not really true: in C stores to array
types do not exist and structures are identified by their names, not by
structure. This means that this extra pointer equality does not propagate up
(only compound types in interest are pointers) and globbing them late indeed
allows to access pointer to A by pointer to B globally without fear of
disasters.

C cross-TU aliasing rules
and why I don't think globing pointers works for LTO of C only programs


In LTO however the situation is different.  We discussed following
cross-language unification rules

 1) type names does not matter (C standard is clear on that)
 2) field names does not matter (in C/C++ they do but we think matching the
names between C and other languages may be impractical)
 3) qualifiers does not matter (they do for C, byt it may be impractical
for other languages)
 4) references and pointers should be considered equal because we want to
interface languages with references only to C.
I suppose this is important for fortran

These rules do build structural equality up and thus do need to be part of
canonical type computation machinery.  
I looked in detail to what C standard say. It has notion of compatible type
and composite type.  The relevant clauses of C standard are:

  1  Two types have compatible type if their types are the same.
 Additional rules for determining whether two types are compatible are 
described
 in 6.7.2 for type specifiers, in 6.7.3 for type qualifiers, and in 6.7.6 
for
 declarators.  Moreover, two structure, union, or enumerated types declared
 in separate translation units are compatible if their tags and members 
satisfy
 the following requirements:  If one is declared with a tag, the other 
shall be
 declared with the same tag.  If both are completed anywhere within their
 respective translation units, then the following additional requirements 
apply:
 there shall be a one-to-one correspondence between their members such that 
each
 pair of corresponding members are declared with compatible types; if one 
member
 of the pair is declared with an alignment specifier, the other is declared 
with
 an equivalent alignment specifier; and if one member of the pair is 
declared
 with a name, the other is declared with the same name.  For two structures,
 corresponding members shall be declared in the same order.   For two
 structures or unions, corresponding bit-fields shall have the same widths. 
 For
 two enumerations, corresponding members shall have the same values.

(tag is struct a/struct b, so C standard actually require names to match
 for structures/unions/enums to be compatible but by transitivity it needs
 to match 

Re: [PATCH] Don't combine param and return value copies

2015-05-24 Thread Alan Modra
On Sat, May 23, 2015 at 08:45:23AM -0500, Segher Boessenkool wrote:
 Thanks.  Did you see improvements around return as well, or mostly /
 only related to the function start?

The rlwinm vs. rldicl change was in dwarf2out.c add_ranges_num for r3
one insn before a blr.  I'm sure that was due to not combining return
value copies.  In fact, I'm sure all the improvements I saw were due
to changing the exit..  See below.

[snip]
 I agree it looks like a bug waiting to happen.  Please post it as a
 separate patch though.

OK.

  +/* Twiddle BLOCK_FOR_INSN to TO for instructions in the first block BB
  +   that we don't want to combine with other instructions.  */
  +
  +static void
  +twiddle_first_block (basic_block bb, basic_block to)
 
 I don't like this much.  Messing with global state makes things harder
 to change later.  If it is hard to come up with a good name for a
 factor, it usually means it is not such a good factor.
 
 You can do these inside can_combine_{def,use}_p as far as I can see?
 Probably need to give those an extra parameter then: for _def, a bool
 that says don't allow moves from hard regs, set when the scan has
 encountered a NOTE_INSN_FUNCTION_BEG in this bb; and for _use, a regset
 of those hard regs we don't want to allow moves to (those seen in USEs
 later in that same block).  Or do it in the main loop itself, _{def,use}
 are each called in one place only; whatever works best.

Huh, that's the way I started writing this patch..  The reason I went
with modifying BLOCK_FOR_INSN is that the loop setting up LOG_LINKS
needs to test that anyway.  Changing code in the main loop means
every insn in a function will need to be tested for additional
conditions.  I thought that might be slower.  I can see your point
though, especially if someone wanted to wean combine off LOG_LINKS.
I'll rewrite the patch, which I realized was buggy anyway, and didn't
prevent param copies from being combined.  :-(

 What makes return values different from CALL args here, btw?  Why do
 you not want to combine return values, but you leave alone call args?

I don't think there is much difference between SETs for return values
and SETs for call args.  The reason I deliberately left them out is
that in the original discussion we were talking about parameters and
return values.  So I thought I'd better restrict the change to just
those SETs.

It would be a much simpler patch to make combine ignore all SETs
that are a reg,reg copy with one of them a hard reg.  I was a little
worried I'd regress some target if I tried that.  (Results on
powerpc64le-linux for such a change look good.  A lot more cases where
code is better, due to catching the parameter reg,reg copies.  In
looking at gcc/*.o I haven't yet seen any regressions in code quality.)

  +/* Fill in log links field for all insns that we wish to combine.  */
 
 Please don't change this comment; it was more correct before.

But it wasn't correct!  LOG_LINKS are not set up for *all* insns.
Perhaps I should add that we might wish to combine rather than
that we wish to combine?

  @@ -1103,7 +1192,7 @@ create_log_links (void)
   we might wind up changing the semantics of the insn,
   even if reload can make what appear to be valid
   assignments later.  */
  - if (regno  FIRST_PSEUDO_REGISTER
  + if (HARD_REGISTER_NUM_P (regno)
 asm_noperands (PATTERN (use_insn)) = 0)
  continue;
 
 An independent change.

Yeah, I guess.  I tidy these if I'm working on a piece of code.
Here's the whole file done.  Boostrapped and regression tested
powerpc64le-linux and x86_64-linux.

* combine.c: Use HARD_REGISTER_P and HARD_REGISTER_NUM_P as
appropriate throughout file in place of comparing regno
against FIRST_PSEUDO_REGISTER.

Index: combine.c
===
--- combine.c   (revision 223463)
+++ combine.c   (working copy)
@@ -1103,7 +1103,7 @@ create_log_links (void)
 we might wind up changing the semantics of the insn,
 even if reload can make what appear to be valid
 assignments later.  */
- if (regno  FIRST_PSEUDO_REGISTER
+ if (HARD_REGISTER_NUM_P (regno)
   asm_noperands (PATTERN (use_insn)) = 0)
continue;
 
@@ -1730,7 +1730,7 @@ set_nonzero_bits_and_sign_copies (rtx x, const_rtx
   rtx_insn *insn = (rtx_insn *) data;
 
   if (REG_P (x)
-   REGNO (x) = FIRST_PSEUDO_REGISTER
+   !HARD_REGISTER_P (x)
   /* If this register is undefined at the start of the file, we can't
 say what its contents were.  */
! REGNO_REG_SET_P
@@ -1897,7 +1897,7 @@ can_combine_p (rtx_insn *insn, rtx_insn *i3, rtx_i
   (REGNO (XEXP (i3elt, 0)) == regno
  ? reg_set_between_p (XEXP (elt, 0),
   PREV_INSN (insn), i3)
-  

[PATCH] Fixes combined gcc-binutils builds.

2015-05-24 Thread Michael Darling
Combined builds has been broken for about 10 months, because some
binutils configure.in files were renamed to configure.ac, but gcc's
references to them were not updated.  There is a corresponding patch
submitted to binutils-gdb, which renames its few remaining configure.in
files to configure.ac.  Otherwise, fixing the gcc calls to binutils-gdb
configure.* files would be more complicated.

Also, some time ago, gcc renamed its configure.in files to configure.ac.
Fixed a few remaining references to gcc configure.in files, such as in
error messages and documentation.

See PR gcc/other/66259 and binutils-gdb/binutils/18450.

Index: ChangeLog
===
--- ChangeLog (revision 223630)
+++ ChangeLog (working copy)
@@ -1,3 +1,10 @@
+2015-05-24  Michael Darling  darli...@gmail.com
+
+ PR other/66259
+ * config-ml.in: Reflects renaming of configure.in to configure.ac
+ * configure: Reflects renaming of configure.in to configure.ac
+ * configure.ac: Reflects renaming of configure.in to configure.ac
+
 2015-05-16  James Bowman  james.bow...@ftdichip.com

  * configure.ac: FT32 target added.
Index: boehm-gc/ChangeLog
===
--- boehm-gc/ChangeLog (revision 223630)
+++ boehm-gc/ChangeLog (working copy)
@@ -1,3 +1,11 @@
+2015-05-24  Michael Darling  darli...@gmail.com
+
+ PR other/66259
+ * Makefile.direct: Reflects renaming of configure.in to configure.ac
+ * Makefile.dist: Reflects renaming of configure.in to configure.ac
+ * version.h: Reflects renaming of configure.in to configure.ac
+ * doc/README: Reflects renaming of configure.in to configure.ac
+
 2015-05-13  Michael Haubenwallner  michael.haubenwall...@ssi-schaefer.com

  * Makefile.in: Regenerated with automake-1.11.6.
Index: boehm-gc/Makefile.direct
===
--- boehm-gc/Makefile.direct (revision 223630)
+++ boehm-gc/Makefile.direct (working copy)
@@ -331,7 +331,7 @@ DOC_FILES= README.QUICK doc/README.Mac doc/README.
 TESTS= tests/test.c tests/test_cpp.cc tests/trace_test.c \
  tests/leak_test.c tests/thread_leak_test.c tests/middle.c

-GNU_BUILD_FILES= configure.in Makefile.am configure acinclude.m4 \
+GNU_BUILD_FILES= configure.ac Makefile.am configure acinclude.m4 \
  libtool.m4 install-sh configure.host Makefile.in \
  aclocal.m4 config.sub config.guess \
  include/Makefile.am include/Makefile.in \
Index: boehm-gc/Makefile.dist
===
--- boehm-gc/Makefile.dist (revision 223630)
+++ boehm-gc/Makefile.dist (working copy)
@@ -326,7 +326,7 @@ DOC_FILES= README.QUICK doc/README.Mac doc/README.
 TESTS= tests/test.c tests/test_cpp.cc tests/trace_test.c \
  tests/leak_test.c tests/thread_leak_test.c tests/middle.c

-GNU_BUILD_FILES= configure.in Makefile.am configure acinclude.m4 \
+GNU_BUILD_FILES= configure.ac Makefile.am configure acinclude.m4 \
  libtool.m4 install-sh configure.host Makefile.in \
  aclocal.m4 config.sub config.guess \
  include/Makefile.am include/Makefile.in \
Index: boehm-gc/doc/README
===
--- boehm-gc/doc/README (revision 223630)
+++ boehm-gc/doc/README (working copy)
@@ -6,7 +6,7 @@ Copyright (c) 1999-2004 Hewlett-Packard Developmen
 The file linux_threads.c is also
 Copyright (c) 1998 by Fergus Henderson.  All rights reserved.

-The files Makefile.am, and configure.in are
+The files Makefile.am, and configure.ac are
 Copyright (c) 2001 by Red Hat Inc. All rights reserved.

 Several files supporting GNU-style builds are copyrighted by the Free
Index: boehm-gc/version.h
===
--- boehm-gc/version.h (revision 223630)
+++ boehm-gc/version.h (working copy)
@@ -1,4 +1,4 @@
-/* The version here should match that in configure/configure.in */
+/* The version here should match that in configure/configure.ac */
 /* Eventually this one may become unnecessary.  For now we need */
 /* it to keep the old-style build process working. */
 #define GC_TMP_VERSION_MAJOR 6
@@ -14,7 +14,7 @@
  GC_TMP_VERSION_MINOR != GC_VERSION_MINOR || \
  defined(GC_ALPHA_VERSION) != (GC_TMP_ALPHA_VERSION != GC_NOT_ALPHA) || \
  defined(GC_ALPHA_VERSION)  GC_TMP_ALPHA_VERSION != GC_ALPHA_VERSION
-#   error Inconsistent version info.  Check README, version.h, and
configure.in.
+#   error Inconsistent version info.  Check README, version.h, and
configure.ac.
 # endif
 #else
 # define GC_VERSION_MAJOR GC_TMP_VERSION_MAJOR
Index: config/ChangeLog
===
--- config/ChangeLog (revision 223630)
+++ config/ChangeLog (working copy)
@@ -1,3 +1,11 @@
+2015-05-24  Michael Darling  darli...@gmail.com
+
+ PR other/66259
+ * gettext.m4: Reflects renaming of configure.in to configure.ac
+ * po.m4: Reflects renaming of configure.in to configure.ac
+ * 

GIMPLE syntax highlighting for vim

2015-05-24 Thread Mikhail Maltsev
Hi all!

The attached vim script can be used to highlight syntax in GIMPLE dumps
making them somewhat easier to read.

I would like to add this script to gcc/contrib directory. Is that OK?

-- 
Regards,
Mikhail Maltsev
 Syntax highlighting rules for GIMPLE dump files

 Copyright (C) 2015 Free Software Foundation, Inc.

 This script is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 3, or (at your option)
 any later version

 This script highlights syntax in debug dumps containing GIMPLE
 intermediate representation. Such dumps are produced by GCC when
 run with -fdump-tree-* and/or -fdump-ipa-* switches.

 INSTALLATION:
 1. Copy the script to $HOME/.vim/syntax dirctory
 2. Create a file gimple.vim in $HOME/.vim/ftdetect with the
 following command:
 au BufRead,BufNewFile *.[0-2][0-9][0-9][ti].* set filetype=gimple

 The pattern in this autocommand corresponds to defult file names
 of debug dumps, e.g.:
 filename.cc.123t.pass-name


 Do not continue, if syntax is already enabled in current buffer
if exists(b:current_syntax)
finish
endif

 If set to true, Unknown tree in -fdump-tree-original will
 be highlighted as an error
let s:unknown_tree_is_error=0

 Comments for Phi nodes, value ranges, use/def-chains, etc.
syn match   gimpleAnnotation\v#.*$
\ contains=gimpleAnnotationOp,gimpleAnnotationMark,
\ gimpleNumber
syn match   gimpleAnnotationMark# contained
syn keyword   gimpleAnnotationOpPHI VUSE VDEF RANGE PT
\ ALIGN MISALIGN NONZERO contained

 Verbose debug output (enabled by -fdump-tree-*-all)
syn match   gimpleComment   ;;.*$

 Types - mostly borrowed from vim syntax file for C
syn keyword gimpleType  int long short char void
\ signed unsigned float double
\ size_t ssize_t off_t wchar_t ptrdiff_t sig_atomic_t fpos_t
\ clock_t time_t va_list jmp_buf FILE DIR div_t ldiv_t
\ mbstate_t wctrans_t wint_t wctype_t
\ _Bool bool _Complex complex _Imaginary imaginary
\ int8_t int16_t int32_t int64_t
\ uint8_t uint16_t uint32_t uint64_t
\ int_least8_t int_least16_t int_least32_t int_least64_t
\ uint_least8_t uint_least16_t uint_least32_t uint_least64_t
\ int_fast8_t int_fast16_t int_fast32_t int_fast64_t
\ uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t
\ intptr_t uintptr_t
\ intmax_t uintmax_t
\ __label__ __complex__ __volatile__
\ char16_t char32_t sizetype __vtbl_ptr_type

 C/C++-like control structures
syn keyword gimpleStatement goto return
syn keyword gimpleConditional   if else
syn keyword gimpleLoop  while
syn keyword gimpleException try catch finally

 Special 'values'
syn match   gimpleConstant  {CLOBBER}
syn match   gimpleConstant  {ref-all}
syn match   gimpleConstant  {v}

 Blocks
syn region  gimpleBlock start={ end=} transparent fold

 String literals
syn region  gimpleStringstart=/\v/ skip=/\v\\./ end=/\v/

 GENERIC AST nodes
syn keyword gimpleASTNode   BIT_FIELD_REF TARGET_EXPR expr_stmt
\ NON_LVALUE_EXPR
\ must_not_throw_expr eh_spec_block eh_filter
\ eh_must_not_throw aggr_init_expr cleanup_point

if s:unknown_tree_is_error
syn match   gimpleUnknownTree   \vUnknown tree: \w+
end

 Numbers
syn match   gimpleNumber\v([^.a-zA-Z0-9_])\zs-?\d+B?
syn match   gimpleFloat \v\W\zs-?\d+\.\d+

 Basic block label
 bb 123:
syn match   gimpleLabel \v^\s*\zs\bb \d+\
 D.1234:
 L1:
syn match   gimpleLabel \v^\s*\zs\[DL]\.?\d+\
 label: - user-defined label
syn match   gimpleLabel \v^\s*\w+\ze:\s*$

 Match label after goto to suppress highlighting of numbers inside
syn match   gimpleGotoLabel \vbb \d+\[^:]

 Misc C/C++-like keywords
syn keyword gimpleStructure struct union enum typedef class
syn keyword gimpleStorageClass  static register auto volatile extern const 
template
syn keyword gimpleStorageClass  inline __attribute__ _Alignas alignas
syn keyword gimpleStorageClass  _Atomic _Thread_local thread_local
syn keyword gimpleOperator  _Alignof alignof sizeof

hi def link gimpleType  Type
hi def link gimpleNumberNumber
hi def link gimpleFloat Float
hi def link gimpleConstant  Constant
hi def link gimpleStructure Structure
hi def link gimpleStorageClass  StorageClass
hi def link gimpleOperator  Operator
hi def link gimpleASTNode   Operator
hi def link gimpleStatement Statement
hi def link gimpleConditional   Conditional
hi def link gimpleLoop  Repeat
hi def link gimpleException Exception
hi def link gimpleComment   Comment
hi def link gimpleLabel Label
hi def link gimpleAnnotationOp  Debug
hi def link gimpleAnnotationMark Debug
hi def link 

[C++ Patch] Fix 66243, silent cast of scoped enum

2015-05-24 Thread Nathan Sidwell
This is a pretty obvious patch.  We were permitting a scoped enum initializer of 
an another enum to silently decay to int.  That's not right, only unscoped enums 
have that privilege.


committed.

nathan
2015-05-24  Nathan Sidwell  nat...@acm.org

	cp/
	PR c++/66243
	* decl.c (build_enumerator): Don't silently convert scoped enums.

	testsuite/
	PR c++/66243
	* g++.dg/cpp0x/pr66243.C: New.

Index: cp/decl.c
===
--- cp/decl.c	(revision 223613)
+++ cp/decl.c	(working copy)
@@ -13097,7 +13097,8 @@ build_enumerator (tree name, tree value,
 	  if (tmp_value)
 		value = tmp_value;
 	}
-	  else if (! INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (value)))
+	  else if (! INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P
+		   (TREE_TYPE (value)))
 	value = perform_implicit_conversion_flags
 	  (ENUM_UNDERLYING_TYPE (enumtype), value, tf_warning_or_error,
 	   LOOKUP_IMPLICIT | LOOKUP_NO_NARROWING);
Index: testsuite/g++.dg/cpp0x/pr66243.C
===
--- testsuite/g++.dg/cpp0x/pr66243.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/pr66243.C	(working copy)
@@ -0,0 +1,12 @@
+// { dg-do compile { target c++11 } }
+
+enum class A
+{
+  X
+};
+
+enum class B
+{
+  X = A::X // { dg-error could not convert }
+};
+


Re: [PATCH] Don't combine param and return value copies

2015-05-24 Thread Alan Modra
On Mon, May 25, 2015 at 10:26:35AM +0930, Alan Modra wrote:
 looking at gcc/*.o I haven't yet seen any regressions in code quality.)

Well that didn't last very long.  There are regressions, and just from
looking at disassembled object files it would appear to be frame
pointer related.  So the simple patch won't work.

-- 
Alan Modra
Australia Development Lab, IBM


[Ping]: [Patch] [AArch64] PR target 66049: fix add/extend gcc test suite failures

2015-05-24 Thread Kumar, Venkataramanan
Ping! 

-Original Message-
From: gcc-patches-ow...@gcc.gnu.org [mailto:gcc-patches-ow...@gcc.gnu.org] On 
Behalf Of Kumar, Venkataramanan
Sent: Tuesday, May 19, 2015 9:07 PM
To: James Greenhalgh (james.greenha...@arm.com); gcc-patches@gcc.gnu.org
Cc: Kyrill Tkachov (kyrylo.tkac...@arm.com); ramana.radhakrish...@arm.com; 
seg...@kernel.crashing.org; Marcus Shawcroft (marcus.shawcr...@arm.com)
Subject: [Patch] [AArch64] PR target 66049: fix add/extend gcc test suite 
failures

Hi Maintainers, 

Please find the attached patch, that fixes add/extend gcc test suite failures 
in Aarch64 target.  
Ref: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66049

These tests started to fail after we prevented combiner from converting shift 
RTX to mult RTX, when the RTX is not inside a memory operation (r222874) .
Now I have added new add/extend patterns which are based on shift operations,  
to fix these cases.

Testing status with the patch.

(1) GCC bootstrap on AArch64 successful. 
(2)  SPEC2006 INT runs did not show any degradation.
(3) gcc regression testing passed.

(-Snip-)
# Comparing 3 common sum files
## /bin/sh ./gcc-fsf-trunk/contrib/compare_tests  /tmp/gxx-sum1.24998 
/tmp/gxx-sum2.24998 Tests that now work, but didn't before:

gcc.target/aarch64/adds1.c scan-assembler adds\tw[0-9]+, w[0-9]+, w[0-9]+, lsl 
3 gcc.target/aarch64/adds1.c scan-assembler adds\tx[0-9]+, x[0-9]+, x[0-9]+, 
lsl 3 gcc.target/aarch64/adds3.c scan-assembler-times adds\tx[0-9]+, x[0-9]+, 
x[0-9]+, sxtw 2 gcc.target/aarch64/extend.c scan-assembler add\tw[0-9]+,.*uxth 
#?1 gcc.target/aarch64/extend.c scan-assembler add\tx[0-9]+,.*uxtw #?3 
gcc.target/aarch64/extend.c scan-assembler sub\tw[0-9]+,.*uxth #?1 
gcc.target/aarch64/extend.c scan-assembler sub\tx[0-9]+,.*uxth #?1 
gcc.target/aarch64/extend.c scan-assembler sub\tx[0-9]+,.*uxtw #?3 
gcc.target/aarch64/subs1.c scan-assembler subs\tw[0-9]+, w[0-9]+, w[0-9]+, lsl 
3 gcc.target/aarch64/subs1.c scan-assembler subs\tx[0-9]+, x[0-9]+, x[0-9]+, 
lsl 3 gcc.target/aarch64/subs3.c scan-assembler-times subs\tx[0-9]+, x[0-9]+, 
x[0-9]+, sxtw 2

# No differences found in 3 common sum files
(-Snip-)

The patterns are fixing the regressing tests, so I have not added any new 
tests. 
Regarding  removal of the old patterns based on mults,  I am planning to do 
it as a separate work.

Is this OK for trunk ? 

gcc/ChangeLog 

2015-05-19  Venkataramanan Kumar  venkataramanan.ku...@amd.com

* config/aarch64/aarch64.md
(*adds_shift_imm_mode):  New pattern.
(*subs_shift_imm_mode):  Likewise.
(*adds_optabALLX:mode_shift_GPI:mode):  Likewise.
(*subs_optabALLX:mode_shift_GPI:mode): Likewise.
(*add_uxtmode_shift2): Likewise.
(*add_uxtsi_shift2_uxtw): Likewise.
   (*sub_uxtmode_shift2): Likewise.
   (*sub_uxtsi_shift2_uxtw): Likewise.


Regards,
Venkat.
  


 
diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
index 1dbadc0..d0d6a6a 100644
--- a/gcc/config/aarch64/aarch64.md
+++ b/gcc/config/aarch64/aarch64.md
@@ -1539,6 +1539,38 @@
   [(set_attr type alus_sreg,alus_imm,alus_imm)]
 )
 
+(define_insn *adds_shift_imm_mode
+  [(set (reg:CC_NZ CC_REGNUM)
+   (compare:CC_NZ
+(plus:GPI (ASHIFT:GPI 
+   (match_operand:GPI 1 register_operand r)
+   (match_operand:QI 2 aarch64_shift_imm_mode n))
+  (match_operand:GPI 3 register_operand r))
+(const_int 0)))
+   (set (match_operand:GPI 0 register_operand =r)
+   (plus:GPI (ASHIFT:GPI (match_dup 1) (match_dup 2))
+ (match_dup 3)))]
+  
+  adds\\t%w0, %w3, %w1, shift %2
+  [(set_attr type alus_shift_imm)]
+)
+
+(define_insn *subs_shift_imm_mode
+  [(set (reg:CC_NZ CC_REGNUM)
+   (compare:CC_NZ
+(minus:GPI (match_operand:GPI 1 register_operand r)
+   (ASHIFT:GPI
+(match_operand:GPI 2 register_operand r)
+(match_operand:QI 3 aarch64_shift_imm_mode n)))
+(const_int 0)))
+   (set (match_operand:GPI 0 register_operand =r)
+   (minus:GPI (match_dup 1)
+  (ASHIFT:GPI (match_dup 2) (match_dup 3]
+  
+  subs\\t%w0, %w1, %w2, shift %3
+  [(set_attr type alus_shift_imm)]
+)
+
 (define_insn *adds_mul_imm_mode
   [(set (reg:CC_NZ CC_REGNUM)
(compare:CC_NZ
@@ -1599,6 +1631,42 @@
   [(set_attr type alus_ext)]
 )
 
+(define_insn *adds_optabALLX:mode_shift_GPI:mode
+  [(set (reg:CC_NZ CC_REGNUM)
+   (compare:CC_NZ
+(plus:GPI (ashift:GPI 
+   (ANY_EXTEND:GPI 
+(match_operand:ALLX 1 register_operand r))
+   (match_operand 2 aarch64_imm3 Ui3))
+  (match_operand:GPI 3 register_operand r))
+(const_int 0)))
+   (set (match_operand:GPI 0 register_operand =rk)
+   (plus:GPI (ashift:GPI (ANY_EXTEND:GPI (match_dup 1))
+ (match_dup 2))
+ (match_dup 3)))]
+  
+  

RE: [PATCH] Fix PR66168: ICE due to incorrect invariant register info

2015-05-24 Thread Thomas Preud'homme
 From: Jeff Law [mailto:l...@redhat.com]
 Sent: Saturday, May 23, 2015 6:54 AM
 
  -  if (!can_move_invariant_reg (loop, inv, reg))
  +  if (!can_move_invariant_reg (loop, inv, dest))
 Won't this run into into the same problem if DEST is a SUBREG?

One of the very first test in can_move_invariant_reg is:

if (!REG_P (reg) || !HARD_REGISTER_P (reg))
  return false;

So in case of a subreg the insn will not be moved which will execute the same
code as before my patch. It would be nicer if it could work with subreg of
course but this makes for a much smaller and safer patch.

Best regards,

Thomas




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

2015-05-24 Thread Dharmakan Rohit Arul Raj
 -Original Message-
 From: Richard Biener [mailto:rguent...@suse.de]
 Sent: Monday, May 18, 2015 1:06 PM
 To: Jeff Law
 Cc: Dharmakan Rohit-B30502; gcc-patches@gcc.gnu.org; Jakub Jelinek; Alan
 Modra; David Edelsohn; Wienskoski Edmar-RA8797
 Subject: Re: [RFC: Patch, PR 60158] gcc/varasm.c : Pass actual alignment value
 to output_constant_pool_2
 
 On Fri, 15 May 2015, Jeff Law wrote:
 
  On 05/15/2015 04:37 AM, Dharmakan Rohit Arul Raj wrote:
  
-Original Message-
From: Jeff Law [mailto:l...@redhat.com]
Sent: Friday, May 15, 2015 10:30 AM
 Just to summarize: By default in GCC v4.7.x, all the constants
 are put into '.rodata.str1.4' section. In GCC v4.8.x from
 r192719 onwards, one of the move instruction of the string
 constant .LC0 is getting spilled. The reload pass, for any
 constants that aren't allowed and can't be reloaded in to
 registers tries to change them into memory references. Then
 while emitting that string constant to asm code
 (A:varasm.c: output_constant_pool_1), it explicitly passes the
 alignment as 1 which prevents the generation of fix-up table
 entries in  'B: rs6000.c:rs6000_assemble_integer' because the
 data is considered unaligned now.

 The bug seems to have gone latent with an unrelated trunk commit
 r204695 [* tree-ssa-loop-ivopts.c (force_expr_to_var_cost):
 Refactor the code. Handle type conversion.]. This commit chooses
 different spill candidates hence all the string constants are
 being put in to '.rodata.str1.4´section.

 The check I had in the test case is that if there is a
 '.data.rel.ro.local', then there should be '.fixup' section generated.

 Please let me know if you need any other details.
Thanks.  Even though I wasn't able to trigger the bug with the
testcase from 65018, I went ahead and committed this patch to the
trunk.  It can't hurt and it's the right thing to do.
   
Thanks for your patience,
   
  
   Jeff, Thanks for checking-in the changes.
   Can we apply the patch to GCC v4.8 and GCC v4.9 branch as well?
  That's up to the branch maintainers.  I'd think it's safe, but it's
  ultimately their call.
 
 If it's a regression or a wrong-code issue then it's ok to backport given the
 patch is safe, of course.

Just to confirm, can we backport the patch to GCC v4.8  GCC v4.9 branch?

Regards,
Rohit
 


Re: [PATCH GCC]Improve how we handle overflow for type conversion in scev/ivopts, part I

2015-05-24 Thread Bin.Cheng
On Fri, May 22, 2015 at 7:45 PM, Richard Biener
richard.guent...@gmail.com wrote:
 On Wed, May 20, 2015 at 11:41 AM, Bin Cheng bin.ch...@arm.com wrote:
 Hi,
 As we know, GCC is too conservative when checking overflow behavior in SCEV
 and loop related optimizers.  Result is some variable can't be recognized as
 scalar evolution and thus optimizations are missed.  To be specific,
 optimizers like ivopts and vectorizer are affected.
 This issue is more severe on 64 bit platforms, for example, PR62173 is
 failed on aarch64; scev-3.c and scev-4.c were marked as XFAIL on lp64
 platforms.

 As the first part to improve overflow checking in GCC, this patch does below
 improvements:
   1) Ideally, chrec_convert should be responsible to convert scev like
 (type){base, step} to scev like {(type)base, (type)step} when the result
 scev doesn't overflow; chrec_convert_aggressive should do the conversion if
 the result scev could overflow/wrap.  Unfortunately, current implementation
 may use chrec_convert_aggressive to return a scev that won't overflow.  This
 is because of a) the static parameter fold_conversions for
 instantiate_scev_convert can only tracks whether chrec_convert_aggressive
 may be called, rather than if it does some overflow conversion or not;  b)
 the implementation of instantiate_scev_convert sometimes shortcuts the call
 to chrec_convert and misses conversion opportunities.  This patch improves
 this.
   2) iv-no_overflow computed in simple_iv is too conservative.  With 1)
 fixed, iv-no_overflow should reflects whether chrec_convert_aggressive does
 return an overflow scev.  This patch improves this.
   3) chrec_convert should be able to prove the resulting scev won't overflow
 with loop niter information.  This patch doesn't finish this, but it
 factored a new interface out of scev_probably_wraps_p for future
 improvement.  And that will be the part II patch.

 With the improvements in SCEV, this patch also improves optimizer(IVOPT)
 that uses scev information like below:
   For array reference in the form of arr[IV], GCC tries to derive new
 address iv {arr+iv.base, iv.step*elem_size} from IV.  If IV overflow wrto a
 type that is narrower than address space, this derivation is not true
 because arr[IV] isn't a scev.  Root cause why scev-*.c are failed now is
 the overflow information of IV is too conservative.  IVOPT has to be
 conservative to reject arr[IV] as a scev.  With more accurate overflow
 information, IVOPT can be improved too.  So this patch fixes the mentioned
 long standing issues.

 Bootstrap and test on x86_64, x86 and aarch64.
 BTW, test gcc.target/i386/pr49781-1.c failed on x86_64, but I can confirmed
 it's not this patch's fault.

 So what's your opinion on this?.

 I maybe mixing things up but does

 +chrec_convert_aggressive (tree type, tree chrec, bool *fold_conversions)
  {
 ...
 +  if (evolution_function_is_affine_p (chrec))
 +{
 +  tree base, step;
 +  struct loop *loop;
 +
 +  loop = get_chrec_loop (chrec);
 +  base = CHREC_LEFT (chrec);
 +  step = CHREC_RIGHT (chrec);
 +  if (convert_affine_scev (loop, type, base, step, NULL, true))
 +   return build_polynomial_chrec (loop-num, base, step);

 ^^^ not forget to set *fold_conversions to true?  Or we need to use
 convert_affine_scev (..., false)?

Nice catch.  It's supposed to be called only if source scev has no
overflow behavior introduced by previous call to
chrec_convert_aggressive.  In other words, it should be guarded by
!*fold_conversions like below:

+
+  if (!*fold_conversions  evolution_function_is_affine_p (chrec))
+{
+  tree base, step;
+  struct loop *loop;
+
+  loop = get_chrec_loop (chrec);
+  base = CHREC_LEFT (chrec);
+  step = CHREC_RIGHT (chrec);
+  if (convert_affine_scev (loop, type, base, step, NULL, true))
+return build_polynomial_chrec (loop-num, base, step);
+}

The scenario is rare that didn't exposed in either bootstrap or reg-test.

Here is the updated patch without any other difference.  Bootstrap and
test on x86_64  AArch64.

Thanks,
bin

 +}

 (bah, and the diff somehow messes up -p context :/  which is why I like
 context diffs more)

 Other from the above the patch looks good to me.

 Thanks,
 Richard.

 Thanks,
 bin

 2015-05-20  Bin Cheng  bin.ch...@arm.com

 PR tree-optimization/62173
 * tree-ssa-loop-ivopts.c (struct iv): New field.  Reorder fields.
 (alloc_iv, set_iv): New parameter.
 (determine_biv_step): Delete.
 (find_bivs): Inline original determine_biv_step.  Pass new
 argument to set_iv.
 (idx_find_step): Use no_overflow information for conversion.
 * tree-scalar-evolution.c (analyze_scalar_evolution_in_loop): Let
 resolve_mixers handle folded_casts.
 (instantiate_scev_name): Change bool parameter to bool pointer.
 (instantiate_scev_poly, instantiate_scev_binary): Ditto.
 (instantiate_array_ref, 

Re: [C frontend] Fix construction of TYPE_STUB_DECL

2015-05-24 Thread Jan Hubicka
Hi,
this patch implements the idea.  It uses anon for anonymous namespace
types and updates ipa-devirt to rely on it (and also sanity check that).
The patch has bootstrapped/regtested powerpc64le-linux, will commit it
tomorrow if there are no complains to unbreak the Ada LTO bootstrap.

Honza

PR lto/66180
* mangle.c (mangle_decl): Mangle anonymous namespace types as anon
* ipa-devirt.c (type_with_linkage): CHeck that TYPE_STUB_DECL
is set; check for assembler name at LTO time.
(type_in_anonymous_namespace): Remove hacks, check that all
anonymous types are called anon
(odr_type_p): Simplify; add check for anon
(odr_subtypes_equivalent): Add odr_type_p check.
* tree.c (need_assembler_name_p): Even anonymous namespace
needs assembler name.

* g++.dg/lto/pr66180_0.C: New testcase.
* g++.dg/lto/pr66180_1.C: New testcase.
Index: cp/mangle.c
===
--- cp/mangle.c (revision 223628)
+++ cp/mangle.c (working copy)
@@ -3511,7 +3511,20 @@
   if (dep)
 return;
 
-  id = get_mangled_id (decl);
+  /* During LTO we keep mangled names of TYPE_DECLs for ODR type merging.
+ It is not needed to assign names to anonymous namespace, but we use the
+ anon marker to be able to tell if type is C++ ODR type or type
+ produced by other language.  */
+  if (TREE_CODE (decl) == TYPE_DECL
+   TYPE_STUB_DECL (TREE_TYPE (decl))
+   !TREE_PUBLIC (TYPE_STUB_DECL (TREE_TYPE (decl
+id = get_identifier (anon);
+  else
+{
+  gcc_assert (TREE_CODE (decl) != TYPE_DECL
+ || !no_linkage_check (TREE_TYPE (decl), true));
+  id = get_mangled_id (decl);
+}
   SET_DECL_ASSEMBLER_NAME (decl, id);
 
   if (G.need_abi_warning
Index: ipa-devirt.c
===
--- ipa-devirt.c(revision 223629)
+++ ipa-devirt.c(working copy)
@@ -252,9 +252,15 @@
 {
   /* Builtin types do not define linkage, their TYPE_CONTEXT is NULL.  */
   if (!TYPE_CONTEXT (t)
-  || !TYPE_NAME (t) || TREE_CODE (TYPE_NAME (t)) != TYPE_DECL)
+  || !TYPE_NAME (t) || TREE_CODE (TYPE_NAME (t)) != TYPE_DECL
+  || !TYPE_STUB_DECL (t))
 return false;
 
+  /* In LTO do not get confused by non-C++ produced types or types built
+ with -fno-lto-odr-type-merigng.  */
+  if (in_lto_p  !DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t)))
+return false;
+
   return (RECORD_OR_UNION_TYPE_P (t)
  || TREE_CODE (t) == ENUMERAL_TYPE);
 }
@@ -269,18 +275,14 @@
 
   if (TYPE_STUB_DECL (t)  !TREE_PUBLIC (TYPE_STUB_DECL (t)))
 {
-  if (DECL_ARTIFICIAL (TYPE_NAME (t)))
-   return true;
-  tree ctx = DECL_CONTEXT (TYPE_NAME (t));
-  while (ctx)
-   {
- if (TREE_CODE (ctx) == NAMESPACE_DECL)
-   return !TREE_PUBLIC (ctx);
- if (TREE_CODE (ctx) == BLOCK)
-   ctx = BLOCK_SUPERCONTEXT (ctx);
- else
-   ctx = get_containing_scope (ctx);
-   }
+  /* C++ FE uses magic anon as assembler names of anonymous types.
+verify that this match with type_in_anonymous_namespace_p.  */
+#ifdef ENABLE_CHECKING
+  if (in_lto_p)
+   gcc_assert (!strcmp (anon,
+   IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (TYPE_NAME (t);
+#endif
+  return true;
 }
   return false;
 }
@@ -292,14 +294,25 @@
 bool
 odr_type_p (const_tree t)
 {
-  if (type_with_linkage_p (t)  type_in_anonymous_namespace_p (t))
-return true;
   /* We do not have this information when not in LTO, but we do not need
  to care, since it is used only for type merging.  */
   gcc_checking_assert (in_lto_p || flag_lto);
 
-  return (TYPE_NAME (t)  TREE_CODE (TYPE_NAME (t)) == TYPE_DECL
-   (DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t;
+  if (TYPE_NAME (t)  TREE_CODE (TYPE_NAME (t)) == TYPE_DECL
+   (DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t
+{
+#ifdef ENABLE_CHECKING
+  /* C++ FE uses magic anon as assembler names of anonymous types.
+verify that this match with type_in_anonymous_namespace_p.  */
+  gcc_assert (!type_with_linkage_p (t)
+ || strcmp (anon,
+IDENTIFIER_POINTER
+   (DECL_ASSEMBLER_NAME (TYPE_NAME (t
+ || type_in_anonymous_namespace_p (t));
+#endif
+  return true;
+}
+  return false;
 }
 
 /* Return TRUE if all derived types of T are known and thus
@@ -774,7 +787,7 @@
 return false;
   /* Limit recursion: If subtypes are ODR types and we know
  that they are same, be happy.  */
-  if (!get_odr_type (t1, true)-odr_violated)
+  if (!odr_type_p (t1) || !get_odr_type (t1, true)-odr_violated)
 return true;
 }
 
Index: testsuite/g++.dg/lto/pr66180_0.C
===
--- testsuite/g++.dg/lto/pr66180_0.C

Re: [Patch, fortran] PR66079 - [6 Regression] memory leak with source allocation in internal subprogram

2015-05-24 Thread Paul Richard Thomas
Dear Andre,

I'll put both points right. Thanks for pointing them out.

Cheers

Paul

On 23 May 2015 at 19:52, Andre Vehreschild ve...@gmx.de wrote:
 Hi Paul,

 does this patch apply to current trunk cleanly? I get an issue with the last
 hunk, because all of the prerequisites are gone since r223445. The string copy
 is completely handled by the trans_assignment at the bottom of the if
 (code-expr3) block. Therefore I doubt the patches last hunk is needed any
 longer.

 Do you have an example why this hunk is needed?

 Index: gcc/fortran/trans-stmt.c
 ===
 *** gcc/fortran/trans-stmt.c(revision 223233)
 --- gcc/fortran/trans-stmt.c(working copy)
 *** gfc_trans_allocate (gfc_code * code)
 *** 5200,5206 
 }
   /* else expr3 = NULL_TREE set above.  */
 }
 ! else
 {
   /* In all other cases evaluate the expr3 and create a
  temporary.  */
 --- 5200,5207 
 }
   /* else expr3 = NULL_TREE set above.  */
 }
 ! else if (!(code-expr3-ts.type == BT_DERIVED
 ! code-expr3-ts.u.derived-attr.alloc_comp))
 {
   /* In all other cases evaluate the expr3 and create a
  temporary.  */

 When I get the code right, than all derived-typed source= expressions that 
 have
 an allocatable component will not be prepared for copy to the allocated 
 object.
 This also means, that functions returning an object of such a type are called
 multiple times. Once for each object to allocate. Is this really desired?

 I am sorry, that I have to say that, but the check2305.diff file does not 
 bring
 the testcase with it.

 Regards,
 Andre


 On Sat, 23 May 2015 14:48:53 +0200
 Paul Richard Thomas paul.richard.tho...@gmail.com wrote:

 Dear All,

 This patch started out fixing a single source of memory leak and then
 went on to fix various other issues that I found upon investigation.

 The fortran ChangeLog entry is sufficiently descripive that I do not
 think that there is a need to say more.

 Bootstrapped and regtested on x86_64/FC21 - OK for trunk?

 I am rather sure that some of the issues go further back than 6.0. I
 will investigate what should be fixed for 5.2.

 Cheers

 Paul

 2015-05-23  Paul Thomas  pa...@gcc.gnu.org

 PR fortran/66079
 * trans-expr.c (gfc_conv_procedure_call): Allocatable scalar
 function results must be freed and nullified after use. Create
 a temporary to hold the result to prevent duplicate calls.
 * trans-stmt.c (gfc_trans_allocate): Prevent memory leaks by
 not evaluating expr3 for scalar derived types with allocatable
 components. Fixed character length allocatable results and
 dummies need to be dereferenced. Also, if al_len is NULL use
 memsz for the string copy.

 2015-05-23  Paul Thomas  pa...@gcc.gnu.org

 PR fortran/66079
 * gfortran.dg/allocatable_scalar_13.f90: New test


 --
 Andre Vehreschild * Email: vehre ad gmx dot de



-- 
Outside of a dog, a book is a man's best friend. Inside of a dog it's
too dark to read.

Groucho Marx


New Swedish PO file for 'gcc' (version 5.1.0)

2015-05-24 Thread Translation Project Robot
Hello, gentle maintainer.

This is a message from the Translation Project robot.

A revised PO file for textual domain 'gcc' has been submitted
by the Swedish team of translators.  The file is available at:

http://translationproject.org/latest/gcc/sv.po

(This file, 'gcc-5.1.0.sv.po', has just now been sent to you in
a separate email.)

All other PO files for your package are available in:

http://translationproject.org/latest/gcc/

Please consider including all of these in your next release, whether
official or a pretest.

Whenever you have a new distribution with a new version number ready,
containing a newer POT file, please send the URL of that distribution
tarball to the address below.  The tarball may be just a pretest or a
snapshot, it does not even have to compile.  It is just used by the
translators when they need some extra translation context.

The following HTML page has been updated:

http://translationproject.org/domain/gcc.html

If any question arises, please contact the translation coordinator.

Thank you for all your work,

The Translation Project robot, in the
name of your translation coordinator.
coordina...@translationproject.org