Re: [PATCH] genmatch fix (PR tree-optimization/71563)

2017-01-01 Thread Jakub Jelinek
On Thu, Dec 29, 2016 at 10:18:34PM +0100, Jakub Jelinek wrote:
> On Tue, Dec 20, 2016 at 09:45:03PM +0100, Jakub Jelinek wrote:
> > That is what I tried first, but there is some bug in genmatch.c that
> > prevents it.  The:
> >  (for vec (VECTOR_CST CONSTRUCTOR)
> >   (simplify
> >(shiftrotate @0 vec@1)
> > results in case SSA_NAME: being added to a switch:
> > case SSA_NAME:
> >   if (do_valueize (valueize, op1) != NULL_TREE)
> > {
> >   gimple *def_stmt = SSA_NAME_DEF_STMT (op1);
> >   if (gassign *def = dyn_cast  (def_stmt))
> > switch (gimple_assign_rhs_code (def))
> >   {
> >   case CONSTRUCTOR:
> > and the SSA_NAME@1 in another simplification resulted in another
> > case SSA_NAME:
> > into the same switch (rather than appending to the case SSA_NAME).
> 
> This patch attempts to deal with that.  The change for the new version of
> the patch with SSA_NAME@1 I'll post right away is (twice).  Two case SSA_NAME:
> in a single switch of course don't work well.

Oops, forgot to add the actual patch, here it is:

2017-01-02  Jakub Jelinek  

* genmatch.c (dt_node::gen_kids_1): If generic_exprs include SSA_NAME
and exprs_len || fns_len, emit the code for SSA_NAME next to the exprs
and fns handling, rather than in a separate case SSA_NAME.

--- gcc/genmatch.c.jj   2016-11-09 16:34:58.0 +0100
+++ gcc/genmatch.c  2016-12-29 22:11:25.088950033 +0100
@@ -2913,6 +2913,20 @@ dt_node::gen_kids_1 (FILE *f, int indent
 
   indent -= 6;
   fprintf_indent (f, indent, "}\n");
+  /* See if there is SSA_NAME among generic_exprs and if yes, emit it
+here rather than in the next loop.  */
+  for (unsigned i = 0; i < generic_exprs.length (); ++i)
+   {
+ expr *e = as_a (generic_exprs[i]->op);
+ id_base *op = e->operation;
+ if (*op == SSA_NAME && (exprs_len || fns_len))
+   {
+ fprintf_indent (f, indent + 4, "{\n");
+ generic_exprs[i]->gen (f, indent + 6, gimple);
+ fprintf_indent (f, indent + 4, "}\n");
+   }
+   }
+
   fprintf_indent (f, indent, "  break;\n");
 }
 
@@ -2922,6 +2936,9 @@ dt_node::gen_kids_1 (FILE *f, int indent
   id_base *op = e->operation;
   if (*op == CONVERT_EXPR || *op == NOP_EXPR)
fprintf_indent (f, indent, "CASE_CONVERT:\n");
+  else if (*op == SSA_NAME && (exprs_len || fns_len))
+   /* Already handled above.  */
+   continue;
   else
fprintf_indent (f, indent, "case %s:\n", op->id);
   fprintf_indent (f, indent, "  {\n");


Jakub


[libstdc++,doc] Use canonical address for C++ ABI

2017-01-01 Thread Gerald Pfeifer
When I updated those URLs in June 2015, I must have missed these
references in libstdc++ land.

Fixed thusly (via revision 244001), and I plan on backporting to 
GCC 6 and possibly GCC 5 later.

Gerald

2017-01-01  Gerald Pfeifer  

* doc/xml/faq.xml: Update address of C++ ABI link.
* doc/xml/manual/abi.xml: Ditto.

Index: doc/xml/faq.xml
===
--- doc/xml/faq.xml (revision 243528)
+++ doc/xml/faq.xml (working copy)
@@ -1230,7 +1230,7 @@
 details than for C, and most CPU designers (for good reasons elaborated
 below) have not stepped up to publish C++ ABIs.  Such an ABI has been
 defined for the Itanium architecture (see
-http://www.w3.org/1999/xlink; 
xlink:href="http://www.codesourcery.com/cxx-abi/;>C++
+http://www.w3.org/1999/xlink; 
xlink:href="http://mentorembedded.github.io/cxx-abi/;>C++
 ABI for Itanium) and that is used by G++ and other compilers
 as the de facto standard ABI on many common architectures (including x86).
 G++ can also use the ARM architecture's EABI, for embedded
Index: doc/xml/manual/abi.xml
===
--- doc/xml/manual/abi.xml  (revision 243528)
+++ doc/xml/manual/abi.xml  (working copy)
@@ -42,7 +42,7 @@
   virtual functions, etc. These details are defined as the compiler
   Application Binary Interface, or ABI. The GNU C++ compiler uses an
   industry-standard C++ ABI starting with version 3. Details can be
-  found in the http://www.w3.org/1999/xlink; 
xlink:href="http://mentorembedded.github.com/cxx-abi/abi.html;>ABI
+  found in the http://www.w3.org/1999/xlink; 
xlink:href="http://mentorembedded.github.io/cxx-abi/abi.html;>ABI
   specification.
 
 
@@ -736,7 +736,7 @@
 the way the compiler deals with this class in by-value return
 statements or parameters: instead of passing instances of this
 class in registers, the compiler will be forced to use memory. See the
-section on http://www.w3.org/1999/xlink; 
xlink:href="http://mentorembedded.github.com/cxx-abi/abi.html#calls;>Function
+section on http://www.w3.org/1999/xlink; 
xlink:href="http://mentorembedded.github.io/cxx-abi/abi.html#calls;>Function
 Calling Conventions and APIs
  of the C++ ABI documentation for further details.
 
@@ -1094,7 +1094,7 @@
 
   
http://www.w3.org/1999/xlink;
- xlink:href="http://www.codesourcery.com/cxx-abi/;>
+ xlink:href="http://mentorembedded.github.io/cxx-abi/;>
  C++ ABI Summary

   


Fix ICE with weakref

2017-01-01 Thread Jan Hubicka
Hi,
this patch fixes oversight in symtab_node::binds_to_current_def_p when dealing
with weakrefs.

Bootstrapped/regtested x86_64-linux, comitted.

Honza

PR middle-end/77674
* symtab.c (symtab_node::binds_to_current_def_p): Fix handling of
transparent aliases.

PR middle-end/77674
* g++.dg/torture/pr77674.C: New testcase.
Index: symtab.c
===
--- symtab.c(revision 243992)
+++ symtab.c(working copy)
@@ -2214,6 +2214,9 @@ symtab_node::binds_to_current_def_p (sym
 {
   if (!definition)
 return false;
+  if (transparent_alias)
+return definition
+  && get_alias_target()->binds_to_current_def_p (ref);
   if (decl_binds_to_current_def_p (decl))
 return true;
 
@@ -2225,8 +2228,6 @@ symtab_node::binds_to_current_def_p (sym
   if (DECL_EXTERNAL (decl))
 return false;
 
-  if (!externally_visible)
-debug ();
   gcc_assert (externally_visible);
 
   if (ref)
Index: testsuite/g++.dg/torture/pr77674.C
===
--- testsuite/g++.dg/torture/pr77674.C  (revision 0)
+++ testsuite/g++.dg/torture/pr77674.C  (working copy)
@@ -0,0 +1,15 @@
+// { dg-do compile }
+typedef struct { } __fsid_t;
+typedef unsigned long int pthread_t;
+extern "C" {
+  extern __inline __attribute__ ((__gnu_inline__)) int pthread_equal 
(pthread_t __thread1, pthread_t __thread2) throw ()   {
+  }
+}
+typedef pthread_t __gthread_t;
+static __typeof (pthread_equal)  __gthrw_pthread_equal __attribute__ 
((__weakref__ ("pthread_equal")));
+
+static inline int __gthread_equal (__gthread_t __t1, __gthread_t __t2)
+{
+  return __gthrw_pthread_equal (__t1, __t2);
+}
+


Re: [PATCH] [PR rtl-optimization/65618] Fix MIPS ADA bootstrap failure

2017-01-01 Thread Jeff Law

On 12/20/2016 07:38 AM, James Cowgill wrote:

Hi,

On 19/12/16 21:43, Jeff Law wrote:

On 12/19/2016 08:44 AM, James Cowgill wrote:

2016-12-16  James Cowgill  

PR rtl-optimization/65618
* emit-rtl.c (try_split): Update "after" when moving a
NOTE_INSN_CALL_ARG_LOCATION.

diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index 7de17454037..6be124ac038 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -3742,6 +3742,11 @@ try_split (rtx pat, rtx_insn *trial, int last)
next = NEXT_INSN (next))
 if (NOTE_KIND (next) == NOTE_INSN_CALL_ARG_LOCATION)
   {
+/* Advance after to the next instruction if it is about to
+   be removed.  */
+if (after == next)
+  after = NEXT_INSN (after);
+
 remove_insn (next);
 add_insn_after (next, insn, NULL);
 break;


So the thing I don't like when looking at this code is we set AFTER
immediately upon entry to try_split.  But we don't use it until near the
very end of try_split.  That's just asking for trouble.

Can we reasonably initialize AFTER just before it's used?


I wasn't sure but looking closer I think that would be fine. This patch
also works and does what Richard Sandiford suggested in the PR.

2016-12-20  James Cowgill  

PR rtl-optimization/65618
* emit-rtl.c (try_split): Move initialization of "before" and
"after" to just before the call to emit_insn_after_setloc.

OK.
jeff



Re: [PATCH] Replace DW_FORM_ref_sup with DW_FORM_ref_sup{4,8}

2017-01-01 Thread Jeff Law

On 12/20/2016 11:57 AM, Jakub Jelinek wrote:

Hi!

Recently DW_FORM_ref_sup (which is meant e.g. for dwz, gcc doesn't emit it)
has been renamed to DW_FORM_ref_sup4 (and changed so that it is always 4
byte) and DW_FORM_ref_sup8 (always 8 byte) has been added.

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

2016-12-20  Jakub Jelinek  

* dwarf2.def (DW_FORM_ref_sup): Renamed to ...
(DW_FORM_ref_sup4): ... this.  New form.
(DW_FORM_ref_sup8): New form.

OK.
jeff



Re: [PATCH] avoid non-printable characters in diagnostics (c/77620, c/77521)

2017-01-01 Thread Martin Sebor

On 12/31/2016 12:08 PM, Gerald Pfeifer wrote:

On Fri, 9 Sep 2016, Martin Sebor wrote:

I mentioned the hex vs octal notation to invite input into which
of the two of them people would prefer to see used by the %qc and
qs directives, and whether it's worth considering changing the %qE
directive to use the same notation as well, for consistency (and
to help with readability if there is consensus that one is clearer
than the other).


I do think hex is the way to go, and that it would be good to be
consistent across the board.

(All e-mail alert, but I don't think I saw a response to that.)


What I meant by ambiguity is for example a string like "\1234"
where it's not obvious where the octal sequence ends.  Is it '\1'
followed  by "234" or '\12' followed by "34" or '\123' followed
by "4"?  (It's only possible to tell if one knows that GCC always
uses three digits for the octal character, but not everyone knows
that.)


Agreed.  And octal notation is just not very common today, too,
I'd argue.


Thanks.  I think the thread petered out after that and I didn't
remember to get back to it and the still outstanding %qE problem
where GCC uses the octal base and doesn't convert the character
values to unsigned char, resulting in confusing output like that
below:

$ echo 'constexpr int i = "\x80";' | gcc -S -Wall -Wextra -xc++ -
:1:19: error: invalid conversion from ‘const char*’ to ‘int’ 
[-fpermissive]
:1:19: error: ‘(int)((const char*)"\3777600")’ is not a 
constant expression


(The still unconfirmed bug 77573 came out of my tests of the fix
for the related bugs in the subject and tracks the wide character
part of the problem.)

Martin


Re: Avoid excessively-big hash tables in empty-add cycles

2017-01-01 Thread Jeff Law

On 12/23/2016 10:54 AM, Richard Sandiford wrote:

A big source of cache misses when compiling a recent version of
gimple-match.ii was the call to cv_cache.empty () in clear_cv_cache.
The problem was that at one early point the hash table had grown
to 8191 entries (128k on LP64 hosts).  It then stayed at that size
for the rest of the compilation, even though subsequent uses needed
only a small number of entries (usually fewer than ten).  We would
still clear the whole 128k each time clear_cv_cache was called.

empty() already looks for cases where the hash table is very big
and cuts it down.  At the moment it fires when the table is 1M
in size and reduces it to the next selected prime above 1K (so
almost 2K in practice).  One fix would have been to lower the
threshold, but that didn't feel like the right approach.  Reducing
the current limit of 1M by a factor of 8 would be pretty significant
on its own, but I think this cv_cache behaviour would have been a
problem even with 64k or 32k tables.

I think the existing check is really for cases in which even a
well-populated table would need to be shrunk rather than cleared.
Here the problem isn't that the table is excessively big in
absolute terms, more that one outlier has made the table much
too big for the general case.

traverse() already shrinks the table if it's "too empty",
which is taken to be if:

  no. elements * 8 < capacity && capacity > 32

So an alternative would be to apply the same test (and the same choice
of shrunken size) to empty_slow too.  The patch below does this.
It gives a 2.5% improvement in gimple-match.ii compile time at -O0 -g
and doesn't seem to adversely affect any other tests I've tried.

Of course, there's a theoretical risk of a table alternating between
one large element count and one small element count.  If there was a
factor of eight difference between the two, we could shrink the table
on seeing each small element count, then grow it again when adding the
large number of elements.  That seems pretty unlikely in practice
though.

Also, empty_slow() does involve a traversal if some form of manual
gc is needed on active elements, so trying to recover from an outlier
should have even more benefit there.  (cv_cache uses automatic gc and so
the traversal gets optimised away.)

The calculation of the existing 1M threshold was assuming that each
entry was pointer-sized.  This patch makes it use the actual size of the
entry instead.

Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?

Thanks,
Richard

[Sorry for the verbose write-up]


gcc/
* hash-table.h (hash_table::too_empty_p): New function.
(hash_table::expand): Use it.
(hash_table::traverse): Likewise.
(hash_table::empty_slot): Use sizeof (value_type) instead of
sizeof (PTR) to convert bytes to elements.  Shrink the table
if the current size is excessive for the current number of
elements.

OK.
jeff



Split CALL predictor to direct/indirect/polymorphic variant

2017-01-01 Thread Jan Hubicka
Hi,
this patch splits call predictor to direct/indirect/polymorphic variant.
The motivation is that the predictor seems to do poor job on GAP benchmark
predicting that path containing an indirect call is unlikely. These calls
are quite specific, so it makes sense to have separate predictor for them.

The values was measured by Martin on SPEC2k6 and will need tweaking to get
gap performance back. I think this is OK given that we have quite small
sample of benchmarks having indirect call in the hot loop, but I would like
to do that incrementally.

Bootstrapped/regtested x86_64-linux, comitted.

Honza

PR middle-end/77484
* predict.def (PRED_CALL): Update hitrate.
(PRED_INDIR_CALL, PRED_POLYMORPHIC_CALL): New predictors.
* predict.c (tree_estimate_probability_bb): Split CALL predictor
into direct/indirect/polymorphic variants.
Index: predict.def
===
--- predict.def (revision 243992)
+++ predict.def (working copy)
@@ -116,7 +116,13 @@ DEF_PREDICTOR (PRED_TREE_OPCODE_NONEQUAL
 DEF_PREDICTOR (PRED_TREE_FPOPCODE, "fp_opcode (on trees)", HITRATE (90), 0)
 
 /* Branch guarding call is probably taken.  */
-DEF_PREDICTOR (PRED_CALL, "call", HITRATE (67), 0)
+DEF_PREDICTOR (PRED_CALL, "call", HITRATE (55), 0)
+
+/* PRED_CALL is not very reliable predictor and it turns out to be even
+   less reliable for indirect calls and polymorphic calls.  For spec2k6
+   the predictio nis slightly in the direction of taking the call.  */
+DEF_PREDICTOR (PRED_INDIR_CALL, "indirect call", HITRATE (51), 0)
+DEF_PREDICTOR (PRED_POLYMORPHIC_CALL, "polymorphic call", HITRATE (58), 0)
 
 /* Recursive calls are usually not taken or the function will recurse
indefinitely.  */
Index: predict.c
===
--- predict.c   (revision 243992)
+++ predict.c   (working copy)
@@ -2786,7 +2786,12 @@ tree_estimate_probability_bb (basic_bloc
 something exceptional.  */
  && gimple_has_side_effects (stmt))
{
- predict_edge_def (e, PRED_CALL, NOT_TAKEN);
+ if (gimple_call_fndecl (stmt))
+   predict_edge_def (e, PRED_CALL, NOT_TAKEN);
+ else if (virtual_method_call_p (gimple_call_fn (stmt)))
+   predict_edge_def (e, PRED_POLYMORPHIC_CALL, TAKEN);
+ else
+   predict_edge_def (e, PRED_INDIR_CALL, TAKEN);
  break;
}
}


Re: [C++ PATCH] Implement LWG2296 helper intrinsic

2017-01-01 Thread Jakub Jelinek
On Sun, Jan 01, 2017 at 10:27:24AM -0400, Gerald Pfeifer wrote:
> On Fri, 7 Oct 2016, Jakub Jelinek wrote:
> > The following patch adds __builtin_addressof with the semantics it has in
> > clang, i.e. it is a constexpr & operator alternative that never uses the
> > overloaded & operator.
> 
> Nice!
> 
> Are you planning to document this in gcc-7/changes.html ?

We shouldn't document the builtin, but that std::addressof is usable in
constexpr contexts.  I'll defer documentation thereof to Jon, together with
other libstdc++ changes.

Jakub


Re: [C++ PATCH] Implement LWG2296 helper intrinsic

2017-01-01 Thread Gerald Pfeifer
On Fri, 7 Oct 2016, Jakub Jelinek wrote:
> The following patch adds __builtin_addressof with the semantics it has in
> clang, i.e. it is a constexpr & operator alternative that never uses the
> overloaded & operator.

Nice!

Are you planning to document this in gcc-7/changes.html ?

Gerald


[PATCH] Small contrib/update-copyright.py tweaks

2017-01-01 Thread Jakub Jelinek
Hi!

We don't have libjava anymore, on the other side gcc.dg/params/README
needs to be skipped, because it contains foreign historical copyright.

Committed as obvious.

2017-01-01  Jakub Jelinek  

* update-copyright.py (TestsuiteFilter): Skip params/README.
(GCCCmdLine): Remove libjava and libjava/testsuite add_dir.

--- contrib/update-copyright.py (revision 243992)
+++ contrib/update-copyright.py (revision 243993)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 #
-# Copyright (C) 2013-2016 Free Software Foundation, Inc.
+# Copyright (C) 2013-2017 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
@@ -34,9 +34,9 @@
 # all copyright notices (and possibly at other times to check whether
 # new files have been added with old years).  On the other hand:
 #
-#update-copyright.pl --this-year libjava
+#update-copyright.pl --this-year libitm
 #
-# would run the script on just libjava/.
+# would run the script on just libitm/.
 #
 # Note that things like --version output strings must be updated before
 # this script is run.  There's already a separate procedure for that.
@@ -585,6 +585,9 @@ class TestsuiteFilter (GenericFilter):
 # and isn't updated.
 if filename == 'README' and os.path.basename (dir) == 'g++.niklas':
 return True
+# Similarly params/README.
+if filename == 'README' and os.path.basename (dir) == 'params':
+return True
 return GenericFilter.skip_file (self, dir, filename)
 
 class LibCppFilter (GenericFilter):
@@ -732,8 +735,6 @@ class GCCCmdLine (CmdLine):
 self.add_dir ('libgomp')
 self.add_dir ('libiberty')
 self.add_dir ('libitm')
-self.add_dir ('libjava', LibJavaFilter())
-self.add_dir (os.path.join ('libjava', 'testsuite'), TestsuiteFilter())
 self.add_dir ('libobjc')
 # liboffloadmic is imported from upstream.
 self.add_dir ('libquadmath')

Jakub


[committed] Update copyright years

2017-01-01 Thread Jakub Jelinek
Hi!

I've committed following patch as obvious and rotated a few ChangeLog files.

2017-01-01  Jakub Jelinek  

gcc/
* gcc.c (process_command): Update copyright notice dates.
* gcov-dump.c (print_version): Ditto.
* gcov.c (print_version): Ditto.
* gcov-tool.c (print_version): Ditto.
* gengtype.c (create_file): Ditto.
* doc/cpp.texi: Bump @copying's copyright year.
* doc/cppinternals.texi: Ditto.
* doc/gcc.texi: Ditto.
* doc/gccint.texi: Ditto.
* doc/gcov.texi: Ditto.
* doc/install.texi: Ditto.
* doc/invoke.texi: Ditto.
gcc/fortran/
* gfortranspec.c (lang_specific_driver): Update copyright notice
dates.
* gfc-internals.texi: Bump @copying's copyright year.
* gfortran.texi: Ditto.
* intrinsic.texi: Ditto.
* invoke.texi: Ditto.
gcc/ada/
* gnat_ugn.texi: Bump @copying's copyright year.
* gnat_rm.texi: Likewise.
gcc/go/
* gccgo.texi: Bump @copyrights-go year.
libitm/
* libitm.texi: Bump @copying's copyright year.
libgomp/
* libgomp.texi: Bump @copying's copyright year.
libquadmath/
* libquadmath.texi: Bump @copying's copyright year.

--- libitm/libitm.texi  (revision 232052)
+++ libitm/libitm.texi  (revision 232053)
@@ -7,7 +7,7 @@
 
 
 @copying
-Copyright @copyright{} 2011-2016 Free Software Foundation, Inc.
+Copyright @copyright{} 2011-2017 Free Software Foundation, Inc.
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.2 or
--- libgomp/libgomp.texi(revision 232052)
+++ libgomp/libgomp.texi(revision 232053)
@@ -7,7 +7,7 @@
 
 
 @copying
-Copyright @copyright{} 2006-2016 Free Software Foundation, Inc.
+Copyright @copyright{} 2006-2017 Free Software Foundation, Inc.
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
--- libquadmath/libquadmath.texi(revision 232052)
+++ libquadmath/libquadmath.texi(revision 232053)
@@ -6,7 +6,7 @@
 @c %**end of header
 
 @copying
-Copyright @copyright{} 2010-2016 Free Software Foundation, Inc.
+Copyright @copyright{} 2010-2017 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
--- gcc/doc/cpp.texi(revision 232052)
+++ gcc/doc/cpp.texi(revision 232053)
@@ -10,7 +10,7 @@
 
 @copying
 @c man begin COPYRIGHT
-Copyright @copyright{} 1987-2016 Free Software Foundation, Inc.
+Copyright @copyright{} 1987-2017 Free Software Foundation, Inc.
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
--- gcc/doc/gcc.texi(revision 232052)
+++ gcc/doc/gcc.texi(revision 232053)
@@ -40,7 +40,7 @@
 @c %**end of header
 
 @copying
-Copyright @copyright{} 1988-2016 Free Software Foundation, Inc.
+Copyright @copyright{} 1988-2017 Free Software Foundation, Inc.
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
--- gcc/doc/cppinternals.texi   (revision 232052)
+++ gcc/doc/cppinternals.texi   (revision 232053)
@@ -18,7 +18,7 @@
 @ifinfo
 This file documents the internals of the GNU C Preprocessor.
 
-Copyright (C) 2000-2016 Free Software Foundation, Inc.
+Copyright (C) 2000-2017 Free Software Foundation, Inc.
 
 Permission is granted to make and distribute verbatim copies of
 this manual provided the copyright notice and this permission notice
@@ -47,7 +47,7 @@ into another language, under the above c
 @page
 @vskip 0pt plus 1filll
 @c man begin COPYRIGHT
-Copyright @copyright{} 2000-2016 Free Software Foundation, Inc.
+Copyright @copyright{} 2000-2017 Free Software Foundation, Inc.
 
 Permission is granted to make and distribute verbatim copies of
 this manual provided the copyright notice and this permission notice
--- gcc/doc/gccint.texi (revision 232052)
+++ gcc/doc/gccint.texi (revision 232053)
@@ -26,7 +26,7 @@
 @c %**end of header
 
 @copying
-Copyright @copyright{} 1988-2016 Free Software Foundation, Inc.
+Copyright @copyright{} 1988-2017 Free Software Foundation, Inc.
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
--- gcc/doc/invoke.texi (revision 232052)
+++ gcc/doc/invoke.texi (revision 232053)
@@ -8,7 +8,7 @@
 @c man end
 
 @c man begin COPYRIGHT
-Copyright @copyright{} 1988-2016 Free Software Foundation, Inc.
+Copyright @copyright{} 1988-2017 Free Software Foundation, Inc.
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
--- gcc/doc/gcov.texi   (revision 232052)
+++ gcc/doc/gcov.texi   (revision 232053)
@@ -4,7 +4,7 @@
 
 

[PATCH] PR 78534 Change character length from int to size_t

2017-01-01 Thread Janne Blomqvist
In order to handle large character lengths on (L)LP64 targets, switch
the GFortran character length from an int to a size_t.

This is an ABI change, as procedures with character arguments take
hidden arguments with the character length.

I also changed the _size member in vtables from int to size_t, as
there were some cases where character lengths and sizes were
apparently mixed up and caused regressions otherwise. Although I
haven't tested, this might enable very large derived types as well.

Also, as there are some places in the frontend were negative character
lengths are used as special flag values, in the frontend the character
length is handled as a signed variable of the same size as a size_t,
although in the runtime library it really is size_t.

I haven't changed the character length variables for the co-array
intrinsics, as this is something that may need to be synchronized with
OpenCoarrays.

Another change in this place is that the algorithm for
gfc_trans_string_copy has been rewritten to avoid a
-Wstringop-overflow warning.

This is v3 of the patch. All the issues pointed out by FX's review of
v2 have been fixed. In particular, there are now new functions
gfc_mpz_get_hwi and gfc_mpz_set_hwi, similar to the GMP functions
mpz_get_si and mpz_set_si, except that they get/set a HOST_WIDE_INT
instead of a long value. Similarly, gfc_get_int_expr now takes a
HOST_WIDE_INT instead of a long, gfc_extract_long is replaced by
gfc_extract_hwi. Also, the preliminary work to handle
gfc_charlen_type_node being unsigned has been removed.

Regtested on x86_64-pc-linux-gnu, Ok for trunk?

frontend:

2017-01-01  Janne Blomqvist  

PR fortran/78534
PR fortran/66310
* class.c (gfc_find_derived_vtab): Use gfc_size_kind instead of
hardcoded kind.
(find_intrinsic_vtab): Likewise.
* expr.c (gfc_get_character_expr): Length parameter of type
gfc_charlen_t.
(gfc_get_int_expr): Value argument of type HOST_WIDE_INT.
(gfc_extract_hwi): New function.
(simplify_const_ref): Make string_len of type gfc_charlen_t.
(gfc_simplify_expr): Use HOST_WIDE_INT for substring refs.
* gfortran.h (gfc_mpz_get_hwi): New prototype.
(gfc_mpz_set_hwi): Likewise.
(gfc_charlen_t): New typedef.
(gfc_expr): Use gfc_charlen_t for character lengths.
(gfc_size_kind): New extern variable.
(gfc_extract_hwi): New prototype.
(gfc_get_character_expr): Use gfc_charlen_t for character length.
(gfc_get_int_expr): Use HOST_WIDE_INT type for value argument.
* iresolve.c (gfc_resolve_repeat): Pass string length directly without
temporary, use gfc_charlen_int_kind.
* match.c (select_intrinsic_set_tmp): Use HOST_WIDE_INT for charlen.
* misc.c (gfc_mpz_get_hwi): New function.
(gfc_mpz_set_hwi): New function.
* module.c (atom_int): Change type from int to HOST_WIDE_INT.
(parse_integer): Don't complain about large integers.
(write_atom): Use HOST_WIDE_INT for integers.
(mio_integer): Handle integer type mismatch.
(mio_hwi): New function.
(mio_intrinsic_op): Use HOST_WIDE_INT.
(mio_array_ref): Likewise.
(mio_expr): Likewise.
* resolve.c (resolve_select_type): Use HOST_WIDE_INT for charlen,
use snprintf.
(resolve_charlen): Use mpz_sgn to determine sign.
* simplify.c (gfc_simplify_repeat): Use HOST_WIDE_INT/gfc_charlen_t
instead of long.
* target-memory.c (size_character): Length argument of type
gfc_charlen_t.
(gfc_encode_character): Likewise.
(gfc_interpret_character): Use gfc_charlen_t.
* target-memory.h (gfc_encode_character): Modify prototype.
* trans-array.c (get_array_ctor_var_strlen): Use
gfc_conv_mpz_to_tree_type.
* trans-const.c (gfc_conv_mpz_to_tree_type): New function.
* trans-const.h (gfc_conv_mpz_to_tree_type): New prototype.
* trans-expr.c (gfc_class_len_or_zero_get): Build const of type
gfc_charlen_type_node.
(gfc_conv_intrinsic_to_class): Use gfc_charlen_int_kind instead of
4, fold_convert to correct type.
(gfc_conv_class_to_class): Build const of type size_type_node for
size.
(gfc_copy_class_to_class): Likewise.
(gfc_conv_string_length): Use same type in expression.
(gfc_conv_substring): Likewise, use HOST_WIDE_INT for charlen.
(gfc_conv_string_tmp): Make sure len is of the right type.
(gfc_conv_concat_op): Use same type in expression.
(gfc_conv_procedure_call): Likewise.
(gfc_trans_string_copy): Rewrite to avoid -Wstringop-overflow
warning in generated code.
(alloc_scalar_allocatable_for_subcomponent_assignment):
fold_convert to right type.
(gfc_trans_subcomponent_assign): Likewise.
(trans_class_vptr_len_assignment): Build const of