Re: [Patch, Fortran] PR 85841: [F2018] reject deleted features

2018-05-21 Thread Janus Weil
2018-05-21 18:57 GMT+02:00 Steve Kargl :
> On Mon, May 21, 2018 at 12:14:13PM +0200, Janus Weil wrote:
>>
>> So, here is the promised follow-up patch. It mostly removes
>> GFC_STD_F2008_TS and replaces it by GFC_STD_F2018 in a mechanical
>> manner. Plus, it fixes the resulting fallout in the testsuite and
>> updates the documentation. The non-mechanical parts are libgfortran.h
>> and options.c. Regtests cleanly. Ok for trunk with a suitable
>> ChangeLog?
>
> Looks good to me.

I have now also committed this follow-up as r260499 (after checking
that not only the gfortran testsuite is regression-free, but also the
Fortran part of the libgomp testsuite).

Cheers,
Janus


Re: [PATCH 1/2] extend.texi: update Global Register Variables section

2018-05-21 Thread Alexander Monakov
On Mon, 21 May 2018, Jeff Law wrote:
> Whether or not a global register is saved in the prologue and restored
> in the epilogue is actually a function of the target's prologue/epilogue
> implementation.
> 
> So ISTM this paragraph needs to be refined a bit.  Essentially it may or
> may not change the ABI.  It really depends on the target implementation.

As far as I can tell, that would be a target bug; if global registers are
restored in epilogues, they are not useful.

Alexander


Re: libcpp PATCH to avoid deprecated copy assignment

2018-05-21 Thread Jason Merrill
On Mon, May 21, 2018 at 9:25 PM, Gerald Pfeifer  wrote:
> Hi Jason,
>
> I'm afraid this change
>
>   2018-05-17  Jason Merrill  
>
> * line-map.c (linemap_init): Use placement new.
> * system.h: #include .
>
> broke bootstrap on systems using libc++ instead of libstdc++ (such
> as newer versions of FreeBSD, reported on FreeBSD 11 but could also
> be noticable on Darwin):
>
>   gmake[3]: Entering directory 
> '/scratch/tmp/gerald/OBJ-0522-0110/build-x86_64-unknown-freebsd11.2/libcpp'
>   c++ -std=gnu++98  -I/scratch/tmp/gerald/gcc-HEAD/libcpp -I.
>   -I/scratch/tmp/gerald/gcc-HEAD/libcpp/../include
>   -I/scratch/tmp/gerald/gcc-HEAD/libcpp/include
>   -g -O2 -W -Wall -Wno-narrowing -Wwrite-strings -Wmissing-format-attribute
>   -pedantic -Wno-long-long  -fno-exceptions -fno-rtti
>   -I/scratch/tmp/gerald/gcc-HEAD/libcpp -I.
>   -I/scratch/tmp/gerald/gcc-HEAD/libcpp/../include
>   -I/scratch/tmp/gerald/gcc-HEAD/libcpp/include   -c -o charset.o
>   -MT charset.o -MMD -MP -MF .deps/charset.Tpo
>   /scratch/tmp/gerald/gcc-HEAD/libcpp/charset.c
>   In file included from 
> /scratch/tmp/gerald/gcc-HEAD/libcpp/charset.c:21:/scratch/tmp/gerald/gcc-HEAD/libcpp/system.h:435:9:
>  warning: keyword is hidden by macro definition [-Wkeyword-macro]
>   #define true 1
>   ^
>   /scratch/tmp/gerald/gcc-HEAD/libcpp/system.h:436:9: warning: keyword is 
> hidden by macro definition [-Wkeyword-macro]
>   #define false 0
>   ^
>   In file included from /scratch/tmp/gerald/gcc-HEAD/libcpp/charset.c:21:
>   In file included from /scratch/tmp/gerald/gcc-HEAD/libcpp/system.h:442:
>   In file included from /usr/include/c++/v1/new:91:
>   /usr/include/c++/v1/exception:180:5: error: no member named 'fancy_abort' 
> in namespace 'std::__1'; did you mean simply 'fancy_abort'?
>   _VSTD::abort();
>   ^~~
>   /usr/include/c++/v1/__config:447:15: note: expanded from macro '_VSTD'
>   #define _VSTD std::_LIBCPP_NAMESPACE
> ^
>   /scratch/tmp/gerald/gcc-HEAD/libcpp/system.h:399:13: note: 'fancy_abort' 
> declared here
>   extern void fancy_abort (const char *, int, const char *) 
> ATTRIBUTE_NORETURN;
>   ^
>
>
> The problem appears to be the added #include ; we had a similar
> situation last October, cf. the thread starting at
>
>   https://gcc.gnu.org/ml/gcc-patches/2017-10/threads.html#01478
>
> Simply adding #include  before #include  does not help
> in this case, though; I just tried that.

Does moving the #include  up higher help?
commit 76804c272544cdc90bd2b468f52f414e18f1c6da
Author: Jason Merrill 
Date:   Mon May 21 22:02:11 2018 -0400

* system.h: #include  earlier.

diff --git a/libcpp/system.h b/libcpp/system.h
index 76420e16cfb..3fde817cb83 100644
--- a/libcpp/system.h
+++ b/libcpp/system.h
@@ -37,6 +37,10 @@ along with GCC; see the file COPYING3.  If not see
 
 #include 
 
+#ifdef __cplusplus
+#include 
+#endif
+
 /* Define a generic NULL if one hasn't already been defined.  */
 #ifndef NULL
 #define NULL 0
@@ -438,10 +442,6 @@ extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN;
 /* Some compilers do not allow the use of unsigned char in bitfields.  */
 #define BOOL_BITFIELD unsigned int
 
-#ifdef __cplusplus
-#include 
-#endif
-
 /* Poison identifiers we do not want to use.  */
 #if (GCC_VERSION >= 3000)
 #undef calloc


Re: C++ PATCH to implement P0614R1, Range-based for statements with initializer (take 2)

2018-05-21 Thread Jason Merrill
On Mon, May 21, 2018 at 7:34 PM, Marek Polacek  wrote:
> The previous version of this patch got confused by
>
>   for (int i = 0; n > 0 ? true : false; i++)
> // ...
>
> because even though we see a ; followed by a :, it's not a range-based for 
> with
> an initializer.  I find it very strange that this didn't show up during the
> regtest.
>
> To fix this, I had to uglify range_based_for_with_init_p to also check for a 
> ?.
> Yuck.

Perhaps cp_parser_skip_to_closing_parenthesis_1 should handle balanced
?: like ()/[]/{}.

Jason


Re: [PATCH v2, rs6000] (PR84302) Fix _mm_slli_epi{32,64} for shift values 16 through 31 and negative

2018-05-21 Thread Gerald Pfeifer
On Mon, 23 Apr 2018, Segher Boessenkool wrote:
>> Can I push this to ibm/gcc-7-branch?
> Don't ask me, I'm not maintainer of that branch.  I would point you
> to the wiki page explaining who owns it, but i cannot find that page.

https://gcc.gnu.org/svn.html

Except that the ibm/gcc-7-branch is not listed there, just a couple
of other ibm/ branches.

Perhaps you guys can address that?

Gerald


Re: libcpp PATCH to avoid deprecated copy assignment

2018-05-21 Thread Gerald Pfeifer
Hi Jason,

I'm afraid this change

  2018-05-17  Jason Merrill  

* line-map.c (linemap_init): Use placement new.
* system.h: #include .

broke bootstrap on systems using libc++ instead of libstdc++ (such 
as newer versions of FreeBSD, reported on FreeBSD 11 but could also
be noticable on Darwin):

  gmake[3]: Entering directory 
'/scratch/tmp/gerald/OBJ-0522-0110/build-x86_64-unknown-freebsd11.2/libcpp'
  c++ -std=gnu++98  -I/scratch/tmp/gerald/gcc-HEAD/libcpp -I. 
  -I/scratch/tmp/gerald/gcc-HEAD/libcpp/../include
  -I/scratch/tmp/gerald/gcc-HEAD/libcpp/include  
  -g -O2 -W -Wall -Wno-narrowing -Wwrite-strings -Wmissing-format-attribute 
  -pedantic -Wno-long-long  -fno-exceptions -fno-rtti
  -I/scratch/tmp/gerald/gcc-HEAD/libcpp -I. 
  -I/scratch/tmp/gerald/gcc-HEAD/libcpp/../include 
  -I/scratch/tmp/gerald/gcc-HEAD/libcpp/include   -c -o charset.o 
  -MT charset.o -MMD -MP -MF .deps/charset.Tpo
  /scratch/tmp/gerald/gcc-HEAD/libcpp/charset.c
  In file included from 
/scratch/tmp/gerald/gcc-HEAD/libcpp/charset.c:21:/scratch/tmp/gerald/gcc-HEAD/libcpp/system.h:435:9:
 warning: keyword is hidden by macro definition [-Wkeyword-macro]
  #define true 1
  ^
  /scratch/tmp/gerald/gcc-HEAD/libcpp/system.h:436:9: warning: keyword is 
hidden by macro definition [-Wkeyword-macro]
  #define false 0
  ^
  In file included from /scratch/tmp/gerald/gcc-HEAD/libcpp/charset.c:21:
  In file included from /scratch/tmp/gerald/gcc-HEAD/libcpp/system.h:442:
  In file included from /usr/include/c++/v1/new:91:
  /usr/include/c++/v1/exception:180:5: error: no member named 'fancy_abort' in 
namespace 'std::__1'; did you mean simply 'fancy_abort'?
  _VSTD::abort();
  ^~~
  /usr/include/c++/v1/__config:447:15: note: expanded from macro '_VSTD'
  #define _VSTD std::_LIBCPP_NAMESPACE
^
  /scratch/tmp/gerald/gcc-HEAD/libcpp/system.h:399:13: note: 'fancy_abort' 
declared here
  extern void fancy_abort (const char *, int, const char *) 
ATTRIBUTE_NORETURN;
  ^


The problem appears to be the added #include ; we had a similar
situation last October, cf. the thread starting at

  https://gcc.gnu.org/ml/gcc-patches/2017-10/threads.html#01478

Simply adding #include  before #include  does not help
in this case, though; I just tried that.

Gerald


Re: [PATCH] Make __ibm128 a distinct type, patch 2 of 2 (PR 85657)

2018-05-21 Thread Segher Boessenkool
On Fri, May 18, 2018 at 07:27:15PM -0400, Michael Meissner wrote:
> Here is patch 2 of 2 to make __ibm128 a distinct type.  This patch makes the
> long double pack and unpack builtins only work if the long double type is IBM
> extended double.  It adds two new builtins to pack and unpack __ibm128 types.
> 
> This has been tested on a little endian power8 system with bootstrap and
> regression test (with the previous patch also applied).  Can I check this into
> the trunk and the GCC 8 branch?
> 
> [gcc]
> 2018-05-18  Michael Meissner  
> 
>   PR target/85657
>   * config/rs6000/rs6000-builtin.def (BU_IBM128_2): New helper macro
>   for __builtin_{,un}pack_ibm128.
>   (PACK_IF): Declare __builtin_{,un}pack_ibm128.
>   (UNPACK_IF): Likewise.
>   * config/rs6000/rs6000.c (rs6000_builtin_mask_calculate): The mask
>   for long double builtins (RS6000_BTM_LDBL128) requires that long
>   double is IBM extended double.
>   (rs6000_invalid_builtin): Add a new error message if the long
>   double {,un}pack builtins are used when long double is IEEE
>   128-bit floating point.
>   * config/rs6000/rs6000.h (RS6000_BTM_LDBL128): Update comment.
>   * doc/extend.texi (PowerPC builtins): Update documention for
>   __builtin_{,un}pack_longdouble.  Add documentation for
>   __builtin_{,un}pack_ibm128.
> 
> [gcc/testsuite]
> 2018-05-18  Michael Meissner  
> 
>   PR target/85657
>   * gcc.target/powerpc/pr85657-4.c: New tests for pack/unpack
>   __ibm128 builtin functions, and whether an appropriate error
>   message is generate if the long double pack/unpack are used when
>   long double is IEEE 128.
>   * gcc.target/powerpc/pr85657-5.c: Likewise.
>   * gcc.target/powerpc/pr85657-6.c: Likewise.

-ENOPATCH?


Segher


C++ PATCH to implement P0614R1, Range-based for statements with initializer (take 2)

2018-05-21 Thread Marek Polacek
The previous version of this patch got confused by

  for (int i = 0; n > 0 ? true : false; i++)
// ...

because even though we see a ; followed by a :, it's not a range-based for with
an initializer.  I find it very strange that this didn't show up during the
regtest.

To fix this, I had to uglify range_based_for_with_init_p to also check for a ?.
Yuck.

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

2018-05-21  Marek Polacek  

Implement P0614R1, Range-based for statements with initializer.
* parser.c (cp_parser_range_based_for_with_init_p): New.
(cp_parser_init_statement): Use it.  Parse the optional init-statement
for a range-based for loop.

* g++.dg/cpp2a/range-for1.C: New test.
* g++.dg/cpp2a/range-for2.C: New test.
* g++.dg/cpp2a/range-for3.C: New test.
* g++.dg/cpp2a/range-for4.C: New test.
* g++.dg/cpp2a/range-for5.C: New test.
* g++.dg/cpp2a/range-for6.C: New test.
* g++.dg/cpp2a/range-for7.C: New test.

diff --git gcc/cp/parser.c gcc/cp/parser.c
index 3f621911f12..2693cf37a3e 100644
--- gcc/cp/parser.c
+++ gcc/cp/parser.c
@@ -11255,6 +11255,52 @@ cp_parser_statement_seq_opt (cp_parser* parser, tree 
in_statement_expr)
 }
 }
 
+/* Return true if this is the C++20 version of range-based-for with
+   init-statement.  */
+
+static bool
+cp_parser_range_based_for_with_init_p (cp_parser *parser)
+{
+  bool r = false;
+  bool saw_query;
+
+  /* Save tokens so that we can put them back.  */
+  cp_lexer_save_tokens (parser->lexer);
+
+  /* There has to be an unnested ; followed by an unnested :.  */
+  if (cp_parser_skip_to_closing_parenthesis_1 (parser,
+  /*recovering=*/false,
+  CPP_SEMICOLON,
+  /*consume_paren=*/false) != -1)
+goto out;
+
+  /* We found the semicolon, eat it now.  */
+  cp_lexer_consume_token (parser->lexer);
+
+  /* Don't get confused by an unnested "?:" operator.  This requires a nested
+ stashing of tokens.  */
+  cp_lexer_save_tokens (parser->lexer);
+  saw_query
+= cp_parser_skip_to_closing_parenthesis_1 (parser, /*recovering=*/false,
+  CPP_QUERY,
+  /*consume_paren=*/false) == -1;
+  cp_lexer_rollback_tokens (parser->lexer);
+  if (saw_query)
+goto out;
+
+  /* Now look for ':' that is not nested in () or {}.  */
+  r = (cp_parser_skip_to_closing_parenthesis_1 (parser,
+   /*recovering=*/false,
+   CPP_COLON,
+   /*consume_paren=*/false) == -1);
+
+out:
+  /* Roll back the tokens we skipped.  */
+  cp_lexer_rollback_tokens (parser->lexer);
+
+  return r;
+}
+
 /* Return true if we're looking at (init; cond), false otherwise.  */
 
 static bool
