Re: [PATCH] i386: Fix up *avx_vperm_broadcast_v4df [PR93430]

2020-01-26 Thread Uros Bizjak
On Sun, Jan 26, 2020 at 12:55 AM Jakub Jelinek  wrote:
>
> Hi!
>
> Apparently my recent patch which moved the *avx_vperm_broadcast* and
> *vpermil* patterns before vpermpd broke the following testcase, the
> define_insn_and_split matched always but the splitter condition only split
> it if not -mavx2 for V4DFmode, basically relying on the vpermpd pattern to
> come first.
>
> The following patch fixes it by moving that part of SPLIT-CONDITION into
> CONDITION, so that when it is not met, we just don't match the pattern
> and thus match the later vpermpd pattern in that case.
> Except, for { 0, 0, 0, 0 } permutation, there is actually no reason to do
> that, vbroadcastsd from memory seems to be slightly cheaper than vpermpd $0.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2020-01-26  Jakub Jelinek  
>
> PR target/93430
> * config/i386/sse.md (*avx_vperm_broadcast_): Disallow for
> TARGET_AVX2 and V4DFmode not in the split condition, but in the
> pattern condition, though allow { 0, 0, 0, 0 } broadcast always.
>
> * gcc.dg/pr93430.c: New test.
> * gcc.target/i386/avx2-pr93430.c: New test.

LGTM.

Thanks,
Uros.