@@ -12299,7 +12345,7 @@ cp_parser_iteration_statement (cp_parser* parser, bool 
*if_p, bool ivdep,
  simple-declaration  */
 
 static bool
-cp_parser_init_statement (cp_parser* parser, tree *decl)
+cp_parser_init_statement (cp_parser *parser, tree *decl)
 {
   /* If the next token is a `;', then we have an empty
  expression-statement.  Grammatically, this is also a
@@ -12312,6 +12358,29 @@ cp_parser_init_statement (cp_parser* parser, tree 
*decl)
   bool is_range_for = false;
   bool saved_colon_corrects_to_scope_p = parser->colon_corrects_to_scope_p;
 
+  /* Try to parse the init-statement.  */
+  if (cp_parser_range_based_for_with_init_p (parser))
+   {
+ tree dummy;
+ cp_parser_parse_tentatively (parser);
+ /* Parse the declaration.  */
+ cp_parser_simple_declaration (parser,
+   /*function_definition_allowed_p=*/false,
+   );
+ cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
+ if (!cp_parser_parse_definitely (parser))
+   /* That didn't work, try to parse it as an expression-statement.  */
+   cp_parser_expression_statement (parser, NULL_TREE);
+
+ if (cxx_dialect < cxx2a)
+   {
+ pedwarn (cp_lexer_peek_token (parser->lexer)->location, 0,
+  "range-based % loops with initializer only "
+  "available with -std=c++2a or -std=gnu++2a");
+ *decl = error_mark_node;
+   }
+   }
+
   /* A colon is used in range-based for.  */
   parser->colon_corrects_to_scope_p = false;
 
@@ -12325,7 +12394,7 @@ cp_parser_init_statement (cp_parser* parser, tree *decl)
   parser->colon_corrects_to_scope_p = saved_colon_corrects_to_scope_p;
   if (cp_lexer_next_token_is (parser->lexer, CPP_COLON))
{
- /* It is a range-for, consume the ':' */
+ /* It is a range-for, 

New Spanish PO file for 'gcc' (version 8.1.0)

2018-05-21 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 Spanish team of translators.  The file is available at:

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

(This file, 'gcc-8.1.0.es.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.




Re: [PATCH] use string length to relax -Wstringop-overflow for nonstrings (PR 85623)

2018-05-21 Thread Jeff Law
On 05/10/2018 01:26 PM, Martin Sebor wrote:
> GCC 8.1 warns for unbounded (and some bounded) string comparisons
> involving arrays declared attribute nonstring (i.e., char arrays
> that need not be nul-terminated).  For instance:
> 
>   extern __attribute__((nonstring)) char a[4];
> 
>   int f (void)
>   {
> return strncmp (a, "123", sizeof a);
>   }
> 
>   warning: ‘strcmp’ argument 1 declared attribute ‘nonstring’
> 
> Note that the warning refers to strcmp even though the call in
> the source is to strncmp, because prior passes transform one to
> the other.
> 
> The warning above is unnecessary (for strcmp) and incorrect for
> strncmp because the call reads exactly four bytes from the non-
> string array a regardless of the bound and so there is no risk
> that it will read past the end of the array.
> 
> The attached change enhances the warning to use the length of
> the string argument to suppress some of these needless warnings
> for both bounded and unbounded string comparison functions.
> When the length of the string is unknown, the warning uses its
> size (when possible) as the upper bound on the number of accessed
> bytes.  The change adds no new warnings.
> 
> I'm looking for approval to commit it to both trunk and 8-branch.
> 
> Martin
> 
> gcc-85623.diff
> 
> 
> PR c/85623 - strncmp() warns about attribute 'nonstring' incorrectly in 
> -Wstringop-overflow
> 
> gcc/ChangeLog:
> 
>   PR c/85623
>   * calls.c (maybe_warn_nonstring_arg): Use string length to set
>   or ajust the presumed bound on an operation to avoid unnecessary
>   warnings.
s/ajust/adjust/

> 
> gcc/testsuite/ChangeLog:
> 
>   PR c/85623
>   * c-c++-common/attr-nonstring-3.c: Adjust.
>   * c-c++-common/attr-nonstring-4.c: Adjust.
>   * c-c++-common/attr-nonstring-6.c: New test.
> 
> diff --git a/gcc/calls.c b/gcc/calls.c
> index 9eb0467..f5c8ad4 100644
> --- a/gcc/calls.c
> +++ b/gcc/calls.c
> @@ -55,6 +55,7 @@ along with GCC; see the file COPYING3.  If not see
>  #include "stringpool.h"
>  #include "attribs.h"
>  #include "builtins.h"
> +#include "gimple-fold.h"
>  
>  /* Like PREFERRED_STACK_BOUNDARY but in units of bytes, not bits.  */
>  #define STACK_BYTES (PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT)
> @@ -1612,15 +1613,36 @@ maybe_warn_nonstring_arg (tree fndecl, tree exp)
>/* The bound argument to a bounded string function like strncpy.  */
>tree bound = NULL_TREE;
>  
> +  /* The range of lengths of a string argument to one of the comparison
> + functions.  If the length is less than the bound it is used instead.  */
> +  tree lenrng[2] = { NULL_TREE, NULL_TREE };
> +
>/* It's safe to call "bounded" string functions with a non-string
>   argument since the functions provide an explicit bound for this
>   purpose.  */
>switch (DECL_FUNCTION_CODE (fndecl))
>  {
> -case BUILT_IN_STPNCPY:
> -case BUILT_IN_STPNCPY_CHK:
> +case BUILT_IN_STRCMP:
>  case BUILT_IN_STRNCMP:
>  case BUILT_IN_STRNCASECMP:
> +  {
> + /* For these, if one argument refers to one or more of a set
> +of string constants or arrays of known size, determine
> +the range of their known or possible lengths and use it
> +conservatively as the bound for the unbounded function,
> +and to adjust the range of the bound of the bounded ones.  */
> + unsigned stride = with_bounds ? 2 : 1;
> + for (unsigned argno = 0; argno < nargs && !*lenrng; argno += stride)
> +   {
> + tree arg = CALL_EXPR_ARG (exp, argno);
> + if (!get_attr_nonstring_decl (arg))
> +   get_range_strlen (arg, lenrng);
> +   }
> +  }
> +  /* Fall through.  */
> +
> +case BUILT_IN_STPNCPY:
> +case BUILT_IN_STPNCPY_CHK:
>  case BUILT_IN_STRNCPY:
>  case BUILT_IN_STRNCPY_CHK:
>{
> @@ -1647,6 +1669,33 @@ maybe_warn_nonstring_arg (tree fndecl, tree exp)
> + {
> +   /* Replace the bound on the oparation with the upper bound
s/oparation/operation/

OK for the trunk with the nits fixed.

Also note that I've acked a patch from Martin L (I believe) that removes
the chkp/bounds checking bits that were deprecated in gcc-8.  So there's
some chance the bounds-related bits will need to be updated depending on
whether or not Martin's L's patch has been committed.

This isn't strictly a regression.  So unless this is affecting some
critical code (ie glibc, kernel or something similar) this probably
would require an explicit OK from Jakub or Richi to be eligible for the
gcc-8 branch.

jeff


Re: [PATCH] testsuite: Introduce be/le selectors

2018-05-21 Thread Segher Boessenkool
On Mon, May 21, 2018 at 11:59:43PM +0200, Rainer Orth wrote:
> Hi Segher,
> 
> > This patch creates "be" and "le" selectors, which can be used by all
> > architectures, similar to ilp32 and lp64.
> >
> > Is this okay for trunk?
> 
> two issues: I don't find be and le particularly expressive.  Maybe
> big-endian and little-endian?

But they will be used a _lot_, at least for rs6000, in places where space
is it a premium.  Like in scan-assembler-times and the like.

> Besides, whatever we do, the new keywords need documenting in
> sourcebuild.texi.

Ah yes, I forgot.  Thanks.


Segher


Re: [ARM] Fix PR85434: spill of stack protector's guard address

2018-05-21 Thread Jeff Law
On 05/02/2018 12:57 AM, Thomas Preudhomme wrote:
> Hi Segher,
> 
> As mentionned in the ticket this was my first thought but this means
> making the pattern aware of all the possible way the address could be
> access (PIC Vs non-PIC, Arm Vs Thumb-2 Vs Thumb-1) to decide how many
> scratch registers are needed. I'd rather reuse the existing pattern as
> much as possible to make sure they are well tested. Ideally I wanted a
> way to mark a REG RTX so that it is never spilled and such that the
> mark is propagated when the register is moved to another register or
> propagated. But that is a bigger change so decided it should be an
> improvement for later but needed another solution right now.
> 
> By the way about making sure the address is not left in a register, I
> have a question regarding the current stack_protect_set and
> stack_protect_check pattern and their requirements to have register
> cleared afterwards: why is that necessary? Currently not all registers
> are cleared and the guard is available in the canari before it is
> overwritten anyway so I don't see how clearing the register adds any
> extra security. What sort of attack is it protecting against?
I'm not aware of any way to make a REG so that it's never spilled.  It's
a concept we simply don't have.

About the closest you get is a fixed register.  But you certainly don't
want to do that.

I really think you're going to have to address this primarily in the ARM
backend, probably making a fair amount of things opaque to the rest of
the compiler.

Jeff


Re: [PATCH] avoid duplicate warning for strcmp with a nonstring (PR 85359)

2018-05-21 Thread Jeff Law
On 04/12/2018 06:02 PM, Martin Sebor wrote:
> Attached is a minor update that avoids additional duplicate
> warnings exposed by more extensive testing (for PR 85369).
> 
> On 04/12/2018 02:52 PM, Martin Sebor wrote:
>> The attached patch makes a small tweak to avoid issuing a duplicate
>> warning for calls to strcmp with a nonstring argument.  The most
>> onerous part of this was figuring out how to test for the absence
>> of duplicate warnings.  The "hack" I used (dg-regexp) is in place
>> until a more straightforward solution becomes available.  (David
>> Malcolm has something planned for GCC 9.)
>>
>> Martin
> 
> 
> gcc-85359.diff
> 
> 
> PR middle-end/85359 - duplicate -Wstringop-overflow for a strcmp call with a 
> nonstring pointer
> 
> gcc/ChangeLog:
> 
>   PR middle-end/85359
>   * builtins.c (expand_builtin_strcpy): Call maybe_warn_nonstring_arg
>   only when expasion succeeds.
>   (expand_builtin_strcmp): Same.
>   (expand_builtin_strncmp): Same.
> 
> gcc/testsuite/ChangeLog:
> 
>   PR middle-end/85359
>   * gcc.dg/attr-nonstring.c: New test.
OK.
jeff


Re: [PATCH] PR gcc/84923 - gcc.dg/attr-weakref-1.c failed on aarch64

2018-05-21 Thread vladimir . mezentsev


On 05/21/2018 01:30 PM, Jeff Law wrote:
> On 05/17/2018 02:42 AM, Richard Biener wrote:
>> On Thu, 17 May 2018, Kyrill Tkachov wrote:
>>
>>> Hi,
>>>
>>> Given this is a midend change it's a good idea to CC some of the maintainers
>>> of that area.
>>> I've copied richi and Honza.
>> The patch is ok for trunk (it's actually mine...) and for the branch
>> after a while.
> Installed.
>
> Vladimir -- do you have write access?  
  No. I don't.

> ISTM it would make sense for you
> to have access if you plan to continue submitting changes.

yes. I plan to continue submitting changes.

-Vladimir

>
> Jeff



Re: [PATCH] testsuite: Introduce be/le selectors

2018-05-21 Thread Rainer Orth
Hi Segher,

> This patch creates "be" and "le" selectors, which can be used by all
> architectures, similar to ilp32 and lp64.
>
> Is this okay for trunk?

two issues: I don't find be and le particularly expressive.  Maybe
big-endian and little-endian?

Besides, whatever we do, the new keywords need documenting in
sourcebuild.texi.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


[PATCH] testsuite: Introduce be/le selectors

2018-05-21 Thread Segher Boessenkool
This patch creates "be" and "le" selectors, which can be used by all
architectures, similar to ilp32 and lp64.

Is this okay for trunk?


Segher


2017-05-21  Segher Boessenkool  

gcc/testsuite/
* lib/target-supports.exp (check_effective_target_be): New.
(check_effective_target_le): New.

---
 gcc/testsuite/lib/target-supports.exp | 16 
 1 file changed, 16 insertions(+)

diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index cfc22a2..3b9460d 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -2641,6 +2641,22 @@ proc check_effective_target_long_neq_int { } {
 }]
 }
 
+# Return 1 if we're generating big-endian code.
+
+proc check_effective_target_be { } {
+return [check_no_compiler_messages be object {
+   int dummy[__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ ? 1 : -1];
+}]
+}
+
+# Return 1 if we're generating little-endian code.
+
+proc check_effective_target_le { } {
+return [check_no_compiler_messages le object {
+   int dummy[__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ ? 1 : -1];
+}]
+}
+
 # Return 1 if the target supports long double larger than double,
 # 0 otherwise.
 
-- 
1.8.3.1



Re: [PATCH 1/2] extend.texi: update Global Register Variables section

2018-05-21 Thread Jeff Law
On 05/10/2018 03:47 AM, Alexander Monakov wrote:
> 
> 
> On Mon, 23 Apr 2018, Alexander Monakov wrote:
> 
>> This rewrites global register vars doc to reflect that the register is no 
>> longer
>> reserved exclusively, but in fact is available for general allocation, and 
>> also
>> adds the requirement to properly inform the compiler where inline asms are
>> accessing the variable.
>>
>> This:
>> -@item The register is not saved and restored by any functions.
>> is reworded to verbosely spell out gotchas related to calls/returns.
>>
>>  * extend.texi (Global Register Variables): Rewrite the bullet list.
>>  Note that the register is available for allocation. Note that access
>>  via inline asm must use constraints. Add note about async-signal
>>  handlers. Remove paragraph about automagic register selection.
>> ---
>>  gcc/doc/extend.texi | 29 +++--
>>  1 file changed, 19 insertions(+), 10 deletions(-)
> 
> Ping? I believe the substance of new text has been hashed out with Michael.
> I'd appreciate a review for language and style issues.
> 
> Thanks.
> Alexander
> 
>> diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
>> index 5571d05d93b..f663741e36c 100644
>> --- a/gcc/doc/extend.texi
>> +++ b/gcc/doc/extend.texi
>> @@ -9549,11 +9549,21 @@ After defining a global register variable, for the 
>> current compilation
>>  unit:
>>  
>>  @itemize @bullet
>> -@item The register is reserved entirely for this use, and will not be 
>> -allocated for any other purpose.
>> -@item The register is not saved and restored by any functions.
>> -@item Stores into this register are never deleted even if they appear to be 
>> -dead, but references may be deleted, moved or simplified.
>> +@item If the register is a call-saved register, call ABI is affected:
>> +the register will not be restored in function epilogue sequences after
>> +the variable has been assigned.  Therefore, functions cannot safely
>> +return to callers that assume standard ABI.
Whether or not a global register is saved in the prologue and restored
in the epilogue is actually a function of the target's prologue/epilogue
implementation.

So ISTM this paragraph needs to be refined a bit.  Essentially it may or
may not change the ABI.  It really depends on the target implementation.


The rest of the doc changes look fine.

jeff


Re: [Patch, Fortran] PR 85841: [F2018] reject deleted features

2018-05-21 Thread Janus Weil
2018-05-21 22:18 GMT+02:00 Janus Weil :
> I'll take care of fixing the remaining libgomp failures.

Should be done with r260487. Please let me know if you observe any
additional problems.

Cheers,
Janus


Re: [testsuite] Add scan-offload-rtl-dump

2018-05-21 Thread Jeff Law
On 05/03/2018 08:15 AM, Tom de Vries wrote:
> Hi,
> 
> I'm posting this patch for the record.
> 
> I wrote it but haven't found a use for it yet. I find it easier to write
> asm scans for nvptx than rtl ones.
If you do find a use, then consider this pre-approved.

jeff


Re: [C++ Patch] Remove cp_parser_parameter_declaration_list parameter

2018-05-21 Thread Jason Merrill
OK.

On Mon, May 21, 2018 at 3:47 PM, Paolo Carlini  wrote:
> Hi,
>
> I noticed a few days ago that the second parameter of the function is
> redundant, we can just rely on the return value possibly being
> error_mark_node (I even ran the testsuite with the function instrumented
> with a gcc_assert (*is_error == (parameters == error_mark_node); immediately
> before the return, at some point). Tested x86_64-linux.
>
> Thanks, Paolo.
>
> 
>


Re: C++ PATCH to implement P0614R1, Range-based for statements with initializer

2018-05-21 Thread Jason Merrill
OK.

On Mon, May 21, 2018 at 3:50 PM, Marek Polacek  wrote:
> This is my attempt to implement P0614R1, a C++20 feature whereby we may now 
> use
> an init-statement in a range-based for loop like this:
>
>   for (int i = bar (); const auto  : a)
> // ...
>
> The somewhat tricky part was to distinguish a range-based for from an 
> ordinary for
> statement, hence the cp_parser_range_based_for_with_init_p shenanigans.  Note
> that we must be able to cope with lambdas/statement-expressions in the
> initializer as well as with loops such as
>
>   for (int i = 0; int j = 0; )
> // ...
>
> and the following seems to handle all of it.
>
> What d'ya think?
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
>
> 2018-05-21  Marek Polacek  
>
> Implement P0614R1, Range-based for statements with initializer.
> * parser.c (cp_parser_range_based_for_with_init_p): New.
> (cp_parser_init_statement): Use it.  Parse the optional init-statement
> for a range-based for loop.
>
> * g++.dg/cpp2a/range-for1.C: New test.
> * g++.dg/cpp2a/range-for2.C: New test.
> * g++.dg/cpp2a/range-for3.C: New test.
> * g++.dg/cpp2a/range-for4.C: New test.
> * g++.dg/cpp2a/range-for5.C: New test.
> * g++.dg/cpp2a/range-for6.C: New test.
>
> diff --git gcc/cp/parser.c gcc/cp/parser.c
> index c0058085ee9..47a825f2da0 100644
> --- gcc/cp/parser.c
> +++ gcc/cp/parser.c
> @@ -11255,6 +11255,39 @@ cp_parser_statement_seq_opt (cp_parser* parser, tree 
> in_statement_expr)
>  }
>  }
>
> +/* Return true if this is the C++20 version of range-based-for with
> +   init-statement.  */
> +
> +static bool
> +cp_parser_range_based_for_with_init_p (cp_parser *parser)
> +{
> +  bool r = false;
> +
> +  /* Save tokens so that we can put them back.  */
> +  cp_lexer_save_tokens (parser->lexer);
> +
> +  /* There has to be an unnested ; followed by an unnested :.  */
> +  if (cp_parser_skip_to_closing_parenthesis_1 (parser,
> +  /*recovering=*/false,
> +  CPP_SEMICOLON,
> +  /*consume_paren=*/false) != -1)
> +goto out;
> +
> +  /* We found the semicolon, eat it now.  */
> +  cp_lexer_consume_token (parser->lexer);
> +  /* Now look for ':' that is not nested in () or {}.  */
> +  r = (cp_parser_skip_to_closing_parenthesis_1 (parser,
> +   /*recovering=*/false,
> +   CPP_COLON,
> +   /*consume_paren=*/false) == 
> -1);
> +
> +out:
> +  /* Roll back the tokens we skipped.  */
> +  cp_lexer_rollback_tokens (parser->lexer);
> +
> +  return r;
> +}
> +
>  /* Return true if we're looking at (init; cond), false otherwise.  */
>
>  static bool
> @@ -12242,7 +12275,7 @@ cp_parser_iteration_statement (cp_parser* parser, 
> bool *if_p, bool ivdep,
>   simple-declaration  */
>
>  static bool
> -cp_parser_init_statement (cp_parser* parser, tree *decl)
> +cp_parser_init_statement (cp_parser *parser, tree *decl)
>  {
>/* If the next token is a `;', then we have an empty
>   expression-statement.  Grammatically, this is also a
> @@ -12255,6 +12288,29 @@ cp_parser_init_statement (cp_parser* parser, tree 
> *decl)
>bool is_range_for = false;
>bool saved_colon_corrects_to_scope_p = 
> parser->colon_corrects_to_scope_p;
>
> +  /* Try to parse the init-statement.  */
> +  if (cp_parser_range_based_for_with_init_p (parser))
> +   {
> + tree dummy;
> + cp_parser_parse_tentatively (parser);
> + /* Parse the declaration.  */
> + cp_parser_simple_declaration (parser,
> +   
> /*function_definition_allowed_p=*/false,
> +   );
> + cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
> + if (!cp_parser_parse_definitely (parser))
> +   /* That didn't work, try to parse it as an expression-statement.  
> */
> +   cp_parser_expression_statement (parser, NULL_TREE);
> +
> + if (cxx_dialect < cxx2a)
> +   {
> + pedwarn (cp_lexer_peek_token (parser->lexer)->location, 0,
> +  "range-based % loops with initializer only "
> +  "available with -std=c++2a or -std=gnu++2a");
> + *decl = error_mark_node;
> +   }
> +   }
> +
>/* A colon is used in range-based for.  */
>parser->colon_corrects_to_scope_p = false;
>
> @@ -12268,7 +12324,7 @@ cp_parser_init_statement (cp_parser* parser, tree 
> *decl)
>parser->colon_corrects_to_scope_p = saved_colon_corrects_to_scope_p;
>if (cp_lexer_next_token_is (parser->lexer, CPP_COLON))
> {
> - /* It is a range-for, consume the ':' */
> + /* It is 

Re: [PATCH] PR gcc/84923 - gcc.dg/attr-weakref-1.c failed on aarch64

2018-05-21 Thread Jeff Law
On 05/17/2018 02:42 AM, Richard Biener wrote:
> On Thu, 17 May 2018, Kyrill Tkachov wrote:
> 
>> Hi,
>>
>> Given this is a midend change it's a good idea to CC some of the maintainers
>> of that area.
>> I've copied richi and Honza.
> 
> The patch is ok for trunk (it's actually mine...) and for the branch
> after a while.
Installed.

Vladimir -- do you have write access?  ISTM it would make sense for you
to have access if you plan to continue submitting changes.

Jeff


Re: [PATCH] Another DSE improvement and thinko fix

2018-05-21 Thread Jeff Law
On 05/17/2018 06:15 AM, Richard Biener wrote:
> 
> The previous DSE improvements left us with skipping elements we could
> have possibly removed because I messed up the iterator increment
> upon removal.  The following fixes this and also adds another pruning
> opportunity in case the only stmt feeded by the def is an already
> visited PHI.
> 
> Bootstrap and regtest running on x86_64-unknown-linux-gnu.
> 
> Richard.
> 
> 2018-05-17  Richard Biener  
> 
> * tree-ssa-dse.c (dse_classify_store): Fix iterator increment
> for pruning loop and prune defs feeding only already visited PHIs.
LGTM.
jeff


Re: Fix tree-ssa-strlen handling of partial clobber (PR85814)

2018-05-21 Thread Jeff Law
On 05/18/2018 02:09 AM, Richard Sandiford wrote:
> In this PR we have:
> 
>   c_5 = c_4(D) + 4;
>   c_12 = c_5 + 1;
>   *c_5 = 2;
>   a = 2;  // A
>   c_21 = c_12 + 1;
>   *c_12 = 2;
>   a = 2;  // B
>   c_28 = c_21 + 1;
>   *c_21 = 2;
>   a = 2;
>   c_7 = c_28 + 1;
>   *c_28 = 2;
> 
> where a is a global int.  We decide that A can't clobber *c_5 == c_4[4]
> because the latter implies that c_4 is an object of 5 bytes or more,
> whereas a has exactly 4 bytes.
> 
> The assumption for B and *c_5 is the same, but when considering B and
> *c_12, we only follow the definition of c_12 to c_5 + 1 (for good
> reason) and so have *c_12 == c_5[1].  We then don't have the same
> size guarantee and so assume that B could clobber *c_12.  This leads
> to a situation in which the strinfo for c_5 is still valid but the
> next strinfo (c_12) isn't.  We then segfaulted while trying to get
> the strinfo for c_21 + 1 == c_5 + 3 because get_stridx_plus_constant
> assumed that c_5's next strinfo (c_12) would be valid too.
> 
> And of course it should be valid really.  It doesn't make sense for the
> string based at c_5 to be valid but a substring of it to be invalid.
> I don't think we can guarantee that such weird corner cases never
> happen though, even if we tried to avoid this one.
> 
> One possibility would be to mark c_12 as valid on the basis that c_5
> is valid, but I'm not sure the complication is worth it given that it
> seems to trigger very rarely.  A better optimisation would be to get
> the unroller to clean up after itself a bit more...
> 
> Although this particular instance of the bug relies on r249880, I think
> we could have similar problems in GCC 7.  It would be much harder to
> trigger though, especially since it relies on unfolded IR like the above.
> 
> Tested on aarch64-linux-gnu, aarch64_be-elf and x86_64-linux-gnu.
> OK for trunk and GCC 8?
> 
> Richard
> 
> 
> 2018-05-18  Richard Sandiford  
> 
> gcc/
>   PR tree-optimization/85814
>   * tree-ssa-strlen.c (get_stridx_plus_constant): Cope with
>   a null return from get_strinfo when unsharing the next
>   strinfo in the chain.
> 
> gcc/testsuite/
>   PR tree-optimization/85814
>   * gcc.dg/torture/pr85814.c: New test.
OK, including backports.

jeff


Re: [PATCH] avoid assuming that a DECL necessarily has a constant size (PR 85826)

2018-05-21 Thread Jeff Law
On 05/18/2018 12:15 PM, Martin Sebor wrote:
> Under some apparently rare conditions a DECL can have a non-
> constant size that the fix for bug 85753 committed last week
> into trunk was not prepared for.  The attached change removes
> the assumption to avoid the ICE that otherwise results.
> 
> Martin
> 
> PS The test case that triggers the ICE makes use of variable-
> length structs and local functions, both of which are fairly
> obscure GCC extensions that I tend to forget to consider when
> writing GCC code.  I tried to construct a less convoluted (and
> strictly conforming) test case but in all of those I've come
> up with a variable-length object is represented by a pointer
> (pointing to memory returned by __builtin_alloca_with_align()).
> Is there a straightforward way to create a variable-size DECL
> that doesn't rely on GCC extensions?
I think creating a type of a variable size, then an object of that type
is the key.  So a type with a flexible array/vla.  Which is precisely
what your test does.

For the most part DECL_SIZE comes from TYPE_SIZE.  See layout_decl.


> 
> gcc-85826.diff
> 
> 
> PR tree-optimization/85826 - ICE in gimple-ssa-warn-restruct on a 
> variable-length struct
> 
> gcc/ChangeLog:
> 
>   PR tree-optimization/85826
>   * gimple-ssa-warn-restrict.c (builtin_memref::builtin_memref): Avoid
>   assuming that a DECL necesarily has a constant size.
> 
> gcc/testsuite/ChangeLog:
> 
>   PR tree-optimization/85826
>   * gcc.dg/Wrestrict-17.c: New test.
OK.
jeff


Re: [Patch, Fortran] PR 85841: [F2018] reject deleted features

2018-05-21 Thread Janus Weil
2018-05-21 22:16 GMT+02:00 Jakub Jelinek :
> On Mon, May 21, 2018 at 01:06:21PM -0700, Steve Kargl wrote:
>> On Mon, May 21, 2018 at 09:39:29PM +0200, Janus Weil wrote:
>> >
>> > Regarding the libgomp.fortran cases: Those are not included in "make
>> > check-fortran", right? How do I actually run them? Is this documented
>> > somewhere?
>>
>> Good question!
>>
>> When I want to do a specific check, I do something of the form
>>
>> % gmake check-fortran RUNTESTFLAGS="dg.exp=\*alloc\*.f90"
>>
>> which runs all tests with 'alloc' in the file name.  I don't
>> know the magic incantation for libgomp.fortran short of a
>> full on 'gmake check'.
>
> E.g. in toplevel directory do
> make check-target-libgomp RUNTESTFLAGS=fortran.exp

Thanks!

I'll take care of fixing the remaining libgomp failures.

Sorry again for the breakage,
Janus


Re: [PATCH] Print working directory to gcov files (PR gcov-profile/84846).

2018-05-21 Thread Eric Botcazou
> Simple format extension which prints working directory of TU when it was
> compiled. It's requested by LCOV folks.

Can we make that optional, please?  Having the coverage results depends on the 
current working directory is quite annoying, to say the least.

-- 
Eric Botcazou


Re: [Patch, Fortran] PR 85841: [F2018] reject deleted features

2018-05-21 Thread Jakub Jelinek
On Mon, May 21, 2018 at 01:06:21PM -0700, Steve Kargl wrote:
> On Mon, May 21, 2018 at 09:39:29PM +0200, Janus Weil wrote:
> > 
> > Regarding the libgomp.fortran cases: Those are not included in "make
> > check-fortran", right? How do I actually run them? Is this documented
> > somewhere?
> 
> Good question!
> 
> When I want to do a specific check, I do something of the form
> 
> % gmake check-fortran RUNTESTFLAGS="dg.exp=\*alloc\*.f90"
> 
> which runs all tests with 'alloc' in the file name.  I don't
> know the magic incantation for libgomp.fortran short of a
> full on 'gmake check'.

E.g. in toplevel directory do
make check-target-libgomp RUNTESTFLAGS=fortran.exp

Jakub


Re: [Patch, Fortran] PR 85841: [F2018] reject deleted features

2018-05-21 Thread H.J. Lu
On Mon, May 21, 2018 at 1:06 PM, Steve Kargl
 wrote:
> On Mon, May 21, 2018 at 09:39:29PM +0200, Janus Weil wrote:
>>
>> Regarding the libgomp.fortran cases: Those are not included in "make
>> check-fortran", right? How do I actually run them? Is this documented
>> somewhere?
>
> Good question!
>
> When I want to do a specific check, I do something of the form
>
> % gmake check-fortran RUNTESTFLAGS="dg.exp=\*alloc\*.f90"
>
> which runs all tests with 'alloc' in the file name.  I don't
> know the magic incantation for libgomp.fortran short of a
> full on 'gmake check'.
>

They are under target/libgomp.

-- 
H.J.


Re: [Patch, Fortran] PR 85841: [F2018] reject deleted features

2018-05-21 Thread Steve Kargl
On Mon, May 21, 2018 at 09:39:29PM +0200, Janus Weil wrote:
> 
> Regarding the libgomp.fortran cases: Those are not included in "make
> check-fortran", right? How do I actually run them? Is this documented
> somewhere?

Good question!

When I want to do a specific check, I do something of the form

% gmake check-fortran RUNTESTFLAGS="dg.exp=\*alloc\*.f90"

which runs all tests with 'alloc' in the file name.  I don't
know the magic incantation for libgomp.fortran short of a
full on 'gmake check'.

-- 
Steve



Re: C++ PATCH to implement P0614R1, Range-based for statements with initializer

2018-05-21 Thread Marek Polacek
Actually, scratch this.  I found an issue with the current patch.  Sorry.

On Mon, May 21, 2018 at 03:50:05PM -0400, Marek Polacek wrote:
> This is my attempt to implement P0614R1, a C++20 feature whereby we may now 
> use
> an init-statement in a range-based for loop like this:
...

Marek


Re: [RFT PATCH, AVX512]: Implement scalar float->unsigned int truncations with AVX512F

2018-05-21 Thread Uros Bizjak
On Mon, May 21, 2018 at 4:53 PM, Uros Bizjak  wrote:
> Hello!
>
> Attached patch implements scalar float->unsigned int truncations with AVX512F.
>
> 2018-05-21  Uros Bizjak  
>
> * config/i386/i386.md (fixuns_truncdi2): New insn pattern.
> (fixuns_truncsi2_avx512f): Ditto.
> (*fixuns_truncsi2_avx512f_zext): Ditto.
> (fixuns_truncsi2): Also enable for AVX512F and TARGET_SSE_MATH.
> Emit fixuns_truncsi2_avx512f for AVX512F targets.
>
> testsuite/ChangeLog:
>
> 2018-05-21  Uros Bizjak  
>
> * gcc.target/i386/cvt-2.c: New test.
>
> Patch was bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.
>
> Unfortunately, I have to means to test the patch on AVX512 target, so
> to avoid some hidden issue, I'd like to ask someone to test it on live
> target.

Ops, ssemodesuffix handling was missing in the insn mnemonic. Fixed in
the attached v-2 patch.

Uros.
Index: config/i386/i386.md
===
--- config/i386/i386.md (revision 260441)
+++ config/i386/i386.md (working copy)
@@ -5017,6 +5017,18 @@
}
 })
 
+;; Unsigned conversion to DImode
+
+(define_insn "fixuns_truncdi2"
+  [(set (match_operand:DI 0 "register_operand" "=r")
+   (unsigned_fix:DI
+ (match_operand:MODEF 1 "nonimmediate_operand" "vm")))]
+  "TARGET_64BIT && TARGET_AVX512F && TARGET_SSE_MATH"
+  "vcvtt2usi\t{%1, %0|%0, %1}"
+  [(set_attr "type" "sseicvt")
+   (set_attr "prefix" "evex")
+   (set_attr "mode" "DI")])
+
 ;; Unsigned conversion to SImode.
 
 (define_expand "fixuns_truncsi2"
@@ -5027,7 +5039,7 @@
  (use (match_dup 2))
  (clobber (match_scratch: 3))
  (clobber (match_scratch: 4))])]
-  "!TARGET_64BIT && TARGET_SSE2 && TARGET_SSE_MATH"
+  "(!TARGET_64BIT || TARGET_AVX512F) && TARGET_SSE2 && TARGET_SSE_MATH"
 {
   machine_mode mode = mode;
   machine_mode vecmode = mode;
@@ -5034,6 +5046,12 @@
   REAL_VALUE_TYPE TWO31r;
   rtx two31;
 
+  if (TARGET_AVX512F)
+{
+  emit_insn (gen_fixuns_truncsi2_avx512f (operands[0], operands[1]));
+  DONE;
+}
+
   if (optimize_insn_for_size_p ())
 FAIL;
 
@@ -5043,6 +5061,27 @@
   operands[2] = force_reg (vecmode, two31);
 })
 
+(define_insn "fixuns_truncsi2_avx512f"
+  [(set (match_operand:SI 0 "register_operand" "=r")
+   (unsigned_fix:SI
+ (match_operand:MODEF 1 "nonimmediate_operand" "vm")))]
+  "TARGET_AVX512F && TARGET_SSE_MATH"
+  "vcvtt2usi\t{%1, %0|%0, %1}"
+  [(set_attr "type" "sseicvt")
+   (set_attr "prefix" "evex")
+   (set_attr "mode" "SI")])
+
+(define_insn "*fixuns_truncsi2_avx512f_zext"
+  [(set (match_operand:DI 0 "register_operand" "=r")
+   (zero_extend:DI
+ (unsigned_fix:SI
+   (match_operand:MODEF 1 "nonimmediate_operand" "vm"]
+  "TARGET_64BIT && TARGET_AVX512F"
+  "vcvtt2usi\t{%1, %k0|%k0, %1}"
+  [(set_attr "type" "sseicvt")
+   (set_attr "prefix" "evex")
+   (set_attr "mode" "SI")])
+
 (define_insn_and_split "*fixuns_trunc_1"
   [(set (match_operand:SI 0 "register_operand" "=,")
(unsigned_fix:SI
Index: testsuite/gcc.target/i386/cvt-2.c
===
--- testsuite/gcc.target/i386/cvt-2.c   (nonexistent)
+++ testsuite/gcc.target/i386/cvt-2.c   (working copy)
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mavx512f -mfpmath=sse" } */
+
+unsigned int f2ui (float x) { return x; }
+unsigned int d2ui (double x) { return x; }
+
+#ifdef __x86_64__
+unsigned long f2ul (float x) { return x; }
+unsigned long d2ul (double x) { return x; }
+#endif
+  
+/* { dg-final { scan-assembler-times "vcvttss2usi" 1 { target ia32 } } } */
+/* { dg-final { scan-assembler-times "vcvttsd2usi" 1 { target ia32 } } } */
+/* { dg-final { scan-assembler-times "vcvttss2usi" 2 { target { ! ia32 } } } } 
*/
+/* { dg-final { scan-assembler-times "vcvttsd2usi" 2 { target { ! ia32 } } } } 
*/


C++ PATCH to implement P0614R1, Range-based for statements with initializer

2018-05-21 Thread Marek Polacek
This is my attempt to implement P0614R1, a C++20 feature whereby we may now use
an init-statement in a range-based for loop like this:

  for (int i = bar (); const auto  : a)
// ...

The somewhat tricky part was to distinguish a range-based for from an ordinary 
for
statement, hence the cp_parser_range_based_for_with_init_p shenanigans.  Note
that we must be able to cope with lambdas/statement-expressions in the
initializer as well as with loops such as 

  for (int i = 0; int j = 0; )
// ...

and the following seems to handle all of it.

What d'ya think?

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

2018-05-21  Marek Polacek  

Implement P0614R1, Range-based for statements with initializer.
* parser.c (cp_parser_range_based_for_with_init_p): New.
(cp_parser_init_statement): Use it.  Parse the optional init-statement
for a range-based for loop.

* g++.dg/cpp2a/range-for1.C: New test.
* g++.dg/cpp2a/range-for2.C: New test.
* g++.dg/cpp2a/range-for3.C: New test.
* g++.dg/cpp2a/range-for4.C: New test.
* g++.dg/cpp2a/range-for5.C: New test.
* g++.dg/cpp2a/range-for6.C: New test.

diff --git gcc/cp/parser.c gcc/cp/parser.c
index c0058085ee9..47a825f2da0 100644
--- gcc/cp/parser.c
+++ gcc/cp/parser.c
@@ -11255,6 +11255,39 @@ cp_parser_statement_seq_opt (cp_parser* parser, tree 
in_statement_expr)
 }
 }
 
+/* Return true if this is the C++20 version of range-based-for with
+   init-statement.  */
+
+static bool
+cp_parser_range_based_for_with_init_p (cp_parser *parser)
+{
+  bool r = false;
+
+  /* Save tokens so that we can put them back.  */
+  cp_lexer_save_tokens (parser->lexer);
+
+  /* There has to be an unnested ; followed by an unnested :.  */
+  if (cp_parser_skip_to_closing_parenthesis_1 (parser,
+  /*recovering=*/false,
+  CPP_SEMICOLON,
+  /*consume_paren=*/false) != -1)
+goto out;
+
+  /* We found the semicolon, eat it now.  */
+  cp_lexer_consume_token (parser->lexer);
+  /* Now look for ':' that is not nested in () or {}.  */
+  r = (cp_parser_skip_to_closing_parenthesis_1 (parser,
+   /*recovering=*/false,
+   CPP_COLON,
+   /*consume_paren=*/false) == -1);
+
+out:
+  /* Roll back the tokens we skipped.  */
+  cp_lexer_rollback_tokens (parser->lexer);
+
+  return r;
+}
+
 /* Return true if we're looking at (init; cond), false otherwise.  */
 
 static bool
@@ -12242,7 +12275,7 @@ cp_parser_iteration_statement (cp_parser* parser, bool 
*if_p, bool ivdep,
  simple-declaration  */
 
 static bool
-cp_parser_init_statement (cp_parser* parser, tree *decl)
+cp_parser_init_statement (cp_parser *parser, tree *decl)
 {
   /* If the next token is a `;', then we have an empty
  expression-statement.  Grammatically, this is also a
@@ -12255,6 +12288,29 @@ cp_parser_init_statement (cp_parser* parser, tree 
*decl)
   bool is_range_for = false;
   bool saved_colon_corrects_to_scope_p = parser->colon_corrects_to_scope_p;
 
+  /* Try to parse the init-statement.  */
+  if (cp_parser_range_based_for_with_init_p (parser))
+   {
+ tree dummy;
+ cp_parser_parse_tentatively (parser);
+ /* Parse the declaration.  */
+ cp_parser_simple_declaration (parser,
+   /*function_definition_allowed_p=*/false,
+   );
+ cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
+ if (!cp_parser_parse_definitely (parser))
+   /* That didn't work, try to parse it as an expression-statement.  */
+   cp_parser_expression_statement (parser, NULL_TREE);
+
+ if (cxx_dialect < cxx2a)
+   {
+ pedwarn (cp_lexer_peek_token (parser->lexer)->location, 0,
+  "range-based % loops with initializer only "
+  "available with -std=c++2a or -std=gnu++2a");
+ *decl = error_mark_node;
+   }
+   }
+
   /* A colon is used in range-based for.  */
   parser->colon_corrects_to_scope_p = false;
 
@@ -12268,7 +12324,7 @@ cp_parser_init_statement (cp_parser* parser, tree *decl)
   parser->colon_corrects_to_scope_p = saved_colon_corrects_to_scope_p;
   if (cp_lexer_next_token_is (parser->lexer, CPP_COLON))
{
- /* It is a range-for, consume the ':' */
+ /* It is a range-for, consume the ':'.  */
  cp_lexer_consume_token (parser->lexer);
  is_range_for = true;
  if (cxx_dialect < cxx11)
@@ -12280,9 +12336,9 @@ cp_parser_init_statement (cp_parser* parser, tree *decl)
}
}
   else
- /* The ';' is not consumed yet because we told
-  

[C++ Patch] Remove cp_parser_parameter_declaration_list parameter

2018-05-21 Thread Paolo Carlini

Hi,

I noticed a few days ago that the second parameter of the function is 
redundant, we can just rely on the return value possibly being 
error_mark_node (I even ran the testsuite with the function instrumented 
with a gcc_assert (*is_error == (parameters == error_mark_node); 
immediately before the return, at some point). Tested x86_64-linux.


Thanks, Paolo.



2018-05-21  Paolo Carlini  

* parser.c (cp_parser_parameter_declaration_list): Remove
bool* parameter.
(cp_parser_parameter_declaration_clause): Adjust.
(cp_parser_cache_defarg): Likewise.
Index: parser.c
===
--- parser.c(revision 260280)
+++ parser.c(working copy)
@@ -2235,7 +2235,7 @@ static void cp_parser_type_specifier_seq
 static tree cp_parser_parameter_declaration_clause
   (cp_parser *);
 static tree cp_parser_parameter_declaration_list
-  (cp_parser *, bool *);
+  (cp_parser *);
 static cp_parameter_declarator *cp_parser_parameter_declaration
   (cp_parser *, bool, bool *);
 static tree cp_parser_default_argument 
@@ -21191,7 +21209,6 @@ cp_parser_parameter_declaration_clause (cp_parser*
   tree parameters;
   cp_token *token;
   bool ellipsis_p;
-  bool is_error;
 
   temp_override cleanup
 (parser->auto_is_implicit_function_template_parm_p);
@@ -21239,12 +21256,12 @@ cp_parser_parameter_declaration_clause (cp_parser*
 }
 
   /* Parse the parameter-declaration-list.  */
-  parameters = cp_parser_parameter_declaration_list (parser, _error);
+  parameters = cp_parser_parameter_declaration_list (parser);
   /* If a parse error occurred while parsing the
  parameter-declaration-list, then the entire
  parameter-declaration-clause is erroneous.  */
-  if (is_error)
-return NULL;
+  if (parameters == error_mark_node)
+return NULL_TREE;
 
   /* Peek at the next token.  */
   token = cp_lexer_peek_token (parser->lexer);
@@ -21284,11 +21301,10 @@ cp_parser_parameter_declaration_clause (cp_parser*
 
Returns a representation of the parameter-declaration-list, as for
cp_parser_parameter_declaration_clause.  However, the
-   `void_list_node' is never appended to the list.  Upon return,
-   *IS_ERROR will be true iff an error occurred.  */
+   `void_list_node' is never appended to the list.  */
 
 static tree
-cp_parser_parameter_declaration_list (cp_parser* parser, bool *is_error)
+cp_parser_parameter_declaration_list (cp_parser* parser)
 {
   tree parameters = NULL_TREE;
   tree *tail = 
@@ -21295,8 +21311,6 @@ static tree
   bool saved_in_unbraced_linkage_specification_p;
   int index = 0;
 
-  /* Assume all will go well.  */
-  *is_error = false;
   /* The special considerations that apply to a function within an
  unbraced linkage specifications do not apply to the parameters
  to the function.  */
@@ -21338,7 +21352,6 @@ static tree
 then the entire parameter-declaration-list is erroneous.  */
   if (decl == error_mark_node)
{
- *is_error = true;
  parameters = error_mark_node;
  break;
}
@@ -28958,7 +28971,9 @@ cp_parser_cache_defarg (cp_parser *parser, bool ns
{
  cp_lexer_consume_token (parser->lexer);
  begin_scope (sk_function_parms, NULL_TREE);
- cp_parser_parameter_declaration_list (parser, );
+ if (cp_parser_parameter_declaration_list (parser)
+ == error_mark_node)
+   error = true;
  pop_bindings_and_leave_scope ();
}
  if (!cp_parser_error_occurred (parser) && !error)


Re: [Patch, Fortran] PR 85841: [F2018] reject deleted features

2018-05-21 Thread Janus Weil
2018-05-21 21:23 GMT+02:00 Steve Kargl :
> On Mon, May 21, 2018 at 12:10:01PM -0700, Steve Kargl wrote:
>> On Mon, May 21, 2018 at 09:06:40PM +0200, Janus Weil wrote:
>> > Hi Steve,
>> >
>> > > The attached patch fixes a few testcases that were missed
>> > > in the original patch.  Do you have these already in an
>> > > updated patch, or would you like me to commit my patch?
>> >
>> > I saw the message just now and had no time to react yet. Please feel
>> > free to commit your patch.
>> >
>>
>> OK, I'll commit with an appropriate ChangeLog in a few minutes.
>>
>
> Done.

Thank you!

I wonder why I did not see the gfortran.dg/graphite failures. My
testsuite log looks like those should have been run:

Running /home/jweil/gcc/trunk/gcc/testsuite/gfortran.dg/graphite/graphite.exp
...
Running /home/jweil/gcc/trunk/gcc/testsuite/gfortran.dg/graphite/graphite.exp
...
Running /home/jweil/gcc/trunk/gcc/testsuite/gfortran.dg/graphite/graphite.exp
...
Running /home/jweil/gcc/trunk/gcc/testsuite/gfortran.dg/graphite/graphite.exp
...

However no failures were reported!

Regarding the libgomp.fortran cases: Those are not included in "make
check-fortran", right? How do I actually run them? Is this documented
somewhere?

Cheers,
Janus


Re: [Patch, Fortran] PR 85841: [F2018] reject deleted features

2018-05-21 Thread Steve Kargl
On Mon, May 21, 2018 at 12:10:01PM -0700, Steve Kargl wrote:
> On Mon, May 21, 2018 at 09:06:40PM +0200, Janus Weil wrote:
> > Hi Steve,
> > 
> > > The attached patch fixes a few testcases that were missed
> > > in the original patch.  Do you have these already in an
> > > updated patch, or would you like me to commit my patch?
> > 
> > I saw the message just now and had no time to react yet. Please feel
> > free to commit your patch.
> > 
> 
> OK, I'll commit with an appropriate ChangeLog in a few minutes.
> 

Done.

-- 
Steve


[Committed] Fix Fortran testsuite failures

2018-05-21 Thread Steve Kargl
I've committed the attached patch, which fixes a few testsuite
failures related to changes in how gfortran handles legacy code.

2018-05-21  Steven G. Kargl  

* gfortran.dg/graphite/block-2.f: Adjust testcase for new gfortran
warnings for deleted and obsolescent features.
* gfortran.dg/graphite/id-19.f: Ditto.
* gfortran.dg/graphite/id-20.f: Ditto.
* gfortran.dg/graphite/id-27.f90: Ditto.
* gfortran.dg/graphite/pr82449.f: Ditto.

PS: Yes, I forgot a ChangLog entry.  I'll commit that in a minute.

-- 
Steve
Index: gcc/testsuite/gfortran.dg/graphite/block-2.f
===
--- gcc/testsuite/gfortran.dg/graphite/block-2.f	(revision 260479)
+++ gcc/testsuite/gfortran.dg/graphite/block-2.f	(working copy)
@@ -1,3 +1,5 @@
+! { dg-do compile }
+! { dg-options "-std=legacy" }
   SUBROUTINE MATRIX_MUL_UNROLLED (A, B, C, L, M, N)
   DIMENSION A(L,M), B(M,N), C(L,N)
 
Index: gcc/testsuite/gfortran.dg/graphite/id-19.f
===
--- gcc/testsuite/gfortran.dg/graphite/id-19.f	(revision 260479)
+++ gcc/testsuite/gfortran.dg/graphite/id-19.f	(working copy)
@@ -1,3 +1,5 @@
+! { dg-do compile }
+! { dg-options "-std=legacy" }
   SUBROUTINE ECCODR(FPQR)
   DIMENSION FPQR(25,25,25)
   INTEGER P,Q,R
Index: gcc/testsuite/gfortran.dg/graphite/id-20.f
===
--- gcc/testsuite/gfortran.dg/graphite/id-20.f	(revision 260479)
+++ gcc/testsuite/gfortran.dg/graphite/id-20.f	(working copy)
@@ -1,4 +1,4 @@
-! { dg-options "-O3 -ffast-math" }
+! { dg-options "-O3 -ffast-math -std=legacy" }
 
   DIMENSION FPQR(25,25,25)
   INTEGER P,Q,R
Index: gcc/testsuite/gfortran.dg/graphite/id-27.f90
===
--- gcc/testsuite/gfortran.dg/graphite/id-27.f90	(revision 260479)
+++ gcc/testsuite/gfortran.dg/graphite/id-27.f90	(working copy)
@@ -1,4 +1,5 @@
-! { dg-additional-options "-Ofast" }
+! { dg-do compile }
+! { dg-additional-options "-Ofast -std=legacy" }
 MODULE module_ra_gfdleta
   INTEGER, PARAMETER  :: NBLY=15
   REAL   , SAVE :: EM1(28,180),EM1WDE(28,180),TABLE1(28,180), &
Index: gcc/testsuite/gfortran.dg/graphite/pr82449.f
===
--- gcc/testsuite/gfortran.dg/graphite/pr82449.f	(revision 260479)
+++ gcc/testsuite/gfortran.dg/graphite/pr82449.f	(working copy)
@@ -1,5 +1,5 @@
 ! { dg-do compile }
-! { dg-options "-O2 -floop-nest-optimize" }
+! { dg-options "-O2 -floop-nest-optimize -std=legacy" }
 
   SUBROUTINE JDFIDX(MKL,KGSH)
   DIMENSION MKL(6,6)


Re: [Patch, Fortran] PR 85841: [F2018] reject deleted features

2018-05-21 Thread Steve Kargl
On Mon, May 21, 2018 at 09:06:40PM +0200, Janus Weil wrote:
> Hi Steve,
> 
> > The attached patch fixes a few testcases that were missed
> > in the original patch.  Do you have these already in an
> > updated patch, or would you like me to commit my patch?
> 
> I saw the message just now and had no time to react yet. Please feel
> free to commit your patch.
> 

OK, I'll commit with an appropriate ChangeLog in a few minutes.

-- 
Steve


Re: [Patch, Fortran] PR 85841: [F2018] reject deleted features

2018-05-21 Thread Janus Weil
Hi Steve,

> The attached patch fixes a few testcases that were missed
> in the original patch.  Do you have these already in an
> updated patch, or would you like me to commit my patch?

I saw the message just now and had no time to react yet. Please feel
free to commit your patch.

Thanks,
Janus


Re: [PATCH][RFC] Add dynamic edge/bb flag allocation

2018-05-21 Thread Jeff Law
On 05/18/2018 07:15 AM, David Malcolm wrote:
> On Fri, 2018-05-18 at 13:11 +0200, Richard Biener wrote:
>> The following adds a simple alloc/free_flag machinery allocating
>> bits from an int typed pool and applies that to bb->flags and edge-
>>> flags.
>> This should allow infrastructure pieces to use egde/bb flags
>> temporarily
>> without worrying that users might already use it as for example
>> BB_VISITED and friends.  It converts one clever user to the new
>> interface.
>>
>> The allocation state is per CFG but we could also make it global
>> or merge the two pools so one allocates a flag that can be used for
>> bbs and edges at the same time.
>>
>> Thus - any opinions welcome.  I'm mainly targeting cfganal algorithms
>> where I want to add a few region-based ones that to be O(region-size)
>> complexity may not use sbitmaps for visited sets because of the
>> clearing
>> overhead and bitmaps are probably more expensive to use than a
>> BB/edge
>> flag that needs to be cleared afterwards.
>>
>> Built on x86_64, otherwise untested.
>>
>> Any comments?
> 
> Rather than putting alloc/free pairs at the usage sites, how about an
> RAII class?  Something like this:
Yes, please if at all possible we should be using RAII.

jeff


Re: [Patch, Fortran] PR 85841: [F2018] reject deleted features

2018-05-21 Thread Steve Kargl
On Mon, May 21, 2018 at 09:00:58AM +0200, Janus Weil wrote:
> 2018-05-21 0:19 GMT+02:00 Steve Kargl :
> > On Sun, May 20, 2018 at 09:44:47PM +0200, Janus Weil wrote:
> >>
> >> >> The patch still regtests cleanly. Ok for trunk?
> >> >
> >> > Patch looks good to me.  The only thing that worries me is
> >> > whether the patch will cause the SPEC benchmark to throw
> >> > an error or warning that it did not before.  As I don't have
> >> > SPEC benchmark and it cost $$$, I'm not going to let it
> >> > bother too much.
> >>
> >> Unfortunately I don't have access to SPEC either. Is anyone in a
> >> position to check this?
> >
> > We'll find out evidently as one of the C/C++ developers run SPEC.
> 
> Ok, we have plenty of time to fix up things before the next release anyway.
> 

Janus,

The attached patch fixes a few testcases that were missed
in the original patch.  Do you have these already in an
updated patch, or would you like me to commit my patch?

-- 
Steve
Index: gcc/testsuite/gfortran.dg/graphite/block-2.f
===
--- gcc/testsuite/gfortran.dg/graphite/block-2.f	(revision 260479)
+++ gcc/testsuite/gfortran.dg/graphite/block-2.f	(working copy)
@@ -1,3 +1,5 @@
+! { dg-do compile }
+! { dg-options "-std=legacy" }
   SUBROUTINE MATRIX_MUL_UNROLLED (A, B, C, L, M, N)
   DIMENSION A(L,M), B(M,N), C(L,N)
 
Index: gcc/testsuite/gfortran.dg/graphite/id-19.f
===
--- gcc/testsuite/gfortran.dg/graphite/id-19.f	(revision 260479)
+++ gcc/testsuite/gfortran.dg/graphite/id-19.f	(working copy)
@@ -1,3 +1,5 @@
+! { dg-do compile }
+! { dg-options "-std=legacy" }
   SUBROUTINE ECCODR(FPQR)
   DIMENSION FPQR(25,25,25)
   INTEGER P,Q,R
Index: gcc/testsuite/gfortran.dg/graphite/id-20.f
===
--- gcc/testsuite/gfortran.dg/graphite/id-20.f	(revision 260479)
+++ gcc/testsuite/gfortran.dg/graphite/id-20.f	(working copy)
@@ -1,4 +1,4 @@
-! { dg-options "-O3 -ffast-math" }
+! { dg-options "-O3 -ffast-math -std=legacy" }
 
   DIMENSION FPQR(25,25,25)
   INTEGER P,Q,R
Index: gcc/testsuite/gfortran.dg/graphite/id-27.f90
===
--- gcc/testsuite/gfortran.dg/graphite/id-27.f90	(revision 260479)
+++ gcc/testsuite/gfortran.dg/graphite/id-27.f90	(working copy)
@@ -1,4 +1,5 @@
-! { dg-additional-options "-Ofast" }
+! { dg-do compile }
+! { dg-additional-options "-Ofast -std=legacy" }
 MODULE module_ra_gfdleta
   INTEGER, PARAMETER  :: NBLY=15
   REAL   , SAVE :: EM1(28,180),EM1WDE(28,180),TABLE1(28,180), &
Index: gcc/testsuite/gfortran.dg/graphite/pr82449.f
===
--- gcc/testsuite/gfortran.dg/graphite/pr82449.f	(revision 260479)
+++ gcc/testsuite/gfortran.dg/graphite/pr82449.f	(working copy)
@@ -1,5 +1,5 @@
 ! { dg-do compile }
-! { dg-options "-O2 -floop-nest-optimize" }
+! { dg-options "-O2 -floop-nest-optimize -std=legacy" }
 
   SUBROUTINE JDFIDX(MKL,KGSH)
   DIMENSION MKL(6,6)


Re: [PATCH] Make __ibm128 a distinct type, patch 1 of 2 (PR 85657)

2018-05-21 Thread Segher Boessenkool
Hi!

On Fri, May 18, 2018 at 06:22:31PM -0400, Michael Meissner wrote:
>   * config/rs6000/rs6000.c (rs6000_init_builtins): Always create
>   __ibm128 as a distinct type.

This is not what it does though?  It only does that if TARGET_FLOAT128_TYPE?
And it does not make long double a separate type in all cases.

So please fix the changelog.

I think the patch is a step in the right direction, please apply to trunk.
Okay for 8 too (after the usual shakedown).


Segher


Re: [PATCH] Make __FUNCTION__ a mergeable string and do not generate symbol entry.

2018-05-21 Thread Jason Merrill
On Mon, May 21, 2018 at 9:33 AM, Martin Liška  wrote:
> On 10/24/2017 10:24 PM, Jason Merrill wrote:
>> On Thu, Sep 14, 2017 at 5:22 AM, Martin Liška  wrote:
>>> On 08/10/2017 09:43 PM, Jason Merrill wrote:
 On 07/14/2017 01:35 AM, Martin Liška wrote:
> On 05/01/2017 09:13 PM, Jason Merrill wrote:
>> On Wed, Apr 26, 2017 at 6:58 AM, Martin Liška  wrote:
>>> On 04/25/2017 01:58 PM, Jakub Jelinek wrote:
 On Tue, Apr 25, 2017 at 01:48:05PM +0200, Martin Liška wrote:
> Hello.
>
> This is patch that was originally installed by Jason and later 
> reverted due to PR70422.
> In the later PR Richi suggested a fix for that and Segher verified 
> that it helped him
> to survive regression tests. That's reason why I'm resending that.
>
> Patch can bootstrap on ppc64le-redhat-linux and survives regression 
> tests.
>
> Ready to be installed?
> Martin

> >From a34ce0ef37ae00609c9f3ff98a9cb0b7db6a8bd0 Mon Sep 17 00:00:00 
> >2001
> From: marxin 
> Date: Thu, 20 Apr 2017 14:56:30 +0200
> Subject: [PATCH] Make __FUNCTION__ a mergeable string and do not 
> generate
>   symbol entry.
>
> gcc/cp/ChangeLog:
>
> 2017-04-20  Jason Merrill  
>   Martin Liska  
>   Segher Boessenkool  
>
>   PR c++/64266
>   PR c++/70353
>   PR bootstrap/70422
>   Core issue 1962
>   * decl.c (cp_fname_init): Decay the initializer to pointer.
>   (cp_make_fname_decl): Set DECL_DECLARED_CONSTEXPR_P,
>   * pt.c (tsubst_expr) [DECL_EXPR]: Set DECL_VALUE_EXPR,
>   DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P and
>   DECL_IGNORED_P.  Don't call cp_finish_decl.

 If we don't emit those into the debug info, will the debugger be
 able to handle __FUNCTION__ etc. properly?
>>>
>>> No, debugger with the patch can't handled these. Similar to how clang
>>> behaves currently. Maybe it can be conditionally enabled with -g3, or 
>>> -g?
>>>
 Admittedly, right now we emit it into debug info only if those decls
 are actually used, say on:
 const char * foo () { return __FUNCTION__; }
 const char * bar () { return ""; }
 we'd emit foo::__FUNCTION__, but not bar::__FUNCTION__, so the debugger
 has to have some handling of it anyway.  But while in functions
 that don't refer to __FUNCTION__ it is always the debugger that needs
 to synthetize those and thus they will be always pointer-equal,
 if there are some uses of it and for other uses the debugger would
 synthetize it, there is the possibility that the debugger synthetized
 string will not be the same object as actually used in the function.
>>>
>>> You're right, currently one has to use a special function to be able to
>>> print it in debugger. I believe we've already discussed that, according
>>> to spec, the strings don't have to point to a same string.
>>>
>>> Suggestions what we should do with the patch?
>>
>> We need to emit debug information for these variables.  From Jim's
>> description in 70422 it seems that the problem is that the reference
>> to the string from the debug information is breaking
>> function_mergeable_rodata_prefix, which relies on
>> current_function_decl.  It seems to me that its callers should pass
>> along their decl parameter so that f_m_r_p can use the decl's
>> DECL_CONTEXT rather than rely on current_function_decl being set
>> properly>
>> Jason
>>
>
> Ok, after some time I returned back to it. I followed your advises and
> changed the function function_mergeable_rodata_prefix. Apart from a small
> rebase was needed.
>
> May I ask Jim to test the patch?
> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

> +  DECL_IGNORED_P (decl) = 1;

 As I said before, we do need to emit debug information for these 
 variables, so this is wrong.
>>>
>>> Hello.
>>>
>>> Sorry for overlooking that.
>>>

> -  section *s = targetm.asm_out.function_rodata_section 
> (current_function_decl);
> +  tree decl = current_function_decl;
> +  if (decl && DECL_CONTEXT (decl)
> +  && TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL)
> +decl = DECL_CONTEXT (decl);

 I don't see how this would help; it still relies on current_function_decl 
 being set correctly, which was the problem we were running into before.
>>>
>>> I see, that's what I wanted to discuss on Cauldron with you, but eventually 
>>> I did 

[PATCH] Add support for opening file streams from wide character strings

2018-05-21 Thread Jonathan Wakely

C++17 added new overloads to  class templates to support
opening files from wide character strings "on systems where
filesystem::path::value_type is not char". This patch adds those
overloads conditional on _wfopen being available, and enables them for
pre-C++17 modes as well.

Add support for opening file streams from wide character strings.
* config/io/basic_file_stdio.cc [_GLIBCXX_HAVE__WFOPEN]
(__basic_file::open(const wchar_t*, ios_base::openmode)):
Define new overload.
* config/io/basic_file_stdio.h [_GLIBCXX_HAVE__WFOPEN]
(__basic_file::open(const wchar_t*, ios_base::openmode)):
Declare new overload.
* configure.ac: Check for _wfopen.
* crossconfig.m4: Likewise.
* configure: Regenerate.
* config.h.in: Regenerate.
* include/bits/fstream.tcc [_GLIBCXX_HAVE__WFOPEN]
(basic_filebuf::open(const wchar_t*, ios_base::openmode)):
Define new overload.
* include/std/fstream [_GLIBCXX_HAVE__WFOPEN]
(basic_filebuf::open(const wchar_t*, ios_base::openmode)):
Declare new overload.
[_GLIBCXX_HAVE__WFOPEN]
(basic_ifstream::basic_ifstream(const wchar_t*, openmode))
(basic_ifstream::basic_open(const wchar_t*, openmode))
(basic_ofstream::basic_ifstream(const wchar_t*, openmode))
(basic_ofstream::basic_open(const wchar_t*, openmode))
(basic_fstream::basic_ifstream(const wchar_t*, openmode))
(basic_fstream::basic_open(const wchar_t*, openmode)): Define
new overloads.
* testsuite/27_io/basic_filebuf/open/wchar_t/1.cc: New.
* testsuite/27_io/basic_ifstream/cons/wchar_t/1.cc: New.
* testsuite/27_io/basic_ifstream/open/wchar_t/1.cc: New.
* testsuite/27_io/basic_ofstream/cons/wchar_t/1.cc: New.
* testsuite/27_io/basic_ofstream/open/wchar_t/1.cc: New.
* testsuite/27_io/basic_fstream/cons/wchar_t/1.cc: New.
* testsuite/27_io/basic_fstream/open/wchar_t/1.cc: New.

Tested on powerpc64le-linux, and also by manually running the new
tests on x86_64-w64-mingw32. Committed to trunk.


commit d23fabace1584989770a586ced3cdfbe34b1599c
Author: Jonathan Wakely 
Date:   Mon May 21 15:28:34 2018 +0100

Add support for opening file streams from wide character strings

C++17 added new overloads to  class templates to support
opening files from wide character strings "on systems where
filesystem::path::value_type is not char". This patch adds those
overloads conditional on _wfopen being available, and enables them for
pre-C++17 modes as well.

Add support for opening file streams from wide character strings.
* config/io/basic_file_stdio.cc [_GLIBCXX_HAVE__WFOPEN]
(__basic_file::open(const wchar_t*, ios_base::openmode)):
Define new overload.
* config/io/basic_file_stdio.h [_GLIBCXX_HAVE__WFOPEN]
(__basic_file::open(const wchar_t*, ios_base::openmode)):
Declare new overload.
* configure.ac: Check for _wfopen.
* crossconfig.m4: Likewise.
* configure: Regenerate.
* config.h.in: Regenerate.
* include/bits/fstream.tcc [_GLIBCXX_HAVE__WFOPEN]
(basic_filebuf::open(const wchar_t*, ios_base::openmode)):
Define new overload.
* include/std/fstream [_GLIBCXX_HAVE__WFOPEN]
(basic_filebuf::open(const wchar_t*, ios_base::openmode)):
Declare new overload.
[_GLIBCXX_HAVE__WFOPEN]
(basic_ifstream::basic_ifstream(const wchar_t*, openmode))
(basic_ifstream::basic_open(const wchar_t*, openmode))
(basic_ofstream::basic_ifstream(const wchar_t*, openmode))
(basic_ofstream::basic_open(const wchar_t*, openmode))
(basic_fstream::basic_ifstream(const wchar_t*, openmode))
(basic_fstream::basic_open(const wchar_t*, openmode)): Define
new overloads.
* testsuite/27_io/basic_filebuf/open/wchar_t/1.cc: New.
* testsuite/27_io/basic_ifstream/cons/wchar_t/1.cc: New.
* testsuite/27_io/basic_ifstream/open/wchar_t/1.cc: New.
* testsuite/27_io/basic_ofstream/cons/wchar_t/1.cc: New.
* testsuite/27_io/basic_ofstream/open/wchar_t/1.cc: New.
* testsuite/27_io/basic_fstream/cons/wchar_t/1.cc: New.
* testsuite/27_io/basic_fstream/open/wchar_t/1.cc: New.

diff --git a/libstdc++-v3/config/io/basic_file_stdio.cc 
b/libstdc++-v3/config/io/basic_file_stdio.cc
index a46814802cd..09ccd6a4788 100644
--- a/libstdc++-v3/config/io/basic_file_stdio.cc
+++ b/libstdc++-v3/config/io/basic_file_stdio.cc
@@ -249,6 +249,39 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 return __ret;
   }
 
+#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T
+  __basic_file*

Re: [PATCH rs6000] Fix PR85698

2018-05-21 Thread Pat Haugen
On 5/17/18 1:57 PM, Segher Boessenkool wrote:
> On Thu, May 17, 2018 at 07:58:20PM +0200, Richard Biener wrote:
>> On May 17, 2018 6:04:36 PM GMT+02:00, Segher Boessenkool 
>>  wrote:
>>> On Thu, May 17, 2018 at 10:42:46AM -0500, Pat Haugen wrote:
 The following patch fixes a problem that resulted in incorrect code
>>> generation for the CPU2017 benchmark 525.x264_r. The fix correctly
>>> checks the "dest" operand, which is the memory operand.
 Bootstrap/regtest on powerp64le and powerpc64 (-m32/-m64) with no new
 regressions. Ok for trunk?
>>> Okay.  Thanks!
>> Don't forget the branch. 
> It's okay for both 7 and 8, too.
> 

Fix has been backported to both 7 and 8 branches along with a fix to GCC 8 
branch gcc.target/powerpc/vec-setup-be-long.c to remove the XFAIL that was 
pre-approved off list.

-Pat



Re: [Bug libstdc++/85845] [9 Regression] Many libstdc++ test failures

2018-05-21 Thread François Dumont

I just committed this patch as trivial.

I must have run tests without rebuilding pre-compiled headers. I'll have 
to find out how to build tests without pre-compiled headers to avoid it 
in the future.


François

On 20/05/2018 19:06, fdumont at gcc dot gnu.org wrote:

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

François Dumont  changed:

What|Removed |Added

  Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org  |fdumont at gcc dot 
gnu.org



Index: include/bits/stl_tree.h
===
--- include/bits/stl_tree.h	(revision 260477)
+++ include/bits/stl_tree.h	(working copy)
@@ -980,7 +980,7 @@
 public:
   _Rb_tree(_Rb_tree&& __x, _Node_allocator&& __a)
   noexcept( noexcept(
-	_Rb_tree(std::declval<_Rb_tree>(), std::declval<_Node_allocator>(),
+	_Rb_tree(std::declval<_Rb_tree&&>(), std::declval<_Node_allocator&&>(),
 		 std::declval())) )
   : _Rb_tree(std::move(__x), std::move(__a),
 		 typename _Alloc_traits::is_always_equal{})


Re: [Patch, Fortran] PR 85841: [F2018] reject deleted features

2018-05-21 Thread Steve Kargl
On Mon, May 21, 2018 at 12:14:13PM +0200, Janus Weil wrote:
> 
> So, here is the promised follow-up patch. It mostly removes
> GFC_STD_F2008_TS and replaces it by GFC_STD_F2018 in a mechanical
> manner. Plus, it fixes the resulting fallout in the testsuite and
> updates the documentation. The non-mechanical parts are libgfortran.h
> and options.c. Regtests cleanly. Ok for trunk with a suitable
> ChangeLog?

Looks good to me.

HJ Lu posted of list of failures 

https://gcc.gnu.org/ml/fortran/2018-05/msg00067.html

Can you cast an eye over the failures?  I suspect
these can be fixed by adding 

{ dg-options -std=f2008 } 

or similar.

-- 
steve


Re: [PATCH 1/2][Aarch64] Improve FP to int conversions

2018-05-21 Thread Richard Earnshaw (lists)
On 18/05/18 21:34, Michael Collison wrote:
> This patch improves additional cases of FP to integer conversions.
> 
> Example 1:
> 
> unsigned long
> f7 (double x)
> {
>   return (unsigned) y;
> }
> 
> 
> At -O2
> 
> Trunk generates:
> 
> f7:
>   fcvtzu  w0, d0
>   uxtwx0, w0
>   ret
> 
> With the patch we can merge the zero-extend and reduce the sequence to one 
> instruction at -O2
> 
> f7:
>   fcvtzu  x0, d0
>   ret
>   
> Bootstrapped and regression tested on aarch64-linux-gnu. Okay for trunk?
> 
> 2018-05-15  Michael Collison  
> 
>   * config/aarch64/aarch64.md:
>   (*fix_to_zero_extenddfdi2): New pattern.
>   * gcc.target/aarch64/fix_extend1.c: New testcase.
> 

OK, either with, or without, Richard S's testsuite change.

R.
> 
> gnutools-6527-pt1.patch
> 
> 
> From 69f5f84710a709ae1db6d09b9326a6c804011057 Mon Sep 17 00:00:00 2001
> From: Michael Collison 
> Date: Fri, 11 May 2018 06:22:49 +0100
> Subject: [PATCH 1/2] Patch 1 to improve fp to int conversions
> 
> 
> diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
> index 32a0e1f..b37b56e 100644
> --- a/gcc/config/aarch64/aarch64.md
> +++ b/gcc/config/aarch64/aarch64.md
> @@ -5113,6 +5113,16 @@
>[(set_attr "type" "f_cvtf2i")]
>  )
>  
> +(define_insn "*fix_to_zero_extenddi2"
> +  [(set (match_operand:DI 0 "register_operand" "=r")
> + (zero_extend:DI
> +  (unsigned_fix:SI
> +   (match_operand:GPF 1 "register_operand" "w"]
> +  "TARGET_FLOAT"
> +  "fcvtzu\t%w0, %1"
> +  [(set_attr "type" "f_cvtf2i")]
> +)
> +
>  (define_insn "2"
>[(set (match_operand:GPF 0 "register_operand" "=w,w")
>  (FLOATUORS:GPF (match_operand: 1 "register_operand" 
> "w,r")))]
> diff --git a/gcc/testsuite/gcc.target/aarch64/fix_extend1.c 
> b/gcc/testsuite/gcc.target/aarch64/fix_extend1.c
> new file mode 100644
> index 000..3a251d0
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/fix_extend1.c
> @@ -0,0 +1,17 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2" } */
> +
> +unsigned long
> +f7 (double x)
> +{
> +  return (unsigned) x;
> +}
> +
> +unsigned long
> +f7_2 (float x)
> +{
> +  return (unsigned) x;
> +}
> +
> +/* { dg-final { scan-assembler "fcvtzu\\tw\[0-9\]+, d\[0-9\]+" } } */
> +/* { dg-final { scan-assembler "fcvtzu\\tw\[0-9\]+, s\[0-9\]+" } } */
> 



Re: [C++ Patch] PR 84588 ("[8 Regression] internal compiler error: Segmentation fault (contains_struct_check())")​ (Take 2)

2018-05-21 Thread Jason Merrill
OK.

On Mon, May 21, 2018 at 8:41 AM, Paolo Carlini  wrote:
> Hi again,
>
> On 19/05/2018 15:30, Jason Merrill wrote:
>>
>> How about doing cp_parser_commit_to_tentative_parse if we see
>> something that must be a declaration?  cp_parser_simple_declaration
>> has
>>
>>/* If we have seen at least one decl-specifier, and the next token
>>   is not a parenthesis, then we must be looking at a declaration.
>>   (After "int (" we might be looking at a functional cast.)  */
>>if (decl_specifiers.any_specifiers_p
>>&& cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_PAREN)
>>&& cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_BRACE)
>>&& !cp_parser_error_occurred (parser))
>>  cp_parser_commit_to_tentative_parse (parser);
>>
>> That seems useful here, as well.  Maybe factored into a separate function.
>
> The below implements this new idea, which indeed appears to work well: I
> tested it and testsuite-wise seems essentially equivalent to what I posted
> yesterday, besides a slightly worse error-recovery for the first issue in
> cpp1z/decomp16.C: an additional 'no match for ‘operator=’' error.
>
> Thanks!
> Paolo.
>
> //
>


[patch, rfc] Fortran async I/O support

2018-05-21 Thread Nicolas Koenig

Hey everyone,

Thomas and I have been working on adding asynchronous I/O to 
libgfortran. The patch is almost done, the only thing still missing is 
to link libgfortran against libpthread if it exists(which is for some 
reason necessary despite using __gthread) and deactivating it if 
libpthread doesn't exist (MinGW). At the moment it is still required to 
explicitly link against libpthread with -pthread when a program is 
compiled. Because of this we weren't able to run regression tests yet, 
since every single test fails.


It would be great if somebody else could try the patch and report their 
experiences. Also, if anyone knows how to add the whole conditional 
libpthread thing in the build script, a little help would be very welcome.


    Nicolas

P.S.: I have a new email address, the old one has some problems.

Index: gcc/fortran/trans-io.c
===
--- gcc/fortran/trans-io.c	(Revision 259739)
+++ gcc/fortran/trans-io.c	(Arbeitskopie)
@@ -1527,7 +1527,7 @@ gfc_trans_wait (gfc_code * code)
 mask |= IOPARM_common_err;
 
   if (p->id)
-mask |= set_parameter_value (, var, IOPARM_wait_id, p->id);
+mask |= set_parameter_ref (, _block, var, IOPARM_wait_id, p->id);
 
   set_parameter_const (, var, IOPARM_common_flags, mask);
 
Index: libgfortran/Makefile.am
===
--- libgfortran/Makefile.am	(Revision 259739)
+++ libgfortran/Makefile.am	(Arbeitskopie)
@@ -100,7 +100,8 @@ io/transfer128.c \
 io/unit.c \
 io/unix.c \
 io/write.c \
-io/fbuf.c
+io/fbuf.c \
+io/async.c
 
 endif
 
@@ -108,7 +109,8 @@ gfor_io_headers= \
 io/io.h \
 io/fbuf.h \
 io/format.h \
-io/unix.h
+io/unix.h \
+io/async.h
 
 gfor_helper_src= \
 intrinsics/associated.c \
Index: libgfortran/Makefile.in
===
--- libgfortran/Makefile.in	(Revision 259739)
+++ libgfortran/Makefile.in	(Arbeitskopie)
@@ -70,7 +70,8 @@ target_triplet = @target@
 @LIBGFOR_MINIMAL_FALSE@io/unit.c \
 @LIBGFOR_MINIMAL_FALSE@io/unix.c \
 @LIBGFOR_MINIMAL_FALSE@io/write.c \
-@LIBGFOR_MINIMAL_FALSE@io/fbuf.c
+@LIBGFOR_MINIMAL_FALSE@io/fbuf.c \
+@LIBGFOR_MINIMAL_FALSE@io/async.c
 
 @LIBGFOR_MINIMAL_FALSE@am__append_3 = \
 @LIBGFOR_MINIMAL_FALSE@intrinsics/access.c \
@@ -352,7 +353,7 @@ am__objects_47 = $(am__objects_4) $(am__objects_5)
 @LIBGFOR_MINIMAL_FALSE@	inquire.lo intrinsics.lo list_read.lo \
 @LIBGFOR_MINIMAL_FALSE@	lock.lo open.lo read.lo transfer.lo \
 @LIBGFOR_MINIMAL_FALSE@	transfer128.lo unit.lo unix.lo write.lo \
-@LIBGFOR_MINIMAL_FALSE@	fbuf.lo
+@LIBGFOR_MINIMAL_FALSE@	fbuf.lo async.lo
 am__objects_49 = size_from_kind.lo $(am__objects_48)
 @LIBGFOR_MINIMAL_FALSE@am__objects_50 = access.lo c99_functions.lo \
 @LIBGFOR_MINIMAL_FALSE@	chdir.lo chmod.lo clock.lo cpu_time.lo \
@@ -650,7 +651,8 @@ gfor_io_headers = \
 io/io.h \
 io/fbuf.h \
 io/format.h \
-io/unix.h
+io/unix.h \
+io/async.h
 
 gfor_helper_src = intrinsics/associated.c intrinsics/abort.c \
 	intrinsics/args.c intrinsics/cshift0.c intrinsics/eoshift0.c \
@@ -1550,6 +1552,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/any_l8.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/args.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/associated.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/async.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/backtrace.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bessel_r10.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bessel_r16.Plo@am__quote@
@@ -5813,6 +5816,13 @@ fbuf.lo: io/fbuf.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o fbuf.lo `test -f 'io/fbuf.c' || echo '$(srcdir)/'`io/fbuf.c
 
+async.lo: io/async.c
+@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT async.lo -MD -MP -MF $(DEPDIR)/async.Tpo -c -o async.lo `test -f 'io/async.c' || echo '$(srcdir)/'`io/async.c
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/async.Tpo $(DEPDIR)/async.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='io/async.c' object='async.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o async.lo `test -f 'io/async.c' || echo '$(srcdir)/'`io/async.c
+
 associated.lo: intrinsics/associated.c
 @am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC 

[PATCH][AArch64][committed] Fix gcc.target/aarch64/vec_init_1.c for tiny and large mcmodels

2018-05-21 Thread Kyrill Tkachov

Hi all,

This recently-committed test fails the INS scan for tiny and large memory 
models.
That is because instead of the:
make_vector:
adrpx1, a
adrpx0, b
moviv0.4s, 0
ldr s2, [x1, #:lo12:a]
ldr s1, [x0, #:lo12:b]
ins v0.s[2], v2.s[0]
ins v0.s[3], v1.s[0]
ret

That we generate for the default small model, we end up with a simple register
addressing mode with no addend/offset for the lane load:
make_vector:
moviv0.4s, 0
adr x1, a
adr x0, b
ld1 {v0.s}[2], [x1]
ld1 {v0.s}[3], [x0]
ret

and

make_vector:
moviv0.4s, 0
adrpx0, .LC0
ldr x1, [x0, #:lo12:.LC0]
adrpx0, .LC1
ldr x0, [x0, #:lo12:.LC1]
ld1 {v0.s}[2], [x1]
ld1 {v0.s}[3], [x0]
ret

So we end up merging the load and the lane insert.
This patch adjusts the testcase to scan for the right thing accordingly.
Checked that the testcase passes with -mcmodel=tiny, -mcmodel=small, 
-mcmodel=large.

Committing to trunk as obvious.

Thanks,
Kyrill

2018-05-21  Kyrylo Tkachov  

* gcc.target/aarch64/vec_init_1.c: Scan for LD1 instead of INS for
tiny and large memory models.
commit fb56afe1f049ba92235c4c272bd39dc730ce5d1f
Author: kyrtka01 
Date:   Mon May 21 15:39:05 2018 +0100

[AArch64] Fix gcc.target/aarch64/vec_init_1.c for tiny and large mcmodels

diff --git a/gcc/testsuite/gcc.target/aarch64/vec_init_1.c b/gcc/testsuite/gcc.target/aarch64/vec_init_1.c
index e245dc1..c8b48da 100644
--- a/gcc/testsuite/gcc.target/aarch64/vec_init_1.c
+++ b/gcc/testsuite/gcc.target/aarch64/vec_init_1.c
@@ -25,7 +25,11 @@ main (int argc, char **argv)
   return 0;
 }
 
-/* { dg-final { scan-assembler-times "ins\\t" 2 } } */
+/* For memory models that don't have an addend on the lane value
+   load we can merge the load and lane insert into an LD1.
+   For others we expect LDR + INS sequences.  */
+/* { dg-final { scan-assembler-times "ld1\\t" 2 { target { aarch64_tiny || aarch64_large } } } } */
+/* { dg-final { scan-assembler-times "ins\\t" 2 { target aarch64_small } } } */
 /* What we want to check, is that make_vector does not stp the whole vector
to the stack.  Unfortunately here we scan the body of main() too, which may
be a bit fragile - the test is currently passing only because of the option


Re: Gimple FE support for internal functions

2018-05-21 Thread Christophe Lyon
On 17 May 2018 at 10:25, Richard Sandiford  wrote:
> This patch gets the gimple FE to parse calls to internal functions.
> The only non-obvious thing was how the functions should be written
> to avoid clashes with real function names.  One option would be to
> go the magic number of underscores route, but we already do that for
> built-in functions, and it would be good to keep them visually
> distinct.  In the end I borrowed the local/internal label convention
> from asm and used:
>
>   x = .SQRT (y);
>
> I don't think even C++ has found a meaning for a leading dot yet.
>
> Tested on aarch64-linux-gnu (with and without SVE), aarch64_be-elf
> and x86_64-linux-gnu.  OK to install?
>
> Richard
>
>
> 2018-05-17  Richard Sandiford  
>
> gcc/
> * internal-fn.h (lookup_internal_fn): Declare
> * internal-fn.c (lookup_internal_fn): New function.
> * gimple.c (gimple_build_call_from_tree): Handle calls to
> internal functions.
> * gimple-pretty-print.c (dump_gimple_call): Print "." before
> internal function names.
> * tree-pretty-print.c (dump_generic_node): Likewise.
> * tree-ssa-scopedtables.c (expr_hash_elt::print): Likewise.
>
> gcc/c/
> * gimple-parser.c: Include internal-fn.h.
> (c_parser_gimple_statement): Treat a leading CPP_DOT as a call.
> (c_parser_gimple_call_internal): New function.
> (c_parser_gimple_postfix_expression): Use it to handle CPP_DOT.
> Fix typos in comment.
>
> gcc/testsuite/
> * gcc.dg/gimplefe-28.c: New test.

Hi Richard,

I've noticed that this new test fails on arm-none-linux-gnueabi and
arm-none-eabi:
during RTL pass: expand
/gcc/testsuite/gcc.dg/gimplefe-28.c: In function 'f1':
/gcc/testsuite/gcc.dg/gimplefe-28.c:5:1: internal compiler error: in
maybe_gen_insn, at optabs.c:7240
0xa9157a maybe_gen_insn(insn_code, unsigned int, expand_operand*)
/gcc/optabs.c:7240
0xa91658 maybe_expand_insn(insn_code, unsigned int, expand_operand*)
/gcc/optabs.c:7284
0xa91688 expand_insn(insn_code, unsigned int, expand_operand*)
/gcc/optabs.c:7315
0x94242d expand_direct_optab_fn
/gcc/internal-fn.c:2918
0x6c5d14 expand_call_stmt
/gcc/cfgexpand.c:2598
0x6c6fd4 expand_gimple_stmt_1
/gcc/cfgexpand.c:3644
0x6c6fd4 expand_gimple_stmt
/gcc/cfgexpand.c:3810
0x6c7ab4 expand_gimple_tailcall
/gcc/cfgexpand.c:3856
0x6c9183 expand_gimple_basic_block
/gcc/cfgexpand.c:5816
0x6cbf26 execute
/gcc/cfgexpand.c:6445

It passes on arm-none-linux-gnueabihf and armeb-none-linux-gnueabihf.

Christophe


> * gcc.dg/asan/use-after-scope-9.c: Adjust expected output for
> internal function calls.
> * gcc.dg/goacc/loop-processing-1.c: Likewise.
>
> Index: gcc/internal-fn.h
> ===
> --- gcc/internal-fn.h   2018-05-16 12:48:59.194282896 +0100
> +++ gcc/internal-fn.h   2018-05-17 09:17:58.757608747 +0100
> @@ -107,6 +107,8 @@ internal_fn_name (enum internal_fn fn)
>return internal_fn_name_array[(int) fn];
>  }
>
> +extern internal_fn lookup_internal_fn (const char *);
> +
>  /* Return the ECF_* flags for function FN.  */
>
>  extern const int internal_fn_flags_array[];
> Index: gcc/internal-fn.c
> ===
> --- gcc/internal-fn.c   2018-05-16 12:48:59.410941892 +0100
> +++ gcc/internal-fn.c   2018-05-17 09:22:49.808912358 +0100
> @@ -64,6 +64,26 @@ #define DEF_INTERNAL_FN(CODE, FLAGS, FNS
>0
>  };
>
> +/* Return the internal function called NAME, or IFN_LAST if there's
> +   no such function.  */
> +
> +internal_fn
> +lookup_internal_fn (const char *name)
> +{
> +  typedef hash_map name_to_fn_map_type;
> +  static name_to_fn_map_type *name_to_fn_map;
> +
> +  if (!name_to_fn_map)
> +{
> +  name_to_fn_map = new name_to_fn_map_type (IFN_LAST);
> +  for (unsigned int i = 0; i < IFN_LAST; ++i)
> +   name_to_fn_map->put (internal_fn_name (internal_fn (i)),
> +internal_fn (i));
> +}
> +  internal_fn *entry = name_to_fn_map->get (name);
> +  return entry ? *entry : IFN_LAST;
> +}
> +
>  /* Fnspec of each internal function, indexed by function number.  */
>  const_tree internal_fn_fnspec_array[IFN_LAST + 1];
>
> Index: gcc/gimple.c
> ===
> --- gcc/gimple.c2018-05-16 12:48:59.410941892 +0100
> +++ gcc/gimple.c2018-05-17 09:22:49.808912358 +0100
> @@ -350,12 +350,19 @@ gimple_build_call_from_tree (tree t, tre
>  {
>unsigned i, nargs;
>gcall *call;
> -  tree fndecl = get_callee_fndecl (t);
>
>gcc_assert (TREE_CODE (t) == CALL_EXPR);
>
>nargs = call_expr_nargs (t);
> -  call = gimple_build_call_1 (fndecl ? fndecl : CALL_EXPR_FN (t), nargs);
> +
> +  tree fndecl = 

Re: [PATCH , rs6000] Add missing builtin test cases, fix arguments to match specifications.

2018-05-21 Thread Carl Love
GCC maintainers:

I updated the CommitLog for gcc/testsuite/gcc.target/powerpc/altivec-
12.c to clarify the change.

A new test selector for big endian (be) and little endian (le) is added
to specify the platform for the tests to run on independent of the
platform being 32-bit or 64 bit.  The various be test files were
updated to use the selectors as needed.

The patch was retested on:

powerpc64le-unknown-linux-gnu (Power 8 LE)   
    powerpc64le-unknown-linux-gnu (Power 9 LE)
    powerpc64-unknown-linux-gnu (Power 8 BE)

With no regressions.

Please let me know if the patch looks OK for GCC mainline.

 Carl Love
---

gcc/testsuite/ChangeLog:

2018-05-18  Carl Love  

* gcc.target/powerpc/altivec-12.c (main): Fix declaration of ucz
to make it consistent with the naming convention in the file.
* gcc.target/powerpc/altivec-7-be.c (dg-do): Fix target.
Update instruction counts.
* gcc.target/powerpc/altivec-7-le.c (dg-final): Update instruction
counts.
* gcc.target/powerpc/altivec-7.h (main): Add vec_unpackh and
vec_unpackl tests.
* gcc.target/powerpc/builtins-1-le.c (Do not override) Change target
to LE.
(scan-assembler-times): Clean up arguments.  Add instruction counts
for new tests.
* gcc.target/powerpc/builtins-1-be.c (scan-assembler-times): Clean up
arguments.
Add instruction counts for new tests.
* gcc.target/powerpc/builtins-1.h (main): Add test case for vec_and.
vec_round, vec_rsqrt, vec_rsqrte, vec_mergee, vec_mergh, vec_mergo.
Remove vec_ctf tests returning double.  Remove vec_cts with
double args. Remove vec_sel with invalid arguments. Add tests for
vec_splat.
* gcc.target/powerpc/builtins-3-runnable.c (main): Add test for
vec_doublee, vec_doubleo, vec_doublel, vec_doubleh, vec_signed,
vec_unsigned.
* gcc.target/powerpc/builtins-3.c: Rename to builtins-3-be.h.
Add tests test_sll_vuill_vuill_vuc, test_sll_vsill_vsill_vuc.
Move dg-final checks for BE to builtins-3-be.c.
Move dg-final checks for LE to builtins-3-le.c.
* gcc.target/powerpc/builtins-3-be.c: New file.
* gcc.target/powerpc/builtins-3-le.c: New file.
* gcc.target/powerpc/p9-xxbr-2.c (rev_bool_long_long): Added test for
vec_revb.
* gcc.target/powerpc/vsx-7-be.c (dg-do): Make target BE. Clean up
scan-assembler-times arguments.
* gcc.target/powerpc/vsx-builtin-7.c: Add test functions splat_sc_s8,
splat_uc_u8, splat_ssi_s16, splat_usi_s16, splat_si_s32, splat_ui_u32,
splat_sll, splat_uc, splat_int128, splat_uint128.
Make second argument of vec_extract and vec_insert a signed int.
* gcc.target/powerpc/vsx-vector-5.c (vrint): Add vrint test for float
argument.
* lib/target-supports.exp: Add check_effective_target_be and
check_effective_target_le.
---
 gcc/testsuite/gcc.target/powerpc/altivec-12.c  |   2 +-
 gcc/testsuite/gcc.target/powerpc/altivec-7-be.c|  23 +-
 gcc/testsuite/gcc.target/powerpc/altivec-7-le.c|  25 +-
 gcc/testsuite/gcc.target/powerpc/altivec-7.h   |  17 +
 gcc/testsuite/gcc.target/powerpc/builtins-1-be.c   | 112 +++
 gcc/testsuite/gcc.target/powerpc/builtins-1-le.c   | 115 ---
 gcc/testsuite/gcc.target/powerpc/builtins-1.h  |  53 +++-
 gcc/testsuite/gcc.target/powerpc/builtins-3-be.c   |  77 +
 gcc/testsuite/gcc.target/powerpc/builtins-3-le.c   |  77 +
 .../gcc.target/powerpc/builtins-3-runnable.c   |  23 +-
 gcc/testsuite/gcc.target/powerpc/builtins-3.c  | 342 -
 gcc/testsuite/gcc.target/powerpc/builtins-3.h  | 309 +++
 gcc/testsuite/gcc.target/powerpc/p9-xxbr-2.c   |   8 +-
 gcc/testsuite/gcc.target/powerpc/vsx-7-be.c|   8 +-
 gcc/testsuite/gcc.target/powerpc/vsx-builtin-7.c   | 135 
 gcc/testsuite/gcc.target/powerpc/vsx-vector-5.c|  17 +-
 gcc/testsuite/lib/target-supports.exp  |  16 +
 17 files changed, 832 insertions(+), 527 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/powerpc/builtins-3-be.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/builtins-3-le.c
 delete mode 100644 gcc/testsuite/gcc.target/powerpc/builtins-3.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/builtins-3.h

diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-12.c 
b/gcc/testsuite/gcc.target/powerpc/altivec-12.c
index b0267b5..1f3175f 100644
--- a/gcc/testsuite/gcc.target/powerpc/altivec-12.c
+++ b/gcc/testsuite/gcc.target/powerpc/altivec-12.c
@@ -18,7 +18,7 @@ vector char scz;
 vector unsigned char uca = {0,4,8,1,5,9,2,6,10,3,7,11,15,12,14,13};
 vector unsigned char ucb = {6,4,8,3,1,9,2,6,10,3,7,11,15,12,14,13};
 vector unsigned char uc_expected = 

[Ada] Spurious warning on object declaration with address clause

2018-05-21 Thread Pierre-Marie de Rodat
The compiler warns on an object declaration with default initialization
and an address clause, to indicate that the overlay implied by the address
clause might affect a value elsewhere. The warning is suppressed if the type
carries the Suppress_Initialization aspect. With this patch the compiler
also inhibits the warning if the aspect is specified for the object itself.

Tested on x86_64-pc-linux-gnu, committed on trunk

2018-05-21  Ed Schonberg  

gcc/ada/

* freeze.adb (Warn_Overlay): Do not emit a wawrning on an object
declaration with an explicit address clause and a type with default
initialization, if the declaration carries an aspect
Suppress_Initialization.

gcc/testsuite/

* gnat.dg/suppress_initialization.adb,
gnat.dg/suppress_initialization_pkg.ads: New testcase.--- gcc/ada/freeze.adb
+++ gcc/ada/freeze.adb
@@ -8690,11 +8690,14 @@ package body Freeze is
   --  tested for because predefined String types are initialized by inline
   --  code rather than by an init_proc). Note that we do not give the
   --  warning for Initialize_Scalars, since we suppressed initialization
-  --  in this case. Also, do not warn if Suppress_Initialization is set.
+  --  in this case. Also, do not warn if Suppress_Initialization is set
+  --  either on the type, or on the object via pragma or aspect.
 
   if Present (Expr)
 and then not Is_Imported (Ent)
 and then not Initialization_Suppressed (Typ)
+and then not (Ekind (Ent) = E_Variable
+and then Initialization_Suppressed (Ent))
 and then (Has_Non_Null_Base_Init_Proc (Typ)
or else Is_Access_Type (Typ)
or else (Normalize_Scalars

--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/suppress_initialization.adb
@@ -0,0 +1,8 @@
+--  { dg-do compile }
+
+with Suppress_Initialization_Pkg;
+
+procedure Suppress_Initialization is
+begin
+   Suppress_Initialization_Pkg.Read;
+end Suppress_Initialization;

--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/suppress_initialization_pkg.ads
@@ -0,0 +1,31 @@
+with Interfaces; use Interfaces;
+with System;
+
+package Suppress_Initialization_Pkg is
+
+   type Discriminated_Type (Foo : Unsigned_8 := 0) is record
+  case Foo is
+ when 0 =>
+Bar  : Boolean;
+ when 1 =>
+Baz  : Unsigned_32;
+ when others =>
+null;
+  end case;
+   end record;
+
+   for Discriminated_Type use record
+  Foo at 0 range  0 ..  7;
+  Bar at 1 range  0 ..  0;
+  Baz at 1 range  0 .. 31;
+   end record;
+
+   External : Discriminated_Type
+   with
+ Volatile,
+ Suppress_Initialization,
+ Address => System'To_Address (16#1234_5678#);
+
+   procedure Read;
+
+end Suppress_Initialization_Pkg;



[Ada] Error message on invalid conversion involving limited views

2018-05-21 Thread Pierre-Marie de Rodat
A type conversion may be illegal if the expression in the conversion has a
limited view of a type. This patch expands the error report to indicate the
presence of a limited view, and when the context is a package body it suggests
the addition of a regular with-clause to make the full view available.

Compiling client.adb must yield:

   client.adb:6:16: invalid conversion, not compatible with limited view
  of type "Map_Type" defined at maps.ads:2
   client.adb:6:16: add with_clause for "Maps" to current unit


package Maps is
  type Map_Type is null record;
end;

limited with Maps;
package Payloads is
  function Get_Map return access Maps.Map_Type;
end;

with Maps;
package Maps2 is
  type New_Map_Type is new Maps.Map_Type;
end;

with Maps2;
package Client is
  procedure Foo (Map : Maps2.New_Map_Type) is null;
  procedure Bar;
end;

with Payloads;
package body Client is
  procedure Bar is
  begin
 Foo (Maps2.New_Map_Type (Payloads.Get_Map.all));
  end;
end;

Tested on x86_64-pc-linux-gnu, committed on trunk

2018-05-21  Ed Schonberg  

gcc/ada/

* sem_res.adb (Valid_Conversion): Improve error message on an illegal
type conversion whose expression has a limited view of a type.--- gcc/ada/sem_res.adb
+++ gcc/ada/sem_res.adb
@@ -13011,8 +13011,33 @@ package body Sem_Res is
   --  Here we have a real conversion error
 
   else
- Conversion_Error_NE
-   ("invalid conversion, not compatible with }", N, Opnd_Type);
+
+ --  Check for missing regular with_clause when only a limited view
+ --  of target is available.
+
+ if From_Limited_With (Opnd_Type)
+   and then In_Package_Body
+ then
+Conversion_Error_NE
+  ("invalid conversion, not compatible with limited view of }",
+N, Opnd_Type);
+Conversion_Error_NE ("\add with_clause for& to current unit!", N,
+  Scope (Opnd_Type));
+
+ elsif Is_Access_Type (Opnd_Type)
+   and then From_Limited_With (Designated_Type (Opnd_Type))
+   and then In_Package_Body
+ then
+Conversion_Error_NE
+  ("invalid conversion, not compatible with }", N, Opnd_Type);
+Conversion_Error_NE ("\add with_clause for& to current unit!", N,
+  Scope (Designated_Type (Opnd_Type)));
+
+ else
+Conversion_Error_NE
+  ("invalid conversion, not compatible with }", N, Opnd_Type);
+ end if;
+
  return False;
   end if;
end Valid_Conversion;



[Ada] Aspects on stubs

2018-05-21 Thread Pierre-Marie de Rodat
This patch ensures that aspect specifications which appear on package,
protected, and task body stubs are properly analyzed.


-- Source --


--  pack.ads

package Pack
  with SPARK_Mode,
   Abstract_State => State
is
   -
   -- Refined_Depends, Refined_Global --
   -

   procedure Proc_1;
   procedure Proc_2
 with Global  => (In_Out => State),
  Depends => (State  => State);

   task Task_Obj_1;
   task Task_Obj_2
 with Global  => (In_Out => State),
  Depends => (State  => State);

   --
   -- Refined_Post --
   --

   function Func_1 (Formal : Integer) return Integer;
   function Func_2 (Formal : Integer) return Integer
 with Post => Func_2'Result > Formal;

   ---
   -- Refined_State --
   ---

   package Pack_1 is end Pack_1;
   package Pack_2 with Abstract_State => State_2 is end Pack_2;

   
   -- SPARK_Mode --
   

   package Pack_3 with SPARK_Mode => Off is end Pack_3;
   package Pack_4 with SPARK_Mode => Off is end Pack_4;
   package Pack_5 is end Pack_5;

   protected type Prot_Typ_1 with SPARK_Mode => Off is end Prot_Typ_1;
   protected type Prot_Typ_2 with SPARK_Mode => Off is end Prot_Typ_2;
   protected type Prot_Typ_3 is end Prot_Typ_3;

   procedure Proc_3 with SPARK_Mode => Off;
   procedure Proc_4 with SPARK_Mode => Off;
   procedure Proc_5;

   task type Task_Typ_1 with SPARK_Mode => Off;
   task type Task_Typ_2 with SPARK_Mode => Off;
   task type Task_Typ_3;
end Pack;

--  pack.adb

package body Pack
  with SPARK_Mode,
   Refined_State => (State => Constit)
is
   Constit : Integer := 0;

   -
   -- Refined_Depends, Refined_Global --
   -

   procedure Proc_1 is separate
 with Refined_Global  => (In_Out  => Constit),   --  Error
  Refined_Depends => (Constit => Constit);   --  Error

   procedure Proc_2 is separate
 with Refined_Global  => (In_Out  => Constit),   --  OK
  Refined_Depends => (Constit => Constit);   --  OK

   task body Task_Obj_1 is separate
 with Refined_Global  => (In_Out  => Constit),   --  Error
  Refined_Depends => (Constit => Constit);   --  Error

   task body Task_Obj_2 is separate
 with Refined_Global  => (In_Out  => Constit),   --  OK
  Refined_Depends => (Constit => Constit);   --  OK

   --
   -- Refined_Post --
   --

   function Func_1 (Formal : Integer) return Integer is separate
 with Refined_Post => Func_1'Result > Formal;--  OK

   function Func_2 (Formal : Integer) return Integer is separate
 with Refined_Post => Func_2'Result > Formal;--  OK

   ---
   -- Refined_State --
   ---

   package body Pack_1 is separate
 with Refined_State => (State_1 => Constit_1);   --  Error

   package body Pack_2 is separate
 with Refined_State => (State_2 => Constit_2);   --  Error

   
   -- SPARK_Mode --
   

   package body Pack_3 is separate with SPARK_Mode => On;--  Error
   package body Pack_4 is separate;
   package body Pack_5 is separate with SPARK_Mode => Off;   --  Error

   protected body Prot_Typ_1 is separate with SPARK_Mode => On;  --  Error
   protected body Prot_Typ_2 is separate;
   protected body Prot_Typ_3 is separate with SPARK_Mode => Off; --  Error

   procedure Proc_3 is separate with SPARK_Mode => On;   --  Error
   procedure Proc_4 is separate;
   procedure Proc_5 is separate with SPARK_Mode => Off;  --  Error

   task body Task_Typ_1 is separate with SPARK_Mode => On;   --  Error
   task body Task_Typ_2 is separate;
   task body Task_Typ_3 is separate with SPARK_Mode => Off;  --  Error
end Pack;

--  pack-func_1.adb

separate (Pack)

function Func_1 (Formal : Integer) return Integer
  with Refined_Post => Func_1'Result > Formal--  Error
is
begin
   return Formal * 10;
end Func_1;

--  pack-func_2.adb

separate (Pack)

function Func_2 (Formal : Integer) return Integer
  with Refined_Post => Func_2'Result > Formal--  Error
is
begin
   return Formal * 10;
end Func_2;

--  pack-pack_1.adb

separate (Pack)

package body Pack_1
  with SPARK_Mode,
   Refined_State => (State_1 => Constit_1)   --  Error
is
   Constit_1 : Integer := 1;
end Pack_1;

--  pack-pack_2.adb

separate (Pack)

package body Pack_2
  with SPARK_Mode,
   Refined_State => (State_2 => Constit_2)   --  OK
is
   Constit_2 : Integer := 2;
end Pack_2;

--  pack-pack_3.adb


[Ada] Spurious error on early call region of tagged type

2018-05-21 Thread Pierre-Marie de Rodat
This patch corrects the part of the access-before-elaboration mechanism which
ensures that the freeze node of a tagged type is within the early call region
of all its overriding bodies to ignore predefined primitives.


-- Source --


--  pack.ads

package Pack with SPARK_Mode is
   type Parent_Typ is tagged null record;
   procedure Prim (Obj : Parent_Typ);

   type Deriv_Typ is new Parent_Typ with private;
   overriding procedure Prim (Obj : Deriv_Typ);

private
   type Deriv_Typ is new Parent_Typ with null record;
end Pack;

-
-- Compilation --
-

$ gcc -c pack.ads

Tested on x86_64-pc-linux-gnu, committed on trunk

2018-05-21  Hristian Kirtchev  

gcc/ada/

* exp_cg.adb: Remove with and use clause for Exp_Disp.
* exp_ch9.adb: Remove with and use clause for Exp_Disp.
* exp_disp.adb (Is_Predefined_Dispatching_Operation): Moved to Sem_Util.
(Is_Predefined_Interface_Primitive): Moved to Sem_Util.
(Is_Predefined_Internal_Operation): Moved to Sem_Util.
* exp_disp.ads (Is_Predefined_Dispatching_Operation): Moved to Sem_Util.
(Is_Predefined_Interface_Primitive): Moved to Sem_Util.
(Is_Predefined_Internal_Operation): Moved to Sem_Util.
* exp_dist.adb: Remove with and use clause for Exp_Disp.
* freeze.adb: Remove with and use clause for Exp_Disp.
* sem_cat.adb: Remove with and use clause for Exp_Disp.
* sem_ch6.adb: Remove with and use clause for Exp_Disp.
* sem_ch12.adb: Remove with and use clause for Exp_Disp.
* sem_elab.adb (Check_Overriding_Primitive): Do not process predefined
primitives.
* sem_util.adb: Remove with and use clause for Exp_Disp.
(Is_Predefined_Dispatching_Operation): Moved from Exp_Disp.
(Is_Predefined_Interface_Primitive): Moved from Exp_Disp.
(Is_Predefined_Internal_Operation): Moved from Exp_Disp.
* sem_util.ads (Is_Predefined_Dispatching_Operation): Moved from
Exp_Disp.
(Is_Predefined_Interface_Primitive): Moved from Exp_Disp.
(Is_Predefined_Internal_Operation): Moved from Exp_Disp.--- gcc/ada/exp_cg.adb
+++ gcc/ada/exp_cg.adb
@@ -26,7 +26,6 @@
 with Atree;use Atree;
 with Einfo;use Einfo;
 with Elists;   use Elists;
-with Exp_Disp; use Exp_Disp;
 with Exp_Dbug; use Exp_Dbug;
 with Exp_Tss;  use Exp_Tss;
 with Lib;  use Lib;

--- gcc/ada/exp_ch9.adb
+++ gcc/ada/exp_ch9.adb
@@ -31,7 +31,6 @@ with Exp_Ch3;  use Exp_Ch3;
 with Exp_Ch6;  use Exp_Ch6;
 with Exp_Ch11; use Exp_Ch11;
 with Exp_Dbug; use Exp_Dbug;
-with Exp_Disp; use Exp_Disp;
 with Exp_Sel;  use Exp_Sel;
 with Exp_Smem; use Exp_Smem;
 with Exp_Tss;  use Exp_Tss;

--- gcc/ada/exp_disp.adb
+++ gcc/ada/exp_disp.adb
@@ -2177,89 +2177,6 @@ package body Exp_Disp is
 and then Is_Dispatch_Table_Entity (Etype (Name (N)));
end Is_Expanded_Dispatching_Call;
 
-   -
-   -- Is_Predefined_Dispatching_Operation --
-   -
-
-   function Is_Predefined_Dispatching_Operation
- (E : Entity_Id) return Boolean
-   is
-  TSS_Name : TSS_Name_Type;
-
-   begin
-  if not Is_Dispatching_Operation (E) then
- return False;
-  end if;
-
-  Get_Name_String (Chars (E));
-
-  --  Most predefined primitives have internally generated names. Equality
-  --  must be treated differently; the predefined operation is recognized
-  --  as a homogeneous binary operator that returns Boolean.
-
-  if Name_Len > TSS_Name_Type'Last then
- TSS_Name := TSS_Name_Type (Name_Buffer (Name_Len - TSS_Name'Length + 1
- .. Name_Len));
- ifChars (E) = Name_uSize
-   or else TSS_Name  = TSS_Stream_Read
-   or else TSS_Name  = TSS_Stream_Write
-   or else TSS_Name  = TSS_Stream_Input
-   or else TSS_Name  = TSS_Stream_Output
-   or else
- (Chars (E) = Name_Op_Eq
-and then Etype (First_Formal (E)) = Etype (Last_Formal (E)))
-   or else Chars (E) = Name_uAssign
-   or else TSS_Name  = TSS_Deep_Adjust
-   or else TSS_Name  = TSS_Deep_Finalize
-   or else Is_Predefined_Interface_Primitive (E)
- then
-return True;
- end if;
-  end if;
-
-  return False;
-   end Is_Predefined_Dispatching_Operation;
-
-   ---
-   -- Is_Predefined_Internal_Operation  --
-   ---
-
-   function Is_Predefined_Internal_Operation
- (E : Entity_Id) return Boolean
-   is
-  TSS_Name : TSS_Name_Type;
-
-   begin
-  if not Is_Dispatching_Operation (E) then
- return False;
-  end if;
-
-  Get_Name_String (Chars (E));
-
-  --  Most predefined primitives have internally generated names. Equality
-  --  must be treated 

[Ada] Exit statement in loops over iterable objects

2018-05-21 Thread Pierre-Marie de Rodat
This patch fixes an omission in the expansion of loops over GNAT-specific
iterable objects. If the source includes an explicit name for the loop,
that name has to be preserved in the expanded code to allow exit statements
to mention it.

Tested on x86_64-pc-linux-gnu, committed on trunk

2018-05-21  Ed Schonberg  

gcc/ada/

* exp_ch5.adb (Build_Formal_Container_Iteration): If source has
explicit name for iterator loop, preserve that name in expanded
construct, for possible use in exit statements.

gcc/testsuite/

* gnat.dg/exit1.adb: New testcase.--- gcc/ada/exp_ch5.adb
+++ gcc/ada/exp_ch5.adb
@@ -237,6 +237,15 @@ package body Exp_Ch5 is
 New_Occurrence_Of (Cursor, Loc,
   Statements => Stats,
   End_Label  => Empty);
+
+  --  If the contruct has a specified loop name, preserve it in the
+  --  new loop, for possible use in exit statements.
+
+  if Present (Identifier (N))
+and then Comes_From_Source (Identifier (N))
+  then
+ Set_Identifier (New_Loop, Identifier (N));
+  end if;
end Build_Formal_Container_Iteration;
 
--

--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/exit1.adb
@@ -0,0 +1,45 @@
+--  { dg-do run }
+--  { dg-output "1 2 3 4 5 6 7 \| 1- 1 2 3 2- 1 2 3 3- 1 2 3 4- 1 2 3 5- 1 2 3" }
+
+with Ada.Text_IO; use Ada.Text_IO;
+
+procedure Exit1 is
+   type Int_Range is record
+  First, Last : Integer;
+   end record
+  with Iterable => (First => First,
+Next => Next,
+Previous => Previous,
+Last => Last,
+Has_Element => Has_Element,
+Element => Element);
+
+   function First (IR : Int_Range) return Integer is (IR.First);
+   function Last (IR : Int_Range) return Integer is (IR.Last);
+   function Next (IR : Int_Range; N : Integer) return Integer is (N + 1);
+   function Previous (IR : Int_Range; N : Integer) return Integer is (N - 1);
+   function Has_Element (IR : Int_Range; N : Integer) return Boolean is
+ (N in IR.First ..IR.Last);
+   function Element (IR : Int_Range; N : Integer) return Integer is (N);
+
+   IR : Int_Range := (1, 10);
+
+begin
+A_Loop:   for I of IR loop
+  Put (I'Img);
+  exit A_Loop when I = 7;
+   end loop A_Loop;
+   Put (" | ");
+
+B_Loop:   for I of IR loop
+  Put (I'Img & '-');
+  C_Loop : for J of IR loop
+ Put (J'Img);
+ exit when J = 3;
+  end loop C_Loop;
+
+  exit B_Loop when I = 5;
+   end loop B_Loop;
+   New_Line;
+
+end Exit1;



[Ada] Placement of pragma Elaboration_Checks

2018-05-21 Thread Pierre-Marie de Rodat
This patch modifies the semantics of pragma Elaboration_Checks. The pragma
was intended to be a configuration pragma, however its placement was never
verified until now.

The pragma may appear in the following contexts:

   * Configuration pragmas file

   * Prior to the context clauses of a compilation unit's initial declaration

Any other placement of the pragma will result in a warning and the effects of
the offending pragma will be ignored.


-- Source --


--  elab_checks_1.adc

pragma Elaboration_Checks (Dynamic);

--  elab_checks_2.adc

pragma Elaboration_Checks (Dynamic);
pragma Elaboration_Checks (Static);  --  Error

--  pack_1.ads

pragma Elaboration_Checks (Static);  --  OK

package Pack_1 is
end Pack_1;

--  pack_2.ads

pragma Elaboration_Checks (Static);  --  OK
pragma Elaboration_Checks (Static);  --  Error

package Pack_2 is
end Pack_2;

--  pack_3.ads

package Pack_3 is
   procedure Proc;
end Pack_3;

--  pack_3.adb

pragma Elaboration_Checks (Static);  --  Error

package body Pack_3 is
   procedure Proc is begin null; end Proc;
end Pack_3;

--  pack_4.ads

package Pack_4 is
   procedure Proc;
end Pack_4;

--  pack_4.adb

package body Pack_4 is
   procedure Proc is separate;
end Pack_4;

--  pack_4-proc.adb

pragma Elaboration_Checks (Static);  --  Error

separate (Pack_4)
procedure Proc is begin null; end Proc;

--  gen.ads

generic
   with function Called_At_Elaboration return Boolean;

package Gen is
   procedure Proc;
end Gen;

--  gen.adb

package body Gen is
   procedure Proc is
  Obj : constant Boolean := Called_At_Elaboration;
   begin null; end Proc;
begin
   Proc;
end Gen;

--  abe_static.ads

pragma Elaboration_Checks (Static);

with Gen;

package ABE_Static is
   function ABE return Boolean;

   package Inst_1 is new Gen (ABE);
end ABE_Static;

--  abe_static.adb

package body ABE_Static is
   package Inst_2 is new Gen (ABE);

   package Subunit is
   end Subunit;

   package body Subunit is separate;

   function ABE return Boolean is
   begin
  return True;
   end ABE;
end ABE_Static;

--  abe_static-subunit.adb

separate (ABE_Static)

package body Subunit is
   package Inst_3 is new Gen (ABE);

   package Nested_Subunit is
   end Nested_Subunit;

   package body Nested_Subunit is separate;
end Subunit;

--  abe_static-subunit-nested_subunit.adb

separate (ABE_Static.Subunit)

package body Nested_Subunit is
   package Inst_4 is new Gen (ABE);
end Nested_Subunit;

--  abe_static_main.adb

with ABE_Static;

procedure ABE_Static_Main is begin null; end ABE_Static_Main;


-- Compilation and output --


$ gcc -c pack_1.ads -gnatec=elab_checks_1.adc
$ gcc -c pack_1.ads -gnatec=elab_checks_2.adc
$ gcc -c pack_1.ads
$ gcc -c pack_2.ads
$ gcc -c pack_3.adb
$ gcc -c pack_4.adb
$ gnatmake -q -gnatE abe_static_main.adb
elab_checks_2.adc:2:01: pragma "Elaboration_Checks" duplicates pragma declared
  at line 1
pack_2.ads:2:01: pragma "Elaboration_Checks" duplicates pragma declared at line
  1
pack_3.adb:1:01: warning: effects of pragma "Elaboration_Checks" are ignored
pack_3.adb:1:01: warning: place pragma on initial declaration of library unit
pack_4-proc.adb:1:01: warning: effects of pragma "Elaboration_Checks" are
  ignored
pack_4-proc.adb:1:01: warning: place pragma on initial declaration of library
  unit
abe_static.adb:2:04: warning: in instantiation at gen.adb:3
abe_static.adb:2:04: warning: cannot call "ABE" before body seen
abe_static.adb:2:04: warning: Program_Error may be raised at run time
abe_static.adb:2:04: warning:   body of unit "ABE_Static" elaborated
abe_static.adb:2:04: warning:   procedure "Proc" called at gen.adb:6, instance
  at line 2
abe_static.adb:2:04: warning:   function "ABE" called at gen.adb:3, instance at
  line 2
abe_static.ads:8:04: warning: in instantiation at gen.adb:3
abe_static.ads:8:04: warning: cannot call "ABE" before body seen
abe_static.ads:8:04: warning: Program_Error may be raised at run time
abe_static.ads:8:04: warning:   spec of unit "ABE_Static" elaborated
abe_static.ads:8:04: warning:   procedure "Proc" called at gen.adb:6, instance
  at line 8
abe_static.ads:8:04: warning:   function "ABE" called at gen.adb:3, instance at
  line 8
abe_static-subunit.adb:4:04: warning: in instantiation at gen.adb:3
abe_static-subunit.adb:4:04: warning: cannot call "ABE" before body seen
abe_static-subunit.adb:4:04: warning: Program_Error may be raised at run time
abe_static-subunit.adb:4:04: warning:   body of unit "ABE_Static" elaborated
abe_static-subunit.adb:4:04: warning:   procedure "Proc" called at gen.adb:6,
  instance at line 4
abe_static-subunit.adb:4:04: warning:   function "ABE" called at gen.adb:3,
  instance at line 4
abe_static-subunit-nested_subunit.adb:4:04: 

[Ada] Use type conversion when inlining may trigger a run-time check

2018-05-21 Thread Pierre-Marie de Rodat
In the frontend inlining used in GNATprove, inlining of a return statement
was using an unchecked type conversion, which could cause a necessary
run-time check on the conversion to be skipped. Now fixed.

There is no impact on compilation.

Tested on x86_64-pc-linux-gnu, committed on trunk

2018-05-21  Yannick Moy  

gcc/ada/

* inline.adb (Expand_Inlined_Call.Process_Formals): Use a type
conversion instead of an unchecked type conversion when inlining a
return statement, unless type qualification is required (for character
and string literal) or no check can result from the conversion (for
access types).
* opt.ads: Update comment.--- gcc/ada/inline.adb
+++ gcc/ada/inline.adb
@@ -2482,26 +2482,42 @@ package body Inline is
end if;
 
--  Because of the presence of private types, the views of the
-   --  expression and the context may be different, so place an
-   --  unchecked conversion to the context type to avoid spurious
+   --  expression and the context may be different, so place
+   --  a type conversion to the context type to avoid spurious
--  errors, e.g. when the expression is a numeric literal and
--  the context is private. If the expression is an aggregate,
--  use a qualified expression, because an aggregate is not a
-   --  legal argument of a conversion. Ditto for numeric literals
-   --  and attributes that yield a universal type, because those
-   --  must be resolved to a specific type.
-
-   if Nkind_In (Expression (N), N_Aggregate, N_Null)
+   --  legal argument of a conversion. Ditto for numeric, character
+   --  and string literals, and attributes that yield a universal
+   --  type, because those must be resolved to a specific type.
+
+   if Nkind_In (Expression (N), N_Aggregate,
+N_Null,
+N_Character_Literal,
+N_String_Literal)
  or else Yields_Universal_Type (Expression (N))
then
   Ret :=
 Make_Qualified_Expression (Sloc (N),
   Subtype_Mark => New_Occurrence_Of (Ret_Type, Sloc (N)),
   Expression   => Relocate_Node (Expression (N)));
-   else
+
+   --  Use an unchecked type conversion between access types, for
+   --  which a type conversion would not always be valid, as no
+   --  check may result from the conversion.
+
+   elsif Is_Access_Type (Ret_Type) then
   Ret :=
 Unchecked_Convert_To
   (Ret_Type, Relocate_Node (Expression (N)));
+
+   --  Otherwise use a type conversion, which may trigger a check
+
+   else
+  Ret :=
+Make_Type_Conversion (Sloc (N),
+  Subtype_Mark => New_Occurrence_Of (Ret_Type, Sloc (N)),
+  Expression   => Relocate_Node (Expression (N)));
end if;
 
if Nkind (Targ) = N_Defining_Identifier then

--- gcc/ada/opt.ads
+++ gcc/ada/opt.ads
@@ -727,7 +727,7 @@ package Opt is
--  Set True to activate inlining by front-end expansion (even on GCC
--  targets, where inlining is normally handled by the back end). Set by
--  the flag -gnatN (which is now considered obsolescent, since the GCC
-   --  back end can do a better job of inlining than the front end these days.
+   --  back end can do a better job of inlining than the front end these days).
 
Full_Path_Name_For_Brief_Errors : Boolean := False;
--  PROJECT MANAGER



[Ada] Spurious error on indexed call as prefix of a call

2018-05-21 Thread Pierre-Marie de Rodat
This patch refines the handling of the well-known syntactic ambiguity created
by a function with defaulted parameters that returns an array, so that F (X)
may designate a call to the function, or an indexing of a parameterless call.
This patch handles the case where such a call is itself the prefix of another
call, and the function is a primitive operation invoked in prefix form.

Tested on x86_64-pc-linux-gnu, committed on trunk

2018-05-21  Ed Schonberg  

gcc/ada/

* sem_ch4.adb (Analyze_One_Call): Recognize complex cases where an
indexed call originally in prefix forn is itself the prefix of a
further call.

gcc/testsuite/

* gnat.dg/array30.adb: New testcase.--- gcc/ada/sem_ch4.adb
+++ gcc/ada/sem_ch4.adb
@@ -3199,12 +3199,28 @@ package body Sem_Ch4 is
   Actuals : constant List_Id   := Parameter_Associations (N);
   Prev_T  : constant Entity_Id := Etype (N);
 
+  --  Recognize cases of prefixed calls that have been rewritten in
+  --  various ways. The simplest case is a rewritten selected component,
+  --  but it can also be an already-examined indexed component, or a
+  --  prefix that is itself a rewritten prefixed call that is in turn
+  --  an indexed call (the syntactic ambiguity involving the indexing of
+  --  a function with defaulted parameters that returns an array).
+  --  A flag Maybe_Indexed_Call might be useful here ???
+
   Must_Skip  : constant Boolean := Skip_First
  or else Nkind (Original_Node (N)) = N_Selected_Component
  or else
(Nkind (Original_Node (N)) = N_Indexed_Component
   and then Nkind (Prefix (Original_Node (N)))
+= N_Selected_Component)
+ or else
+   (Nkind (Parent (N)) = N_Function_Call
+  and then Is_Array_Type (Etype (Name (N)))
+  and then Etype (Original_Node (N)) =
+Component_Type (Etype (Name (N)))
+  and then Nkind (Original_Node (Parent (N)))
 = N_Selected_Component);
+
   --  The first formal must be omitted from the match when trying to find
   --  a primitive operation that is a possible interpretation, and also
   --  after the call has been rewritten, because the corresponding actual
@@ -4352,6 +4368,10 @@ package body Sem_Ch4 is
   QE_Scop : Entity_Id;
 
begin
+  --  The processing is similar to that for quantified expressions,
+  --  which have a similar structure and are eventually transformed
+  --  into a loop.
+
   QE_Scop := New_Internal_Entity (E_Loop, Current_Scope, Sloc (N), 'L');
   Set_Etype  (QE_Scop, Standard_Void_Type);
   Set_Scope  (QE_Scop, Current_Scope);

--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/array30.adb
@@ -0,0 +1,40 @@
+--  { dg-do run }
+
+with Ada.Text_IO;
+
+procedure Array30 is
+
+   package P is
+  type T is tagged record
+ value : Integer := 123;
+  end record;
+
+  type Ar is array (1..10) of T;
+  function F (Obj : T) return Ar;
+  function F2 (Obj : T) return T;
+   end P;
+   use P;
+
+   package body P is
+  function F (Obj : T) return Ar is
+  begin
+ return (others => <>);
+  end;
+
+  function F2 (Obj : T) return T is
+  begin
+ return (value => -111);
+  end F2;
+  end P;
+
+  Thing : T;
+begin
+  if Thing.F (4).Value /= 0 then
+ if Thing.F (5).Value /= 123 then
+raise Program_Error;
+ end if;
+ if Thing.F (5).F2.Value /= -111 then
+raise Program_Error;
+ end if;
+  end if;
+end;



[Ada] Robustify traceback caching for executable in current dir

2018-05-21 Thread Pierre-Marie de Rodat
Any program calling Gnat.Traceback.Symbolic.Enable_Cache for
dwarf based symbolization fails with a segmentation violation
when spawned with an inaccurate argv[0] such that it couldn't
be found on PATH.

argv[0] is most often found on PATH. One plausible case where
it isn't is when argv[0] is a mere file name and . isn't on PATH,
which might happen out of imprecise exec calls.

This change robustifies the Traceback.Symbolic implementation
to work in this case as well, by just trying to work with argv[0]
untouched as the executable file to fetch dwarf info from.

Tested on x86_64-pc-linux-gnu, committed on trunk

2018-05-21  Olivier Hainque  

gcc/ada/

* libgnat/s-trasym__dwarf.adb (Executable_Name): Return argv[0] instead
of empty string when argv[0] couldn't be found on PATH.
(Enable_Cache): Raise Program_Error instead of attempting a null
pointer dereference when the Exec_Module initialization failed.--- gcc/ada/libgnat/s-trasym__dwarf.adb
+++ gcc/ada/libgnat/s-trasym__dwarf.adb
@@ -151,8 +151,8 @@ package body System.Traceback.Symbolic is
 
function Executable_Name return String;
--  Returns the executable name as reported by argv[0]. If gnat_argv not
-   --  initialized or if argv[0] executable not found in path, function returns
-   --  an empty string.
+   --  initialized, return an empty string. If the argv[0] executable is not
+   --  found in the PATH, return it unresolved.
 
function Get_Executable_Load_Address return System.Address;
pragma Import
@@ -289,6 +289,12 @@ package body System.Traceback.Symbolic is
 
   --  Add all modules
   Init_Exec_Module;
+
+  if Exec_Module_State = Failed then
+ raise Program_Error with
+   "cannot enable cache, executable state initialization failed.";
+  end if;
+
   Cache_Chain := Exec_Module'Access;
 
   if Include_Modules then
@@ -347,17 +353,33 @@ package body System.Traceback.Symbolic is
  return "";
   end if;
 
+  --  See if we can resolve argv[0] to a full path (to a file that we will
+  --  be able to open). If the resolution fails, we were probably spawned
+  --  by an imprecise exec call, typically passing a mere file name as
+  --  argv[0] for a program in the current directory with '.' not on PATH.
+  --  Best we can do is fallback to argv[0] unchanged in this case. If we
+  --  fail opening that downstream, we'll just bail out.
+
   declare
- Addr : constant System.Address :=
-   locate_exec_on_path (Conv.To_Pointer (Gnat_Argv) (0));
- Result : constant String := Value (Addr);
+ Argv0 : constant System.Address
+   := Conv.To_Pointer (Gnat_Argv) (0);
+
+ Resolved_Argv0 : constant System.Address
+   := locate_exec_on_path (Argv0);
+
+ Exe_Argv : constant System.Address
+   := (if Resolved_Argv0 /= System.Null_Address
+   then Resolved_Argv0
+   else Argv0);
+
+ Result : constant String := Value (Exe_Argv);
 
   begin
  --  The buffer returned by locate_exec_on_path was allocated using
- --  malloc, so we should use free to release the memory.
+ --  malloc and we should release this memory.
 
- if Addr /= Null_Address then
-System.CRTL.free (Addr);
+ if Resolved_Argv0 /= Null_Address then
+System.CRTL.free (Resolved_Argv0);
  end if;
 
  return Result;



[Ada] Remove External aspect from predefined abstract states

2018-05-21 Thread Pierre-Marie de Rodat
Explicit External aspect was an equivalant to an implicit default.  It was only
needed as a workaround for a frontend bug. (If it meant to serve as
documentation, there should be explicit Effective_Reads and Effective_Writes
set to False too.)

No test, because these changes are semantically neutral.

Tested on x86_64-pc-linux-gnu, committed on trunk

2018-05-21  Piotr Trojanek  

gcc/ada/

* libgnarl/a-reatim.ads (Clock_Time): Remove External aspect.
* libgnarl/a-taside.ads (Tasking_State): Likewise.
* libgnat/a-calend.ads (Clock_Time): Likewise.--- gcc/ada/libgnarl/a-reatim.ads
+++ gcc/ada/libgnarl/a-reatim.ads
@@ -38,9 +38,7 @@ pragma Elaborate_All (System.Task_Primitives.Operations);
 
 package Ada.Real_Time with
   SPARK_Mode,
-  Abstract_State => (Clock_Time with Synchronous,
- External => (Async_Readers,
-  Async_Writers)),
+  Abstract_State => (Clock_Time with Synchronous),
   Initializes=> Clock_Time
 is
 

--- gcc/ada/libgnarl/a-taside.ads
+++ gcc/ada/libgnarl/a-taside.ads
@@ -38,9 +38,7 @@ with System.Tasking;
 
 package Ada.Task_Identification with
   SPARK_Mode,
-  Abstract_State => (Tasking_State with Synchronous,
-External => (Async_Readers,
- Async_Writers)),
+  Abstract_State => (Tasking_State with Synchronous),
   Initializes=> Tasking_State
 is
pragma Preelaborate;

--- gcc/ada/libgnat/a-calend.ads
+++ gcc/ada/libgnat/a-calend.ads
@@ -35,9 +35,7 @@
 
 package Ada.Calendar with
   SPARK_Mode,
-  Abstract_State => (Clock_Time with Synchronous,
- External => (Async_Readers,
-  Async_Writers)),
+  Abstract_State => (Clock_Time with Synchronous),
   Initializes=> Clock_Time
 is
 



[Ada] Spurious error in inlining for GNATprove on prefix call notation

2018-05-21 Thread Pierre-Marie de Rodat
During the special inlining done in GNATprove mode, a call in prefix
notation leads to a spurious error. Now fixed.

Tested on x86_64-pc-linux-gnu, committed on trunk

2018-05-21  Yannick Moy  

gcc/ada/

* sem_ch6.adb (Analyze_Procedure_Call): Refine test to recognize prefix
call notation in inlined call in GNATprove mode.--- gcc/ada/sem_ch6.adb
+++ gcc/ada/sem_ch6.adb
@@ -1933,7 +1933,9 @@ package body Sem_Ch6 is
 begin
if Is_Tagged_Type (Typ)
  and then Present (First_Formal (Subp))
- and then Etype (First_Formal (Subp)) = Typ
+ and then (Etype (First_Formal (Subp)) = Typ
+ or else
+   Class_Wide_Type (Etype (First_Formal (Subp))) = Typ)
  and then Try_Object_Operation (P)
then
   return;



[Ada] Crash on incorrect frontend inlining in GNATprove mode

2018-05-21 Thread Pierre-Marie de Rodat
In some cases, the inlining performed in GNATprove mode leads to a crash,
when inlining a call where a return statement of the inlined function
returns a string literal. Now fixed.

Tested on x86_64-pc-linux-gnu, committed on trunk

2018-05-21  Yannick Moy  

gcc/ada/

* sem_eval.adb (Static_Length): Take into account case of variable of
subtype string literal.--- gcc/ada/sem_eval.adb
+++ gcc/ada/sem_eval.adb
@@ -3403,6 +3403,13 @@ package body Sem_Eval is
  if Nkind (Expr) = N_String_Literal then
 return UI_From_Int (String_Length (Strval (Expr)));
 
+ --  With frontend inlining as performed in GNATprove mode, a variable
+ --  may be inserted that has a string literal subtype. Deal with this
+ --  specially as for the previous case.
+
+ elsif Ekind (Etype (Expr)) = E_String_Literal_Subtype then
+return String_Literal_Length (Etype (Expr));
+
  --  Second easy case, not constrained subtype, so no length
 
  elsif not Is_Constrained (Etype (Expr)) then



[Ada] Spurious error on synchronous refinement

2018-05-21 Thread Pierre-Marie de Rodat
This patch ensures that an abstract state declared with simple option
"synchronous" is automatically considered "external".

Tested on x86_64-pc-linux-gnu, committed on trunk

2018-05-21  Hristian Kirtchev  

gcc/ada/

* einfo.adb (Is_External_State): An abstract state is also external
when it is declared with option "synchronous".
* einfo.ads: Update the documentation of synthesized attribute
Is_External_State.
* sem_util.adb (Find_Simple_Properties): New routine.
(Is_Enabled_External_Property): New routine.
(State_Has_Enabled_Property): Reimplemented. The two flavors of option
External have precedence over option Synchronous when determining
whether a property is in effect.

gcc/testsuite/

* gnat.dg/sync2.adb, gnat.dg/sync2.ads: New testcase.--- gcc/ada/einfo.adb
+++ gcc/ada/einfo.adb
@@ -8083,8 +8083,14 @@ package body Einfo is
 
function Is_External_State (Id : E) return B is
begin
+  --  To qualify, the abstract state must appear with option "external" or
+  --  "synchronous" (SPARK RM 7.1.4(8) and (10)).
+
   return
-Ekind (Id) = E_Abstract_State and then Has_Option (Id, Name_External);
+Ekind (Id) = E_Abstract_State
+  and then (Has_Option (Id, Name_External)
+  or else
+Has_Option (Id, Name_Synchronous));
end Is_External_State;
 
--
@@ -8255,6 +8261,9 @@ package body Einfo is
 
function Is_Synchronized_State (Id : E) return B is
begin
+  --  To qualify, the abstract state must appear with simple option
+  --  "synchronous" (SPARK RM 7.1.4(10)).
+
   return
 Ekind (Id) = E_Abstract_State
   and then Has_Option (Id, Name_Synchronous);

--- gcc/ada/einfo.ads
+++ gcc/ada/einfo.ads
@@ -2553,7 +2553,7 @@ package Einfo is
 
 --Is_External_State (synthesized)
 --   Applies to all entities, true for abstract states that are subject to
---   option External.
+--   option External or Synchronous.
 
 --Is_Finalized_Transient (Flag252)
 --   Defined in constants, loop parameters of generalized iterators, and

--- gcc/ada/sem_util.adb
+++ gcc/ada/sem_util.adb
@@ -10261,92 +10261,157 @@ package body Sem_Util is
   
 
   function State_Has_Enabled_Property return Boolean is
- Decl : constant Node_Id := Parent (Item_Id);
- Opt  : Node_Id;
- Opt_Nam  : Node_Id;
- Prop : Node_Id;
- Prop_Nam : Node_Id;
- Props: Node_Id;
+ Decl : constant Node_Id := Parent (Item_Id);
 
-  begin
- --  The declaration of an external abstract state appears as an
- --  extension aggregate. If this is not the case, properties can never
- --  be set.
+ procedure Find_Simple_Properties
+   (Has_External: out Boolean;
+Has_Synchronous : out Boolean);
+ --  Extract the simple properties associated with declaration Decl
 
- if Nkind (Decl) /= N_Extension_Aggregate then
-return False;
- end if;
+ function Is_Enabled_External_Property return Boolean;
+ --  Determine whether property Property appears within the external
+ --  property list of declaration Decl, and return its status.
 
- --  When External appears as a simple option, it automatically enables
- --  all properties.
+ 
+ -- Find_Simple_Properties --
+ 
 
- Opt := First (Expressions (Decl));
- while Present (Opt) loop
-if Nkind (Opt) = N_Identifier
-  and then Chars (Opt) = Name_External
-then
-   return True;
-end if;
+ procedure Find_Simple_Properties
+   (Has_External: out Boolean;
+Has_Synchronous : out Boolean)
+ is
+Opt : Node_Id;
 
-Next (Opt);
- end loop;
+ begin
+--  Assume that none of the properties are available
 
- --  When External specifies particular properties, inspect those and
- --  find the desired one (if any).
+Has_External:= False;
+Has_Synchronous := False;
 
- Opt := First (Component_Associations (Decl));
- while Present (Opt) loop
-Opt_Nam := First (Choices (Opt));
+Opt := First (Expressions (Decl));
+while Present (Opt) loop
+   if Nkind (Opt) = N_Identifier then
+  if Chars (Opt) = Name_External then
+ Has_External := True;
 
-if Nkind (Opt_Nam) = N_Identifier
-  and then Chars (Opt_Nam) = Name_External
-then
-   Props := Expression (Opt);
+  elsif Chars (Opt) = Name_Synchronous then
+   

[Ada] Only allow Has_Discriminants on type entities

2018-05-21 Thread Pierre-Marie de Rodat
This patch enforces what the comment for Has_Discriminant says:

--Has_Discriminants (Flag5)
--   Defined in all types and subtypes.

to avoid semantically undefined calls on non-type entities. It also adapts
other routines to respect this comment.

No user-visible impact.

Tested on x86_64-pc-linux-gnu, committed on trunk

2018-05-21  Piotr Trojanek  

gcc/ada/

* einfo.adb (Has_Discriminants): Stronger assertion.
(Set_Has_Discriminants): Stronger assertion.
* sem_ch13.adb (Push_Scope_And_Install_Discriminants): Adapt to respect
the stronger assertion on Has_Discriminant.
(Uninstall_Discriminants_And_Pop_Scope): Same as above.
* sem_util.adb (New_Copy_Tree): Same as above.
* sem_ch7.adb (Generate_Parent_References): Prevent calls to
Has_Discriminant on non-type entities that might happen when the
compiled code has errors.
* sem_ch3.adb (Derived_Type_Declaration): Only call
Set_Has_Discriminant on type entities.--- gcc/ada/einfo.adb
+++ gcc/ada/einfo.adb
@@ -1567,7 +1567,7 @@ package body Einfo is
 
function Has_Discriminants (Id : E) return B is
begin
-  pragma Assert (Nkind (Id) in N_Entity);
+  pragma Assert (Is_Type (Id));
   return Flag5 (Id);
end Has_Discriminants;
 
@@ -4730,7 +4730,7 @@ package body Einfo is
 
procedure Set_Has_Discriminants (Id : E; V : B := True) is
begin
-  pragma Assert (Nkind (Id) in N_Entity);
+  pragma Assert (Is_Type (Id));
   Set_Flag5 (Id, V);
end Set_Has_Discriminants;
 

--- gcc/ada/sem_ch13.adb
+++ gcc/ada/sem_ch13.adb
@@ -12307,7 +12307,7 @@ package body Sem_Ch13 is
 
procedure Push_Scope_And_Install_Discriminants (E : Entity_Id) is
begin
-  if Has_Discriminants (E) then
+  if Is_Type (E) and then Has_Discriminants (E) then
  Push_Scope (E);
 
  --  Make the discriminants visible for type declarations and protected
@@ -13491,7 +13491,7 @@ package body Sem_Ch13 is
 
procedure Uninstall_Discriminants_And_Pop_Scope (E : Entity_Id) is
begin
-  if Has_Discriminants (E) then
+  if Is_Type (E) and then Has_Discriminants (E) then
  Uninstall_Discriminants (E);
  Pop_Scope;
   end if;

--- gcc/ada/sem_ch3.adb
+++ gcc/ada/sem_ch3.adb
@@ -16664,7 +16664,13 @@ package body Sem_Ch3 is
 Error_Msg_N
   ("elementary or array type cannot have discriminants",
Defining_Identifier (First (Discriminant_Specifications (N;
-Set_Has_Discriminants (T, False);
+
+--  Unset Has_Discriminants flag to prevent cascaded errors, but
+--  only if we are not already processing a malformed syntax tree.
+
+if Is_Type (T) then
+   Set_Has_Discriminants (T, False);
+end if;
 
  --  The type is allowed to have discriminants
 

--- gcc/ada/sem_ch7.adb
+++ gcc/ada/sem_ch7.adb
@@ -1399,10 +1399,13 @@ package body Sem_Ch7 is
 
 --  We are looking at an incomplete or private type declaration
 --  with a known_discriminant_part whose full view is an
---  Unchecked_Union.
+--  Unchecked_Union. The seemingly useless check with Is_Type
+--  prevents cascaded errors when routines defined only for type
+--  entities are called with non-type entities.
 
 if Nkind_In (Decl, N_Incomplete_Type_Declaration,
N_Private_Type_Declaration)
+  and then Is_Type (Defining_Identifier (Decl))
   and then Has_Discriminants (Defining_Identifier (Decl))
   and then Present (Full_View (Defining_Identifier (Decl)))
   and then

--- gcc/ada/sem_util.adb
+++ gcc/ada/sem_util.adb
@@ -19392,7 +19392,9 @@ package body Sem_Util is
   begin
  --  Discriminant_Constraint
 
- if Has_Discriminants (Base_Type (Id)) then
+ if Is_Type (Id)
+   and then Has_Discriminants (Base_Type (Id))
+ then
 Set_Discriminant_Constraint (Id, Elist_Id (
   Copy_Field_With_Replacement
 (Field=> Union_Id (Discriminant_Constraint (Id)),
@@ -19849,7 +19851,9 @@ package body Sem_Util is
 
  --  Discriminant_Constraint
 
- if Has_Discriminants (Base_Type (Id)) then
+ if Is_Type (Id)
+   and then Has_Discriminants (Base_Type (Id))
+ then
 Visit_Field
   (Field=> Union_Id (Discriminant_Constraint (Id)),
Semantic => True);



[Ada] Tighten Object_Reader.Get_Memory_Bounds

2018-05-21 Thread Pierre-Marie de Rodat
Symbolization of traceback entries from dwarf info was
failing in some cases with shared libraries on ELF targets,
from unexpected overlapping of what we believed were code
regions for distinct modules.

This is caused by the inclusion of all SHF_ALLOC sections in
the set of sections of possible relevance to determine the span
of possible code addresses for a module.

This change renames the Get_memory_Bound subprogram to better
convey that we really care about sections hosting executable code
in particular, matching what the spec comments already claims.

It also renames the boolean flag conveying the info of relevance
in the Object_Section record, and adjusts the ELF implementation
of Get_Section to feed this flag from SHF_EXECINSTR instead of
SHF_ALLOC.

Tested on x86_64-pc-linux-gnu, committed on trunk

2018-05-21  Olivier Hainque  

gcc/ada/

* libgnat/s-objrea.ads (Get_Memory_Bounds): Rename as Get_Xcode_Bounds.
(Object_Section): Rename Flag_Alloc component as Flag_Xcode.
* libgnat/s-objrea.adb (Get_Xcode_Bounds): Adjust to new subprogram and
component name.
(Get_Section, ELF case): Set Flag_Xcode from SHF_EXECINSTR.
* libgnat/s-dwalin.adb (Open): Adjust to the Get_Memory_Bounds name
change.--- gcc/ada/libgnat/s-dwalin.adb
+++ gcc/ada/libgnat/s-dwalin.adb
@@ -414,9 +414,10 @@ package body System.Dwarf_Lines is
 
   Success := True;
 
-  --  Get memory bounds
+  --  Get memory bounds for executable code.  Note that such code
+  --  might come from multiple sections.
 
-  Get_Memory_Bounds (C.Obj.all, Lo, Hi);
+  Get_Xcode_Bounds (C.Obj.all, Lo, Hi);
   C.Low  := Storage_Offset (Lo);
   C.High := Storage_Offset (Hi);
 

--- gcc/ada/libgnat/s-objrea.adb
+++ gcc/ada/libgnat/s-objrea.adb
@@ -114,6 +114,7 @@ package body System.Object_Reader is
   end record;
 
   SHF_ALLOC : constant := 2;
+  SHF_EXECINSTR : constant := 4;
 
   type Symtab_Entry32 is record
  St_Name  : uint32;  --  Name (string table index)
@@ -552,7 +553,7 @@ package body System.Object_Reader is
  Offset (SHdr.Sh_Offset),
  uint64 (SHdr.Sh_Addr),
  uint64 (SHdr.Sh_Size),
- (SHdr.Sh_Flags and SHF_ALLOC) /= 0);
+ (SHdr.Sh_Flags and SHF_EXECINSTR) /= 0);
   end Get_Section;
 
   
@@ -1679,11 +1680,11 @@ package body System.Object_Reader is
   end if;
end Get_Section;
 
-   ---
-   -- Get_Memory_Bounds --
-   ---
+   --
+   -- Get_Xcode_Bounds --
+   --
 
-   procedure Get_Memory_Bounds
+   procedure Get_Xcode_Bounds
  (Obj   : in out Object_File;
   Low, High : out uint64) is
   Sec : Object_Section;
@@ -1692,9 +1693,11 @@ package body System.Object_Reader is
   Low := uint64'Last;
   High := uint64'First;
 
+  --  Now find the lowest and highest offsets
+  --  attached to executable code sections
   for Idx in 1 .. Num_Sections (Obj) loop
  Sec := Get_Section (Obj, Idx - 1);
- if Sec.Flag_Alloc then
+ if Sec.Flag_Xcode then
 if Sec.Addr < Low then
Low := Sec.Addr;
 end if;
@@ -1703,7 +1706,7 @@ package body System.Object_Reader is
 end if;
  end if;
   end loop;
-   end Get_Memory_Bounds;
+   end Get_Xcode_Bounds;
 
--
-- Name --

--- gcc/ada/libgnat/s-objrea.ads
+++ gcc/ada/libgnat/s-objrea.ads
@@ -277,7 +277,7 @@ package System.Object_Reader is
   Sec : Object_Section) return Mapped_Stream;
--  Create a stream for section Sec
 
-   procedure Get_Memory_Bounds
+   procedure Get_Xcode_Bounds
  (Obj   : in out Object_File;
   Low, High : out uint64);
--  Return the low and high addresses of the code for the object file. Can
@@ -434,8 +434,8 @@ private
   Size   : uint64 := 0;
   --  Length of the section in bytes
 
-  Flag_Alloc : Boolean := False;
-  --  True if the section is mapped in memory by the OS loader
+  Flag_Xcode : Boolean := False;
+  --  True if the section is advertised to contain executable code
end record;
 
Null_Section : constant Object_Section := (0, 0, 0, 0, False);



[Ada] Extend legality of Scalar_Storage_Order to formal types

2018-05-21 Thread Pierre-Marie de Rodat
This patch extends the legality of the GNAT attribute Scalar_Storage_Order,
to apply to formal private types. Previously this extension applied only
in GNAT_Mode, to support instantiations of Ada.Sequential_IO, but it is more
generally useful.

The following must compile quietly:


with Memory_View_Generic;
procedure Main is
   type T is array (1..10) of integer;
   package OK is new Memory_View_Generic (T);

   type T2 is new Long_Float;
   package Wrong is new Memory_View_Generic (T2);
begin
   null;
end;

with System;
generic
   type Source_Type is private;
package Memory_View_Generic is
   -- various declarations ...
   SSO : System.Bit_Order := Source_Type'Scalar_Storage_Order;
end Memory_View_Generic;

Tested on x86_64-pc-linux-gnu, committed on trunk

2018-05-21  Ed Schonberg  

gcc/ada/

* sem_attr.adb (Analyze_Attribute, case Scalar_Storage_Order): The
attribute reference is legal within a generic unit when the prefix is a
formal private type.--- gcc/ada/sem_attr.adb
+++ gcc/ada/sem_attr.adb
@@ -5709,11 +5709,15 @@ package body Sem_Attr is
 
  if not (Is_Record_Type (P_Type) or else Is_Array_Type (P_Type)) then
 
---  In GNAT mode, the attribute applies to generic types as well
---  as composite types, and for non-composite types always returns
---  the default bit order for the target.
-
-if not (GNAT_Mode and then Is_Generic_Type (P_Type))
+--  The attribute applies to generic private types (in which case
+--  the legality rule is applied in the instance) as well as to
+--  composite types. For noncomposite types it always returns the
+--  default bit order for the target.
+--  Allowing formal private types was originally introduced in
+--  GNAT_Mode only, to compile instances of Sequential_IO, but
+--  users find it more generally useful in generic units.
+
+if not (Is_Generic_Type (P_Type) and then Is_Private_Type (P_Type))
   and then not In_Instance
 then
Error_Attr_P
@@ -11074,7 +11078,7 @@ package body Sem_Attr is
 
 --  The context may be a constrained access type (however ill-
 --  advised such subtypes might be) so in order to generate a
---  constraint check when needed set the type of the attribute
+--  constraint check we need to set the type of the attribute
 --  reference to the base type of the context.
 
 Set_Etype (N, Btyp);
@@ -11837,6 +11841,8 @@ package body Sem_Attr is
   if Attr_Id = Attribute_Elaborated then
  null;
 
+  --  Should this be restricted to Expander_Active???
+
   else
  Freeze_Expression (P);
   end if;



[Ada] Robustify traceback symbolization from dwarf info

2018-05-21 Thread Pierre-Marie de Rodat
Symbolization of traceback entries from dwarf info is
failing in multiple cases for addresses originating from
shared libraries.

Part of the problem is a confusion across different functions
regarding the kind of "address" at hand, sometimes full process
runtime addresses (e.g. in traceback entries), sometimes module
relative (e.g. in dwarf info segments).

This change fixes this by introducing the use of distinct types
for the two kinds of addresses, resorting to System.Address
for runtime addresses and to Storage_Elements.Storage_Offset
for module relative values. The accompanying code changes
tidy a few places where we can now use standard operators
to combine offets & addresses, and include a few corrections
of consistency problems at spots where comparisons were done
between runtime addresses and relative offsets.

Tested on x86_64-pc-linux-gnu, committed on trunk

2018-05-21  Olivier Hainque  

gcc/ada/

* libgnat/s-dwalin.ads (Dwarf_Context): Change type of Load_Address to
Address, and type of Low, High to Storage_Offset.
(Low): Rename as Low_Address and convey that the return value is a
runtime reference accounting for a load address.
* libgnat/s-dwalin.adb (Read_Aranges_Entry): Adjust to the
address/offset type changes.
(Aranges_Lookup): Likewise.
(Symbolic_Address): Likewise.
(Symbolic_Traceback): Likewise.
(Dump_Cache): Likewise.
(Is_Inside): Likewise.
(Open): Likewise.
(Set_Load_Address): Likewise.
(Low_Address): Likewise, and account for C.Load_Address.
* libgnat/s-trasym__dwarf.adb (Lt): Use Low_Address instead of Low.
(Multi_Module_Symbolic_Traceback): Compare address in traceback
with module Low_Address instead of Low.--- gcc/ada/libgnat/s-dwalin.adb
+++ gcc/ada/libgnat/s-dwalin.adb
@@ -74,7 +74,7 @@ package body System.Dwarf_Lines is
 
procedure Read_Aranges_Entry
  (C : in out Dwarf_Context;
-  Start :out Integer_Address;
+  Start :out Storage_Offset;
   Len   :out Storage_Count);
--  Read a single .debug_aranges pair
 
@@ -86,7 +86,7 @@ package body System.Dwarf_Lines is
 
procedure Aranges_Lookup
  (C   : in out Dwarf_Context;
-  Addr:Address;
+  Addr:Storage_Offset;
   Info_Offset :out Offset;
   Success :out Boolean);
--  Search for Addr in .debug_aranges and return offset Info_Offset in
@@ -151,7 +151,7 @@ package body System.Dwarf_Lines is
 
procedure Symbolic_Address
  (C   : in out Dwarf_Context;
-  Addr:Address;
+  Addr:Storage_Offset;
   Dir_Name:out Str_Access;
   File_Name   :out Str_Access;
   Subprg_Name :out String_Ptr_Len;
@@ -296,20 +296,22 @@ package body System.Dwarf_Lines is
  return;
   end if;
   for I in Cache'Range loop
- Put (System.Address_Image (C.Low + Storage_Count (Cache (I).First)));
- Put (" - ");
- Put
-   (System.Address_Image
-  (C.Low + Storage_Count (Cache (I).First + Cache (I).Size)));
- Put (" l@");
- Put
-   (System.Address_Image
-  (To_Address (Integer_Address (Cache (I).Line;
- Put (": ");
- S:= Read_Symbol (C.Obj.all, Offset (Cache (I).Sym));
- Name := Object_Reader.Name (C.Obj.all, S);
- Put (String (Name.Ptr (1 .. Name.Len)));
- New_Line;
+ declare
+E : Search_Entry renames Cache (I);
+Base_Address : constant System.Address :=
+  To_Address (Integer_Address (C.Low + Storage_Count (E.First)));
+ begin
+Put (System.Address_Image (Base_Address));
+Put (" - ");
+Put (System.Address_Image (Base_Address + Storage_Count (E.Size)));
+Put (" l@");
+Put (System.Address_Image (To_Address (Integer_Address (E.Line;
+Put (": ");
+S:= Read_Symbol (C.Obj.all, Offset (E.Sym));
+Name := Object_Reader.Name (C.Obj.all, S);
+Put (String (Name.Ptr (1 .. Name.Len)));
+New_Line;
+ end;
   end loop;
end Dump_Cache;
 
@@ -372,18 +374,19 @@ package body System.Dwarf_Lines is
 
function Is_Inside (C : Dwarf_Context; Addr : Address) return Boolean is
begin
-  return (Addr >= To_Address (To_Integer (C.Low) + C.Load_Address)
-and Addr <= To_Address (To_Integer (C.High) + C.Load_Address));
+  return (Addr >= C.Low + C.Load_Address
+and then Addr <= C.High + C.Load_Address);
end Is_Inside;
 
-   -
-   -- Low --
-   -
+   -
+   -- Low_Address --
+   -
 
-   function Low (C : Dwarf_Context) return Address is
+   function Low_Address (C : Dwarf_Context)
+  return System.Address is

[Ada] Propagate load addresses for traceback cache on Linux

2018-05-21 Thread Pierre-Marie de Rodat
Symbolization of traceback addresses through shared libraries
requires information on the shared libraries load addresses, which
was at hand on Linuxbut not propagated through the runtime when
caching is enabled.  This change fixes this.

Tested on x86_64-pc-linux-gnu, committed on trunk

2018-05-21  Olivier Hainque  

gcc/ada/

* libgnat/s-trasym__dwarf.adb (Add_Module_To_Cache): Expect a
Load_Address argument and pass it down to Init_Module.
* libgnat/s-tsmona__linux.adb (Build_Cache_For_All_Modules): Pass
lm.l_addr as the Load_Address to Add_Module_To_Cache.--- gcc/ada/libgnat/s-trasym__dwarf.adb
+++ gcc/ada/libgnat/s-trasym__dwarf.adb
@@ -123,7 +123,8 @@ package body System.Traceback.Symbolic is
--  Return the String contained in Item, up until the first NUL character
 
pragma Warnings (Off, "*Add_Module_To_Cache*");
-   procedure Add_Module_To_Cache (Module_Name : String);
+   procedure Add_Module_To_Cache (Module_Name : String;
+  Load_Address : System.Address);
--  To be called by Build_Cache_For_All_Modules to add a new module to the
--  list. May not be referenced.
 
@@ -217,12 +218,14 @@ package body System.Traceback.Symbolic is
-- Add_Module_To_Cache --
-
 
-   procedure Add_Module_To_Cache (Module_Name : String) is
+   procedure Add_Module_To_Cache (Module_Name : String;
+  Load_Address : System.Address)
+   is
   Module  : Module_Cache_Acc;
   Success : Boolean;
begin
   Module := new Module_Cache;
-  Init_Module (Module.all, Success, Module_Name);
+  Init_Module (Module.all, Success, Module_Name, Load_Address);
   if not Success then
  Free (Module);
  return;

--- gcc/ada/libgnat/s-tsmona__linux.adb
+++ gcc/ada/libgnat/s-tsmona__linux.adb
@@ -122,7 +122,7 @@ package body Module_Name is
   while lm /= null loop
  if Big_String_Conv.To_Pointer (lm.l_name) (1) /= ASCII.NUL then
 --  Discard non-file (like the executable itself or the gate).
-Add_Module_To_Cache (Value (lm.l_name));
+Add_Module_To_Cache (Value (lm.l_name), lm.l_addr);
  end if;
  lm := lm.l_next;
   end loop;



[Ada] Premature secondary stack reclamation

2018-05-21 Thread Pierre-Marie de Rodat
This patch modifies the creation of transient scopes to eliminate potential
premature secondary stack reclamations when there is no suitable transient
context and the scope was intended to manage the secondary stack. Instead,
the logic was changed to accommodate a special case where an assignment with
suppressed controlled actions that appears within a type initialization
procedure requires secondary stack reclamation.

The patch also corrects the handling of function calls which utilize the
secondary stack in loop parameter specifications. Previously the predicate
which determined whether the function will utilize the secondary stack was
not accurate enough, and in certain cases could lead to leaks.


-- Source --


--  iterators.ads

package Iterators is
   type Iterator is limited interface;
   type Iterator_Access is access all Iterator'Class;

   function Next
 (I   : in out Iterator;
  Element : out Character) return Boolean is abstract;

   procedure Iterate
 (I: in out Iterator'Class;
  Proc : access procedure (Element : Character));
end Iterators;

--  iterators.adb

package body Iterators is
   procedure Iterate
 (I: in out Iterator'Class;
  Proc : access procedure (Element : Character))
   is
  Element : Character;
   begin
  while I.Next (Element) loop
 Proc (Element);
  end loop;
   end Iterate;
end Iterators;

--  base.ads

with Iterators; use Iterators;

package Base is
   type String_Access is access all String;
   type Node is tagged record
  S : String_Access;
   end record;

   type Node_Access is access all Node'Class;
   type Node_Array is array (Positive range <>) of Node_Access;

   function As_Array (N : Node_Access) return Node_Array;
   function Get_String (C : Character) return String;

   type Node_Iterator is limited new Iterator with record
  Node : Node_Access;
  I: Positive;
   end record;

   overriding function Next
 (It  : in out Node_Iterator;
  Element : out Character) return Boolean;

   function Constructor_1 (N : Node_Access) return Node_Iterator;
   function Constructor_2 (N : Node_Access) return Node_Iterator;
end Base;

--  base.adb

package body Base is
   function As_Array (N : Node_Access) return Node_Array is
   begin
  return (1 => N);
   end As_Array;

   function Get_String (C : Character) return String is
   begin
  return (1 .. 40 => C);
   end Get_String;

   function Next
 (It  : in out Node_Iterator;
  Element : out Character) return Boolean
   is
   begin
  if It.I > It.Node.S'Last then
 return False;
  else
 It.I := It.I + 1;
 Element := It.Node.S (It.I - 1);
 return True;
  end if;
   end Next;

   function Constructor_1 (N : Node_Access) return Node_Iterator is
   begin
  return Node_Iterator'(N, 1);
   end Constructor_1;

   function Constructor_2 (N : Node_Access) return Node_Iterator is
   begin
  return Constructor_1 (As_Array (N) (1));
   end Constructor_2;
end Base;

--  main.adb

with Ada.Text_IO; use Ada.Text_IO;
with Base;use Base;
with Iterators;   use Iterators;

procedure Main is
   N : constant Node_Access := new Node'(S => new String'("hello world"));

   procedure Process (C : Character) is
   begin
  Put_Line (Get_String (C));
   end Process;

   C : Iterator'Class := Constructor_2 (N);

begin
   C.Iterate (Process'Access);
end Main;


-- Compilation and output --


$ gnatmake -q main.adb
$ ./main












Tested on x86_64-pc-linux-gnu, committed on trunk

2018-05-21  Hristian Kirtchev  

gcc/ada/

* exp_ch7.adb (Establish_Transient_Scope): Code cleanup. Do not
delegate the secondary stack management when there is no suitable
transient context, and the transient scope was intended to manage the
secondary stack because this causes premature reclamation. Change the
transient scope creation logic by special casing assignment statements
of controlled components for type initialization procedures.
(Find_Node_To_Be_Wrapped): Renamed to Find_Transient_Context. Update
the comment on usage.
(Find_Transient_Context): Change the initinte loop into a while loop.
Iterations schemes and iterator specifications are not valid transient
contexts because they rely on special processing. Assignment statements
are now treated as a normal transient context, special cases are
handled by the 

[RFT PATCH, AVX512]: Implement scalar float->unsigned int truncations with AVX512F

2018-05-21 Thread Uros Bizjak
Hello!

Attached patch implements scalar float->unsigned int truncations with AVX512F.

2018-05-21  Uros Bizjak  

* config/i386/i386.md (fixuns_truncdi2): New insn pattern.
(fixuns_truncsi2_avx512f): Ditto.
(*fixuns_truncsi2_avx512f_zext): Ditto.
(fixuns_truncsi2): Also enable for AVX512F and TARGET_SSE_MATH.
Emit fixuns_truncsi2_avx512f for AVX512F targets.

testsuite/ChangeLog:

2018-05-21  Uros Bizjak  

* gcc.target/i386/cvt-2.c: New test.

Patch was bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Unfortunately, I have to means to test the patch on AVX512 target, so
to avoid some hidden issue, I'd like to ask someone to test it on live
target.

Uros.
Index: config/i386/i386.md
===
--- config/i386/i386.md (revision 260441)
+++ config/i386/i386.md (working copy)
@@ -5017,6 +5017,18 @@
}
 })
 
+;; Unsigned conversion to DImode
+
+(define_insn "fixuns_truncdi2"
+  [(set (match_operand:DI 0 "register_operand" "=r")
+   (unsigned_fix:DI
+ (match_operand:MODEF 1 "nonimmediate_operand" "vm")))]
+  "TARGET_64BIT && TARGET_AVX512F && TARGET_SSE_MATH"
+  "vcvttsd2usi\t{%1, %0|%0, %1}"
+  [(set_attr "type" "sseicvt")
+   (set_attr "prefix" "evex")
+   (set_attr "mode" "DI")])
+
 ;; Unsigned conversion to SImode.
 
 (define_expand "fixuns_truncsi2"
@@ -5027,7 +5039,7 @@
  (use (match_dup 2))
  (clobber (match_scratch: 3))
  (clobber (match_scratch: 4))])]
-  "!TARGET_64BIT && TARGET_SSE2 && TARGET_SSE_MATH"
+  "(!TARGET_64BIT || TARGET_AVX512F) && TARGET_SSE2 && TARGET_SSE_MATH"
 {
   machine_mode mode = mode;
   machine_mode vecmode = mode;
@@ -5034,6 +5046,12 @@
   REAL_VALUE_TYPE TWO31r;
   rtx two31;
 
+  if (TARGET_AVX512F)
+{
+  emit_insn (gen_fixuns_truncsi2_avx512f (operands[0], operands[1]));
+  DONE;
+}
+
   if (optimize_insn_for_size_p ())
 FAIL;
 
@@ -5043,6 +5061,27 @@
   operands[2] = force_reg (vecmode, two31);
 })
 
+(define_insn "fixuns_truncsi2_avx512f"
+  [(set (match_operand:SI 0 "register_operand" "=r")
+   (unsigned_fix:SI
+ (match_operand:MODEF 1 "nonimmediate_operand" "vm")))]
+  "TARGET_AVX512F && TARGET_SSE_MATH"
+  "vcvttsd2usi\t{%1, %0|%0, %1}"
+  [(set_attr "type" "sseicvt")
+   (set_attr "prefix" "evex")
+   (set_attr "mode" "SI")])
+
+(define_insn "*fixuns_truncsi2_avx512f_zext"
+  [(set (match_operand:DI 0 "register_operand" "=r")
+   (zero_extend:DI
+ (unsigned_fix:SI
+   (match_operand:MODEF 1 "nonimmediate_operand" "vm"]
+  "TARGET_64BIT && TARGET_AVX512F"
+  "vcvttsd2usi\t{%1, %k0|%k0, %1}"
+  [(set_attr "type" "sseicvt")
+   (set_attr "prefix" "evex")
+   (set_attr "mode" "SI")])
+
 (define_insn_and_split "*fixuns_trunc_1"
   [(set (match_operand:SI 0 "register_operand" "=,")
(unsigned_fix:SI
Index: testsuite/gcc.target/i386/cvt-2.c
===
--- testsuite/gcc.target/i386/cvt-2.c   (nonexistent)
+++ testsuite/gcc.target/i386/cvt-2.c   (working copy)
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mavx512f -mfpmath=sse" } */
+
+unsigned int f2ui (float x) { return x; }
+unsigned int d2ui (double x) { return x; }
+
+#ifdef __x86_64__
+unsigned long f2ul (float x) { return x; }
+unsigned long d2ul (double x) { return x; }
+#endif
+  
+/* { dg-final { scan-assembler-times "vcvttss2usi" 1 { target ia32 } } } */
+/* { dg-final { scan-assembler-times "vcvttsd2usi" 1 { target ia32 } } } */
+/* { dg-final { scan-assembler-times "vcvttss2usi" 2 { target { ! ia32 } } } } 
*/
+/* { dg-final { scan-assembler-times "vcvttsd2usi" 2 { target { ! ia32 } } } } 
*/


Re: [PATCH][RFC] Radically simplify emission of balanced tree for switch statements.

2018-05-21 Thread Sudakshina Das

On 21/05/18 15:00, Rainer Orth wrote:

Hi Martin,


Thanks for opened eyes, following patch will fix that.
It's quite obvious, I'll install it right after tests will finish.


unfortunately, it didn't fix either issue:

* The switchlower -> switchlower1 renames in the dg-final* lines
   (attached) are still necessary to avoid the UNRESOLVED errors.
   Although obvious, I haven't installed them since ...

* ... even so

FAIL: gcc.dg/tree-prof/update-loopch.c scan-tree-dump switchlower1 "Removing basic 
block"

   remains.

[...]

You are right, it's using -O2, thus your patch is right. Please install the
patch
after testing. It's obvious fix.


But what about the remaining FAIL?



Sorry to add to this, but I have also observed the following failures on 
 aarch64-none-elf, aarch64-none-linux-gnu and aarch64_be-none-elf 
targets bisected to this commit:


FAIL: gcc.dg/sancov/cmp0.c   -O0   scan-tree-dump-times optimized 
"__builtin___sanitizer_cov_trace_const_cmp" 7


FAIL: gcc.dg/sancov/cmp0.c   -O0   scan-tree-dump-times optimized 
"__builtin___sanitizer_cov_trace_switch \\(" 2


FAIL: gcc.dg/sancov/cmp0.c   -O0 -g   scan-tree-dump-times optimized 
"__builtin___sanitizer_cov_trace_const_cmp" 7


FAIL: gcc.dg/sancov/cmp0.c   -O0 -g   scan-tree-dump-times optimized 
"__builtin___sanitizer_cov_trace_switch \\(" 2


FAIL: gcc.dg/tree-ssa/pr77445-2.c scan-tree-dump-not thread3 "not 
considered"


FAIL: gcc.dg/tree-ssa/ssa-dom-thread-7.c scan-tree-dump-not vrp2 "Jumps 
threaded"


Sudi


Rainer





Re: [wwwdocs] Buildstat update for 7.x

2018-05-21 Thread Gerald Pfeifer
On Sat, 19 May 2018, Tom G. Christensen wrote:
> Latest results for 7.x

Thanks, Tom!  All applied.

Gerald


Re: [PATCH][RFC] Radically simplify emission of balanced tree for switch statements.

2018-05-21 Thread Rainer Orth
Hi Martin,

>>> Thanks for opened eyes, following patch will fix that.
>>> It's quite obvious, I'll install it right after tests will finish.
>> 
>> unfortunately, it didn't fix either issue:
>> 
>> * The switchlower -> switchlower1 renames in the dg-final* lines
>>   (attached) are still necessary to avoid the UNRESOLVED errors.
>>   Although obvious, I haven't installed them since ...
>> 
>> * ... even so
>> 
>> FAIL: gcc.dg/tree-prof/update-loopch.c scan-tree-dump switchlower1 "Removing 
>> basic block"
>> 
>>   remains.
[...]
> You are right, it's using -O2, thus your patch is right. Please install the
> patch
> after testing. It's obvious fix.

But what about the remaining FAIL?

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [PATCH][RFC] Radically simplify emission of balanced tree for switch statements.

2018-05-21 Thread Martin Liška
On 05/21/2018 01:18 PM, Rainer Orth wrote:
> Hi Martin,
> 
>> On 05/18/2018 03:55 PM, Rainer Orth wrote:
>>> Hi Martin,
>>>
 So the patch looks fine, only very very slightly binary is produced. I'm
 going to install the patch so that
 I can carry on more complex patches based on this one.
>>>
>>> it seems you didn't properly test the testsuite part: I see
>>>
>>> +UNRESOLVED: gcc.dg/tree-prof/update-loopch.c scan-tree-dump switchlower
>>> "Removing basic block"
>>> +UNRESOLVED: gcc.dg/tree-prof/update-loopch.c scan-tree-dump switchlower
>>> "loop depth 1, count 3"
>>> +UNRESOLVED: gcc.dg/tree-prof/update-loopch.c scan-tree-dump-not
>>> switchlower "Invalid sum"
>>> +UNRESOLVED: gcc.dg/tree-prof/update-loopch.c scan-tree-dump-not
>>> switchlower "loop depth 1, count 2"
>>>
>>> everywhere.  The log has
>>>
>>> gcc.dg/tree-prof/update-loopch.c: dump file does not exist
>>>
>>> Obviously you forgot the adapt the dg-final* files for the dumpfile
>>> name.  If I do, three of the failures go away, but
>>>
>>> FAIL: gcc.dg/tree-prof/update-loopch.c scan-tree-dump switchlower1
>>> "Removing basic block"
>>>
>>> remains (on 32 and 64-bit Linux/x86_64).
>>>
>>> Please fix.
>>>
>>> Rainer
>>>
>>
>> Thanks for opened eyes, following patch will fix that.
>> It's quite obvious, I'll install it right after tests will finish.
> 
> unfortunately, it didn't fix either issue:
> 
> * The switchlower -> switchlower1 renames in the dg-final* lines
>   (attached) are still necessary to avoid the UNRESOLVED errors.
>   Although obvious, I haven't installed them since ...
> 
> * ... even so
> 
> FAIL: gcc.dg/tree-prof/update-loopch.c scan-tree-dump switchlower1 "Removing 
> basic block"
> 
>   remains.
> 
>   Rainer

Hi.

You are right, it's using -O2, thus your patch is right. Please install the 
patch 
after testing. It's obvious fix.

Martin

> 
> 
>> From 7ae0c7d4a81166dbf5e9dff5d35e4c9d63b1c058 Mon Sep 17 00:00:00 2001
>> From: marxin 
>> Date: Fri, 18 May 2018 16:17:57 +0200
>> Subject: [PATCH] Remove redundand pass pass_lower_switch.
>>
>> gcc/ChangeLog:
>>
>> 2018-05-18  Martin Liska  
>>
>>  * passes.def: Remove a redundant pass.
>> ---
>>  gcc/passes.def | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/gcc/passes.def b/gcc/passes.def
>> index 050009464ea..055d354f959 100644
>> --- a/gcc/passes.def
>> +++ b/gcc/passes.def
>> @@ -399,9 +399,8 @@ along with GCC; see the file COPYING3.  If not see
>>NEXT_PASS (pass_lower_vaarg);
>>NEXT_PASS (pass_lower_vector);
>>NEXT_PASS (pass_lower_complex_O0);
>> -  NEXT_PASS (pass_lower_switch_O0);
>>NEXT_PASS (pass_sancov_O0);
>> -  NEXT_PASS (pass_lower_switch);
>> +  NEXT_PASS (pass_lower_switch_O0);
>>NEXT_PASS (pass_asan_O0);
>>NEXT_PASS (pass_tsan_O0);
>>NEXT_PASS (pass_sanopt);
> 




Re: [PATCH 1/2, expr.c] Optimize switch with sign-extended index.

2018-05-21 Thread Jeff Law
On 05/02/2018 04:05 PM, Jim Wilson wrote:
> This improves the code for a switch statement on targets that sign-extend
> function arguments, such as RISC-V.  Given a simple testcase
> 
> extern void asdf(int);
> void foo(int x) {
>   switch (x) {
>   case 0: asdf(10); break;
>   case 1: asdf(11); break;
>   case 2: asdf(12); break;
>   case 3: asdf(13); break;
>   case 4: asdf(14); break;
>   }
> }
> 
> Compiled for a 64-bit target, we get for the tablejump
> 
>   li  a5,4
>   bgtua0,a5,.L1
>   sllia0,a0,32
>   lui a5,%hi(.L4)
>   addia5,a5,%lo(.L4)
>   srlia0,a0,30
>   add a0,a0,a5
>   lw  a5,0(a0)
>   jr  a5
> 
> There is some unnecessary shifting here.  a0 (x) gets shifted left by 32 then
> shifted right by 30 to zero-extend it and multiply by 4 for the table index.
> However, after the unsigned greater than branch, we know the value is between
> 0 and 4.  We also know that a 32-bit int is passed as a 64-bit sign-extended
> long for this target.  Thus we get the same exact value if we sign-extend
> instead of zero-extend, and the code is one instruction shorter.  We get a 
> slli
> by 2 instead of the slli 32/srli 30.
> 
> The following patch implements this optimization.  It checks for a range that
> does not have the sign-bit set, and an index value that is already sign
> extended, and then does a sign extend instead of an zero extend.
> 
> This has been tested with a riscv{32,64}-{elf,linux} builds and testsuite 
> runs.
> There were no regressions.  It was also tested with an x86_64-linux build and
> testsuite run.
> 
> Ok?
> 
> Jim
> 
>   gcc/
>   * expr.c (do_tablejump): When converting index to Pmode, if we have a
>   sign extended promoted subreg, and the range does not have the sign bit
>   set, then do a sign extend.
OK.

Jeff


Re: [PR63185][RFC] Improve DSE with branches

2018-05-21 Thread Jeff Law
On 05/15/2018 04:47 PM, Kugan Vivekanandarajah wrote:
> Hi Richard,
> 
> On 15 May 2018 at 19:20, Richard Biener  wrote:
>> On Tue, 15 May 2018, Richard Biener wrote:
>>
>>> On Mon, 14 May 2018, Kugan Vivekanandarajah wrote:
>>>
 Hi,

 Attached patch handles PR63185 when we reach PHI with temp != NULLL.
 We could see the PHI and if there isn't any uses for PHI that is
 interesting, we could ignore that ?

 Bootstrapped and regression tested on x86_64-linux-gnu.
 Is this OK?
>>>
>>> No, as Jeff said we can't do it this way.
>>>
>>> If we end up with multiple VDEFs in the walk of defvar immediate
>>> uses we know we are dealing with a CFG fork.  We can't really
>>> ignore any of the paths but we have to
>>>
>>>  a) find the merge point (and the associated VDEF)
>>>  b) verify for each each chain of VDEFs with associated VUSEs
>>> up to that merge VDEF that we have no uses of the to classify
>>> store and collect (partial) kills
>>>  c) intersect kill info and continue walking from the merge point
>>>
>>> in b) there's the optional possibility to find sinking opportunities
>>> in case we have kills on some paths but uses on others.  This is why
>>> DSE should be really merged with (store) sinking.
>>>
>>> So if we want to enhance DSEs handling of branches then we need
>>> to refactor the simple dse_classify_store function.  Let me take
>>> an attempt at this today.
>>
>> First (baby) step is the following - it arranges to collect the
>> defs we need to continue walking from and implements trivial
>> reduction by stopping at (full) kills.  This allows us to handle
>> the new testcase (which was already handled in the very late DSE
>> pass with the help of sinking the store).
> 
> Thanks for the explanation and thanks for working on this.
> 
>>
>> I took the opportunity to kill the use_stmt parameter of
>> dse_classify_store as the only user is only looking for whether
>> the kills were all clobbers which I added a new parameter for.
>>
>> I didn't adjust the byte-tracking case fully (I'm not fully understanding
>> the code in the case of a use and I'm not sure whether it's worth
>> doing the def reduction with byte-tracking).
> 
> Since byte tracking is tracking the killed subset of bytes in the
> original def, in your patch can we calculate the bytes killed by each
> defs[i] and then find the intersection for the iteration. If we don't
> have complete kill, we can use this to set live bytes and iterate till
> all the live_bytes are cleared like it was done earlier.
Correct.

Jeff


Re: [PR63185][RFC] Improve DSE with branches

2018-05-21 Thread Jeff Law
On 05/16/2018 07:55 AM, Richard Biener wrote:
> On Wed, 16 May 2018, Richard Biener wrote:
> 
>> On Tue, 15 May 2018, Richard Biener wrote:
>>
>>> On Tue, 15 May 2018, Richard Biener wrote:
>>>
 On Tue, 15 May 2018, Richard Biener wrote:

> On Tue, 15 May 2018, Richard Biener wrote:
>
>> On Tue, 15 May 2018, Richard Biener wrote:
>>
>>> On Mon, 14 May 2018, Kugan Vivekanandarajah wrote:
>>>
 Hi,

 Attached patch handles PR63185 when we reach PHI with temp != NULLL.
 We could see the PHI and if there isn't any uses for PHI that is
 interesting, we could ignore that ?

 Bootstrapped and regression tested on x86_64-linux-gnu.
 Is this OK?
>>>
>>> No, as Jeff said we can't do it this way.
>>>
>>> If we end up with multiple VDEFs in the walk of defvar immediate
>>> uses we know we are dealing with a CFG fork.  We can't really
>>> ignore any of the paths but we have to
>>>
>>>  a) find the merge point (and the associated VDEF)
>>>  b) verify for each each chain of VDEFs with associated VUSEs
>>> up to that merge VDEF that we have no uses of the to classify
>>> store and collect (partial) kills
>>>  c) intersect kill info and continue walking from the merge point
>>>
>>> in b) there's the optional possibility to find sinking opportunities
>>> in case we have kills on some paths but uses on others.  This is why
>>> DSE should be really merged with (store) sinking.
>>>
>>> So if we want to enhance DSEs handling of branches then we need
>>> to refactor the simple dse_classify_store function.  Let me take
>>> an attempt at this today.
>>
>> First (baby) step is the following - it arranges to collect the
>> defs we need to continue walking from and implements trivial
>> reduction by stopping at (full) kills.  This allows us to handle
>> the new testcase (which was already handled in the very late DSE
>> pass with the help of sinking the store).
>>
>> I took the opportunity to kill the use_stmt parameter of
>> dse_classify_store as the only user is only looking for whether
>> the kills were all clobbers which I added a new parameter for.
>>
>> I didn't adjust the byte-tracking case fully (I'm not fully understanding
>> the code in the case of a use and I'm not sure whether it's worth
>> doing the def reduction with byte-tracking).
>>
>> Your testcase can be handled by reducing the PHI and the call def
>> by seeing that the only use of a candidate def is another def
>> we have already processed.  Not sure if worth special-casing though,
>> I'd rather have a go at "recursing".  That will be the next
>> patch.
>>
>> Bootstrap & regtest running on x86_64-unknown-linux-gnu.
>
> Applied.
>
> Another intermediate one below, fixing the byte-tracking for
> stmt with uses.  This also re-does the PHI handling by simply
> avoiding recursion by means of a visited bitmap and stopping
> at the DSE classify stmt when re-visiting it instead of failing.
> This covers Pratamesh loop case for which I added ssa-dse-33.c.
> For the do-while loop this still runs into the inability to
> handle two defs to walk from.
>
> Bootstrap & regtest running on x86_64-unknown-linux-gnu.

 Ok, loop handling doesn't work in general since we run into the
 issue that SSA form across the backedge is not representing the
 same values.  Consider

  
  # .MEM_22 = PHI <.MEM_12(D)(2), .MEM_13(4)>
  # n_20 = PHI <0(2), n_7(4)>
  # .MEM_13 = VDEF <.MEM_22>
  bytes[n_20] = _4;
  if (n_20 > 7)
goto ;

  
  n_7 = n_20 + 1;
  # .MEM_15 = VDEF <.MEM_13>
  bytes[n_20] = _5;
  goto ;

 then when classifying the store in bb4, visiting the PHI node
 gets us to the store in bb3 which appears to be killing.

if (gimple_code (temp) == GIMPLE_PHI)
 -   defvar = PHI_RESULT (temp);
 +   {
 + /* If we visit this PHI by following a backedge then reset
 +any info in ref that may refer to SSA names which we'd need
 +to PHI translate.  */
 + if (gimple_bb (temp) == gimple_bb (stmt)
 + || dominated_by_p (CDI_DOMINATORS, gimple_bb (stmt),
 +gimple_bb (temp)))
 +   /* ???  ref->ref may not refer to SSA names or it may only
 +  refer to SSA names that are invariant with respect to the
 +  loop represented by this PHI node.  */
 +   ref->ref = NULL_TREE;
 + defvar = PHI_RESULT (temp);
 + bitmap_set_bit (visited, SSA_NAME_VERSION (defvar));
 +   }

 should be a workable solution for that.  I'm checking that, but
 eventually you can think of other things 

Re: [PATCH] Make __FUNCTION__ a mergeable string and do not generate symbol entry.

2018-05-21 Thread Martin Liška
On 10/24/2017 10:24 PM, Jason Merrill wrote:
> On Thu, Sep 14, 2017 at 5:22 AM, Martin Liška  wrote:
>> On 08/10/2017 09:43 PM, Jason Merrill wrote:
>>> On 07/14/2017 01:35 AM, Martin Liška wrote:
 On 05/01/2017 09:13 PM, Jason Merrill wrote:
> On Wed, Apr 26, 2017 at 6:58 AM, Martin Liška  wrote:
>> On 04/25/2017 01:58 PM, Jakub Jelinek wrote:
>>> On Tue, Apr 25, 2017 at 01:48:05PM +0200, Martin Liška wrote:
 Hello.

 This is patch that was originally installed by Jason and later 
 reverted due to PR70422.
 In the later PR Richi suggested a fix for that and Segher verified 
 that it helped him
 to survive regression tests. That's reason why I'm resending that.

 Patch can bootstrap on ppc64le-redhat-linux and survives regression 
 tests.

 Ready to be installed?
 Martin
>>>
 >From a34ce0ef37ae00609c9f3ff98a9cb0b7db6a8bd0 Mon Sep 17 00:00:00 2001
 From: marxin 
 Date: Thu, 20 Apr 2017 14:56:30 +0200
 Subject: [PATCH] Make __FUNCTION__ a mergeable string and do not 
 generate
   symbol entry.

 gcc/cp/ChangeLog:

 2017-04-20  Jason Merrill  
   Martin Liska  
   Segher Boessenkool  

   PR c++/64266
   PR c++/70353
   PR bootstrap/70422
   Core issue 1962
   * decl.c (cp_fname_init): Decay the initializer to pointer.
   (cp_make_fname_decl): Set DECL_DECLARED_CONSTEXPR_P,
   * pt.c (tsubst_expr) [DECL_EXPR]: Set DECL_VALUE_EXPR,
   DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P and
   DECL_IGNORED_P.  Don't call cp_finish_decl.
>>>
>>> If we don't emit those into the debug info, will the debugger be
>>> able to handle __FUNCTION__ etc. properly?
>>
>> No, debugger with the patch can't handled these. Similar to how clang
>> behaves currently. Maybe it can be conditionally enabled with -g3, or -g?
>>
>>> Admittedly, right now we emit it into debug info only if those decls
>>> are actually used, say on:
>>> const char * foo () { return __FUNCTION__; }
>>> const char * bar () { return ""; }
>>> we'd emit foo::__FUNCTION__, but not bar::__FUNCTION__, so the debugger
>>> has to have some handling of it anyway.  But while in functions
>>> that don't refer to __FUNCTION__ it is always the debugger that needs
>>> to synthetize those and thus they will be always pointer-equal,
>>> if there are some uses of it and for other uses the debugger would
>>> synthetize it, there is the possibility that the debugger synthetized
>>> string will not be the same object as actually used in the function.
>>
>> You're right, currently one has to use a special function to be able to
>> print it in debugger. I believe we've already discussed that, according
>> to spec, the strings don't have to point to a same string.
>>
>> Suggestions what we should do with the patch?
>
> We need to emit debug information for these variables.  From Jim's
> description in 70422 it seems that the problem is that the reference
> to the string from the debug information is breaking
> function_mergeable_rodata_prefix, which relies on
> current_function_decl.  It seems to me that its callers should pass
> along their decl parameter so that f_m_r_p can use the decl's
> DECL_CONTEXT rather than rely on current_function_decl being set
> properly>
> Jason
>

 Ok, after some time I returned back to it. I followed your advises and
 changed the function function_mergeable_rodata_prefix. Apart from a small
 rebase was needed.

 May I ask Jim to test the patch?
 Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>>>
 +  DECL_IGNORED_P (decl) = 1;
>>>
>>> As I said before, we do need to emit debug information for these variables, 
>>> so this is wrong.
>>
>> Hello.
>>
>> Sorry for overlooking that.
>>
>>>
 -  section *s = targetm.asm_out.function_rodata_section 
 (current_function_decl);
 +  tree decl = current_function_decl;
 +  if (decl && DECL_CONTEXT (decl)
 +  && TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL)
 +decl = DECL_CONTEXT (decl);
>>>
>>> I don't see how this would help; it still relies on current_function_decl 
>>> being set correctly, which was the problem we were running into before.
>>
>> I see, that's what I wanted to discuss on Cauldron with you, but eventually 
>> I did not find time.
>> Well problem that I see is that we want to make decision based on 
>> DECL_CONTEXT(fname_decl), but mergeable_string_section
>> is called with STRING_CST (which is VALUE_EXPR of created 

[PATCH PR85804]Fix wrong code by correcting bump step computation in vector(1) load of single-element group access

2018-05-21 Thread Bin Cheng
Hi,
As reported in PR85804, bump step is wrongly computed for vector(1) load of
single-element group access.  This patch fixes the issue by correcting bump
step computation for the specific VMAT_CONTIGUOUS case.

Bootstrap and test on x86_64 and AArch64 ongoing, is it OK?

Thanks,
bin

2018-05-17  Bin Cheng  

PR tree-optimization/85804
* tree-vect-stmts.c (vectorizable_load): Compute correct bump step
for vector(1) load in single-element group access.

gcc/testsuite
2018-05-17  Bin Cheng  

PR tree-optimization/85804
* gcc.c-torture/execute/pr85804.c: New test.From 502bcd1e445186a56b6ea254a0cd2406fb62f08c Mon Sep 17 00:00:00 2001
From: Bin Cheng 
Date: Fri, 18 May 2018 14:18:14 +0100
Subject: [PATCH] pr85804-20180517

---
 gcc/testsuite/gcc.c-torture/execute/pr85804.c | 22 ++
 gcc/tree-vect-stmts.c | 15 +++
 2 files changed, 37 insertions(+)
 create mode 100644 gcc/testsuite/gcc.c-torture/execute/pr85804.c

diff --git a/gcc/testsuite/gcc.c-torture/execute/pr85804.c b/gcc/testsuite/gcc.c-torture/execute/pr85804.c
new file mode 100644
index 000..b8929b1
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr85804.c
@@ -0,0 +1,22 @@
+/* { dg-options "-O2 -ftree-vectorize -fno-vect-cost-model" } */
+
+long d[64] = {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+void abort ();
+void __attribute__((noinline)) foo (int b)
+{
+  if (b)
+abort ();
+}
+int main() {
+  int b = 0;
+  for (int c = 0; c <= 5; c++)
+b ^= d[c * 5 + 1];
+  foo (b);
+  return 0;
+}
+
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 64a157d..e6b95b3 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -7262,6 +7262,7 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
   gphi *phi = NULL;
   vec dr_chain = vNULL;
   bool grouped_load = false;
+  bool single_element = false;
   gimple *first_stmt;
   gimple *first_stmt_for_drptr = NULL;
   bool inv_p;
@@ -7822,6 +7823,15 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
   first_stmt = stmt;
   first_dr = dr;
   group_size = vec_num = 1;
+  /* For single-element vector in a single-element group, record the group
+	 size in order to compute correct bump size.  */
+  if (!slp
+	  && memory_access_type == VMAT_CONTIGUOUS
+	  && STMT_VINFO_GROUPED_ACCESS (stmt_info))
+	{
+	  single_element = true;
+	  group_size = GROUP_SIZE (vinfo_for_stmt (first_stmt));
+	}
   group_gap_adj = 0;
   ref_type = reference_alias_ptr_type (DR_REF (first_dr));
 }
@@ -7992,6 +8002,11 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
   else
 	aggr_type = vectype;
   bump = vect_get_data_ptr_increment (dr, aggr_type, memory_access_type);
+  /* Multiply bump size by group size for single-element vector in single-
+	 element group.  */
+  if (single_element && group_size > 1)
+	bump = fold_build2 (MULT_EXPR, TREE_TYPE (bump), bump,
+			build_int_cst (TREE_TYPE (bump), group_size));
 }
 
   tree vec_mask = NULL_TREE;
-- 
1.9.1



[PATCH] Fix std::filesystem::absolute for empty paths

2018-05-21 Thread Jonathan Wakely

* src/filesystem/std-ops.cc (absolute): Report an error for empty
paths.
(weakly_canonical(const path&)): Do not call canonical on empty path.
(weakly_canonical(const path&, error_code&)): Likewise.
* testsuite/27_io/filesystem/operations/absolute.cc: Check for errors.

Tested powerpcle-linux, committed to trunk.

commit 0fd34cfc51004390afc7195732f9dbf3dd363420
Author: Jonathan Wakely 
Date:   Mon May 21 13:38:40 2018 +0100

Fix std::filesystem::absolute for empty paths

* src/filesystem/std-ops.cc (absolute): Report an error for empty
paths.
(weakly_canonical(const path&)): Do not call canonical on empty 
path.
(weakly_canonical(const path&, error_code&)): Likewise.
* testsuite/27_io/filesystem/operations/absolute.cc: Check for 
errors.

diff --git a/libstdc++-v3/src/filesystem/std-ops.cc 
b/libstdc++-v3/src/filesystem/std-ops.cc
index 74868cd48e6..00e4f987fc3 100644
--- a/libstdc++-v3/src/filesystem/std-ops.cc
+++ b/libstdc++-v3/src/filesystem/std-ops.cc
@@ -84,13 +84,20 @@ fs::absolute(const path& p)
 fs::path
 fs::absolute(const path& p, error_code& ec)
 {
+  path ret;
+  if (p.empty())
+{
+  ec = make_error_code(std::errc::no_such_file_or_directory);
+  return ret;
+}
 #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
   ec = std::make_error_code(errc::not_supported);
-  return {};
 #else
   ec.clear();
-  return current_path() / p;
+  ret = current_path();
+  ret /= p;
 #endif
+  return ret;
 }
 
 namespace
@@ -1513,7 +1520,8 @@ fs::weakly_canonical(const path& p)
   ++iter;
 }
   // canonicalize:
-  result = canonical(result);
+  if (!result.empty())
+result = canonical(result);
   // append the non-existing elements:
   while (iter != end)
 result /= *iter++;
@@ -1551,7 +1559,7 @@ fs::weakly_canonical(const path& p, error_code& ec)
   ++iter;
 }
   // canonicalize:
-  if (!ec)
+  if (!ec && !result.empty())
 result = canonical(result, ec);
   if (ec)
 result.clear();
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/absolute.cc 
b/libstdc++-v3/testsuite/27_io/filesystem/operations/absolute.cc
index 4e472edd375..413a86758f0 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/absolute.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/absolute.cc
@@ -31,7 +31,11 @@ void
 test01()
 {
   for (const path& p : __gnu_test::test_paths)
-VERIFY( absolute(p).is_absolute() );
+  {
+std::error_code ec;
+path abs = absolute(p, ec);
+VERIFY( ec || abs.is_absolute() );
+  }
 }
 
 void


Re: [C++ Patch] PR 84588 ("[8 Regression] internal compiler error: Segmentation fault (contains_struct_check())")​ (Take 2)

2018-05-21 Thread Paolo Carlini

Hi again,

On 19/05/2018 15:30, Jason Merrill wrote:

How about doing cp_parser_commit_to_tentative_parse if we see
something that must be a declaration?  cp_parser_simple_declaration
has

   /* If we have seen at least one decl-specifier, and the next token
  is not a parenthesis, then we must be looking at a declaration.
  (After "int (" we might be looking at a functional cast.)  */
   if (decl_specifiers.any_specifiers_p
   && cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_PAREN)
   && cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_BRACE)
   && !cp_parser_error_occurred (parser))
 cp_parser_commit_to_tentative_parse (parser);

That seems useful here, as well.  Maybe factored into a separate function.
The below implements this new idea, which indeed appears to work well: I 
tested it and testsuite-wise seems essentially equivalent to what I 
posted yesterday, besides a slightly worse error-recovery for the first 
issue in cpp1z/decomp16.C: an additional 'no match for ‘operator=’' error.


Thanks!
Paolo.

//

Index: cp/parser.c
===
--- cp/parser.c (revision 260402)
+++ cp/parser.c (working copy)
@@ -11527,6 +11527,53 @@ cp_parser_selection_statement (cp_parser* parser,
 }
 }
 
+/* Helper function for cp_parser_condition and cp_parser_simple_declaration.
+   If we have seen at least one decl-specifier, and the next token
+   is not a parenthesis, then we must be looking at a declaration.
+   (After "int (" we might be looking at a functional cast.)  */
+
+static bool
+cp_parser_maybe_commit_to_declaration (cp_parser* parser,
+  bool any_specifiers_p)
+{
+  if (any_specifiers_p
+  && cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_PAREN)
+  && cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_BRACE)
+  && !cp_parser_error_occurred (parser))
+{
+  cp_parser_commit_to_tentative_parse (parser);
+  return true;
+}
+  return false;
+}
+
+/* Helper function for cp_parser_condition.  Enforces [stmt.stmt]/2:
+   The declarator shall not specify a function or an array.  Returns
+   TRUE if the declarator is valid, FALSE otherwise.  */
+
+static bool
+cp_parser_check_condition_declarator (cp_parser* parser,
+ cp_declarator *declarator,
+ location_t loc)
+{
+  if (function_declarator_p (declarator)
+  || declarator->kind == cdk_array)
+{
+  if (declarator->kind == cdk_array)
+   error_at (loc, "condition declares an array");
+  else
+   error_at (loc, "condition declares a function");
+  if (parser->fully_implicit_function_template_p)
+   abort_fully_implicit_template (parser);
+  cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true,
+/*or_comma=*/false,
+/*consume_paren=*/false);
+  return false;
+}
+  else
+return true;
+}
+
 /* Parse a condition.
 
condition:
@@ -11563,6 +11610,10 @@ cp_parser_condition (cp_parser* parser)
_class_or_enum);
   /* Restore the saved message.  */
   parser->type_definition_forbidden_message = saved_message;
+
+  cp_parser_maybe_commit_to_declaration (parser,
+type_specifiers.any_specifiers_p);
+
   /* If all is well, we might be looking at a declaration.  */
   if (!cp_parser_error_occurred (parser))
 {
@@ -11571,6 +11622,7 @@ cp_parser_condition (cp_parser* parser)
   tree attributes;
   cp_declarator *declarator;
   tree initializer = NULL_TREE;
+  location_t loc = cp_lexer_peek_token (parser->lexer)->location;
 
   /* Parse the declarator.  */
   declarator = cp_parser_declarator (parser, CP_PARSER_DECLARATOR_NAMED,
@@ -11601,6 +11653,9 @@ cp_parser_condition (cp_parser* parser)
  bool non_constant_p;
  int flags = LOOKUP_ONLYCONVERTING;
 
+ if (!cp_parser_check_condition_declarator (parser, declarator, loc))
+   return error_mark_node;
+
  /* Create the declaration.  */
  decl = start_decl (declarator, _specifiers,
 /*initialized_p=*/true,
@@ -11614,12 +11669,18 @@ cp_parser_condition (cp_parser* parser)
  CONSTRUCTOR_IS_DIRECT_INIT (initializer) = 1;
  flags = 0;
}
- else
+ else if (cp_lexer_next_token_is (parser->lexer, CPP_EQ))
{
  /* Consume the `='.  */
- cp_parser_require (parser, CPP_EQ, RT_EQ);
- initializer = cp_parser_initializer_clause (parser, 
_constant_p);
+ cp_lexer_consume_token (parser->lexer);
+ initializer = cp_parser_initializer_clause (parser,
+ _constant_p);
}
+ else
+   {
+ 

Re: [PATCH] PR libstdc++/85818 ensure path::preferred_separator is defined

2018-05-21 Thread Jonathan Wakely

On 17/05/18 16:36 +0100, Jonathan Wakely wrote:

Because path.cc is compiled with -std=gnu++17 the static constexpr
data member is implicitly 'inline' and so no definition gets emitted
unless it gets used in that translation unit. Other translation units
built as C++11 or C++14 still require a namespace-scope definition of
the variable, so mark the definition as used.

PR libstdc++/85818
* src/filesystem/path.cc (path::preferred_separator): Add used
attribute.
* testsuite/experimental/filesystem/path/preferred_separator.cc: New.

Tested powerpc64le-linux, committed to trunk. Backport to gcc-8 to
follow.


I forgot to make the new test depend on the Filesystem lib being
supported. Fixed by this patch, committed to trunk and gcc-8-branch.


commit 3eb1acc290b7b7407a24b62a3d267f344e88ffbd
Author: Jonathan Wakely 
Date:   Mon May 21 13:23:30 2018 +0100

PR libstdc++/85818 make new test require Filesystem support

PR libstdc++/85818
* testsuite/experimental/filesystem/path/preferred_separator.cc: Add
dg-require-filesystem-ts.

diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/preferred_separator.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/preferred_separator.cc
index b470e312bb1..5ca948dfaef 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/path/preferred_separator.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/path/preferred_separator.cc
@@ -17,6 +17,7 @@
 
 // { dg-options "-O0 -lstdc++fs -std=gnu++11" }
 // { dg-do link { target c++11 } }
+// { dg-require-filesystem-ts "" }
 
 #include 
 


Re: [Patch, Fortran] PR 85841: [F2018] reject deleted features

2018-05-21 Thread H.J. Lu
On Mon, May 21, 2018 at 12:00 AM, Janus Weil  wrote:
>
> Thanks. I have committed this version of the patch as r260433.

This caused:

FAIL: gfortran.dg/graphite/block-2.f   -O  (test for excess errors)
FAIL: gfortran.dg/graphite/id-19.f   -O  (test for excess errors)
FAIL: gfortran.dg/graphite/id-20.f   -O  (test for excess errors)
FAIL: gfortran.dg/graphite/id-27.f90   -O  (test for excess errors)
FAIL: gfortran.dg/graphite/pr82449.f   -O  (test for excess errors)
FAIL: gfortran.dg/pr30667.f   -O  (test for excess errors)
FAIL: libgomp.fortran/collapse2.f90   -O0  (test for excess errors)
FAIL: libgomp.fortran/collapse2.f90   -O1  (test for excess errors)
FAIL: libgomp.fortran/collapse2.f90   -O2  (test for excess errors)
FAIL: libgomp.fortran/collapse2.f90   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  (test for
excess errors)
FAIL: libgomp.fortran/collapse2.f90   -O3 -g  (test for excess errors)
FAIL: libgomp.fortran/collapse2.f90   -Os  (test for excess errors)
FAIL: libgomp.fortran/omp_atomic2.f90   -O0  (test for excess errors)
FAIL: libgomp.fortran/omp_atomic2.f90   -O1  (test for excess errors)
FAIL: libgomp.fortran/omp_atomic2.f90   -O2  (test for excess errors)
FAIL: libgomp.fortran/omp_atomic2.f90   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  (test for
excess errors)
FAIL: libgomp.fortran/omp_atomic2.f90   -O3 -g  (test for excess errors)
FAIL: libgomp.fortran/omp_atomic2.f90   -Os  (test for excess errors)
FAIL: libgomp.fortran/omp_parse1.f90   -O0  (test for excess errors)
FAIL: libgomp.fortran/omp_parse1.f90   -O1  (test for excess errors)
FAIL: libgomp.fortran/omp_parse1.f90   -O2  (test for excess errors)
FAIL: libgomp.fortran/omp_parse1.f90   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  (test for
excess errors)
FAIL: libgomp.fortran/omp_parse1.f90   -O3 -g  (test for excess errors)
FAIL: libgomp.fortran/omp_parse1.f90   -Os  (test for excess errors)
FAIL: libgomp.fortran/omp_parse3.f90   -O0  (test for excess errors)
FAIL: libgomp.fortran/omp_parse3.f90   -O1  (test for excess errors)
FAIL: libgomp.fortran/omp_parse3.f90   -O2  (test for excess errors)
FAIL: libgomp.fortran/omp_parse3.f90   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  (test for
excess errors)
FAIL: libgomp.fortran/omp_parse3.f90   -O3 -g  (test for excess errors)
FAIL: libgomp.fortran/omp_parse3.f90   -Os  (test for excess errors)
FAIL: libgomp.fortran/task2.f90   -O  (test for excess errors)
FAIL: libgomp.fortran/vla1.f90   -O0  (test for excess errors)
FAIL: libgomp.fortran/vla1.f90   -O1  (test for excess errors)
FAIL: libgomp.fortran/vla1.f90   -O2  (test for excess errors)
FAIL: libgomp.fortran/vla1.f90   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  (test for
excess errors)
FAIL: libgomp.fortran/vla1.f90   -O3 -g  (test for excess errors)
FAIL: libgomp.fortran/vla1.f90   -Os  (test for excess errors)
FAIL: libgomp.fortran/vla2.f90   -O0  (test for excess errors)
FAIL: libgomp.fortran/vla2.f90   -O1  (test for excess errors)
FAIL: libgomp.fortran/vla2.f90   -O2  (test for excess errors)
FAIL: libgomp.fortran/vla2.f90   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  (test for
excess errors)
FAIL: libgomp.fortran/vla2.f90   -O3 -g  (test for excess errors)
FAIL: libgomp.fortran/vla2.f90   -Os  (test for excess errors)
FAIL: libgomp.fortran/vla3.f90   -O0  (test for excess errors)
FAIL: libgomp.fortran/vla3.f90   -O1  (test for excess errors)
FAIL: libgomp.fortran/vla3.f90   -O2  (test for excess errors)
FAIL: libgomp.fortran/vla3.f90   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  (test for
excess errors)
FAIL: libgomp.fortran/vla3.f90   -O3 -g  (test for excess errors)
FAIL: libgomp.fortran/vla3.f90   -Os  (test for excess errors)
FAIL: libgomp.fortran/vla4.f90   -O0  (test for excess errors)
FAIL: libgomp.fortran/vla4.f90   -O1  (test for excess errors)
FAIL: libgomp.fortran/vla4.f90   -O2  (test for excess errors)
FAIL: libgomp.fortran/vla4.f90   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  (test for
excess errors)
FAIL: libgomp.fortran/vla4.f90   -O3 -g  (test for excess errors)
FAIL: libgomp.fortran/vla4.f90   -Os  (test for excess errors)
FAIL: libgomp.fortran/vla5.f90   -O0  (test for excess errors)
FAIL: libgomp.fortran/vla5.f90   -O1  (test for excess errors)
FAIL: libgomp.fortran/vla5.f90   -O2  (test for excess errors)
FAIL: libgomp.fortran/vla5.f90   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  (test for
excess errors)
FAIL: libgomp.fortran/vla5.f90   -O3 -g  (test for excess errors)
FAIL: libgomp.fortran/vla5.f90   -Os  (test for excess errors)
FAIL: libgomp.fortran/vla6.f90   -O0  (test for excess errors)
FAIL: libgomp.fortran/vla6.f90   -O1  (test for excess 

Re: [PATCH][AArch64] Implement usadv16qi and ssadv16qi standard names

2018-05-21 Thread Kyrill Tkachov


On 19/05/18 02:09, James Greenhalgh wrote:

On Mon, May 14, 2018 at 08:38:40AM -0500, Kyrill Tkachov wrote:

Hi all,

This patch implements the usadv16qi and ssadv16qi standard names.
See the thread at on g...@gcc.gnu.org [1] for background.

The V16QImode variant is important to get right as it is the most commonly used 
pattern:
reducing vectors of bytes into an int.
The midend expects the optab to compute the absolute differences of operands 1 
and 2 and
reduce them while widening along the way up to SImode. So the inputs are 
V16QImode and
the output is V4SImode.

I've tried out a few different strategies for that, the one I settled with is 
to emit:
UABDL2tmp.8h, op1.16b, op2.16b
UABALtmp.8h, op1.16b, op2.16b
UADALPop3.4s, tmp.8h

To work through the semantics let's say operands 1 and 2 are:
op1 { a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 }
op2 { b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15 }
op3 { c0, c1, c2, c3 }

The UABDL2 takes the upper V8QI elements, computes their absolute differences, 
widens them and stores them into the V8HImode tmp:

tmp { ABS(a[8]-b[8]), ABS(a[9]-b[9]), ABS(a[10]-b[10]), ABS(a[11]-b[11]), 
ABS(a[12]-b[12]), ABS(a[13]-b[13]), ABS(a[14]-b[14]), ABS(a[15]-b[15]) }

The UABAL after that takes the lower V8QI elements, computes their absolute 
differences, widens them and accumulates them into the V8HImode tmp from the 
previous step:

tmp { ABS(a[8]-b[8])+ABS (a[0]-b[0]), ABS(a[9]-b[9])+ABS(a[1]-b[1]), 
ABS(a[10]-b[10])+ABS(a[2]-b[2]), ABS(a[11]-b[11])+ABS(a[3]-b[3]), 
ABS(a[12]-b[12])+ABS(a[4]-b[4]), ABS(a[13]-b[13])+ABS(a[5]-b[5]), 
ABS(a[14]-b[14])+ABS(a[6]-b[6]), ABS(a[15]-b[15])+ABS(a[7]-b[7]) }

Finally the UADALP does a pairwise widening reduction and accumulation into the 
V4SImode op3:
op3 { c0+ABS(a[8]-b[8])+ABS(a[0]-b[0])+ABS(a[9]-b[9])+ABS(a[1]-b[1]), 
c1+ABS(a[10]-b[10])+ABS(a[2]-b[2])+ABS(a[11]-b[11])+ABS(a[3]-b[3]), 
c2+ABS(a[12]-b[12])+ABS(a[4]-b[4])+ABS(a[13]-b[13])+ABS(a[5]-b[5]), 
c3+ABS(a[14]-b[14])+ABS(a[6]-b[6])+ABS(a[15]-b[15])+ABS(a[7]-b[7]) }

(sorry for the text dump)

Remember, according to [1] the exact reduction sequence doesn't matter (for 
integer arithmetic at least).
I've considered other sequences as well (thanks Wilco), for example
* UABD + UADDLP + UADALP
* UABLD2 + UABDL + UADALP + UADALP

I ended up settling in the sequence in this patch as it's short (3 
instructions) and in the future we can potentially
look to optimise multiple occurrences of these into something even faster (for 
example accumulating into H registers for longer
before doing a single UADALP in the end to accumulate into the final S 
register).

If your microarchitecture has some some strong preferences for a particular 
sequence, please let me know or, even better, propose a patch
to parametrise the generation sequence by code (or the appropriate RTX cost).


This expansion allows the vectoriser to avoid unpacking the bytes in two steps 
and performing V4SI arithmetic on them.
So, for the code:

unsigned char pix1[N], pix2[N];

int foo (void)
{
int i_sum = 0;
int i;

for (i = 0; i < 16; i++)
  i_sum += __builtin_abs (pix1[i] - pix2[i]);

return i_sum;
}

we now generate on aarch64:
foo:
  adrpx1, pix1
  add x1, x1, :lo12:pix1
  moviv0.4s, 0
  adrpx0, pix2
  add x0, x0, :lo12:pix2
  ldr q2, [x1]
  ldr q3, [x0]
  uabdl2  v1.8h, v2.16b, v3.16b
  uabal   v1.8h, v2.8b, v3.8b
  uadalp  v0.4s, v1.8h
  addvs0, v0.4s
  umovw0, v0.s[0]
  ret


instead of:
foo:
  adrpx1, pix1
  adrpx0, pix2
  add x1, x1, :lo12:pix1
  add x0, x0, :lo12:pix2
  ldr q0, [x1]
  ldr q4, [x0]
  ushll   v1.8h, v0.8b, 0
  ushll2  v0.8h, v0.16b, 0
  ushll   v2.8h, v4.8b, 0
  ushll2  v4.8h, v4.16b, 0
  usubl   v3.4s, v1.4h, v2.4h
  usubl2  v1.4s, v1.8h, v2.8h
  usubl   v2.4s, v0.4h, v4.4h
  usubl2  v0.4s, v0.8h, v4.8h
  abs v3.4s, v3.4s
  abs v1.4s, v1.4s
  abs v2.4s, v2.4s
  abs v0.4s, v0.4s
  add v1.4s, v3.4s, v1.4s
  add v1.4s, v2.4s, v1.4s
  add v0.4s, v0.4s, v1.4s
  addvs0, v0.4s
  umovw0, v0.s[0]
  ret

So I expect this new expansion to be better than the status quo in any case.
Bootstrapped and tested on aarch64-none-linux-gnu.
This gives about 8% on 525.x264_r from SPEC2017 on a Cortex-A72.

Ok for trunk?

You don't say it explicitly here, but I presume the mid-end takes care of
zeroing the accumulator register before the loop (i.e. op3 in your sequence
in aarch64-simd.md)?


Yes, the midend takes care of zeroing the accumulator register
and doing the full reduction at the end of the loop.


If so, looks good to me.

Ok for trunk.


Re: [PATCH][arm][2/2] Remove support for -march=armv3 and older

2018-05-21 Thread Kyrill Tkachov


On 18/05/18 11:33, Richard Earnshaw (lists) wrote:

On 17/05/18 11:26, Kyrill Tkachov wrote:

Hi all,

We deprecated architecture versions earlier than Armv4T in GCC 6 [1].
This patch removes support for architectures lower than Armv4.
That is the -march values armv2, armv2a, armv3, armv3m are removed
with this patch.  I did not remove armv4 because it's a bit more
involved code-wise and there has been some pushback on the implications
for -mcpu=strongarm support.

Removing armv3m and earlier though is pretty straightforward.
This allows us to get rid of the armv3m and mode32 feature bits
in arm-cpus.in as they can be assumed to be universally available.

Consequently the mcpu values arm2, arm250, arm3, arm6, arm60, arm600,
arm610, arm620, arm7, arm7d, arm7di, arm70, arm700, arm700i, arm710,
arm720, arm710c, arm7100, arm7500, arm7500fe, arm7m, arm7dm, arm7dm are
now also removed.

Bootstrapped and tested on arm-none-linux-gnueabihf and on arm-none-eabi
with an aprofile multilib configuration (which builds quite a lot of
library
configurations).

Ramana, Richard, I'd appreciate an ok from either of you that you're
happy for this to go ahead.

OK.


Thanks, I've committed the two patches.



It seems slightly strange that we remove the mode32 feature, but not the
mode26 feature, though I can see how it occurs as a consequence of this
cleanup.

However, we're no longer interested in supporting ARMv4 running in
mode26 (and I think in reality mode26 support was dropped several
releases back), so we should just drop that feature bit as well.
Perhaps you could do a follow-up to remove that too?


Yeah, that can be cleaned up separately.

Thanks,
Kyrill


Thanks,

R.


Thanks,
Kyrill

[1] https://gcc.gnu.org/gcc-6/changes.html#arm

2018-05-17  Kyrylo Tkachov  

 * config/arm/arm-cpus.in (armv3m, mode32): Delete features.
 (ARMv4): Update.
 (ARMv2, ARMv3, ARMv3m): Delete fgroups.
 (ARMv6m): Update.
 (armv2, armv2a, armv3, armv3m): Delete architectures.
 (arm2, arm250, arm3, arm6, arm60, arm600, arm610, arm620,
 arm7, arm7d, arm7di, arm70, arm700, arm700i, arm710, arm720,
 arm710c, arm7100, arm7500, arm7500fe, arm7m, arm7dm, arm7dmi):
 Delete cpus.
 * config/arm/arm.md (maddsidi4): Remove check for arm_arch3m.
 (*mulsidi3adddi): Likewise.
 (mulsidi3): Likewise.
 (*mulsidi3_nov6): Likewise.
 (umulsidi3): Likewise.
 (umulsidi3_nov6): Likewise.
 (umaddsidi4): Likewise.
 (*umulsidi3adddi): Likewise.
 (smulsi3_highpart): Likewise.
 (*smulsi3_highpart_nov6): Likewise.
 (umulsi3_highpart): Likewise.
 (*umulsi3_highpart_nov6): Likewise.
 * config/arm/arm.h (arm_arch3m): Delete.
 * config/arm/arm.c (arm_arch3m): Delete.
 (arm_option_override_internal): Update armv3-related comment.
 (arm_configure_build_target): Delete use of isa_bit_mode32.
 (arm_option_reconfigure_globals): Delete set of arm_ach3m.
 (arm_rtx_costs_internal): Delete check of arm_arch3m.
 * config/arm/arm-fixed.md (mulsq3): Delete check for arm_arch3m.
 (mulsa3): Likewise.
 (mulusa3): Likewise.
 * config/arm/arm-protos.h (arm_arch3m): Delete.
 * config/arm/arm-tables.opt: Regenerate.
 * config/arm/arm-tune.md: Likewise.
 * config/arm/t-arm-elf (all_early_nofp): Delete mentions of
 deleted architectures.

2018-05-17  Kyrylo Tkachov  

 * gcc.target/arm/pr62554.c: Delete.
 * gcc.target/arm/pr69610-1.c: Likewise.
 * gcc.target/arm/pr69610-2.c: Likewise.

armv3.patch


diff --git a/gcc/config/arm/arm-cpus.in b/gcc/config/arm/arm-cpus.in
index 
0a318877f10394e2c045d2a03a8f0757557136cf..16a381c86b6a7947e424b29fe67812990519ada9
 100644
--- a/gcc/config/arm/arm-cpus.in
+++ b/gcc/config/arm/arm-cpus.in
@@ -48,15 +48,9 @@
  
  # Features - general convention: all lower case.
  
-# Extended multiply

-define feature armv3m
-
  # 26-bit mode support
  define feature mode26
  
-# 32-bit mode support

-define feature mode32
-
  # Architecture rel 4
  define feature armv4
  
@@ -215,10 +209,7 @@ define fgroup ALL_FPU_INTERNAL	vfpv2 vfpv3 vfpv4 fpv5 fp16conv fp_dbl ALL_SIMD_I

  # -mfpu support.
  define fgroup ALL_FP  fp16 ALL_FPU_INTERNAL
  
-define fgroup ARMv2   notm

-define fgroup ARMv3   ARMv2 mode32
-define fgroup ARMv3m  ARMv3 armv3m
-define fgroup ARMv4   ARMv3m armv4
+define fgroup ARMv4   armv4 notm
  define fgroup ARMv4t  ARMv4 thumb
  define fgroup ARMv5t  ARMv4t armv5t
  define fgroup ARMv5te ARMv5t armv5te
@@ -232,7 +223,7 @@ define fgroup ARMv6zk ARMv6k
  define fgroup ARMv6t2 ARMv6 thumb2
  # This is suspect.  ARMv6-m doesn't really pull in any useful features
  # from ARMv5* or ARMv6.
-define fgroup ARMv6m  mode32 armv3m armv4 thumb armv5t armv5te armv6 be8
+define fgroup ARMv6m  armv4 thumb armv5t armv5te armv6 be8
  # This is suspect, the 'common' ARMv7 subset excludes the thumb2 'DSP' and
  # integer SIMD 

Re: [PATCH][RFC] Radically simplify emission of balanced tree for switch statements.

2018-05-21 Thread Rainer Orth
Hi Martin,

> On 05/18/2018 03:55 PM, Rainer Orth wrote:
>> Hi Martin,
>> 
>>> So the patch looks fine, only very very slightly binary is produced. I'm
>>> going to install the patch so that
>>> I can carry on more complex patches based on this one.
>> 
>> it seems you didn't properly test the testsuite part: I see
>> 
>> +UNRESOLVED: gcc.dg/tree-prof/update-loopch.c scan-tree-dump switchlower
>> "Removing basic block"
>> +UNRESOLVED: gcc.dg/tree-prof/update-loopch.c scan-tree-dump switchlower
>> "loop depth 1, count 3"
>> +UNRESOLVED: gcc.dg/tree-prof/update-loopch.c scan-tree-dump-not
>> switchlower "Invalid sum"
>> +UNRESOLVED: gcc.dg/tree-prof/update-loopch.c scan-tree-dump-not
>> switchlower "loop depth 1, count 2"
>> 
>> everywhere.  The log has
>> 
>> gcc.dg/tree-prof/update-loopch.c: dump file does not exist
>> 
>> Obviously you forgot the adapt the dg-final* files for the dumpfile
>> name.  If I do, three of the failures go away, but
>> 
>> FAIL: gcc.dg/tree-prof/update-loopch.c scan-tree-dump switchlower1
>> "Removing basic block"
>> 
>> remains (on 32 and 64-bit Linux/x86_64).
>> 
>> Please fix.
>> 
>>  Rainer
>> 
>
> Thanks for opened eyes, following patch will fix that.
> It's quite obvious, I'll install it right after tests will finish.

unfortunately, it didn't fix either issue:

* The switchlower -> switchlower1 renames in the dg-final* lines
  (attached) are still necessary to avoid the UNRESOLVED errors.
  Although obvious, I haven't installed them since ...

* ... even so

FAIL: gcc.dg/tree-prof/update-loopch.c scan-tree-dump switchlower1 "Removing 
basic block"

  remains.

Rainer


> From 7ae0c7d4a81166dbf5e9dff5d35e4c9d63b1c058 Mon Sep 17 00:00:00 2001
> From: marxin 
> Date: Fri, 18 May 2018 16:17:57 +0200
> Subject: [PATCH] Remove redundand pass pass_lower_switch.
>
> gcc/ChangeLog:
>
> 2018-05-18  Martin Liska  
>
>   * passes.def: Remove a redundant pass.
> ---
>  gcc/passes.def | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/gcc/passes.def b/gcc/passes.def
> index 050009464ea..055d354f959 100644
> --- a/gcc/passes.def
> +++ b/gcc/passes.def
> @@ -399,9 +399,8 @@ along with GCC; see the file COPYING3.  If not see
>NEXT_PASS (pass_lower_vaarg);
>NEXT_PASS (pass_lower_vector);
>NEXT_PASS (pass_lower_complex_O0);
> -  NEXT_PASS (pass_lower_switch_O0);
>NEXT_PASS (pass_sancov_O0);
> -  NEXT_PASS (pass_lower_switch);
> +  NEXT_PASS (pass_lower_switch_O0);
>NEXT_PASS (pass_asan_O0);
>NEXT_PASS (pass_tsan_O0);
>NEXT_PASS (pass_sanopt);

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


diff --git a/gcc/testsuite/gcc.dg/tree-prof/update-loopch.c b/gcc/testsuite/gcc.dg/tree-prof/update-loopch.c
--- a/gcc/testsuite/gcc.dg/tree-prof/update-loopch.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/update-loopch.c
@@ -16,7 +16,7 @@ main ()
edge.  */
 /* autofdo cannot do that precise counts */
 /* { dg-final-use-not-autofdo { scan-ipa-dump "loop depth 1, count 4" "profile"} } */
-/* { dg-final-use-not-autofdo { scan-tree-dump "loop depth 1, count 3" "switchlower"} } */
-/* { dg-final-use-not-autofdo { scan-tree-dump-not "loop depth 1, count 2" "switchlower"} } */
-/* { dg-final-use-not-autofdo { scan-tree-dump "Removing basic block" "switchlower"} } */
-/* { dg-final-use { scan-tree-dump-not "Invalid sum" "switchlower"} } */
+/* { dg-final-use-not-autofdo { scan-tree-dump "loop depth 1, count 3" "switchlower1"} } */
+/* { dg-final-use-not-autofdo { scan-tree-dump-not "loop depth 1, count 2" "switchlower1"} } */
+/* { dg-final-use-not-autofdo { scan-tree-dump "Removing basic block" "switchlower1"} } */
+/* { dg-final-use { scan-tree-dump-not "Invalid sum" "switchlower1"} } */


[PATCH 2/2] [ARC] Update warning messges.

2018-05-21 Thread Claudiu Zissulescu
From: claziss 

When we pass an mcpu to the compiler we have two types of (hardware
configuration) flags that are set:

1. Architecture specific, for example code-density is always enabled
for ARCHS architectures. These options are overwriting whatever the
corresponding user options with the preset ones.

2. CPU specific, for example archs is using LL64 option by
default. These options can be freely enabled or disabled.

Because of the above complexity, we need to throw some errors for the
user to know when he/she does something which goes against the above
rules. Thus, I came up with the following set of rules:

1. Overwriting default architecture specific hardware option: it is
ignored, a warning is thrown;

2. Overwriting default CPU specific hardware option: it is taken into
account, a warning is thrown.

Ok to apply?
Claudiu

gcc/
2017-09-26  Claudiu Zissulescu  

* config/arc/arc-arch.h: Update ARC_OPTX macro.
* config/arc/arc-options.def (ARC_OPTX): Introduce a new doc
field.
* config/arc/arc.c (arc_init): Update pic warning.
(irq_range): Update irq range parsing warnings.
(arc_override_options): Update various warning messages.
(arc_handle_aux_attribute): Likewise.

gcc/testsuite
2017-09-26  Claudiu Zissulescu  

* gcc.target/arc/builtin_simdarc.c: Update test.
* gcc.target/arc/mulsi3_highpart-2.c: Likewise.
* gcc.target/arc/tumaddsidi4.c: Likewise.
---
 gcc/config/arc/arc-arch.h|  2 +-
 gcc/config/arc/arc-options.def   | 44 ++--
 gcc/config/arc/arc.c | 90 ++--
 gcc/testsuite/gcc.target/arc/builtin_simdarc.c   |  2 +-
 gcc/testsuite/gcc.target/arc/mulsi3_highpart-2.c |  2 +-
 gcc/testsuite/gcc.target/arc/tumaddsidi4.c   |  2 +-
 6 files changed, 80 insertions(+), 62 deletions(-)

diff --git a/gcc/config/arc/arc-arch.h b/gcc/config/arc/arc-arch.h
index f90be66e200..a3b7dc87be4 100644
--- a/gcc/config/arc/arc-arch.h
+++ b/gcc/config/arc/arc-arch.h
@@ -28,7 +28,7 @@ along with GCC; see the file COPYING3.  If not see
 enum cpu_flags
   {
 #define ARC_OPT(NAME, CODE, MASK, DOC) NAME = CODE,
-#define ARC_OPTX(NAME, CODE, VAR, VAL, DOC) NAME = CODE,
+#define ARC_OPTX(NAME, CODE, VAR, VAL, DOC0, DOC1) NAME = CODE,
 #include "arc-options.def"
 #undef ARC_OPT
 #undef ARC_OPTX
diff --git a/gcc/config/arc/arc-options.def b/gcc/config/arc/arc-options.def
index 61ecd1de150..fefb3081c81 100644
--- a/gcc/config/arc/arc-options.def
+++ b/gcc/config/arc/arc-options.def
@@ -74,32 +74,32 @@ ARC_OPT (FL_DPFP, (1ULL << 13), MASK_DPFP_COMPACT_SET, 
"double precission FP
 ARC_OPT (FL_ARGONAUT, (1ULL << 14), MASK_ARGONAUT_SET,"argonaut")
 ARC_OPT (FL_SIMD, (1ULL << 15), MASK_SIMD_SET,"simd")
 
-ARC_OPTX (FL_MPYOPT_1, (1ULL << 17), arc_mpy_option, 1, "mpy option w")
-ARC_OPTX (FL_MPYOPT_2, (1ULL << 18), arc_mpy_option, 2, "mpy option wlh1")
-ARC_OPTX (FL_MPYOPT_3, (1ULL << 19), arc_mpy_option, 3, "mpy option wlh2")
-ARC_OPTX (FL_MPYOPT_4, (1ULL << 20), arc_mpy_option, 4, "mpy option wlh3")
-ARC_OPTX (FL_MPYOPT_5, (1ULL << 21), arc_mpy_option, 5, "mpy option wlh4")
-ARC_OPTX (FL_MPYOPT_6, (1ULL << 22), arc_mpy_option, 6, "mpy option wlh5")
-ARC_OPTX (FL_MPYOPT_7, (1ULL << 23), arc_mpy_option, 7, "mpy option plus_dmpy")
-ARC_OPTX (FL_MPYOPT_8, (1ULL << 24), arc_mpy_option, 8, "mpy option plus_macd")
-ARC_OPTX (FL_MPYOPT_9, (1ULL << 25), arc_mpy_option, 9, "mpy option 
plus_qmacw")
+ARC_OPTX (FL_MPYOPT_1, (1ULL << 17), arc_mpy_option, 1, "mpy-option", "w")
+ARC_OPTX (FL_MPYOPT_2, (1ULL << 18), arc_mpy_option, 2, "mpy-option", "wlh1")
+ARC_OPTX (FL_MPYOPT_3, (1ULL << 19), arc_mpy_option, 3, "mpy-option", "wlh2")
+ARC_OPTX (FL_MPYOPT_4, (1ULL << 20), arc_mpy_option, 4, "mpy-option", "wlh3")
+ARC_OPTX (FL_MPYOPT_5, (1ULL << 21), arc_mpy_option, 5, "mpy-option", "wlh4")
+ARC_OPTX (FL_MPYOPT_6, (1ULL << 22), arc_mpy_option, 6, "mpy-option", "wlh5")
+ARC_OPTX (FL_MPYOPT_7, (1ULL << 23), arc_mpy_option, 7, "mpy-option", 
"plus_dmpy")
+ARC_OPTX (FL_MPYOPT_8, (1ULL << 24), arc_mpy_option, 8, "mpy-option", 
"plus_macd")
+ARC_OPTX (FL_MPYOPT_9, (1ULL << 25), arc_mpy_option, 9, "mpy-option", 
"plus_qmacw")
 
 ARC_OPT (FL_MPYOPT_7_9, (0x01c2ULL << 17), 0, "mpy option")
 ARC_OPT (FL_MPYOPT_1_6, (0x003fULL << 17), 0, "mpy option")
 
-ARC_OPTX (FL_FPU_FPUS, (1ULL << 26), arc_fpu_build, FPU_FPUS,  
"mfpu=fpus")
-ARC_OPTX (FL_FPU_FPUS_DIV,  (1ULL << 27), arc_fpu_build, FPU_FPUS_DIV, 
"mfpu=fpus_div")
-ARC_OPTX (FL_FPU_FPUS_FMA,  (1ULL << 28), arc_fpu_build, FPU_FPUS_FMA, 
"mfpu=fpus_fma")
-ARC_OPTX (FL_FPU_FPUS_ALL,  (1ULL << 29), arc_fpu_build, FPU_FPUS_ALL, 
"mfpu=fpus_all")
-ARC_OPTX (FL_FPU_FPUDA,(1ULL << 30), arc_fpu_build, FPU_FPUDA, 
"mfpu=fpuda")
-ARC_OPTX (FL_FPU_FPUDA_DIV, (1ULL << 31), arc_fpu_build, FPU_FPUDA_DIV, 
"mfpu=fpuda_div")
-ARC_OPTX 

[PATCH 1/2] [ARC][QuarkSE] Update

2018-05-21 Thread Claudiu Zissulescu
From: claziss 

QuarkSE has lp_count width set to 16 bits. Update the compiler to
consider it.

Ok to apply?
Claudiu

gcc/
2017-07-11  Claudiu Zissulescu  

* config/arc/arc-arch.h (arc_extras): New enum.
(arc_cpu_t): Add field extra.
(arc_cpu_types): Consider the extras.
* config/arc/arc-cpus.def: Add extras info.
* config/arc/arc-opts.h (processor_type): Consider extra field.
* config/arc/arc.c (arc_override_options): Handle extra field.
---
 gcc/config/arc/arc-arch.h   | 19 ---
 gcc/config/arc/arc-cpus.def | 59 -
 gcc/config/arc/arc-opts.h   |  2 +-
 gcc/config/arc/arc.c| 10 
 4 files changed, 57 insertions(+), 33 deletions(-)

diff --git a/gcc/config/arc/arc-arch.h b/gcc/config/arc/arc-arch.h
index 01f95946623..f90be66e200 100644
--- a/gcc/config/arc/arc-arch.h
+++ b/gcc/config/arc/arc-arch.h
@@ -79,6 +79,14 @@ enum arc_tune_attr
 ARC_TUNE_ARCHS4XD_SLOW
   };
 
+/* Extra options for a processor.  */
+
+enum arc_extras
+{
+  HAS_NONE,
+  HAS_LPCOUNT_16
+};
+
 /* CPU specific properties.  */
 
 typedef struct
@@ -95,6 +103,9 @@ typedef struct
   /* Specific flags.  */
   const unsigned long long flags;
 
+  /* Extra value.  */
+  enum arc_extras extra;
+
   /* Tune value.  */
   enum arc_tune_attr tune;
 
@@ -112,12 +123,12 @@ const arc_arch_t arc_arch_types[] =
 
 const arc_cpu_t arc_cpu_types[] =
   {
-{"none", NULL, PROCESSOR_NONE, 0, ARC_TUNE_NONE},
-#define ARC_CPU(NAME, ARCH, FLAGS, TUNE)   \
-{#NAME, _arch_types [BASE_ARCH_##ARCH], PROCESSOR_##NAME, FLAGS, 
ARC_TUNE_##TUNE },
+{"none", NULL, PROCESSOR_NONE, 0, HAS_NONE, ARC_TUNE_NONE},
+#define ARC_CPU(NAME, ARCH, FLAGS, EXTRA, TUNE)
\
+{#NAME, _arch_types [BASE_ARCH_##ARCH], PROCESSOR_##NAME, FLAGS, 
HAS_##EXTRA, ARC_TUNE_##TUNE },
 #include "arc-cpus.def"
 #undef ARC_CPU
-{NULL, NULL, PROCESSOR_NONE, 0, ARC_TUNE_NONE}
+{NULL, NULL, PROCESSOR_NONE, 0, HAS_NONE, ARC_TUNE_NONE}
   };
 
 /* Currently selected cpu type.  */
diff --git a/gcc/config/arc/arc-cpus.def b/gcc/config/arc/arc-cpus.def
index 4aa422f1a39..eea83917b42 100644
--- a/gcc/config/arc/arc-cpus.def
+++ b/gcc/config/arc/arc-cpus.def
@@ -43,36 +43,39 @@
  as defined in arc-options.def file, and allowed by arc-arches.def
  file.  The specific hardware flags are enumerated without using
  spaces between the '|' character and consequtive flags.
+   EXTRA  Extra hardware flags, different than the ones in
+ arc-arches.def.  Here we can specify the width of lp_count,
+ for example.
TUNE  Tune value for the given configuration, otherwise NONE.  */
 
-ARC_CPU (em,   em, 0, NONE)
-ARC_CPU (em_mini,   em, FL_RF16, NONE)
-ARC_CPU (arcem,em, FL_MPYOPT_2|FL_CD|FL_BS, NONE)
-ARC_CPU (em4,  em, FL_CD, NONE)
-ARC_CPU (em4_dmips, em, FL_MPYOPT_2|FL_CD|FL_DIVREM|FL_NORM|FL_SWAP|FL_BS, 
NONE)
-ARC_CPU (em4_fpus,  em, 
FL_MPYOPT_2|FL_CD|FL_DIVREM|FL_NORM|FL_SWAP|FL_BS|FL_FPU_FPUS, NONE)
-ARC_CPU (em4_fpuda, em, 
FL_MPYOPT_2|FL_CD|FL_DIVREM|FL_NORM|FL_SWAP|FL_BS|FL_FPU_FPUDA, NONE)
-ARC_CPU (quarkse_em, em, 
FL_MPYOPT_3|FL_CD|FL_DIVREM|FL_NORM|FL_SWAP|FL_BS|FL_FPX_QUARK|FL_SPFP|FL_DPFP, 
NONE)
-
-ARC_CPU (hs,hs, 0, NONE)
-ARC_CPU (archs, hs, FL_MPYOPT_2|FL_DIVREM|FL_LL64, NONE)
-ARC_CPU (hs34,  hs, FL_MPYOPT_2, NONE)
-ARC_CPU (hs38,  hs, FL_MPYOPT_9|FL_DIVREM|FL_LL64, NONE)
-ARC_CPU (hs38_linux, hs, FL_MPYOPT_9|FL_DIVREM|FL_LL64|FL_FPU_FPUD_ALL, NONE)
-ARC_CPU (hs4x,  hs, FL_MPYOPT_9|FL_DIVREM|FL_LL64, ARCHS4X)
-ARC_CPU (hs4xd, hs, FL_MPYOPT_9|FL_DIVREM|FL_LL64, ARCHS4XD)
-
-ARC_CPU (arc600,  6xx, FL_BS, ARC600)
-ARC_CPU (arc600_norm, 6xx, FL_BS|FL_NORM, ARC600)
-ARC_CPU (arc600_mul64,6xx, FL_BS|FL_NORM|FL_MUL64, ARC600)
-ARC_CPU (arc600_mul32x16, 6xx, FL_BS|FL_NORM|FL_MUL32x16, ARC600)
-ARC_CPU (arc601, 6xx, 0, ARC600)
-ARC_CPU (arc601_norm,6xx, FL_NORM, ARC600)
-ARC_CPU (arc601_mul64,   6xx, FL_NORM|FL_MUL64, ARC600)
-ARC_CPU (arc601_mul32x16, 6xx, FL_NORM|FL_MUL32x16, ARC600)
-
-ARC_CPU (arc700, 700, 0, ARC700_4_2_STD)
-ARC_CPU (nps400, 700, 0, ARC700_4_2_STD)
+ARC_CPU (em,   em, 0, NONE, NONE)
+ARC_CPU (em_mini,   em, FL_RF16, NONE, NONE)
+ARC_CPU (arcem,em, FL_MPYOPT_2|FL_CD|FL_BS, NONE, NONE)
+ARC_CPU (em4,  em, FL_CD, NONE, NONE)
+ARC_CPU (em4_dmips, em, FL_MPYOPT_2|FL_CD|FL_DIVREM|FL_NORM|FL_SWAP|FL_BS, 
NONE, NONE)
+ARC_CPU (em4_fpus,  em, 
FL_MPYOPT_2|FL_CD|FL_DIVREM|FL_NORM|FL_SWAP|FL_BS|FL_FPU_FPUS, NONE, NONE)
+ARC_CPU (em4_fpuda, em, 
FL_MPYOPT_2|FL_CD|FL_DIVREM|FL_NORM|FL_SWAP|FL_BS|FL_FPU_FPUDA, NONE, NONE)
+ARC_CPU (quarkse_em, em, 
FL_MPYOPT_3|FL_CD|FL_DIVREM|FL_NORM|FL_SWAP|FL_BS|FL_FPX_QUARK|FL_SPFP|FL_DPFP, 
LPCOUNT_16, NONE)
+
+ARC_CPU (hs, hs, 0, NONE, NONE)
+ARC_CPU (archs, hs, 

[PATCH 5/6] [ARC] Update fma expansions.

2018-05-21 Thread Claudiu Zissulescu
Make sure only one operand has an immediate.

OK to apply?
Claudiu

gcc/
2018-03-21  Claudiu Zissulescu  

* config/arc/fpu.md (fmasf4): Force operand to register.
(fnmasf4): Likewise.

gcc/testsuite
2018-03-21  Claudiu Zissulescu  

* gcc.target/arc/fma-1.c: New test.
---
 gcc/config/arc/fpu.md|  6 ++
 gcc/testsuite/gcc.target/arc/fma-1.c | 13 +
 2 files changed, 19 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/arc/fma-1.c

diff --git a/gcc/config/arc/fpu.md b/gcc/config/arc/fpu.md
index de876cac0c1..9457922667e 100644
--- a/gcc/config/arc/fpu.md
+++ b/gcc/config/arc/fpu.md
@@ -64,6 +64,9 @@
tmp = gen_rtx_REG (SFmode, ACCL_REGNO);
emit_move_insn (tmp, operands[3]);
operands[3] = tmp;
+   if (!register_operand (operands[1], SFmode)
+&& !register_operand (operands[2], SFmode))
+ operands[2] = force_reg (SFmode, operands[2]);
}")
 
 (define_expand "fnmasf4"
@@ -77,6 +80,9 @@
tmp = gen_rtx_REG (SFmode, ACCL_REGNO);
emit_move_insn (tmp, operands[3]);
operands[3] = tmp;
+   if (!register_operand (operands[1], SFmode)
+&& !register_operand (operands[2], SFmode))
+ operands[2] = force_reg (SFmode, operands[2]);
 }")
 
 (define_insn "fmasf4_fpu"
diff --git a/gcc/testsuite/gcc.target/arc/fma-1.c 
b/gcc/testsuite/gcc.target/arc/fma-1.c
new file mode 100644
index 000..c195ad98127
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arc/fma-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-skip-if "FPU not available" { arc700 || arc6xx } } */
+/* { dg-options "-s -std=gnu11  -O2 -frounding-math -mfpu=fpus_all" } */
+
+const float a, b = 7.8539818525e01;
+
+/* Check if the fma operation is generated correctly.  */
+
+int foo (void)
+{
+  return (float)3.0 * b + a;
+}
+/* { dg-final { scan-assembler "fsmadd" } } */
-- 
2.14.3



[PATCH 4/6] [ARC] Define LINK_GCC_C_SEQUENCE_SPEC.

2018-05-21 Thread Claudiu Zissulescu
From: claziss 

If no specs file is provided, default to nosys library.

Ok to apply?
Claudiu

gcc/
2017-05-03  Claudiu Zissulescu  

* config/arc/elf.h (LINK_GCC_C_SEQUENCE_SPEC): Define.
---
 gcc/config/arc/elf.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/gcc/config/arc/elf.h b/gcc/config/arc/elf.h
index 43ced3b720f..66ee5b698ea 100644
--- a/gcc/config/arc/elf.h
+++ b/gcc/config/arc/elf.h
@@ -73,3 +73,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #undef TARGET_ASM_FILE_END
 #define TARGET_ASM_FILE_END arc_file_end
+
+/* If no specs file is enforced, default to nosys libarary.  */
+#undef LINK_GCC_C_SEQUENCE_SPEC
+#define LINK_GCC_C_SEQUENCE_SPEC   \
+  "--start-group %G %{!specs=*:-lc -lnosys} --end-group"
-- 
2.14.3



[PATCH 6/6] [ARC] Reimplement return padding operation for ARC700.

2018-05-21 Thread Claudiu Zissulescu
From: Claudiu Zissulescu 

For ARC700, adding padding if necessary to avoid a mispredict.  A
return could happen immediately after the function start.  A
call/return and return/return must be 6 bytes apart to avoid
mispredict.

The old implementation was doing this operation very late in the
compilation process, and the additional nop instructions and/or
forcing some other instruction to take their long form was not taken
into account when generating brcc instructions. Thus, wrong code could
be generated.

Ok to apply?
Claudiu

gcc/
2017-03-24  Claudiu Zissulescu  

* config/arc/arc-protos.h (arc_pad_return): Remove.
* config/arc/arc.c (machine_function): Remove force_short_suffix
and size_reason.
(arc_print_operand): Adjust printing of '&'.
(arc_verify_short): Remove conditional printing of short suffix.
(arc_final_prescan_insn): Remove reference to size_reason.
(pad_return): New function.
(arc_reorg): Call pad_return.
(arc_pad_return): Remove.
(arc_init_machine_status): Remove reference to force_short_suffix.
* config/arc/arc.md (vunspec): Add VUNSPEC_ARC_BLOCKAGE.
(attr length): When attribute iscompact is true force to 2
regardless; in the case of maybe check if we want to force the
instruction to have 4 bytes length.
(nopv): Change it to generate 4 byte long nop as well.
(blockage): New pattern.
(simple_return): Remove call to arc_pad_return.
(p_return_i): Likewise.

gcc/testsuite/
2017-03-24  Claudiu Zissulescu  

* gcc.target/arc/pr9001107555.c: New file.
---
 gcc/config/arc/arc-protos.h |   1 -
 gcc/config/arc/arc.c| 156 +---
 gcc/config/arc/arc.md   |  26 +++--
 gcc/testsuite/gcc.target/arc/pr9001107555.c |  38 +++
 4 files changed, 128 insertions(+), 93 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/arc/pr9001107555.c

diff --git a/gcc/config/arc/arc-protos.h b/gcc/config/arc/arc-protos.h
index 67f3b4e3226..ce4b6f84749 100644
--- a/gcc/config/arc/arc-protos.h
+++ b/gcc/config/arc/arc-protos.h
@@ -89,7 +89,6 @@ extern void arc_clear_unalign (void);
 extern void arc_toggle_unalign (void);
 extern void split_addsi (rtx *);
 extern void split_subsi (rtx *);
-extern void arc_pad_return (void);
 extern void arc_split_move (rtx *);
 extern const char *arc_short_long (rtx_insn *insn, const char *, const char *);
 extern rtx arc_regno_use_in (unsigned int, rtx);
diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
index b1a09d82b72..22f1442a027 100644
--- a/gcc/config/arc/arc.c
+++ b/gcc/config/arc/arc.c
@@ -2648,8 +2648,6 @@ typedef struct GTY (()) machine_function
   struct arc_frame_info frame_info;
   /* To keep track of unalignment caused by short insns.  */
   int unalign;
-  int force_short_suffix; /* Used when disgorging return delay slot insns.  */
-  const char *size_reason;
   struct arc_ccfsm ccfsm_current;
   /* Map from uid to ccfsm state during branch shortening.  */
   rtx ccfsm_current_insn;
@@ -4307,7 +4305,7 @@ arc_print_operand (FILE *file, rtx x, int code)
}
   break;
 case '&':
-  if (TARGET_ANNOTATE_ALIGN && cfun->machine->size_reason)
+  if (TARGET_ANNOTATE_ALIGN)
fprintf (file, "; unalign: %d", cfun->machine->unalign);
   return;
 case '+':
@@ -4980,7 +4978,6 @@ static int
 arc_verify_short (rtx_insn *insn, int, int check_attr)
 {
   enum attr_iscompact iscompact;
-  struct machine_function *machine;
 
   if (check_attr > 0)
 {
@@ -4988,10 +4985,6 @@ arc_verify_short (rtx_insn *insn, int, int check_attr)
   if (iscompact == ISCOMPACT_FALSE)
return 0;
 }
-  machine = cfun->machine;
-
-  if (machine->force_short_suffix >= 0)
-return machine->force_short_suffix;
 
   return (get_attr_length (insn) & 2) != 0;
 }
@@ -5030,8 +5023,6 @@ arc_final_prescan_insn (rtx_insn *insn, rtx *opvec 
ATTRIBUTE_UNUSED,
   cfun->machine->prescan_initialized = 1;
 }
   arc_ccfsm_advance (insn, _ccfsm_current);
-
-  cfun->machine->size_reason = 0;
 }
 
 /* Given FROM and TO register numbers, say whether this elimination is allowed.
@@ -7673,6 +7664,76 @@ jli_call_scan (void)
 }
 }
 
+/* Add padding if necessary to avoid a mispredict.  A return could
+   happen immediately after the function start.  A call/return and
+   return/return must be 6 bytes apart to avoid mispredict.  */
+
+static void
+pad_return (void)
+{
+  rtx_insn *insn;
+  long offset;
+
+  if (!TARGET_PAD_RETURN)
+return;
+
+  for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
+{
+  rtx_insn *prev0 = prev_active_insn (insn);
+  bool wantlong = false;
+
+  if (!INSN_P (insn) || GET_CODE (PATTERN (insn)) != SIMPLE_RETURN)
+   continue;
+
+  if (!prev0)
+   {
+ prev0 = emit_insn_before (gen_nopv (), insn);

[PATCH 3/6] [ARC] SYNC instruction is valid on all ARC cores.

2018-05-21 Thread Claudiu Zissulescu
From: claziss 

The sync instruction is part of all ARC architectures. Fix this in the compiler.

Ok to apply?
Claudiu

gcc/
2017-05-03  Claudiu Zissulescu  

* config/arc/builtins.def (SYNC): SYNC instruction is valid on all
ARC cores.
---
 gcc/config/arc/builtins.def | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/arc/builtins.def b/gcc/config/arc/builtins.def
index 349f39fab23..5171ab40842 100644
--- a/gcc/config/arc/builtins.def
+++ b/gcc/config/arc/builtins.def
@@ -34,7 +34,7 @@
 /* Special builtins.  */
 DEF_BUILTIN (NOP,0, void_ftype_void,nothing, 1)
 DEF_BUILTIN (RTIE,   0, void_ftype_void,rtie,1)
-DEF_BUILTIN (SYNC,   0, void_ftype_void,sync,TARGET_ARC700)
+DEF_BUILTIN (SYNC,   0, void_ftype_void,sync,1)
 DEF_BUILTIN (BRK,0, void_ftype_void,brk, 1)
 DEF_BUILTIN (SWI,0, void_ftype_void,swi, 1)
 DEF_BUILTIN (UNIMP_S,0, void_ftype_void,unimp_s, 
!TARGET_ARC600_FAMILY)
-- 
2.14.3



[PATCH 2/6] [ARC] Allow EX instruction for ARC700 and ARCv2.

2018-05-21 Thread Claudiu Zissulescu
From: claziss 

The EX instruction is base line for both architectures. Reflect this in the 
compiler.

OK to apply?
Claudiu

gcc/
2017-05-02  Claudiu Zissulescu  

* config/arc/arc.c (atomic_exchangesi): EX instruction is default
for ARC700 and ARCv2.
---
 gcc/config/arc/atomic.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/arc/atomic.md b/gcc/config/arc/atomic.md
index 13a2e34549c..4a56ca229cc 100644
--- a/gcc/config/arc/atomic.md
+++ b/gcc/config/arc/atomic.md
@@ -120,7 +120,7 @@
(match_operand:SI 1 "mem_noofs_operand" "")
(match_operand:SI 2 "register_operand" "")
(match_operand:SI 3 "const_int_operand" "")]
-  "TARGET_ATOMIC"
+  "TARGET_ARC700 || TARGET_V2"
 {
   enum memmodel model = (enum memmodel) INTVAL (operands[3]);
 
-- 
2.14.3



[PATCH 1/6] [ARC] Add modes scheduler HS

2018-05-21 Thread Claudiu Zissulescu
From: Claudiu Zissulescu 

An update on how the instructions are scheduled for HS processor.

Ok to apply?
Claudiu

---
 gcc/config/arc/arcHS.md | 21 +++--
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/gcc/config/arc/arcHS.md b/gcc/config/arc/arcHS.md
index d49b90c4970..5c1ab5413ab 100644
--- a/gcc/config/arc/arcHS.md
+++ b/gcc/config/arc/arcHS.md
@@ -35,12 +35,14 @@
(eq_attr "type" "store"))
   "hs_issue+hs_ld_st")
 
-(define_insn_reservation "hs_alu0" 2
+;; Advanced ALU
+(define_insn_reservation "hs_alu0" 4
   (and (match_test "TARGET_HS")
(eq_attr "tune" "none")
(eq_attr "type" "cc_arith, two_cycle_core, shift, lr, sr"))
-  "hs_issue+x1,x2")
+  "hs_issue+x1,x2, nothing*2")
 
+;; Basic ALU
 (define_insn_reservation "hs_alu1" 4
   (and (match_test "TARGET_HS")
(eq_attr "tune" "none")
@@ -54,19 +56,26 @@
(eq_attr "type" "div_rem"))
   "hs_issue+divrem_hs, (divrem_hs)*12")
 
-(define_insn_reservation "hs_mul" 3
+(define_insn_reservation "hs_mul" 4
   (and (match_test "TARGET_HS")
(eq_attr "tune" "none")
(eq_attr "type" "mul16_em, multi, umulti"))
   "hs_issue+mul_hs, nothing*3")
 
-;; BYPASS EALU ->
+;; BYPASS Advanced ALU ->
 (define_bypass 1 "hs_alu0" "hs_divrem")
 (define_bypass 1 "hs_alu0" "hs_mul")
+(define_bypass 2 "hs_alu0" "hs_alu0")
+(define_bypass 1 "hs_alu0" "hs_alu1")
+(define_bypass 1 "hs_alu0" "hs_data_load")
+(define_bypass 1 "hs_alu0" "hs_data_store" "store_data_bypass_p")
+(define_bypass 2 "hs_alu0" "hs_data_store")
 
-;; BYPASS BALU ->
+;; BYPASS Basic ALU ->
 (define_bypass 1 "hs_alu1" "hs_alu1")
 (define_bypass 1 "hs_alu1" "hs_data_store" "store_data_bypass_p")
+(define_bypass 3 "hs_alu1" "hs_mul")
+(define_bypass 3 "hs_alu1" "hs_divrem")
 
 ;; BYPASS LD ->
 (define_bypass 1 "hs_data_load" "hs_alu1")
@@ -76,7 +85,7 @@
 (define_bypass 1 "hs_data_load" "hs_data_store" "store_data_bypass_p")
 
 ;; BYPASS MPY ->
-;;(define_bypass 3 "hs_mul" "hs_mul")
+(define_bypass 3 "hs_mul" "hs_mul")
 (define_bypass 1 "hs_mul" "hs_alu1")
 (define_bypass 3 "hs_mul" "hs_divrem")
 (define_bypass 1 "hs_mul" "hs_data_store" "store_data_bypass_p")
-- 
2.14.3



Re: [Patch, Fortran] PR 85841: [F2018] reject deleted features

2018-05-21 Thread Janus Weil
>> >> Btw, with the arrival of the F2018 standard, I wonder whether it
>> >> actually makes sense to keep the option -std=f2008ts, or to remove it
>> >> in favor of -std=f2018, since the two Technical Specifications covered
>> >> by this flag are now part of F2018 (and pretty much the main part!).
>> >> Any opinions on this?
>> >
>> > I think that f2008ts can go away.  We may need to do this
>> > in two step as some users may have f2008ts hardcoded in
>> > Makefiles.  Probably, issue warning for -std=2008ts and
>> > map it to -std=2018 for a brief period (3 to 6 months?)
>> > and then finally remove it.
>>
>> Yes, I agree that it would be a good idea to keep -std=f2008ts as an
>> alias for f2018 for a while (possibly until the next release, 9.0),
>> and document is as deprecated. I can take care of removing the
>> GFC_STD_F2008_TS macro in a follow-up patch.
>
> Sounds good to me.


So, here is the promised follow-up patch. It mostly removes
GFC_STD_F2008_TS and replaces it by GFC_STD_F2018 in a mechanical
manner. Plus, it fixes the resulting fallout in the testsuite and
updates the documentation. The non-mechanical parts are libgfortran.h
and options.c. Regtests cleanly. Ok for trunk with a suitable
ChangeLog?

Cheers,
Janus
Index: gcc/fortran/array.c
===
--- gcc/fortran/array.c	(revision 260433)
+++ gcc/fortran/array.c	(working copy)
@@ -533,7 +533,7 @@ gfc_match_array_spec (gfc_array_spec **asp, bool m
   as->type = AS_ASSUMED_RANK;
   as->rank = -1;
 
-  if (!gfc_notify_std (GFC_STD_F2008_TS, "Assumed-rank array at %C"))
+  if (!gfc_notify_std (GFC_STD_F2018, "Assumed-rank array at %C"))
 	goto cleanup;
 
   if (!match_codim)
Index: gcc/fortran/check.c
===
--- gcc/fortran/check.c	(revision 260433)
+++ gcc/fortran/check.c	(working copy)
@@ -1136,7 +1136,7 @@ gfc_check_atomic (gfc_expr *atom, int atom_no, gfc
   if (!kind_value_check (stat, stat_no, gfc_default_integer_kind))
 	return false;
 
-  if (!gfc_notify_std (GFC_STD_F2008_TS, "STAT= argument to %s at %L",
+  if (!gfc_notify_std (GFC_STD_F2018, "STAT= argument to %s at %L",
 			   gfc_current_intrinsic, >where))
 	return false;
 }
@@ -1349,7 +1349,7 @@ gfc_check_event_query (gfc_expr *event, gfc_expr *
   if (!variable_check (stat, 2, false))
 	return false;
 
-  if (!gfc_notify_std (GFC_STD_F2008_TS, "STAT= argument to %s at %L",
+  if (!gfc_notify_std (GFC_STD_F2018, "STAT= argument to %s at %L",
 			   gfc_current_intrinsic, >where))
 	return false;
 }
@@ -4745,7 +4745,7 @@ gfc_check_c_f_pointer (gfc_expr *cptr, gfc_expr *f
 }
 
   if (fptr->rank > 0 && !is_c_interoperable (fptr, , false, true))
-return gfc_notify_std (GFC_STD_F2008_TS, "Noninteroperable array FPTR "
+return gfc_notify_std (GFC_STD_F2018, "Noninteroperable array FPTR "
 			   "at %L to C_F_POINTER: %s", >where, msg);
 
   return true;
@@ -4786,7 +4786,7 @@ gfc_check_c_f_procpointer (gfc_expr *cptr, gfc_exp
 }
 
   if (!attr.is_bind_c)
-return gfc_notify_std (GFC_STD_F2008_TS, "Noninteroperable procedure "
+return gfc_notify_std (GFC_STD_F2018, "Noninteroperable procedure "
 			   "pointer at %L to C_F_PROCPOINTER", >where);
 
   return true;
@@ -4829,7 +4829,7 @@ gfc_check_c_funloc (gfc_expr *x)
 }
 
   if (!attr.is_bind_c)
-return gfc_notify_std (GFC_STD_F2008_TS, "Noninteroperable procedure "
+return gfc_notify_std (GFC_STD_F2018, "Noninteroperable procedure "
 			   "at %L to C_FUNLOC", >where);
   return true;
 }
@@ -4883,7 +4883,7 @@ gfc_check_c_loc (gfc_expr *x)
 	}
 
   if (x->rank
-	  && !gfc_notify_std (GFC_STD_F2008_TS,
+	  && !gfc_notify_std (GFC_STD_F2018,
 			  "Noninteroperable array at %L as"
 			  " argument to C_LOC: %s", >where, msg))
 	  return false;
@@ -5267,7 +5267,7 @@ gfc_check_num_images (gfc_expr *distance, gfc_expr
   if (!scalar_check (distance, 0))
 	return false;
 
-  if (!gfc_notify_std (GFC_STD_F2008_TS, "DISTANCE= argument to "
+  if (!gfc_notify_std (GFC_STD_F2018, "DISTANCE= argument to "
 			   "NUM_IMAGES at %L", >where))
 	return false;
 }
@@ -5280,7 +5280,7 @@ gfc_check_num_images (gfc_expr *distance, gfc_expr
   if (!scalar_check (failed, 1))
 	return false;
 
-  if (!gfc_notify_std (GFC_STD_F2008_TS, "FAILED= argument to "
+  if (!gfc_notify_std (GFC_STD_F2018, "FAILED= argument to "
 			   "NUM_IMAGES at %L", >where))
 	return false;
 }
@@ -5366,7 +5366,7 @@ gfc_check_this_image (gfc_expr *coarray, gfc_expr
   if (!scalar_check (distance, 2))
 	return false;
 
-  if (!gfc_notify_std (GFC_STD_F2008_TS, "DISTANCE= argument to "
+  if (!gfc_notify_std (GFC_STD_F2018, "DISTANCE= argument to "
 			   "THIS_IMAGE at %L", >where))
 	return false;
 
Index: gcc/fortran/decl.c
===
--- gcc/fortran/decl.c	(revision 

RE: [PATCH] ARC: Add multilib support for linux targets

2018-05-21 Thread Claudiu Zissulescu
Pushed.

Thank you for your contribution,
Claudiu

From: Andrew Burgess [andrew.burg...@embecosm.com]
Sent: Wednesday, May 16, 2018 11:08 PM
To: Alexey Brodkin
Cc: gcc-patches@gcc.gnu.org; Claudiu Zissulescu
Subject: Re: [PATCH] ARC: Add multilib support for linux targets

* Alexey Brodkin  [2018-05-16 22:42:36 +0300]:

> We used to build baremetal (AKA Elf32) multilibbed toolchains for years
> now but never made that for Linux targets since there were problems with
> uClibc n multilib setup. Now with help of Crosstool-NG it is finally
> possible to create uClibc-based multilibbed toolchains and so we add
> relevant CPUs for multilib in case of configuration for "arc*-*-linux*".
>
> This will be essentially useful for glibc-based multilibbbed toolchains
> in the future.
>
> gcc/
> 2018-05-16  Alexey Brodkin 
>
> * config.gcc: Add arc/t-multilib-linux to tmake_file for
> arc*-*-linux*.
> * config/arc/t-multilib-linux: Specify MULTILIB_OPTIONS and
> MULTILIB_DIRNAMES

Looks good.

Thanks,
Andrew

> ---
>  gcc/config.gcc  |  2 +-
>  gcc/config/arc/t-multilib-linux | 25 +
>  2 files changed, 26 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/config/arc/t-multilib-linux
>
> diff --git a/gcc/config.gcc b/gcc/config.gcc
> index a5defb0f0058..8e038a72f613 100644
> --- a/gcc/config.gcc
> +++ b/gcc/config.gcc
> @@ -1059,7 +1059,7 @@ arc*-*-elf*)
>   ;;
>  arc*-*-linux*)
>   tm_file="arc/arc-arch.h dbxelf.h elfos.h gnu-user.h linux.h 
> linux-android.h glibc-stdint.h arc/linux.h ${tm_file}"
> - tmake_file="${tmake_file} arc/t-arc"
> + tmake_file="${tmake_file} arc/t-multilib-linux arc/t-arc"
>   extra_gcc_objs="driver-arc.o"
>   if test "x$with_cpu" != x; then
>   tm_defines="${tm_defines} TARGET_CPU_BUILD=PROCESSOR_$with_cpu"
> diff --git a/gcc/config/arc/t-multilib-linux b/gcc/config/arc/t-multilib-linux
> new file mode 100644
> index ..f357cfc3f926
> --- /dev/null
> +++ b/gcc/config/arc/t-multilib-linux
> @@ -0,0 +1,25 @@
> +# Copyright (C) 2018 Free Software Foundation, Inc.
> +#
> +# This file is part of GCC.
> +#
> +# GCC is free software; you can redistribute it and/or modify it under
> +# the terms of the GNU General Public License as published by the Free
> +# Software Foundation; either version 3, or (at your option) any later
> +# version.
> +#
> +# GCC is distributed in the hope that it will be useful, but WITHOUT ANY
> +# WARRANTY; without even the implied warranty of MERCHANTABILITY or
> +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> +# for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with GCC; see the file COPYING3.  If not see
> +# 
> .
> +
> +MULTILIB_OPTIONS = 
> mcpu=hs/mcpu=archs/mcpu=hs38/mcpu=hs38_linux/mcpu=arc700/mcpu=nps400
> +
> +MULTILIB_DIRNAMES = hs archs hs38 hs38_linux arc700 nps400
> +
> +# Aliases:
> +MULTILIB_MATCHES += mcpu?arc700=mA7
> +MULTILIB_MATCHES += mcpu?arc700=mARC700
> --
> 2.17.0
>


Re: [PATCH] Do not ICE for incomplete types in ICF (PR ipa/85607).

2018-05-21 Thread Martin Liška
PING^1

On 05/11/2018 03:12 PM, Martin Liška wrote:
> On 05/11/2018 11:35 AM, Richard Biener wrote:
>> On Thu, May 10, 2018 at 9:58 AM, Martin Liška  wrote:
>>> Hi.
>>>
>>> It's removal of an assert at place where we calculate hash of a type.
>>> For incomplete types, let's skip it.
>>>
>>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>>>
>>> Ready to be installed?
>>
>> Seems to be a redundant check in the !val case as well.  Also why not
>> at least do
>>
>>   hstate2.add_int (RECORD_TYPE);
>>
>> for incomplete types? 
> 
> Thanks, done that.
> 
>  That said, your patch fixes the ICE but what
>> is supposed to happen for incomplete types?  Note that with LTO
>> we no longer "complete" types so you can see a mix of struct S;
>> and struct S {  }; in the IL.  It looks like comparison later just
>> looks at types_compatible_p here.
> 
> Yes, that should be fine. The hashing of types is only an optimization.
> 
>>
>> Anyway, please at least remove the other redundant assert.
> 
> Done and tested.
> 
> Martin
> 
>>
>> Thanks,
>> Richard.
>>
>>> Martin
>>>
>>>
>>> gcc/ChangeLog:
>>>
>>> 2018-05-09  Martin Liska  
>>>
>>> PR ipa/85607
>>> * ipa-icf.c (sem_item::add_type): Do not ICE for incomplete types.
>>>
>>> gcc/testsuite/ChangeLog:
>>>
>>> 2018-05-09  Martin Liska  
>>>
>>> PR ipa/85607
>>> * g++.dg/ipa/pr85606.C: New test.
>>> ---
>>>  gcc/ipa-icf.c  |  5 -
>>>  gcc/testsuite/g++.dg/ipa/pr85606.C | 14 ++
>>>  2 files changed, 18 insertions(+), 1 deletion(-)
>>>  create mode 100644 gcc/testsuite/g++.dg/ipa/pr85606.C
>>>
>>>
> 



  1   2   >