> --- gcc/config/i386/sse.md.jj   2020-01-24 22:49:19.0 +0100
> +++ gcc/config/i386/sse.md  2020-01-25 18:32:02.100439737 +0100
> @@ -19912,9 +19912,10 @@ (define_insn_and_split "*avx_vperm_broad
>   (match_operand:VF_256 1 "nonimmediate_operand" "m,o,?v")
>   (match_parallel 2 "avx_vbroadcast_operand"
> [(match_operand 3 "const_int_operand" "C,n,n")])))]
> -  "TARGET_AVX"
> +  "TARGET_AVX
> +   && (mode != V4DFmode || !TARGET_AVX2 || operands[3] == const0_rtx)"
>"#"
> -  "&& reload_completed && (mode != V4DFmode || !TARGET_AVX2)"
> +  "&& reload_completed"
>[(set (match_dup 0) (vec_duplicate:VF_256 (match_dup 1)))]
>  {
>rtx op0 = operands[0], op1 = operands[1];
> --- gcc/testsuite/gcc.dg/pr93430.c.jj   2020-01-25 18:39:33.455584367 +0100
> +++ gcc/testsuite/gcc.dg/pr93430.c  2020-01-25 18:38:03.725950223 +0100
> @@ -0,0 +1,33 @@
> +/* PR target/93430 */
> +/* { dg-do compile } */
> +/* { dg-options "-O2" } */
> +/* { dg-additional-options "-mavx -mno-avx2" { target avx } } */
> +
> +typedef double V __attribute__((vector_size (4 * sizeof (double;
> +typedef long long VI __attribute__((vector_size (4 * sizeof (long long;
> +
> +#if __SIZEOF_DOUBLE__ == __SIZEOF_LONG_LONG__
> +void
> +foo (V *x, V *y)
> +{
> +  y[0] = __builtin_shuffle (x[0], x[0], (VI) { 0, 0, 0, 0 });
> +}
> +
> +void
> +bar (V *x, V *y)
> +{
> +  y[0] = __builtin_shuffle (x[0], x[0], (VI) { 1, 1, 1, 1 });
> +}
> +
> +void
> +baz (V *x, V *y)
> +{
> +  y[0] = __builtin_shuffle (x[0], x[0], (VI) { 2, 2, 2, 2 });
> +}
> +
> +void
> +qux (V *x, V *y)
> +{
> +  y[0] = __builtin_shuffle (x[0], x[0], (VI) { 3, 3, 3, 3 });
> +}
> +#endif
> --- gcc/testsuite/gcc.target/i386/avx2-pr93430.c.jj 2020-01-25 
> 18:39:55.282252126 +0100
> +++ gcc/testsuite/gcc.target/i386/avx2-pr93430.c2020-01-25 
> 18:40:35.080646319 +0100
> @@ -0,0 +1,5 @@
> +/* PR target/93430 */
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -mavx2" } */
> +
> +#include "../../gcc.dg/pr93430.c"
>
> Jakub
>


Re: [PATCH] i386: Fix up *{add,sub}v4_doubleword patterns (PR target/93412)

2020-01-26 Thread Uros Bizjak
On Sun, Jan 26, 2020 at 12:59 AM Jakub Jelinek  wrote:
>
> Hi!
>
> In the *{add,sub}v4_doubleword patterns, we don't really want to see a
> VOIDmode last operand, because it then means invalid RTL
> (sign_extend:{TI,POI} (const_int ...)) or so, and therefore something we
> don't really handle in the splitter either.  We have
> *{add,sub}v4_doubleword_1 pattern for those and that is what combine
> will match, the problem in this testcase is just that it was only RA that
> propagated the constant into the instruction.
>
> In the similar *{add,sub}v4 patterns, we make sure not to accept
> VOIDmode operand and similarly to these have _1 suffixed variant that allows
> constants.  Fixed thusly, bootstrapped/regtested on x86_64-linux and
> i686-linux, ok for trunk?
>
> 2020-01-26  Jakub Jelinek  
>
> PR target/93412
> * config/i386/i386.md (*addv4_doubleword, 
> *subv4_doubleword):
> Use nonimmediate_operand instead of x86_64_hilo_general_operand and
> drop  from constraint of last operand.
>
> * gcc.dg/pr93412.c: New test.

OK.

Thanks,
Uros.

> --- gcc/config/i386/i386.md.jj  2020-01-23 16:16:55.982005551 +0100
> +++ gcc/config/i386/i386.md 2020-01-25 19:30:20.358205644 +0100
> @@ -6135,7 +6135,7 @@ (define_insn_and_split "*addv4_doub
> (sign_extend:
>   (match_operand: 1 "nonimmediate_operand" "%0,0"))
> (sign_extend:
> - (match_operand: 2 "x86_64_hilo_general_operand" 
> "r,o")))
> + (match_operand: 2 "nonimmediate_operand" "r,o")))
>   (sign_extend:
> (plus: (match_dup 1) (match_dup 2)
> (set (match_operand: 0 "nonimmediate_operand" "=ro,r")
> @@ -6644,7 +6644,7 @@ (define_insn_and_split "*subv4_doub
> (sign_extend:
>   (match_operand: 1 "nonimmediate_operand" "0,0"))
> (sign_extend:
> - (match_operand: 2 "x86_64_hilo_general_operand" 
> "r,o")))
> + (match_operand: 2 "nonimmediate_operand" "r,o")))
>   (sign_extend:
> (minus: (match_dup 1) (match_dup 2)
> (set (match_operand: 0 "nonimmediate_operand" "=ro,r")
> --- gcc/testsuite/gcc.dg/pr93412.c.jj   2020-01-25 19:36:23.083680678 +0100
> +++ gcc/testsuite/gcc.dg/pr93412.c  2020-01-25 19:36:09.771883437 +0100
> @@ -0,0 +1,15 @@
> +/* PR target/93412 */
> +/* { dg-do compile { target int128 } } */
> +/* { dg-options "-Og" } */
> +
> +unsigned char a;
> +int b;
> +unsigned c;
> +
> +int
> +foo (int e, int f, int g, int h, int k, int i, short j)
> +{
> +  b = __builtin_add_overflow (a, 0, &c);
> +  b = __builtin_add_overflow_p (b, a, (unsigned __int128) 0) ? b : 0;
> +  return e + f + g + a + h + k + i + j + c;
> +}
>
> Jakub
>


Re: [PATCH] sanopt: Avoid crash on anonymous parameter [PR93436]

2020-01-26 Thread Jakub Jelinek
On Sat, Jan 25, 2020 at 07:13:20PM -0500, Marek Polacek wrote:
> Here we crash when using -fsanitize=address -fdump-tree-sanopt because
> the dumping code uses IDENTIFIER_POINTER on a null DECL_NAME.  Instead,
> we can print "" in such a case.  Or we could avoid printing
> that diagnostic altogether.
> 
> I don't think this warrants a testcase.
> 
> Tested x86_64-linux, ok for trunk and 9?

Wouldn't it be better to:
  if (dump_file)
{
  fprintf (dump_file,
   "Rewriting parameter whose address is taken: ");
  print_generic_expr (dump_file, arg, dump_flags);
  fputc ('\n', dump_file);
}
or so?  That way, we can print D.1234 for those, but user has a way
to override it to D. etc.

> 2020-01-25  Marek Polacek  
> 
>   PR tree-optimization/93436
>   * sanopt.c (sanitize_rewrite_addressable_params): Avoid crash on
>   null DECL_NAME.

Jakub



Re: [PATCH] Relax invalidation of TOP N counters in PGO.

2020-01-26 Thread Martin Liška

Hello Honza.

Thank you for the fix!

Martin


Re: [PATCH] Fix gcc.dg/torture/pr91323.c for aarch64 targets

2020-01-26 Thread Jeff Law
On Fri, 2020-01-17 at 12:07 +, Richard Sandiford wrote:
> PR91323 was fixed for x86 and sparc in target code, but aarch64
> instead relies on the target-independent comparison splitters.
> Since LTGT is an unordered-signalling operation, we should split
> it into unordered-signalling operations for any input that could
> be NaN, not just inputs that could be signalling NaNs.
> 
> Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?
> 
> Richard
> 
> 
> 2020-01-17  Richard Sandiford  
> 
> gcc/
>   * dojump.c (split_comparison): Use HONOR_NANS rather than
>   HONOR_SNANS when splitting LTGT.
OK
jeff



Re: [PATCH] cselib: Fix handling of multireg values for call insns [PR93170]

2020-01-26 Thread Jeff Law
On Mon, 2020-01-20 at 12:54 +, Richard Sandiford wrote:
> g:3bd2918594dae34ae84f mishandled the case in which only the
> tail end of a multireg hard register is invalidated by the call.
> Walking all the entries should be both safer and more precise.
> 
> Avoiding cselib_invalidate_regno also means that we no longer
> walk the same list multiple times (which is something we did
> before g:3bd2918594dae34ae84f too).
> 
> Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?
> 
> Richard
> 
> 
> 2020-01-20  Richard Sandiford  
> 
> gcc/
>   PR rtl-optimization/93170
>   * cselib.c (cselib_invalidate_regno_val): New function, split out
>   from...
>   (cselib_invalidate_regno): ...here.
>   (cselib_invalidated_by_call_p): New function.
>   (cselib_process_insn): Iterate over all the hard-register entries in
>   REG_VALUES and invalidate any that cross call-clobbered registers.
> 
> gcc/testsuite/
>   * gcc.dg/torture/pr93170.c: New test.
OK
jeff
> 



Re: [PATCH] lra: Stop registers being incorrectly marked live [PR92989]

2020-01-26 Thread Jeff Law
On Mon, 2020-01-20 at 13:03 +, Richard Sandiford wrote:
> lra_assign has an assert to make sure that no pseudo is allocated
> to a conflicting hard register.  It used to be restricted to
> !flag_ipa_ra, but in g:a1e6ee38e708ef2bdef4 I'd enabled it for
> flag_ipa_ra too.  It then tripped while building libstdc++
> for mips-mti-linux.
> 
> The failure was due to code at the end of process_bb_lives.  For an
> abnormal/EH edge, we need to make sure that all pseudos that are live
> on entry to the destination conflict with all hard registers that are
> clobbered by an abnormal call return.  The usual way to do this would
> be to simulate a clobber of the hard registers, by making them live and
> them making them dead again.  Making the registers live creates the
> conflict; making them dead again restores the correct live set for
> whatever follows.
> 
> However, process_bb_lives skips the second step (making the registers
> dead again) at the start of a BB, presumably on the basis that there's
> no further code that needs a correct live set.  The problem for the PR
> is that that wasn't quite true in practice.  There was code further
> down process_bb_lives that updated the live-in set of the BB for some
> registers, and this live set was "contaminated" by registers that
> weren't live but that created conflicts.  This information then got
> propagated to other blocks, so that registers that were made live
> purely to create a conflict at the start of the EH receiver then became
> needlessly live throughout preceding blocks.  This in turn created a
> fake conflict with pseudos in those blocks, invalidating the choices
> made by IRA.
> 
> The easiest fix seems to be to update the live-in set *before* adding
> the fake live registers.  An alternative would be to simulate the full
> clobber, but that seems a bit wasteful.
> 
> Tested on aarch64-linux-gnu and x86_64-linux-gnu, and that the
> preprocessed libstdc++ code now compiles for mipsisa64-elf.
> OK to install?
> 
> Richard
> 
> 
> 2020-01-20  Richard Sandiford  
> 
> gcc/
>   PR rtl-optimization/92989
>   * lra-lives.c (process_bb_lives): Update the live-in set before
>   processing additional clobbers.
OK
jeff
> 



Re: [PATCH] checking: avoid verify_type_variant crash on incomplete type.

2020-01-26 Thread Jeff Law
On Sat, 2020-01-25 at 23:21 -0500, Jason Merrill wrote:
> Here, we end up calling gen_type_die_with_usage for a type that's in the
> middle of finish_struct_1, after we set TYPE_NEEDS_CONSTRUCTING on it but
> before we copy all the flags to the variants--and, significantly, before we
> set its TYPE_SIZE.  It seems reasonable to only look at
> TYPE_NEEDS_CONSTRUCTING on complete types, since we aren't going to try to
> create an object of an incomplete type any other way.
> 
> Tested x86_64-pc-linux-gnu, OK for trunk/9?
> 
>   PR c++/92601
>   * tree.c (verify_type_variant): Only verify TYPE_NEEDS_CONSTRUCTING
>   of complete types.
OK
Jeff
> 



Re: [PATCH] RX update functions with string constraint

2020-01-26 Thread Jeff Law
On Tue, 2020-01-21 at 14:18 +0200, Darius Galis wrote:
> Hello,
> 
> The following patch updates the setmemsi and rx_setmem functions.
> The patch adds the rx_allow_string_insns constraint to these functions
> in order to be used only when the string support is enabled.
> 
> Regression test is OK, without additional fails, and was tested with the
> following command:
> 
> make -k check-gcc RUNTESTFLAGS=--target_board=rx-sim
> 
> Please let me know if this is OK, Thank you!
> Darius
> 
> Index: gcc/ChangeLog
> ===
> --- gcc/ChangeLog (revision 280157)
> +++ gcc/ChangeLog (working copy)
> @@ -1,3 +1,8 @@
> +2020-01-16  Darius Galis  
> +
> + * config/rx/rx.md (setmemsi): Added rx_allow_string_insns constraint
> + (rx_setmem): Likewise.
Thanks.  I've installed this on the trunk.

Jeff
> 



Re: [PING^7][PATCH 0/4] Fix library testsuite compilation for build sysroot

2020-01-26 Thread Jeff Law
On Tue, 2020-01-21 at 02:19 +, Maciej W. Rozycki wrote:
> On Fri, 20 Dec 2019, Mike Stump wrote:
> 
> > > > This patch series addresses a problem with the testsuite compiler being 
> > > > set up across libatomic, libffi, libgo, libgomp with no correlation 
> > > > whatsoever to the target compiler being used in GCC compilation.  
> > > > Consequently there in no arrangement made to set up the compilation 
> > > > sysroot according to the build sysroot specified for GCC compilation, 
> > > > causing a catastrophic failure across the testsuites affected from the 
> > > > inability to link executables.
> > > 
> > > Ping for:
> > > 
> > > 
> > > 
> > > 
> > 
> > Hum...  I'm wondering who should review this...  Feels like I should, 
> > the problem is it intertwines with the build system as well.  So, let me 
> > approve the testsuite parts so that can clear the way for someone else 
> > to approve the remaining bits (if not obvious).
> 
>  Ping for the build system parts of:
> 
> 
> 
OK.  Sorry for the terrible slowness on this kit.
jeff



Re: [PATCH] Make target_clones resolver fn static.

2020-01-26 Thread Jeff Law
On Tue, 2020-01-21 at 13:48 +0100, Martin Liška wrote:
> From a3faaced989869867671ceadd89b56fabde225ff Mon Sep 17 00:00:00 2001
> From: Martin Liska 
> Date: Thu, 16 Jan 2020 10:38:41 +0100
> Subject: [PATCH] Make target_clones resolver fn static.
> 
> gcc/ChangeLog:
> 
> 2020-01-17  Martin Liska  
> 
>   PR target/93274
>   * config/i386/i386-features.c (make_resolver_func):
>   Align the code with ppc64 target implementaion.
>   We do not need to have gnu_indirect_function
>   as a global function.  Drop TREE_PUBLIC on
>   ifunc symbol.
>   * config/rs6000/rs6000.c (make_resolver_func): Drop
>   TREE_PUBLIC on ifunc symbol.
> 
> gcc/testsuite/ChangeLog:
> 
> 2020-01-17  Martin Liska  
> 
>   PR target/93274
>   * gcc.target/i386/pr81213.c: Adjust to not expect
>   a global unique name.
>   * gcc.target/i386/pr81213-2.c: New test.
Not strictly a regression, but given the codegen impact, I think this
should go in.  OK

jeff


Re: [PATCH] i386: Fix up -fdollars-in-identifiers with identifiers starting with $ in -masm=att (PR target/91298)

2020-01-26 Thread Rainer Orth
Hi Jakub,

> On Thu, Jan 23, 2020 at 09:19:52PM +0100, Rainer Orth wrote:
>> Unlikely: there's barely any development on the Solaris assemblers these
>> days, though I prefer to xfail tests if possible to get notified if they
>> suddenly start to work for some reason.
>
> Ok.

here's what I've installed on master and the gcc-9 branch after testing
on i386-pc-solaris2.11 with as and gas and x86_64-pc-linux-gnu.

Rainer

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


2020-01-24  Rainer Orth  

* gcc.target/i386/pr91298-1.c: xfail on Solaris/x86 with native
assembler.
* gcc.target/i386/pr91298-2.c: Likewise.

# HG changeset patch
# Parent  de8cdf6b12e6fa9639cb9c18c756d9e7c5e97aeb
testsuite: xfail gcc.target/i386/pr91298-?.c on Solaris/x86 with as

The new gcc.target/i386/pr91298-?.c testcases FAIL on Solaris/x86 with the
native assembler:

FAIL: gcc.target/i386/pr91298-1.c (test for excess errors)

Excess errors:
Assembler: pr91298-1.c
"/var/tmp//ccE6r3xb.s", line 5 : Syntax error
Near line: ".globl  $quux"
"/var/tmp//ccE6r3xb.s", line 6 : Syntax error
Near line: ".type   $quux, @function"
"/var/tmp//ccE6r3xb.s", line 7 : Syntax error
Near line: "$quux:"
"/var/tmp//ccE6r3xb.s", line 15 : Syntax error
Near line: ".size   $quux, .-$quux"
"/var/tmp//ccE6r3xb.s", line 24 : Syntax error
Near line: "movl$($a), %eax"
"/var/tmp//ccE6r3xb.s", line 38 : Syntax error
Near line: "leal($a)(,%eax,4), %eax"
"/var/tmp//ccE6r3xb.s", line 51 : Syntax error
Near line: "movl($a), %eax"
"/var/tmp//ccE6r3xb.s", line 63 : Syntax error
Near line: "movl($a)+16, %eax"
"/var/tmp//ccE6r3xb.s", line 97 : Syntax error
Near line: "movl$($quux), %eax"
"/var/tmp//ccE6r3xb.s", line 101 : Syntax error
Near line: ".globl  $a"
"/var/tmp//ccE6r3xb.s", line 104 : Syntax error
Near line: ".type   $a, @object"
"/var/tmp//ccE6r3xb.s", line 105 : Syntax error
Near line: ".size   $a, 72"
"/var/tmp//ccE6r3xb.s", line 106 : Syntax error
Near line: "$a:"
"/var/tmp//ccE6r3xb.s", line 228 : Syntax error
Near line: ".long   ($a)"

FAIL: gcc.target/i386/pr91298-2.c (test for excess errors)

It only allows letters, digits, '_' and '.' in identifiers:
https://docs.oracle.com/cd/E37838_01/html/E61064/eqbsx.html#XALRMeoqjw

For lack of an effective-target keyword matching -fdollars-in-identifiers,
this patch fixes this by xfailing them on *-*-solaris2.* && !gas.

Tested on i386-pc-solaris2.11 with as and gas and x86_64-pc-linux-gnu.

	* gcc.target/i386/pr91298-1.c: xfail on Solaris/x86 with native
	assembler.
	* gcc.target/i386/pr91298-2.c: Likewise.

diff --git a/gcc/testsuite/gcc.target/i386/pr91298-1.c b/gcc/testsuite/gcc.target/i386/pr91298-1.c
--- a/gcc/testsuite/gcc.target/i386/pr91298-1.c
+++ b/gcc/testsuite/gcc.target/i386/pr91298-1.c
@@ -1,6 +1,7 @@
 /* PR target/91298 */
 /* { dg-do assemble } */
 /* { dg-options "-O2 -g -fdollars-in-identifiers" } */
+/* { dg-xfail-if "No support for $ in identifiers" { *-*-solaris2.* && { ! gas } } } */
 
 int $a[18];
 int *foo (void) { return &$a[0]; }
diff --git a/gcc/testsuite/gcc.target/i386/pr91298-2.c b/gcc/testsuite/gcc.target/i386/pr91298-2.c
--- a/gcc/testsuite/gcc.target/i386/pr91298-2.c
+++ b/gcc/testsuite/gcc.target/i386/pr91298-2.c
@@ -1,5 +1,6 @@
 /* PR target/91298 */
 /* { dg-do assemble { target fpic } } */
 /* { dg-options "-O2 -g -fdollars-in-identifiers -fpic" } */
+/* { dg-xfail-if "No support for $ in identifiers" { *-*-solaris2.* && { ! gas } } } */
 
 #include "pr91298-1.c"


[committed] coroutines: Fix whitespace and comment markers.

2020-01-26 Thread Iain Sandoe
This fixes up the uses of non-canonical forms Nathan obseved, for comments
inlined in function calls and some uses of C++ style comment markers that
had slipped through.  Whitespace and comment changes only, NFC intended.

tested in x86_64-darwin16, pushed to master,
thanks
Iain

commit 8022264265dd39887a1723eeda8ae445afad1fde
Author: Iain Sandoe 
Date:   2020-01-26 20:49:04 +

coroutines: Fix whitespace and comment markers.

This amends the cases where inline comments in function calls were
followed by a space.  It also fixes some uses of C++ style and wrongly
wrapped comment end markers.

gcc/cp/ChangeLog:

2020-01-26  Iain Sandoe  

* coroutines.cc: Amend whitespace after inline comments
throughout.  Ensure use of C-style comment markers.

diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index 81fb8c924a7..b222c1f7a8e 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -296,9 +296,8 @@ instantiate_coro_traits (tree fndecl, location_t kw)
 
   tree traits_class
 = lookup_template_class (coro_traits_templ, targ,
-/*in_decl=*/ NULL_TREE,
-/*context=*/ NULL_TREE /*std_node*/,
-/*entering scope=*/ false, tf_warning_or_error);
+/*in_decl=*/NULL_TREE, /*context=*/NULL_TREE,
+/*entering scope=*/false, tf_warning_or_error);
 
   if (traits_class == error_mark_node || traits_class == NULL_TREE)
 {
@@ -335,9 +334,9 @@ instantiate_coro_handle_for_promise_type (location_t kw, 
tree promise_type)
   TREE_VEC_ELT (targ, 0) = promise_type;
   tree handle_type
 = lookup_template_class (coro_handle_identifier, targ,
-/* in_decl */ NULL_TREE,
-/* context */ std_node,
-/* entering scope */ false, tf_warning_or_error);
+/* in_decl=*/NULL_TREE,
+/* context=*/std_node,
+/* entering scope=*/false, tf_warning_or_error);
 
   if (handle_type == error_mark_node)
 {
@@ -356,7 +355,7 @@ find_promise_type (tree traits_class)
 {
   tree promise_type
 = lookup_member (traits_class, coro_promise_type_identifier,
-/* protect */ 1, /*want_type=*/true, tf_warning_or_error);
+/* protect=*/1, /*want_type=*/true, tf_warning_or_error);
 
   if (promise_type)
 promise_type
@@ -539,7 +538,7 @@ coro_common_keyword_context_valid_p (tree fndecl, 
location_t kw_loc,
   /* This is arranged in order of prohibitions in the std.  */
   if (DECL_MAIN_P (fndecl))
 {
-  // [basic.start.main] 3. The function main shall not be a coroutine.
+  /* [basic.start.main] 3. The function main shall not be a coroutine.  */
   error_at (kw_loc, "%qs cannot be used in the % function",
kw_name);
   return false;
@@ -547,7 +546,7 @@ coro_common_keyword_context_valid_p (tree fndecl, 
location_t kw_loc,
 
   if (DECL_DECLARED_CONSTEXPR_P (fndecl))
 {
-  // [dcl.constexpr] 3.3 it shall not be a coroutine.
+  /* [dcl.constexpr] 3.3 it shall not be a coroutine.  */
   error_at (kw_loc, "%qs cannot be used in a % function",
kw_name);
   cp_function_chain->invalid_constexpr = true;
@@ -556,8 +555,8 @@ coro_common_keyword_context_valid_p (tree fndecl, 
location_t kw_loc,
 
   if (FNDECL_USED_AUTO (fndecl))
 {
-  // [dcl.spec.auto] 15. A function declared with a return type that uses
-  // a placeholder type shall not be a coroutine .
+  /* [dcl.spec.auto] 15. A function declared with a return type that uses
+a placeholder type shall not be a coroutine.  */
   error_at (kw_loc,
"%qs cannot be used in a function with a deduced return type",
kw_name);
@@ -566,9 +565,9 @@ coro_common_keyword_context_valid_p (tree fndecl, 
location_t kw_loc,
 
   if (varargs_function_p (fndecl))
 {
-  // [dcl.fct.def.coroutine] The parameter-declaration-clause of the
-  // coroutine shall not terminate with an ellipsis that is not part
-  // of a parameter-declaration.
+  /* [dcl.fct.def.coroutine] The parameter-declaration-clause of the
+coroutine shall not terminate with an ellipsis that is not part
+of a parameter-declaration.  */
   error_at (kw_loc,
"%qs cannot be used in a varargs function", kw_name);
   return false;
@@ -576,14 +575,14 @@ coro_common_keyword_context_valid_p (tree fndecl, 
location_t kw_loc,
 
   if (DECL_CONSTRUCTOR_P (fndecl))
 {
-  // [class.ctor] 7. a constructor shall not be a coroutine.
+  /* [class.ctor] 7. a constructor shall not be a coroutine.  */
   error_at (kw_loc, "%qs cannot be used in a constructor", kw_name);
   return false;
 }
 
   if (DECL_DESTRUCTOR_P (fndecl))
 {
-  // [class.dtor] 21. a destructor s

Re: [PATCH] sanopt: Avoid crash on anonymous parameter [PR93436]

2020-01-26 Thread Marek Polacek
On Sun, Jan 26, 2020 at 12:09:09PM +0100, Jakub Jelinek wrote:
> On Sat, Jan 25, 2020 at 07:13:20PM -0500, Marek Polacek wrote:
> > Here we crash when using -fsanitize=address -fdump-tree-sanopt because
> > the dumping code uses IDENTIFIER_POINTER on a null DECL_NAME.  Instead,
> > we can print "" in such a case.  Or we could avoid printing
> > that diagnostic altogether.
> > 
> > I don't think this warrants a testcase.
> > 
> > Tested x86_64-linux, ok for trunk and 9?
> 
> Wouldn't it be better to:
> if (dump_file)
>   {
> fprintf (dump_file,
>  "Rewriting parameter whose address is taken: ");
> print_generic_expr (dump_file, arg, dump_flags);
> fputc ('\n', dump_file);
>   }
> or so?  That way, we can print D.1234 for those, but user has a way
> to override it to D. etc.

Sure, that's better, thanks.

Here we crash when using -fsanitize=address -fdump-tree-sanopt because
the dumping code uses IDENTIFIER_POINTER on a null DECL_NAME.  Instead,
we can use print_generic_expr.

Tested x86_64-linux, ok for trunk and 9?

2020-01-26  Marek Polacek  

PR tree-optimization/93436
* sanopt.c (sanitize_rewrite_addressable_params): Avoid crash on
null DECL_NAME.
---
 gcc/sanopt.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/gcc/sanopt.c b/gcc/sanopt.c
index 619aae45a15..0788eef597e 100644
--- a/gcc/sanopt.c
+++ b/gcc/sanopt.c
@@ -1174,9 +1174,12 @@ sanitize_rewrite_addressable_params (function *fun)
continue;
 
  if (dump_file)
-   fprintf (dump_file,
-"Rewriting parameter whose address is taken: %s\n",
-IDENTIFIER_POINTER (DECL_NAME (arg)));
+   {
+ fprintf (dump_file,
+  "Rewriting parameter whose address is taken: ");
+ print_generic_expr (dump_file, arg, dump_flags);
+ fputc ('\n', dump_file);
+   }
 
  SET_DECL_PT_UID (var, DECL_PT_UID (arg));
 

base-commit: 9664b52aeb3db9ae35bba1766d677790c8a461ef
-- 
Marek Polacek • Red Hat, Inc. • 300 A St, Boston, MA



Re: [PATCH] sanopt: Avoid crash on anonymous parameter [PR93436]

2020-01-26 Thread Jakub Jelinek
On Sun, Jan 26, 2020 at 04:18:33PM -0500, Marek Polacek wrote:
> 2020-01-26  Marek Polacek  
> 
>   PR tree-optimization/93436
>   * sanopt.c (sanitize_rewrite_addressable_params): Avoid crash on
>   null DECL_NAME.

LGTM, thanks.

> ---
>  gcc/sanopt.c | 9 ++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/gcc/sanopt.c b/gcc/sanopt.c
> index 619aae45a15..0788eef597e 100644
> --- a/gcc/sanopt.c
> +++ b/gcc/sanopt.c
> @@ -1174,9 +1174,12 @@ sanitize_rewrite_addressable_params (function *fun)
>   continue;
>  
> if (dump_file)
> - fprintf (dump_file,
> -  "Rewriting parameter whose address is taken: %s\n",
> -  IDENTIFIER_POINTER (DECL_NAME (arg)));
> + {
> +   fprintf (dump_file,
> +"Rewriting parameter whose address is taken: ");
> +   print_generic_expr (dump_file, arg, dump_flags);
> +   fputc ('\n', dump_file);
> + }
>  
> SET_DECL_PT_UID (var, DECL_PT_UID (arg));
>  
> 
> base-commit: 9664b52aeb3db9ae35bba1766d677790c8a461ef

Jakub



[COMMITTED] c++: Fix -Wnoexcept handling of system headers (PR90992).

2020-01-26 Thread Jason Merrill
The immediate issue here was that the second warning didn't depend on the
first one, so if the first location was in a system header, we'd
mysteriously give the second by itself.

It's also the case that the thing we care about being in a system header is
the function that we want to suggest adding 'noexcept' to, not the
noexcept-expression; it's useful to suggest adding noexcept to a user
function to satisfy a noexcept-expression in a system header.

Tested x86_64-pc-linux-gnu, applying to trunk.

PR c++/90992
* except.c (maybe_noexcept_warning): Check DECL_IN_SYSTEM_HEADER and
temporarily enable -Wsystem-headers.  Change second warning to
conditional inform.
---
 gcc/testsuite/g++.dg/warn/Wnoexcept1.h | 37 ++
 gcc/cp/except.c| 16 ++-
 gcc/testsuite/g++.dg/warn/Wnoexcept1.C | 34 +++
 3 files changed, 81 insertions(+), 6 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/warn/Wnoexcept1.h
 create mode 100644 gcc/testsuite/g++.dg/warn/Wnoexcept1.C

diff --git a/gcc/testsuite/g++.dg/warn/Wnoexcept1.h 
b/gcc/testsuite/g++.dg/warn/Wnoexcept1.h
new file mode 100644
index 000..f59733e705f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wnoexcept1.h
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+#pragma GCC system_header
+
+using size_t = decltype(sizeof(42));
+inline void * operator new (size_t, void *p) noexcept { return p; }
+
+class NotNoexcept {
+public:
+  NotNoexcept() noexcept(false) {}
+  NotNoexcept(const NotNoexcept&) noexcept(false) {}
+  NotNoexcept(NotNoexcept &&) noexcept(false) {}
+  ~NotNoexcept() noexcept(false) {}
+
+  NotNoexcept&operator=(const NotNoexcept&) noexcept(false) { return *this;}
+  NotNoexcept&operator=(NotNoexcept &&) noexcept(false) {return *this;}
+};
+
+template
+void
+construct1(_Up* __p, _Args... __args)
+  noexcept(noexcept(::new((void *)__p) _Up(__args...)))
+{ ::new((void *)__p) _Up(__args...); }
+
+template
+void
+construct2(_Up* __p, _Args... __args)
+  noexcept(noexcept(::new((void *)__p) _Up(__args...)))
+{ ::new((void *)__p) _Up(__args...); }
+
+class Automatic1 {
+public:
+  Automatic1(size_t bla) : Bla(bla) {};
+
+private:
+  size_t Bla;
+  NotNoexcept Dummy;
+};
diff --git a/gcc/cp/except.c b/gcc/cp/except.c
index 0b40234e228..788b96de243 100644
--- a/gcc/cp/except.c
+++ b/gcc/cp/except.c
@@ -1165,13 +1165,17 @@ static GTY(()) vec 
*pending_noexcept_checks;
 static void
 maybe_noexcept_warning (tree fn)
 {
-  if (TREE_NOTHROW (fn))
+  if (TREE_NOTHROW (fn)
+  && (!DECL_IN_SYSTEM_HEADER (fn)
+ || global_dc->dc_warn_system_headers))
 {
-  warning (OPT_Wnoexcept, "noexcept-expression evaluates to % "
-  "because of a call to %qD", fn);
-  warning_at (DECL_SOURCE_LOCATION (fn), OPT_Wnoexcept,
- "but %qD does not throw; perhaps "
- "it should be declared %", fn);
+  temp_override s (global_dc->dc_warn_system_headers, true);
+  auto_diagnostic_group d;
+  if (warning (OPT_Wnoexcept, "noexcept-expression evaluates to % "
+  "because of a call to %qD", fn))
+   inform (DECL_SOURCE_LOCATION (fn),
+   "but %qD does not throw; perhaps "
+   "it should be declared %", fn);
 }
 }
 
diff --git a/gcc/testsuite/g++.dg/warn/Wnoexcept1.C 
b/gcc/testsuite/g++.dg/warn/Wnoexcept1.C
new file mode 100644
index 000..e3a5df64459
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wnoexcept1.C
@@ -0,0 +1,34 @@
+// PR c++/90992
+// { dg-do compile { target c++11 } }
+// { dg-additional-options -Wnoexcept }
+
+#include "Wnoexcept1.h"
+
+// We expect a warning at the declaration of construct2, since Automatic2 is
+// defined below; we don't expect one for construct1, because Automatic1 is
+// defined in the fake system header.
+// { dg-warning "noexcept-expression" "" { target *-*-* } 26 }
+
+class Automatic2 {
+public:
+  Automatic2(size_t bla) : Bla(bla) {}; // { dg-message "noexcept" }
+
+private:
+  size_t Bla;
+  NotNoexcept Dummy;
+};
+
+union U
+{
+  unsigned char buf[sizeof(Automatic1)];
+  Automatic1 a1;
+  Automatic2 a2;
+  U(): buf{} {}
+  ~U() {}
+};
+
+int main() {
+  U u;
+  construct1(&u.a1, 42);
+  construct2(&u.a2, 42);
+}

base-commit: cf17dcc6fc1f9f69d592952c2dd5796a5665bd5a
-- 
2.18.1



[PATCH] Fix missed IPA-CP on by-ref argument directly passed through (PR ipa/93429)

2020-01-26 Thread Feng Xue OS
Current IPA does not propagate aggregate constant for by-ref argument
if it is simple pass-through of caller parameter. Here is an example,

   f1 (int *p)
   {
 ... = *p;
 ...
   }

   f2 (int *p)
   {
  *p = 2;
  f1 (p);
   }

It is easy to know that in f1(), *p should be 2 after a simple propagation
from f2() to f1(). But this is missed due to some bug, which is targeted
by this patch.

Bootstrapped/regtested on x86_64-linux and aarch64-linux.

Feng
---
2020-01-27  Feng Xue  

PR ipa/93429
* ipa-cp.c (propagate_aggs_across_jump_function): Further
check aggregate jump functions if by-ref argument is simple
pass through.
(intersect_aggregates_with_edge): Likewise.

0001-Fix-missed-IPA-CP-on-by-ref-argument-directly-passed.patch
Description:  0001-Fix-missed-IPA-CP-on-by-ref-argument-directly-passed.patch