Re: [C++ PATCH] PR c++/90449 - add -Winaccessible-base option.

2019-06-10 Thread Jason Merrill

On 6/10/19 12:02 PM, Matthew Beliveau wrote:

if (!uniquely_derived_from_p (basetype, t))
- warning (OPT_Wextra, "virtual base %qT inaccessible in %qT due "
-  "to ambiguity", basetype, t);
+ warning (OPT_Winaccessible_base, "virtual base %qT inaccessible in "
+  "%qT due to ambiguity", basetype, t);


You mentioned using -Wextra for this message, and you have a testcase 
for it, but here you remove the only connection between this message and 
-Wextra: with this patch, the virtual base warning will be enabled by 
default.  Perhaps you want to check extra_warnings in the if condition?


Jason


Re: [C++ PATCH] Avoid constexpr garbage for implicit conversion to void.

2019-06-10 Thread Jason Merrill
On Fri, Jun 7, 2019 at 5:08 PM Jason Merrill  wrote:
>
> All expression statements and some other places express implicit conversion to
> void with a CONVERT_EXPR.  There's no reason to build up a new one as part of
> constexpr evaluation.
>
> The ADDR_EXPR change also avoids a bit of garbage by discarding an ADDR_EXPR 
> we
> just built but didn't end up using.
>
> The location wrapper change doesn't affect garbage, it's just a minor
> optimization.

More constexpr garbage reduction:

1) Using a TREE_VEC instead of TREE_LIST to store bindings saves a
bunch of space when dealing with multiple arguments.
2) We don't need to unshare any expressions containing a CONSTRUCTOR,
or expressions within a CONSTRUCTOR; we're only interested in an
initializer which is itself a CONSTRUCTOR, as that's what can get
modified.  A CONSTRUCTOR appearing as a subexpression won't be used to
directly initialize a variable, so we don't need to unshare it.  We
also don't need to unshare the return value of the function, as it
will be unshared if it is used as an initializer.
3) When we free the TREE_VEC for a call we end up not using, we can
also free any CONSTRUCTORs we unshared for it.  This unsharing isn't
necessary, but oddly it significantly reduces the max resident memory
on the testcase I've been looking at, so I'm going to leave it in.  We
also free CONSTRUCTORs for initialized parameters when we're done
evaluating the function.

Tested x86_64-pc-linux-gnu, applied to trunk.
commit 20c4756f8e94a0278b3b74d1e674e3163b1e6a33
Author: Jason Merrill 
Date:   Mon Jun 10 00:16:05 2019 -0400

Reduce constexpr_call memory consumption.

* constexpr.c (cxx_bind_parameters_in_call): Use TREE_VEC rather
than TREE_LIST.
(constexpr_call_hasher::equal, cxx_bind_parameters_in_call)
(cxx_eval_call_expression): Adjust.

diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 10afc419a33..74752bc72dd 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -974,12 +974,7 @@ explain_invalid_constexpr_fn (tree fun)
 struct GTY((for_user)) constexpr_call {
   /* Description of the constexpr function definition.  */
   constexpr_fundef *fundef;
-  /* Parameter bindings environment.  A TREE_LIST where each TREE_PURPOSE
- is a parameter _DECL and the TREE_VALUE is the value of the parameter.
- Note: This arrangement is made to accommodate the use of
- iterative_hash_template_arg (see pt.c).  If you change this
- representation, also change the hash calculation in
- cxx_eval_call_expression.  */
+  /* Parameter bindings environment.  A TREE_VEC of arguments.  */
   tree bindings;
   /* Result of the call.
NULL means the call is being evaluated.
@@ -1069,8 +1064,6 @@ constexpr_call_hasher::hash (constexpr_call *info)
 bool
 constexpr_call_hasher::equal (constexpr_call *lhs, constexpr_call *rhs)
 {
-  tree lhs_bindings;
-  tree rhs_bindings;
   if (lhs == rhs)
 return true;
   if (lhs->hash != rhs->hash)
@@ -1079,19 +1072,7 @@ constexpr_call_hasher::equal (constexpr_call *lhs, 
constexpr_call *rhs)
 return false;
   if (!constexpr_fundef_hasher::equal (lhs->fundef, rhs->fundef))
 return false;
-  lhs_bindings = lhs->bindings;
-  rhs_bindings = rhs->bindings;
-  while (lhs_bindings != NULL && rhs_bindings != NULL)
-{
-  tree lhs_arg = TREE_VALUE (lhs_bindings);
-  tree rhs_arg = TREE_VALUE (rhs_bindings);
-  gcc_assert (same_type_p (TREE_TYPE (lhs_arg), TREE_TYPE (rhs_arg)));
-  if (!cp_tree_equal (lhs_arg, rhs_arg))
-return false;
-  lhs_bindings = TREE_CHAIN (lhs_bindings);
-  rhs_bindings = TREE_CHAIN (rhs_bindings);
-}
-  return lhs_bindings == rhs_bindings;
+  return cp_tree_equal (lhs->bindings, rhs->bindings);
 }
 
 /* Initialize the constexpr call table, if needed.  */
@@ -1380,7 +1361,10 @@ cxx_bind_parameters_in_call (const constexpr_ctx *ctx, 
tree t,
   tree fun = new_call->fundef->decl;
   tree parms = new_call->fundef->parms;
   int i;
-  tree *p = _call->bindings;
+  /* We don't record ellipsis args below.  */
+  int nparms = list_length (parms);
+  int nbinds = nargs < nparms ? nargs : nparms;
+  tree binds = new_call->bindings = make_tree_vec (nbinds);
   for (i = 0; i < nargs; ++i)
 {
   tree x, arg;
@@ -1417,8 +1401,7 @@ cxx_bind_parameters_in_call (const constexpr_ctx *ctx, 
tree t,
arg = adjust_temp_type (type, arg);
  if (!TREE_CONSTANT (arg))
*non_constant_args = true;
- *p = build_tree_list (parms, arg);
- p = _CHAIN (*p);
+ TREE_VEC_ELT (binds, i) = arg;
}
   parms = TREE_CHAIN (parms);
 }
@@ -1745,14 +1728,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree 
t,
 void preserve () { do_free = false; }
 ~free_bindings () {
   if (do_free)
-   {
- while (bindings)
-   {
- tree b = bindings;
- bindings = TREE_CHAIN (bindings);
- 

[PING^4] [PATCH V3] PR88497 - Extend reassoc for vector bit_field_ref

2019-06-10 Thread Kewen.Lin
Hi,

Gentle ping again.  Thanks!

Kewen

on 2019/5/21 上午10:02, Kewen.Lin wrote:
> Hi,
> 
> Gentle ping again.  Thanks!
> 
> 
> Kewen
> 
> on 2019/5/5 下午2:15, Kewen.Lin wrote:
>> Hi,
>>
>> I'd like to gentle ping for this patch:
>> https://gcc.gnu.org/ml/gcc-patches/2019-03/msg00966.html
>>
>> OK for trunk now?
>>
>> Thanks!
>>
>> on 2019/3/20 上午11:14, Kewen.Lin wrote:
>>> Hi,
>>>
>>> Please refer to below link for previous threads.
>>> https://gcc.gnu.org/ml/gcc-patches/2019-03/msg00348.html
>>>
>>> Comparing to patch v2, I've moved up the vector operation target 
>>> check upward together with vector type target check.  Besides, I
>>> ran bootstrap and regtest on powerpc64-linux-gnu (BE), updated 
>>> testcases' requirements and options for robustness.
>>>
>>> Is it OK for GCC10?
>>>
>>>
>>> gcc/ChangeLog
>>>
>>> 2019-03-20  Kewen Lin  
>>>
>>> PR target/88497
>>> * tree-ssa-reassoc.c (reassociate_bb): Swap the positions of 
>>> GIMPLE_BINARY_RHS check and gimple_visited_p check, call new 
>>> function undistribute_bitref_for_vector.
>>> (undistribute_bitref_for_vector): New function.
>>> (cleanup_vinfo_map): Likewise.
>>> (unsigned_cmp): Likewise.
>>>
>>> gcc/testsuite/ChangeLog
>>>
>>> 2019-03-20  Kewen Lin  
>>>
>>> * gcc.dg/tree-ssa/pr88497-1.c: New test.
>>> * gcc.dg/tree-ssa/pr88497-2.c: Likewise.
>>> * gcc.dg/tree-ssa/pr88497-3.c: Likewise.
>>> * gcc.dg/tree-ssa/pr88497-4.c: Likewise.
>>> * gcc.dg/tree-ssa/pr88497-5.c: Likewise.
>>>
>>> ---
>>>  gcc/testsuite/gcc.dg/tree-ssa/pr88497-1.c |  44 +
>>>  gcc/testsuite/gcc.dg/tree-ssa/pr88497-2.c |  33 
>>>  gcc/testsuite/gcc.dg/tree-ssa/pr88497-3.c |  33 
>>>  gcc/testsuite/gcc.dg/tree-ssa/pr88497-4.c |  33 
>>>  gcc/testsuite/gcc.dg/tree-ssa/pr88497-5.c |  33 
>>>  gcc/tree-ssa-reassoc.c| 306 
>>> +-
>>>  6 files changed, 477 insertions(+), 5 deletions(-)
>>>  create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr88497-1.c
>>>  create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr88497-2.c
>>>  create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr88497-3.c
>>>  create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr88497-4.c
>>>  create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr88497-5.c
>>>
>>> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr88497-1.c 
>>> b/gcc/testsuite/gcc.dg/tree-ssa/pr88497-1.c
>>> new file mode 100644
>>> index 000..99c9af8
>>> --- /dev/null
>>> +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr88497-1.c
>>> @@ -0,0 +1,44 @@
>>> +/* { dg-do compile } */
>>> +/* { dg-require-effective-target vect_double } */
>>> +/* { dg-require-effective-target powerpc_vsx_ok { target { powerpc*-*-* } 
>>> } } */
>>> +/* { dg-options "-O2 -ffast-math" } */
>>> +/* { dg-options "-O2 -ffast-math -mvsx -fdump-tree-reassoc1" { target { 
>>> powerpc*-*-* } } } */
>>> +
>>> +/* To test reassoc can undistribute vector bit_field_ref summation.
>>> +
>>> +   arg1 and arg2 are two arrays whose elements of type vector double.
>>> +   Assuming:
>>> + A0 = arg1[0], A1 = arg1[1], A2 = arg1[2], A3 = arg1[3],
>>> + B0 = arg2[0], B1 = arg2[1], B2 = arg2[2], B3 = arg2[3],
>>> +
>>> +   Then:
>>> + V0 = A0 * B0, V1 = A1 * B1, V2 = A2 * B2, V3 = A3 * B3,
>>> +
>>> +   reassoc transforms
>>> +
>>> + accumulator += V0[0] + V0[1] + V1[0] + V1[1] + V2[0] + V2[1]
>>> + + V3[0] + V3[1];
>>> +
>>> +   into:
>>> +
>>> + T = V0 + V1 + V2 + V3
>>> + accumulator += T[0] + T[1];
>>> +
>>> +   Fewer bit_field_refs, only two for 128 or more bits vector.  */
>>> +
>>> +typedef double v2df __attribute__ ((vector_size (16)));
>>> +double
>>> +test (double accumulator, v2df arg1[], v2df arg2[])
>>> +{
>>> +  v2df temp;
>>> +  temp = arg1[0] * arg2[0];
>>> +  accumulator += temp[0] + temp[1];
>>> +  temp = arg1[1] * arg2[1];
>>> +  accumulator += temp[0] + temp[1];
>>> +  temp = arg1[2] * arg2[2];
>>> +  accumulator += temp[0] + temp[1];
>>> +  temp = arg1[3] * arg2[3];
>>> +  accumulator += temp[0] + temp[1];
>>> +  return accumulator;
>>> +}
>>> +/* { dg-final { scan-tree-dump-times "BIT_FIELD_REF" 2 "reassoc1" { target 
>>> { powerpc*-*-* } } } } */
>>> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr88497-2.c 
>>> b/gcc/testsuite/gcc.dg/tree-ssa/pr88497-2.c
>>> new file mode 100644
>>> index 000..61ed0bf5
>>> --- /dev/null
>>> +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr88497-2.c
>>> @@ -0,0 +1,33 @@
>>> +/* { dg-do compile } */
>>> +/* { dg-require-effective-target vect_float } */
>>> +/* { dg-require-effective-target powerpc_altivec_ok { target { 
>>> powerpc*-*-* } } } */
>>> +/* { dg-options "-O2 -ffast-math" } */
>>> +/* { dg-options "-O2 -ffast-math -maltivec -fdump-tree-reassoc1" { target 
>>> { powerpc*-*-* } } } */
>>> +
>>> +/* To test reassoc can undistribute vector bit_field_ref on multiplication.
>>> +
>>> +   v1, v2, v3, v4 of type vector float.
>>> +
>>> +   reassoc transforms
>>> +
>>> + accumulator *= v1[0] * v1[1] * v1[2] * v1[3] *

Re: [PATCH v3 2/3] Add predict_doloop_p target hook

2019-06-10 Thread Kewen.Lin
>> If my understanding on this question is correct, IMHO we should try to make
>> IVOPTs conservative than optimistic, since once the predict is wrong from
>> too optimistic decision, the costing on the doloop use is wrong, it's very
>> possible to affect the global optimal set.  It looks we don't have any ways
>> to recover it in RTL then?  (otherwise, there should be better place to fix
>> the PR).  Although it's also possible to miss some good cases, it's at least
>> as good as before, I'm inclined to make it conservative.
> 
> I wonder if you could simply benchmark what happens if you make
> IVOPTs _always_ create a doloop IV (if possible)?  I doubt the
> cases where a doloop IV is bad (calls, etc.) are too common and
> that in those cases the extra simple IV hurts.
> 

Hi Richard and all,

With these different settings:
Base) without any changes
A) having predict_doloop and enable all checks
B) A + disable check on "too few iterations" (0 <= est_niter < 3)
C) A + disable costly niter check
D) A + disable invalid stmt check (call/computed_goto/switch)

I collected some runtime performance data with SPEC2017 as following:

Avs.Base   Bvs.A  Cvs.A  Dvs.A
500.perlbench_r 0.00%   0.38%   0.00%   -0.19%
502.gcc_r   0.00%   0.38%   0.00%   0.00%
505.mcf_r   0.89%   0.00%   0.00%   0.00%
520.omnetpp_r   -0.41%  -1.25%  0.00%   0.00%
523.xalancbmk_r -0.36%  -0.36%  -0.36%  -0.73%
525.x264_r  1.14%   0.00%   0.00%   0.00%
531.deepsjeng_r -0.26%  0.26%   0.00%   0.00%
541.leela_r 0.00%   0.37%   0.00%   0.00%
548.exchange2_r 0.85%   -0.21%  0.00%   0.00%
557.xz_r-0.77%  0.52%   -0.26%  0.00%
503.bwaves_r0.00%   0.00%   0.36%   0.00%
507.cactuBSSN_r -0.57%  0.00%   0.00%   0.00%
508.namd_r  -0.69%  0.35%   0.00%   0.35%
510.parest_r0.17%   -0.17%  0.00%   -0.17%
511.povray_r-1.31%  -0.44%  0.15%   0.15%
519.lbm_r   0.00%   0.00%   0.00%   0.00%
521.wrf_r   0.33%   -0.44%  -0.33%  -0.33%
526.blender_r   0.26%   0.26%   0.00%   0.00%
527.cam4_r  0.59%   -0.59%  0.00%   -0.39%
538.imagick_r   0.45%   0.00%   0.00%   0.00%
544.nab_r   0.23%   0.00%   0.00%   0.00%
549.fotonik3d_r 1.80%   -0.29%  0.00%   0.00%
554.roms_r  0.00%   0.00%   0.00%   0.00%
geomean 0.10%   -0.05%  -0.02%  -0.06%

As above, the difference is very small, looks like caused by noise and can 
be ignored. 

I also ran partial of test suite with some explicit statistics dumping 
(on gcc/g++/gfortran etc.). No regressions found. The unique files number 
with predicted doloop found are:

  A) 3297
  B) 3416
  C) 3297
  D) 3858

Some observations:
  * Based on A) and C), we can see the checking on costly niter is useless, 
I plan to give the check up or replace it with one existing interface 
expression_expensive_p as Richard mentioned.  (Correct me if you have 
any concerns.)
  * B) does filter some cases, I checked a few different cases, they are 
written with small iteration count indeed.
  * The delta number isn't small between A) and D).

I ran some filtering by compiling C/C++ files at -O2 with A) and D) (-O2 is 
probably not the actual option used in each testing, may not cause the 
difference, but just for simplicity), obtained dumping assembly file and did
further comparison, then I got 60 files finally.

I looked into all 60 cases (I assumed these are typical enough, don't need
to go through the Fortran etc.).  Most of wi/wo differences are expected, 
55 of them use more insns to update biv, but 5 of them are trivial since they
have to use original biv later so it's kept wi/wo the scanning.  Some of 55 
takes one more register in prologue/epilogue, some of them have fewer setup 
insns (which are to calculate the original value and bound for selected iv).

Some typical case looks like:

 Replacing exit test: if (ivtmp_2 != 0)
\  Replacing exit test: if (ivtmp_2 != 0)
  xxx ()   
\  xxx ()
  {
\  {
unsigned long ivtmp.9; 
\unsigned long ivtmp.9;
int iter;  
\int iter;
int _1;
\int _1;
  
-\  
  unsigned int ivtmp_2;
  
-\  
  unsigned int ivtmp_3;
struct bla[100] * _13; 
\struct bla[100] * _13;
void * _14;   

[PATCH V8] Remove empty loop with assumed finiteness (PR tree-optimization/89713)

2019-06-10 Thread Feng Xue OS
Reformat to comply with gcc coding style.

Feng

---
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 37aab79..87cc125 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,16 @@
+2019-06-04  Feng Xue  
+
+   PR tree-optimization/89713
+   * doc/invoke.texi (-ffinite-loops): Document new option.
+   * common.opt (-ffinite-loops): New option.
+   * tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Mark
+   IFN_GOACC_LOOP calls as necessary.
+   * tree-ssa-loop-niter.c (finite_loop_p): Assume loop with an exit
+   is finite.
+   * omp-offload.c (oacc_xform_loop): Skip lowering if return value of
+   IFN_GOACC_LOOP call is not used.
+   * opts.c (default_options_table): Enable -ffinite-loops at -O2+.
+
 2019-06-04  Alan Modra  
 
PR target/90689
diff --git a/gcc/common.opt b/gcc/common.opt
index 0e72fd0..8b0e6ad 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1437,6 +1437,10 @@ ffinite-math-only
 Common Report Var(flag_finite_math_only) Optimization SetByCombined
 Assume no NaNs or infinities are generated.
 
+ffinite-loops
+Common Report Var(flag_finite_loops) Optimization
+Assume that loops with an exit will terminate and not loop indefinitely.
+
 ffixed-
 Common Joined RejectNegative Var(common_deferred_options) Defer
 -ffixed- Mark  as being unavailable to the compiler.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 91c9bb8..1e12595 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -412,6 +412,7 @@ Objective-C and Objective-C++ Dialects}.
 -fdevirtualize-at-ltrans  -fdse @gol
 -fearly-inlining  -fipa-sra  -fexpensive-optimizations  -ffat-lto-objects @gol
 -ffast-math  -ffinite-math-only  -ffloat-store  -fexcess-precision=@var{style} 
@gol
+-ffinite-loops @gol
 -fforward-propagate  -ffp-contract=@var{style}  -ffunction-sections @gol
 -fgcse  -fgcse-after-reload  -fgcse-las  -fgcse-lm  -fgraphite-identity @gol
 -fgcse-sm  -fhoist-adjacent-loads  -fif-conversion @gol
@@ -8282,6 +8283,7 @@ also turns on the following optimization flags:
 -fdelete-null-pointer-checks @gol
 -fdevirtualize  -fdevirtualize-speculatively @gol
 -fexpensive-optimizations @gol
+-ffinite-loops @gol
 -fgcse  -fgcse-lm  @gol
 -fhoist-adjacent-loads @gol
 -finline-small-functions @gol
@@ -9503,6 +9505,15 @@ that may set @code{errno} but are otherwise free of side 
effects.  This flag is
 enabled by default at @option{-O2} and higher if @option{-Os} is not also
 specified.
 
+@item -ffinite-loops
+@opindex ffinite-loops
+@opindex fno-finite-loops
+Assume that a loop with an exit will eventually take the exit and not loop
+indefinitely.  This allows the compiler to remove loops that otherwise have
+no side-effects, not considering eventual endless looping as such.
+
+This option is enabled by default at @option{-O2}.
+
 @item -ftree-dominator-opts
 @opindex ftree-dominator-opts
 Perform a variety of simple scalar cleanups (constant/copy
diff --git a/gcc/omp-offload.c b/gcc/omp-offload.c
index 97ae47b..c8a281c 100644
--- a/gcc/omp-offload.c
+++ b/gcc/omp-offload.c
@@ -300,7 +300,7 @@ oacc_xform_loop (gcall *call)
   tree chunk_size = NULL_TREE;
   unsigned mask = (unsigned) TREE_INT_CST_LOW (gimple_call_arg (call, 5));
   tree lhs = gimple_call_lhs (call);
-  tree type = TREE_TYPE (lhs);
+  tree type = NULL_TREE;
   tree diff_type = TREE_TYPE (range);
   tree r = NULL_TREE;
   gimple_seq seq = NULL;
@@ -308,6 +308,15 @@ oacc_xform_loop (gcall *call)
   unsigned outer_mask = mask & (~mask + 1); // Outermost partitioning
   unsigned inner_mask = mask & ~outer_mask; // Inner partitioning (if any)
 
+  /* Skip lowering if return value of IFN_GOACC_LOOP call is not used.  */
+  if (!lhs)
+{
+  gsi_replace_with_seq (, seq, true);
+  return;
+}
+
+  type = TREE_TYPE (lhs);
+
 #ifdef ACCEL_COMPILER
   chunk_size = gimple_call_arg (call, 4);
   if (integer_minus_onep (chunk_size)  /* Force static allocation.  */
diff --git a/gcc/opts.c b/gcc/opts.c
index 64f94ac..b38bfb1 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -494,6 +494,7 @@ static const struct default_options default_options_table[] 
=
 { OPT_LEVELS_2_PLUS, OPT_fdevirtualize, NULL, 1 },
 { OPT_LEVELS_2_PLUS, OPT_fdevirtualize_speculatively, NULL, 1 },
 { OPT_LEVELS_2_PLUS, OPT_fexpensive_optimizations, NULL, 1 },
+{ OPT_LEVELS_2_PLUS, OPT_ffinite_loops, NULL, 1 },
 { OPT_LEVELS_2_PLUS, OPT_fgcse, NULL, 1 },
 { OPT_LEVELS_2_PLUS, OPT_fhoist_adjacent_loads, NULL, 1 },
 { OPT_LEVELS_2_PLUS, OPT_findirect_inlining, NULL, 1 },
diff --git a/gcc/testsuite/g++.dg/tree-ssa/empty-loop.C 
b/gcc/testsuite/g++.dg/tree-ssa/empty-loop.C
new file mode 100644
index 000..6b1e879
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/empty-loop.C
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-cddce2 -ffinite-loops" } */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+using namespace std;
+
+int foo (vector , list , set , map 
)
+{
+  for 

[PATCH V4] Find constant definition for by-ref argument using dominance information (PR ipa/90401)

2019-06-10 Thread Feng Xue OS
> For future reference, there should be two spaces at the end of the sentence
> before */.  You can use gcc/contrib/check_GNU_style.sh foo.patch to catch
> stuff like this before posting a final patch.

It's good. Thanks for pointing it out.

Feng

---
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 526ed45be89..a21cd737e84 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2019-06-04  Feng Xue  
+
+   PR ipa/90401
+   * ipa-prop.c (add_to_agg_contents_list): New function.
+   (clobber_by_agg_contents_list_p): Likewise.
+   (extract_mem_content): Likewise.
+   (get_place_in_agg_contents_list): Delete.
+   (determine_known_aggregate_parts): Renamed from
+   determine_locally_known_aggregate_parts.  New parameter
+   aa_walk_budget_p.
+
 2019-06-04  Segher Boessenkool  
 
* config/rs6000/constraints.md (define_register_constraint "wp"):
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index d86c2f3db55..a53a6ec5f32 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -1458,7 +1458,7 @@ get_ssa_def_if_simple_copy (tree rhs)
   return rhs;
 }
 
-/* Simple linked list, describing known contents of an aggregate beforere
+/* Simple linked list, describing known contents of an aggregate before
call.  */
 
 struct ipa_known_agg_contents_list
@@ -1471,41 +1471,48 @@ struct ipa_known_agg_contents_list
   struct ipa_known_agg_contents_list *next;
 };
 
-/* Find the proper place in linked list of ipa_known_agg_contents_list
-   structures where to put a new one with the given LHS_OFFSET and LHS_SIZE,
-   unless there is a partial overlap, in which case return NULL, or such
-   element is already there, in which case set *ALREADY_THERE to true.  */
+/* Add a known content item into a linked list of ipa_known_agg_contents_list
+   structure, in which all elements are sorted ascendingly by offset.  */
 
-static struct ipa_known_agg_contents_list **
-get_place_in_agg_contents_list (struct ipa_known_agg_contents_list **list,
-   HOST_WIDE_INT lhs_offset,
-   HOST_WIDE_INT lhs_size,
-   bool *already_there)
+static inline void
+add_to_agg_contents_list (struct ipa_known_agg_contents_list **plist,
+ struct ipa_known_agg_contents_list *item)
 {
-  struct ipa_known_agg_contents_list **p = list;
-  while (*p && (*p)->offset < lhs_offset)
+  struct ipa_known_agg_contents_list *list = *plist;
+
+  for (; list; list = list->next)
 {
-  if ((*p)->offset + (*p)->size > lhs_offset)
-   return NULL;
-  p = &(*p)->next;
+  if (list->offset >= item->offset)
+   break;
+
+  plist = >next;
 }
 
-  if (*p && (*p)->offset < lhs_offset + lhs_size)
+  item->next = list;
+  *plist = item;
+}
+
+/* Check whether a given known content is clobbered by certain element in
+   a linked list of ipa_known_agg_contents_list.  */
+
+static inline bool
+clobber_by_agg_contents_list_p (struct ipa_known_agg_contents_list *list,
+   struct ipa_known_agg_contents_list *item)
+{
+  for (; list; list = list->next)
 {
-  if ((*p)->offset == lhs_offset && (*p)->size == lhs_size)
-   /* We already know this value is subsequently overwritten with
-  something else.  */
-   *already_there = true;
-  else
-   /* Otherwise this is a partial overlap which we cannot
-  represent.  */
-   return NULL;
+  if (list->offset >= item->offset)
+   return list->offset < item->offset + item->size;
+
+  if (list->offset + list->size > item->offset)
+   return true;
 }
-  return p;
+
+  return false;
 }
 
 /* Build aggregate jump function from LIST, assuming there are exactly
-   CONST_COUNT constant entries there and that th offset of the passed argument
+   CONST_COUNT constant entries there and that offset of the passed argument
is ARG_OFFSET and store it into JFUNC.  */
 
 static void
@@ -1528,26 +1535,79 @@ build_agg_jump_func_from_list (struct 
ipa_known_agg_contents_list *list,
 }
 }
 
+/* If STMT is a memory store to the object whose address is BASE, extract
+   information (offset, size, and value) into CONTENT, and return true,
+   otherwise we conservatively assume the whole object is modified with
+   unknown content, and return false.  CHECK_REF means that access to object
+   is expected to be in form of MEM_REF expression.  */
+
+static bool
+extract_mem_content (gimple *stmt, tree base, bool check_ref,
+struct ipa_known_agg_contents_list *content)
+{
+  HOST_WIDE_INT lhs_offset, lhs_size;
+  tree lhs, rhs, lhs_base;
+  bool reverse;
+
+  if (!gimple_assign_single_p (stmt))
+return false;
+
+  lhs = gimple_assign_lhs (stmt);
+  rhs = gimple_assign_rhs1 (stmt);
+
+  if (!is_gimple_reg_type (TREE_TYPE (rhs))
+  || TREE_CODE (lhs) == BIT_FIELD_REF
+  || contains_bitfld_component_ref_p (lhs))
+return false;
+
+  lhs_base = 

C++ PATCH for c++/90825 - endless recursion when evaluating sizeof

2019-06-10 Thread Marek Polacek
This test segvs since r269078, this hunk in particular:

@@ -4581,8 +4713,9 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, 
tree t,
   break;

 case SIZEOF_EXPR:
-  r = fold_sizeof_expr (t);
-  VERIFY_CONSTANT (r);
+  r = cxx_eval_constant_expression (ctx, fold_sizeof_expr (t), lval,
+   non_constant_p, overflow_p,
+   jump_target);
   break;

In a template, fold_sizeof_expr will just create a new SIZEOF_EXPR, that is the
same, but not identical; see cxx_sizeof_expr.  Then cxx_eval_constant_expression
calls itself on this new expr, then fold_sizeof_expr creates another 
SIZEOF_EXPR.
Then we call cxx_eval_constant_expression...

The call to cxx_eval_constant_expression is there to keep constexpr-vla1.C
working.  But we can avoid calling it in a template and it'll still work, and
we avoid this nasty recursion.

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

2019-06-10  Marek Polacek  

PR c++/90825 - endless recursion when evaluating sizeof.
* constexpr.c (cxx_eval_constant_expression): Don't recurse on the
result of fold_sizeof_expr in a template.

* g++.dg/cpp0x/constexpr-sizeof2.C: New test.

diff --git gcc/cp/constexpr.c gcc/cp/constexpr.c
index a2f29694462..a68aac3b531 100644
--- gcc/cp/constexpr.c
+++ gcc/cp/constexpr.c
@@ -4808,9 +4808,13 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, 
tree t,
   break;
 
 case SIZEOF_EXPR:
-  r = cxx_eval_constant_expression (ctx, fold_sizeof_expr (t), lval,
-   non_constant_p, overflow_p,
-   jump_target);
+  r = fold_sizeof_expr (t);
+  /* Don't recurse in a template, because then fold_sizeof_expr merely
+creates a new SIZEOF_EXPR, leading to an infinite recursion.  */
+  if (!processing_template_decl)
+   r = cxx_eval_constant_expression (ctx, r, lval,
+ non_constant_p, overflow_p,
+ jump_target);
   break;
 
 case COMPOUND_EXPR:
diff --git gcc/testsuite/g++.dg/cpp0x/constexpr-sizeof2.C 
gcc/testsuite/g++.dg/cpp0x/constexpr-sizeof2.C
new file mode 100644
index 000..2d3a169d28c
--- /dev/null
+++ gcc/testsuite/g++.dg/cpp0x/constexpr-sizeof2.C
@@ -0,0 +1,14 @@
+// PR c++/90825 - endless recursion when evaluating sizeof.
+// { dg-do compile { target c++11 } }
+
+class address {
+  char host_[63];
+public:
+  static constexpr unsigned buffer_size() noexcept { return sizeof(host_); }
+};
+
+template 
+void load()
+{
+  char host[address::buffer_size()];
+}


Re: [PATCH V3] Find constant definition for by-ref argument using dominance information (PR ipa/90401)

2019-06-10 Thread Marek Polacek
On Tue, Jun 11, 2019 at 01:30:41AM +, Feng Xue OS wrote:
> Some minor changes.
> 
> Feng
> 
> ---
> diff --git a/gcc/ChangeLog b/gcc/ChangeLog
> index 526ed45be89..469b54ddf93 100644
> --- a/gcc/ChangeLog
> +++ b/gcc/ChangeLog
> @@ -1,3 +1,14 @@
> +2019-06-04  Feng Xue  
> +
> + PR ipa/90401
> + * ipa-prop.c (add_to_agg_contents_list): New function.
> + (clobber_by_agg_contents_list_p): Likewise.
> + (extract_mem_content): Likewise.
> + (get_place_in_agg_contents_list): Delete.
> + (determine_known_aggregate_parts): Renamed from
> + determine_locally_known_aggregate_parts. New parameter
> + aa_walk_budget_p.
> +
>  2019-06-04  Segher Boessenkool  
>  
>   * config/rs6000/constraints.md (define_register_constraint "wp"):
> diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
> index d86c2f3db55..2fce69547dd 100644
> --- a/gcc/ipa-prop.c
> +++ b/gcc/ipa-prop.c
> @@ -1458,7 +1458,7 @@ get_ssa_def_if_simple_copy (tree rhs)
>return rhs;
>  }
>  
> -/* Simple linked list, describing known contents of an aggregate beforere
> +/* Simple linked list, describing known contents of an aggregate before
> call.  */
>  
>  struct ipa_known_agg_contents_list
> @@ -1471,41 +1471,48 @@ struct ipa_known_agg_contents_list
>struct ipa_known_agg_contents_list *next;
>  };
>  
> -/* Find the proper place in linked list of ipa_known_agg_contents_list
> -   structures where to put a new one with the given LHS_OFFSET and LHS_SIZE,
> -   unless there is a partial overlap, in which case return NULL, or such
> -   element is already there, in which case set *ALREADY_THERE to true.  */
> +/* Add a known content item into a linked list of ipa_known_agg_contents_list
> +   structure, in which all elements are sorted ascendingly by offset. */

For future reference, there should be two spaces at the end of the sentence
before */.  You can use gcc/contrib/check_GNU_style.sh foo.patch to catch
stuff like this before posting a final patch.

Thanks,
Marek


[PATCH V3] Find constant definition for by-ref argument using dominance information (PR ipa/90401)

2019-06-10 Thread Feng Xue OS
Some minor changes.

Feng

---
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 526ed45be89..469b54ddf93 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2019-06-04  Feng Xue  
+
+   PR ipa/90401
+   * ipa-prop.c (add_to_agg_contents_list): New function.
+   (clobber_by_agg_contents_list_p): Likewise.
+   (extract_mem_content): Likewise.
+   (get_place_in_agg_contents_list): Delete.
+   (determine_known_aggregate_parts): Renamed from
+   determine_locally_known_aggregate_parts. New parameter
+   aa_walk_budget_p.
+
 2019-06-04  Segher Boessenkool  
 
* config/rs6000/constraints.md (define_register_constraint "wp"):
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index d86c2f3db55..2fce69547dd 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -1458,7 +1458,7 @@ get_ssa_def_if_simple_copy (tree rhs)
   return rhs;
 }
 
-/* Simple linked list, describing known contents of an aggregate beforere
+/* Simple linked list, describing known contents of an aggregate before
call.  */
 
 struct ipa_known_agg_contents_list
@@ -1471,41 +1471,48 @@ struct ipa_known_agg_contents_list
   struct ipa_known_agg_contents_list *next;
 };
 
-/* Find the proper place in linked list of ipa_known_agg_contents_list
-   structures where to put a new one with the given LHS_OFFSET and LHS_SIZE,
-   unless there is a partial overlap, in which case return NULL, or such
-   element is already there, in which case set *ALREADY_THERE to true.  */
+/* Add a known content item into a linked list of ipa_known_agg_contents_list
+   structure, in which all elements are sorted ascendingly by offset. */
 
-static struct ipa_known_agg_contents_list **
-get_place_in_agg_contents_list (struct ipa_known_agg_contents_list **list,
-   HOST_WIDE_INT lhs_offset,
-   HOST_WIDE_INT lhs_size,
-   bool *already_there)
+static inline void
+add_to_agg_contents_list (struct ipa_known_agg_contents_list **plist,
+  struct ipa_known_agg_contents_list *item)
 {
-  struct ipa_known_agg_contents_list **p = list;
-  while (*p && (*p)->offset < lhs_offset)
+  struct ipa_known_agg_contents_list *list = *plist;
+
+  for (; list; list = list->next)
 {
-  if ((*p)->offset + (*p)->size > lhs_offset)
-   return NULL;
-  p = &(*p)->next;
+  if (list->offset >= item->offset)
+break;
+
+  plist = >next;
 }
 
-  if (*p && (*p)->offset < lhs_offset + lhs_size)
+  item->next = list;
+  *plist = item;
+}
+
+/* Check whether a given known content is clobbered by certain element in
+   a linked list of ipa_known_agg_contents_list. */
+
+static inline bool
+clobber_by_agg_contents_list_p (struct ipa_known_agg_contents_list *list,
+struct ipa_known_agg_contents_list *item)
+{
+  for (; list; list = list->next)
 {
-  if ((*p)->offset == lhs_offset && (*p)->size == lhs_size)
-   /* We already know this value is subsequently overwritten with
-  something else.  */
-   *already_there = true;
-  else
-   /* Otherwise this is a partial overlap which we cannot
-  represent.  */
-   return NULL;
+  if (list->offset >= item->offset)
+return list->offset < item->offset + item->size;
+
+  if (list->offset + list->size > item->offset)
+return true;
 }
-  return p;
+
+  return false;
 }
 
 /* Build aggregate jump function from LIST, assuming there are exactly
-   CONST_COUNT constant entries there and that th offset of the passed argument
+   CONST_COUNT constant entries there and that offset of the passed argument
is ARG_OFFSET and store it into JFUNC.  */
 
 static void
@@ -1528,26 +1535,79 @@ build_agg_jump_func_from_list (struct 
ipa_known_agg_contents_list *list,
 }
 }
 
+/* If STMT is a memory store to the object whose address is BASE, extract
+   information (offset, size, and value) into CONTENT, and return true,
+   otherwise we conservatively assume the whole object is modified with
+   unknown content, and return false. CHECK_REF means that access to object
+   is expected to be in form of MEM_REF expression. */
+
+static bool
+extract_mem_content (gimple *stmt, tree base, bool check_ref,
+ struct ipa_known_agg_contents_list *content)
+{
+  HOST_WIDE_INT lhs_offset, lhs_size;
+  tree lhs, rhs, lhs_base;
+  bool reverse;
+
+  if (!gimple_assign_single_p (stmt))
+return false;
+
+  lhs = gimple_assign_lhs (stmt);
+  rhs = gimple_assign_rhs1 (stmt);
+
+  if (!is_gimple_reg_type (TREE_TYPE (rhs))
+  || TREE_CODE (lhs) == BIT_FIELD_REF
+  || contains_bitfld_component_ref_p (lhs))
+return false;
+
+  lhs_base = get_ref_base_and_extent_hwi (lhs, _offset,
+  _size, );
+  if (!lhs_base)
+return false;
+
+  if (check_ref)
+{
+  if (TREE_CODE (lhs_base) != MEM_REF
+  || TREE_OPERAND (lhs_base, 0) 

Re: [PATCH, v2] Disable PowerPC pc-relative support until the code is checked in

2019-06-10 Thread Segher Boessenkool
On Fri, Jun 07, 2019 at 07:31:39PM -0400, Michael Meissner wrote:
> Ok, here is the revised version of the patch.  -mcpu=future sets
> -mprefixed-addr but not -mpcrel.  Using either -mpcrel or -mprefixed-addr does
> not set -mcpu=future.  I tweaked the tests for -mpcrel and -mprefixed-addr
> somewhat, and kept the changes to the testsuite.

> -/* Support for a future processor's features.  */
> +/* Support for a future processor's features.  Do not enable -mpcrel until is
> +   fully functional.  */
>  #define ISA_FUTURE_MASKS_SERVER  (ISA_3_0_MASKS_SERVER   
> \
>| OPTION_MASK_FUTURE   \
> -  | OPTION_MASK_PCREL\
>| OPTION_MASK_PREFIXED_ADDR)

"until it is".  Or just say "Do not enable -mpcrel yet." ;-)

> -  /* -mpcrel requires prefixed load/store addressing.  */
> -  if (TARGET_PCREL && !TARGET_PREFIXED_ADDR)
> +  /* -mprefixed-addr (and hence -mpcrel) requires -mcpu=future.  */
> +  if ((TARGET_PREFIXED_ADDR || TARGET_PCREL) && !TARGET_FUTURE)

You don't really need to test for PCREL here, the

> +  /* -mpcrel requires prefixed load/store addressing.  */
> +  if (TARGET_PCREL && !TARGET_PREFIXED_ADDR)

test will error in that case already.

Okay for trunk with the grammar thing fixed.  Thanks!


Segher


[PATCH] Fix i686-linux bootstrap (was Re: [PATCH 1/2] Add alloc_size for libiberty memory allocation functions.)

2019-06-10 Thread Jakub Jelinek
On Fri, Jun 07, 2019 at 09:07:39AM +0200, Martin Liška wrote:
> 2019-06-07  Martin Liska  
> 
>   * ansidecl.h:
>   (ATTRIBUTE_RESULT_SIZE_1): Define new macro.
>   (ATTRIBUTE_RESULT_SIZE_2): Likewise.
>   (ATTRIBUTE_RESULT_SIZE_1_2): Likewise.
>   * libiberty.h (xmalloc): Add RESULT_SIZE attribute.
>   (xrealloc): Likewise.
>   (xcalloc): Likewise.

This change broke i686-linux bootstrap, we get:
error: argument 1 value '4294967292' exceeds maximum object size 2147483647 
[-Werror=alloc-size-larger-than=]
error, false positive warning.
Because blocks.length () is
  unsigned length (void) const
  { return m_vec ? m_vec->length () : 0; }
we decide to jump-thread that and think the 0 value is somehow special and
the warning decides to warn, but the fact is that we don't really know
anything about it (and for such case don't warn).

The caller actually guarantees that blocks.length () is > 0 as it pushes one
basic block to the vector unconditionally, so we can work around this
warning by adding an assertion.  Not entirely happy about that, on the other
side nobody uses trans-mem and so the extra comparison and cold check
isn't that big a deal.

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

2019-06-10  Jakub Jelinek  

PR bootstrap/90819
* trans-mem.c (tm_memopt_compute_available): Add assertion
that blocks is not empty.  Formatting fix.

--- gcc/trans-mem.c.jj  2019-05-20 21:59:20.081717030 +0200
+++ gcc/trans-mem.c 2019-06-10 23:34:31.725056038 +0200
@@ -3708,9 +3708,9 @@ tm_memopt_compute_available (struct tm_r
   /* Allocate a worklist array/queue.  Entries are only added to the
  list if they were not already on the list.  So the size is
  bounded by the number of basic blocks in the region.  */
+  gcc_assert (!blocks.is_empty ());
   qlen = blocks.length () - 1;
-  qin = qout = worklist =
-XNEWVEC (basic_block, qlen);
+  qin = qout = worklist = XNEWVEC (basic_block, qlen);
 
   /* Put every block in the region on the worklist.  */
   for (i = 0; blocks.iterate (i, ); ++i)


Jakub


Re: Test for C++20 p0858 - ConstexprIterator requirements.

2019-06-10 Thread Ed Smith-Rowland via gcc-patches

On 6/10/19 2:43 AM, Ville Voutilainen wrote:

On Mon, 10 Jun 2019 at 02:53, Ed Smith-Rowland <3dw...@verizon.net> wrote:


Darn it, I had those constexpr lib patches in tree.
Attached are what I just committed to gcc-9 and passes there. Those
std::copy didn't really add anything anyway.

They added a test that *i++ = *j++ works, and that i != j works.


Ok,

Here is a version that adds back a hand written copy thing to test 
Ville's observation.


This is tested on a clean branch.

I would also like to add the same copy lines to the gcc-9 branch.

OK?

Ed


2019-06-11  Edward Smith-Rowland  <3dw...@verizon.net>

Test C++20 - p0858 ConstexprIterator requirements.
* testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc:
New test.
* testsuite/23_containers/array/requirements/constexpr_iter.cc:
New test.

diff --git 
a/libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc
 
b/libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc
index 24ab502372a..799fb0391f5 100644
--- 
a/libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc
+++ 
b/libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc
@@ -30,7 +30,11 @@ test()
   static_assert('W' == *(hw.cbegin() + 7));
 
   std::array a2{{0,0,0,0,0,0,0,0,0,0,0,0,0}};
-  std::copy(hw.begin(), hw.end(), a2.begin());
+  auto hwi = hw.begin();
+  auto hwe = hw.end();
+  auto a2i = a2.begin();
+  while (hwi != hwe)
+*a2i++ = *hwi++;
 
   return *(hw.cbegin() + 3);
 }
diff --git 
a/libstdc++-v3/testsuite/23_containers/array/requirements/constexpr_iter.cc 
b/libstdc++-v3/testsuite/23_containers/array/requirements/constexpr_iter.cc
index 88d69d2f8c7..4b5346631c9 100644
--- a/libstdc++-v3/testsuite/23_containers/array/requirements/constexpr_iter.cc
+++ b/libstdc++-v3/testsuite/23_containers/array/requirements/constexpr_iter.cc
@@ -27,9 +27,13 @@ test()
   static_assert(1 == *a1.begin());
   auto n = a1[0] * a1[1]* a1[2];
   static_assert(1 == *a1.cbegin());
-
+ 
   std::array a2{{0, 0, 0}};
-  std::copy(a1.begin(), a1.end(), a2.begin());
+  auto a1i = a1.begin();
+  auto a1e = a1.end();
+  auto a2i = a2.begin();
+  while (a1i != a1e)
+*a2i++ = *a1i++;
 
   return n;
 }


Re: Fix build with inhibit_libc (was Re: [PATCH 2/4] Implement N disk counters for single value and indirect call counters.)

2019-06-10 Thread Jakub Jelinek
On Mon, Jun 10, 2019 at 08:02:26PM +0200, Jakub Jelinek wrote:
> This change broke build without target libc.
> 
> ../../../../libgcc/libgcov-merge.c:37:6: error: conflicting types for 
> ‘__gcov_merge_single’
>37 | void __gcov_merge_single (gcov_type *counters  __attribute__ 
> ((unused)))
>   |  ^~~
> In file included from ../../../../libgcc/libgcov-merge.c:26:
> ../../../../libgcc/libgcov.h:263:13: note: previous declaration of 
> ‘__gcov_merge_single’ was here
>   263 | extern void __gcov_merge_single (gcov_type *, unsigned) 
> ATTRIBUTE_HIDDEN;
>   | ^~~
> 
> It is unclear why it has been changed, when the callers haven't been
> adjusted, nor the prototype.
> 
> So, I'd like to revert this hunk.  Tested with x86_64-linux -> nvptx-none
> cross build, ok for trunk?

Additionally successfully bootstrapped/regtested on x86_64-linux.

> 2019-06-10  Jakub Jelinek  
> 
>   * libgcov-merge.c (__gcov_merge_single): Revert previous change.
> 
> --- libgcc/libgcov-merge.c.jj 2019-06-10 19:39:29.291363550 +0200
> +++ libgcc/libgcov-merge.c2019-06-10 19:58:36.731524778 +0200
> @@ -34,9 +34,8 @@ void __gcov_merge_add (gcov_type *counte
>  #endif
>  
>  #ifdef L_gcov_merge_single
> -void __gcov_merge_single (gcov_type *counters  __attribute__ ((unused)))
> -{
> -}
> +void __gcov_merge_single (gcov_type *counters  __attribute__ ((unused)),
> +   unsigned n_counters __attribute__ ((unused))) {}
>  #endif
>  
>  #else

Jakub


[C++ PATCH] Fix C++ wrong-code due to constant_value_1 (PR c++/90810)

2019-06-10 Thread Jakub Jelinek
Hi!

My PR85077
+   if (VECTOR_TYPE_P (TREE_TYPE (x)))
+ x = fold (x);
cp_fold change apparently broke the following and similar testcases, if
split_nonconstant_init splits the initialization into a runtime part and
some CONSTRUCTOR, it clears TREE_READONLY on it, and constant_value_1
had code to avoid returning that CONSTRUCTOR as the value if not
DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P because that CONSTRUCTOR is only
part of the story.  With the PR85077 change, such CONSTRUCTORs are turned
into VECTOR_CSTs by fold though and constant_value_1 then returns the wrong
thing.

Fixed thusly, bootstrapped/regtested on x86_64-linux, ok for trunk and
9.2/8.4?

2019-06-10  Jakub Jelinek  

PR c++/90810
* init.c (constant_value_1): Handle VECTOR_CST DECL_INITIAL for
!DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P decls like CONSTRUCTOR.

* g++.dg/ext/vector37.C: New test.

--- gcc/cp/init.c.jj2019-05-23 12:57:16.624494279 +0200
+++ gcc/cp/init.c   2019-06-10 17:07:34.779366457 +0200
@@ -2339,8 +2339,11 @@ constant_value_1 (tree decl, bool strict
  || TREE_CODE (init) == STRING_CST)))
break;
   /* Don't return a CONSTRUCTOR for a variable with partial run-time
-initialization, since it doesn't represent the entire value.  */
-  if (TREE_CODE (init) == CONSTRUCTOR
+initialization, since it doesn't represent the entire value.
+Similarly for VECTOR_CSTs created by cp_folding those
+CONSTRUCTORs.  */
+  if ((TREE_CODE (init) == CONSTRUCTOR
+  || TREE_CODE (init) == VECTOR_CST)
  && !DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl))
break;
   /* If the variable has a dynamic initializer, don't use its
--- gcc/testsuite/g++.dg/ext/vector37.C.jj  2019-06-10 17:12:29.092801825 
+0200
+++ gcc/testsuite/g++.dg/ext/vector37.C 2019-06-10 17:11:35.641630817 +0200
@@ -0,0 +1,29 @@
+// PR c++/90810
+// { dg-do run }
+
+void
+foo (float x, float y)
+{
+  typedef float __attribute__ ((__vector_size__ (4 * sizeof (float)), 
__may_alias__)) V;
+  const V a = { x, x, x, x }, b = { y, y, y, y };
+  const V c = a / b;
+  if (c[0] != 6.0f || c[1] != 6.0f || c[2] != 6.0f || c[3] != 6.0f)
+__builtin_abort ();
+}
+
+void
+bar (float y)
+{
+  typedef float __attribute__ ((__vector_size__ (4 * sizeof (float)), 
__may_alias__)) V;
+  const V a = { 7.0f, 8.0f, 9.0f, 10.0f }, b = { 1.0f, 2.0f, 3.0f, y };
+  const V c = a / b;
+  if (c[0] != 7.0f || c[1] != 4.0f || c[2] != 3.0f || c[3] != 5.0f)
+__builtin_abort ();
+}
+
+int
+main ()
+{
+  foo (12.0f, 2.0f);
+  bar (2.0f);
+}

Jakub


[PATCH] Fix nvptx_output_softstack_switch (PR target/90811)

2019-06-10 Thread Jakub Jelinek
Hi!

In PTX, and accepts only .pred, .b16, .b32 and .b64 types, not .u64 etc.
Fixed thusly, bootstrapped/regtested on x86_64-linux with nvptx-none
offloading, ok for trunk and 9.2/8.4?

I'll try to figure out tomorrow if we can avoid the overaligned variables in
this specific testcase, but generally there is always the possibility of
overaligned vars.

2019-06-10  Jakub Jelinek  

PR target/90811
* config/nvptx/nvptx.c (nvptx_output_softstack_switch): Use and.b%d
instead of and.u%d.

* testsuite/libgomp.c/pr90811.c: New test.

--- gcc/config/nvptx/nvptx.c.jj 2019-03-11 22:56:55.934666848 +0100
+++ gcc/config/nvptx/nvptx.c2019-06-10 15:20:43.154588406 +0200
@@ -1475,7 +1475,7 @@ nvptx_output_softstack_switch (FILE *fil
   fputs (";\n", file);
   if (!CONST_INT_P (size) || UINTVAL (align) > GET_MODE_SIZE (DImode))
fprintf (file,
-"\t\tand.u%d %%r%d, %%r%d, -" HOST_WIDE_INT_PRINT_DEC ";\n",
+"\t\tand.b%d %%r%d, %%r%d, -" HOST_WIDE_INT_PRINT_DEC ";\n",
 bits, regno, regno, UINTVAL (align));
 }
   if (cfun->machine->has_softstack)
--- libgomp/testsuite/libgomp.c/pr90811.c.jj2019-06-10 15:43:30.464115978 
+0200
+++ libgomp/testsuite/libgomp.c/pr90811.c   2019-06-10 15:43:37.618003812 
+0200
@@ -0,0 +1,29 @@
+/* PR target/90811 */
+
+int
+main ()
+{
+  long long a[100], b[100];
+  int i;
+  for (i = 0; i < 100; i++)
+{
+  a[i] = i;
+  b[i] = i % 10;
+}
+  #pragma omp target teams distribute parallel for simd map(tofrom: a[:100], 
b[:100])
+  for (i = 0; i < 100; i++)
+{
+  long long c = 0;
+  const long long d[] = { 1, 3, 5, 7, 9 };
+  for (int j = 4; j >= 0; j--)
+ c = d[j] + b[i] * c;
+  a[i] += c;
+}
+  for (i = 0; i < 100; i++)
+{
+  const long long r[] = { 1, 26, 229, 976, 2849, 6646, 13381, 24284, 
40801, 64594 };
+  if (a[i] != r[i % 10] + (i / 10 * 10))
+   __builtin_abort ();
+}
+  return 0;
+}

Jakub


Go patch committed: Support inlining functions that use index expressions

2019-06-10 Thread Ian Lance Taylor
This patch to the Go frontend supports inlining functions that use
index expressions.  It also moves the determine_types pass on an
inlined function body to one place, rather than doing it ad hoc as
needed.  This adds 79 new inlinable functions in the standard library,
such as bytes.HasPrefix and bytes.LastIndexByte.  Bootstrapped and ran
Go testsuite on x86_64-pc-linux-gnu.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 272132)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-764fe6702f2bb8650622d4102de31058e484ecb5
+b1ae35965cadac235d7d218e689944286cccdd90
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/expressions.cc
===
--- gcc/go/gofrontend/expressions.cc(revision 272132)
+++ gcc/go/gofrontend/expressions.cc(working copy)
@@ -7110,6 +7110,12 @@ Binary_expression::do_import(Import_expr
   op = OPERATOR_BITCLEAR;
   imp->advance(4);
 }
+  else if (imp->match_c_string(")"))
+{
+  // Not a binary operator after all.
+  imp->advance(1);
+  return left;
+}
   else
 {
   go_error_at(imp->location(), "unrecognized binary operator");
@@ -12808,6 +12814,38 @@ Array_index_expression::do_get_backend(T
   return ret;
 }
 
+// Export an array index expression.
+
+void
+Array_index_expression::do_export(Export_function_body* efb) const
+{
+  efb->write_c_string("(");
+  this->array_->export_expression(efb);
+  efb->write_c_string(")[");
+
+  Type* old_context = efb->type_context();
+  efb->set_type_context(Type::lookup_integer_type("int"));
+
+  this->start_->export_expression(efb);
+  if (this->end_ == NULL)
+go_assert(this->cap_ == NULL);
+  else
+{
+  efb->write_c_string(":");
+  if (!this->end_->is_nil_expression())
+   this->end_->export_expression(efb);
+  if (this->cap_ != NULL)
+   {
+ efb->write_c_string(":");
+ this->cap_->export_expression(efb);
+   }
+}
+
+  efb->set_type_context(old_context);
+
+  efb->write_c_string("]");
+}
+
 // Dump ast representation for an array index expression.
 
 void
@@ -13068,6 +13106,31 @@ String_index_expression::do_get_backend(
 crash, bstrslice, loc);
 }
 
+// Export a string index expression.
+
+void
+String_index_expression::do_export(Export_function_body* efb) const
+{
+  efb->write_c_string("(");
+  this->string_->export_expression(efb);
+  efb->write_c_string(")[");
+
+  Type* old_context = efb->type_context();
+  efb->set_type_context(Type::lookup_integer_type("int"));
+
+  this->start_->export_expression(efb);
+  if (this->end_ != NULL)
+{
+  efb->write_c_string(":");
+  if (!this->end_->is_nil_expression())
+   this->end_->export_expression(efb);
+}
+
+  efb->set_type_context(old_context);
+
+  efb->write_c_string("]");
+}
+
 // Dump ast representation for a string index expression.
 
 void
@@ -13338,6 +13401,25 @@ Map_index_expression::get_value_pointer(
   return this->value_pointer_;
 }
 
+// Export a map index expression.
+
+void
+Map_index_expression::do_export(Export_function_body* efb) const
+{
+  efb->write_c_string("(");
+  this->map_->export_expression(efb);
+  efb->write_c_string(")[");
+
+  Type* old_context = efb->type_context();
+  efb->set_type_context(this->get_map_type()->key_type());
+
+  this->index_->export_expression(efb);
+
+  efb->set_type_context(old_context);
+
+  efb->write_c_string("]");
+}
+
 // Dump ast representation for a map index expression
 
 void
@@ -17974,6 +18056,29 @@ Expression::import_expression(Import_exp
  imp->require_c_string(")");
  expr = Expression::make_call(expr, args, is_varargs, loc);
}
+  else if (imp->match_c_string("["))
+   {
+ imp->advance(1);
+ Expression* start = Expression::import_expression(imp, loc);
+ Expression* end = NULL;
+ Expression* cap = NULL;
+ if (imp->match_c_string(":"))
+   {
+ imp->advance(1);
+ int c = imp->peek_char();
+ if (c == ':' || c == ']')
+   end = Expression::make_nil(loc);
+ else
+   end = Expression::import_expression(imp, loc);
+ if (imp->match_c_string(":"))
+   {
+ imp->advance(1);
+ cap = Expression::import_expression(imp, loc);
+   }
+   }
+ imp->require_c_string("]");
+ expr = Expression::make_index(expr, start, end, cap, loc);
+   }
   else
break;
 }
Index: gcc/go/gofrontend/expressions.h
===
--- gcc/go/gofrontend/expressions.h (revision 272127)
+++ gcc/go/gofrontend/expressions.h 

Go patch committed: Make heap expressions's write barrier conditional

2019-06-10 Thread Ian Lance Taylor
This patch by Cherry Zhang avoids always invoking the write barrier
for a heap expression.  Heap_expression::do_get_backend emits an
unconditional write barrier if the type has pointers and it is not a
stack allocation.  This patch changes it to use a write barrier for
the assignment only when write barriers are enabled.  While here, also
change it to call gcWriteBarrier instead of typedmemmove for
pointer-shaped types.

For this to work, Function::build needs to be adjusted so that
Heap_expression::do_get_backend is called when there is a parent
block.

Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 272131)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-11d96c36198b75b0485d16524d521e558cf03312
+764fe6702f2bb8650622d4102de31058e484ecb5
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/expressions.cc
===
--- gcc/go/gofrontend/expressions.cc(revision 272127)
+++ gcc/go/gofrontend/expressions.cc(working copy)
@@ -16387,17 +16387,43 @@ Heap_expression::do_get_backend(Translat
);
   Bexpression* btempref = gogo->backend()->var_expression(btemp,
  loc);
-  Bexpression* addr = gogo->backend()->address_expression(btempref, loc);
-
-  Expression* td = Expression::make_type_descriptor(etype, loc);
-  Type* etype_ptr = Type::make_pointer_type(etype);
   space = gogo->backend()->var_expression(space_temp, loc);
+  Type* etype_ptr = Type::make_pointer_type(etype);
   Expression* elhs = Expression::make_backend(space, etype_ptr, loc);
-  Expression* erhs = Expression::make_backend(addr, etype_ptr, loc);
-  Expression* call = Runtime::make_call(Runtime::TYPEDMEMMOVE, loc, 3,
-   td, elhs, erhs);
-  Bexpression* bcall = call->get_backend(context);
-  Bstatement* s = gogo->backend()->expression_statement(fndecl, bcall);
+  Expression* erhs;
+  Expression* call;
+  if (etype->is_direct_iface_type())
+{
+  // Single pointer.
+  Type* uintptr_type = Type::lookup_integer_type("uintptr");
+  erhs = Expression::make_backend(btempref, etype, loc);
+  erhs = Expression::unpack_direct_iface(erhs, loc);
+  erhs = Expression::make_unsafe_cast(uintptr_type, erhs, loc);
+  call = Runtime::make_call(Runtime::GCWRITEBARRIER, loc, 2,
+elhs, erhs);
+}
+  else
+{
+  Expression* td = Expression::make_type_descriptor(etype, loc);
+  Bexpression* addr =
+gogo->backend()->address_expression(btempref, loc);
+  erhs = Expression::make_backend(addr, etype_ptr, loc);
+  call = Runtime::make_call(Runtime::TYPEDMEMMOVE, loc, 3,
+td, elhs, erhs);
+}
+  Statement* cs = Statement::make_statement(call, false);
+
+  space = gogo->backend()->var_expression(space_temp, loc);
+  Bexpression* ref =
+gogo->backend()->indirect_expression(expr_btype, space, true, loc);
+  Expression* eref = Expression::make_backend(ref, etype, loc);
+  btempref = gogo->backend()->var_expression(btemp, loc);
+  erhs = Expression::make_backend(btempref, etype, loc);
+  Statement* as = Statement::make_assignment(eref, erhs, loc);
+
+  as = gogo->check_write_barrier(context->block(), as, cs);
+  Bstatement* s = as->get_backend(context);
+
   assn = gogo->backend()->compound_statement(edecl, s);
 }
   decl = gogo->backend()->compound_statement(decl, assn);
Index: gcc/go/gofrontend/gogo.cc
===
--- gcc/go/gofrontend/gogo.cc   (revision 272127)
+++ gcc/go/gofrontend/gogo.cc   (working copy)
@@ -6323,7 +6323,7 @@ Function::build(Gogo* gogo, Named_object
   // Variables that need to be declared for this function and their
   // initial values.
   std::vector vars;
-  std::vector var_inits;
+  std::vector var_inits;
   std::vector var_decls_stmts;
   for (Bindings::const_definitions_iterator p =
 this->block_->bindings()->begin_definitions();
@@ -6366,7 +6366,7 @@ Function::build(Gogo* gogo, Named_object
  loc);
   if ((*p)->var_value()->is_in_heap())
 parm_ref = Expression::make_heap_expression(parm_ref, loc);
-  var_inits.push_back(parm_ref->get_backend());
+  var_inits.push_back(parm_ref);
}
  else if ((*p)->var_value()->is_in_heap())
{
@@ -6383,7 +6383,7 @@ Function::build(Gogo* gogo, 

Go patch committed: Permit inlining functions with labels and goto statements

2019-06-10 Thread Ian Lance Taylor
This patch to the Go fronted permits inlining functions with labels
and goto statements.  This permits inlining functions with for loops
and some switches, as they are lowered to if and goto statements
before exporting them.  This by itself only adds three new inlinable
functions in the standard library: sort.Search,
context.(*emptyCtx).String, and
cmd/go/internal/work.(*Builder).disableBuildID.  Bootstrapped and ran
Go testsuite on x86_64-pc-linux-gnu.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 272130)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-3f7dcb98df3ce1d4e02d0072fd21e70dc08351db
+11d96c36198b75b0485d16524d521e558cf03312
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/export.cc
===
--- gcc/go/gofrontend/export.cc (revision 272127)
+++ gcc/go/gofrontend/export.cc (working copy)
@@ -1326,3 +1326,26 @@ Export_function_body::temporary_index(co
   go_assert(p != this->temporary_indexes_.end());
   return p->second;
 }
+
+// Return the index of an unnamed label.  If it doesn't already have
+// an index, give it one.
+
+unsigned int
+Export_function_body::unnamed_label_index(const Unnamed_label* label)
+{
+  unsigned int next = this->next_label_index_;
+  std::pair val(label, next);
+  std::pair ins =
+this->label_indexes_.insert(val);
+  if (!ins.second)
+return ins.first->second;
+  else
+{
+  if (next > 0x7fff)
+   go_error_at(label->location(),
+   "too many unnamed labels in export data");
+  ++this->next_label_index_;
+  return next;
+}
+}
Index: gcc/go/gofrontend/export.h
===
--- gcc/go/gofrontend/export.h  (revision 272127)
+++ gcc/go/gofrontend/export.h  (working copy)
@@ -21,6 +21,7 @@ class Package;
 class Import_init_set;
 class Backend;
 class Temporary_statement;
+class Unnamed_label;
 
 // Codes used for the builtin types.  These are all negative to make
 // them easily distinct from the codes assigned by Export::write_type.
@@ -309,7 +310,8 @@ class Export_function_body : public Stri
  public:
   Export_function_body(Export* exp, int indent)
 : exp_(exp), body_(), type_context_(NULL), next_temporary_index_(0),
-  temporary_indexes_(), indent_(indent)
+  temporary_indexes_(), next_label_index_(0), label_indexes_(),
+  indent_(indent)
   { }
 
   // Write a character to the body.
@@ -373,6 +375,11 @@ class Export_function_body : public Stri
   unsigned int
   temporary_index(const Temporary_statement*);
 
+  // Return the index of an unnamed label.  If it doesn't already have
+  // an index, give it one.
+  unsigned int
+  unnamed_label_index(const Unnamed_label*);
+
   // Return a reference to the completed body.
   const std::string&
   body() const
@@ -389,6 +396,10 @@ class Export_function_body : public Stri
   unsigned int next_temporary_index_;
   // Map temporary statements to indexes.
   Unordered_map(const Temporary_statement*, unsigned int) temporary_indexes_;
+  // Index to give to the next unnamed label.
+  unsigned int next_label_index_;
+  // Map unnamed labels to indexes.
+  Unordered_map(const Unnamed_label*, unsigned int) label_indexes_;
   // Current indentation level: the number of spaces before each statement.
   int indent_;
 };
Index: gcc/go/gofrontend/import.cc
===
--- gcc/go/gofrontend/import.cc (revision 272127)
+++ gcc/go/gofrontend/import.cc (working copy)
@@ -1612,6 +1612,19 @@ Import_function_body::read_type()
   return type;
 }
 
+// Return the next size to use for a vector mapping indexes to values.
+
+size_t
+Import_function_body::next_size(size_t have)
+{
+  if (have == 0)
+return 8;
+  else if (have < 256)
+return have * 2;
+  else
+return have + 64;
+}
+
 // Record the index of a temporary statement.
 
 void
@@ -1619,16 +1632,11 @@ Import_function_body::record_temporary(T
   unsigned int idx)
 {
   size_t have = this->temporaries_.size();
-  if (static_cast(idx) >= have)
+  while (static_cast(idx) >= have)
 {
-  size_t want;
-  if (have == 0)
-   want = 8;
-  else if (have < 256)
-   want = have * 2;
-  else
-   want = have + 64;
+  size_t want = Import_function_body::next_size(have);
   this->temporaries_.resize(want, NULL);
+  have = want;
 }
   this->temporaries_[idx] = temp;
 }
@@ -1642,3 +1650,25 @@ Import_function_body::temporary_statemen
 return NULL;
   return this->temporaries_[idx];
 }
+
+// Return an unnamed label given an index, defining the label if we
+// haven't seen it already.
+
+Unnamed_label*
+Import_function_body::unnamed_label(unsigned int idx, 

Re: [PATCH] include MEM_REF type in tree dumps (PR 90676)

2019-06-10 Thread Martin Sebor

On 6/10/19 1:29 PM, Jakub Jelinek wrote:

On Mon, Jun 10, 2019 at 01:23:28PM -0600, Martin Sebor wrote:

+  else if (integer_zerop (TREE_OPERAND (node, 1))
+  /* Dump the types of INTEGER_CSTs explicitly, for we can't
+ infer them and MEM_ATTR caching will share MEM_REFs
+ with differently-typed op0s.  */
+  && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
+  /* Released SSA_NAMES have no TREE_TYPE.  */
+  && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
+  /* Same pointer types, but ignoring POINTER_TYPE vs.
+ REFERENCE_TYPE.  */
+  && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
+  == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1
+  && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
+  == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1
+  && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
+  == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1
+  /* Same value types ignoring qualifiers.  */
+  && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
+  == TYPE_MAIN_VARIANT
+  (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)


You should be using types_compatible_p rather than type equality, that is
all GIMPLE cares about.


The code above predates my change, I just factored it out into
a separate function; it does make the diff bigger.  The code
I introduced only adds the <...> if the size of the access
differs from the size of the operand. I used type sizes rather
than testing their compatibility to minimize the number of tests
that might need updating.

This is the salient bit:

+  pp_string (pp, "MEM");
+
+  tree nodetype = TREE_TYPE (node);
+  tree op0 = TREE_OPERAND (node, 0);
+  tree op1 = TREE_OPERAND (node, 1);
+  tree op1type = TYPE_MAIN_VARIANT (TREE_TYPE (op1));
+
+  if (!tree_int_cst_equal (TYPE_SIZE (nodetype),
+  TYPE_SIZE (TREE_TYPE (op1type
+   {
+ pp_string (pp, " <");
+ /* If the size of the type of the operand is not the same
+as the size of the MEM_REF expression include the type
+of the latter similar to the TDF_GIMPLE output to make
+it clear how many bytes of memory are being accessed.  */
+ dump_generic_node (pp, nodetype, spc, flags | TDF_SLIM, false);
+ pp_string (pp, "> ");
+   }

Martin


Re: [C++ PATCH] Added test for c++/87250

2019-06-10 Thread Marek Polacek
On Mon, Jun 10, 2019 at 04:27:32PM -0400, Matthew Beliveau wrote:
> My test is the result of reducing a file with just "include ",
> just like in the PR.
> 
> It was fixed in r269059 which added a similar test, except mine does
> not use inheritance and is a bit simpler. So I figured it wouldn't
> hurt to cover more scenarios for this ICE.
> 
> I ran the test in my build directory and received 4 passes and 1
> unsupported test, which was expected.

> Bootstrapped/regtested on x86_64-linux, ok for trunk?
> 
> 2019-06-10  Matthew Beliveau  
>   PR c++/87250
>   * g++.dg/cpp0x/pr87250.C: New test.

For future reference: there should be a blank line after the first line.

> diff --git gcc/testsuite/g++.dg/cpp0x/pr87250.C 
> gcc/testsuite/g++.dg/cpp0x/pr87250.C
> new file mode 100644
> index 000..fe4bf1407de
> --- /dev/null
> +++ gcc/testsuite/g++.dg/cpp0x/pr87250.C
> @@ -0,0 +1,12 @@
> +// PR c++/87250
> +// { dg-do compile { target c++11 } }
> +// { dg-options "-Os -fsyntax-only" }
> +
> +template  struct a {
> +  constexpr a(int) {}
> +};
> +template  struct atomic;
> +template <> struct atomic {
> +  a b;
> +  constexpr atomic(bool c) : b(c) {}
> +};

Thanks, applied.

Marek


Go patch committed: Use gcWriteBarrier for pointer-shaped struct/array

2019-06-10 Thread Ian Lance Taylor
This patch by Cherry Zhang changes the Go frontend to use
gcWriteBarrier for pointer-shaped struct/array values.  If a
struct/array is pointer-shaped (i.e. having a single field that is
pointer-shaped), we can use gcWriteBarrier instead of typedmemmove for
the write barrier.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 272127)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-a32739aadf0c7a65fcd5d5b6d0a0d206bff24a4f
+3f7dcb98df3ce1d4e02d0072fd21e70dc08351db
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/wb.cc
===
--- gcc/go/gofrontend/wb.cc (revision 272127)
+++ gcc/go/gofrontend/wb.cc (working copy)
@@ -955,14 +955,21 @@ Gogo::assign_with_write_barrier(Function
   // fallthrough
 
 case Type::TYPE_STRUCT:
-  {
-// TODO: split assignments for small struct/array?
-   rhs = Expression::make_unary(OPERATOR_AND, rhs, loc);
-   rhs->unary_expression()->set_does_not_escape();
-   call = Runtime::make_call(Runtime::TYPEDMEMMOVE, loc, 3,
- Expression::make_type_descriptor(type, loc),
- lhs, rhs);
-  }
+  if (type->is_direct_iface_type())
+{
+  rhs = Expression::unpack_direct_iface(rhs, loc);
+  rhs = Expression::make_unsafe_cast(uintptr_type, rhs, loc);
+  call = Runtime::make_call(Runtime::GCWRITEBARRIER, loc, 2, lhs, rhs);
+}
+  else
+{
+  // TODO: split assignments for small struct/array?
+  rhs = Expression::make_unary(OPERATOR_AND, rhs, loc);
+  rhs->unary_expression()->set_does_not_escape();
+  call = Runtime::make_call(Runtime::TYPEDMEMMOVE, loc, 3,
+Expression::make_type_descriptor(type, 
loc),
+lhs, rhs);
+}
   break;
 }
 


[C++ PATCH] Added test for c++/87250

2019-06-10 Thread Matthew Beliveau
My test is the result of reducing a file with just "include ",
just like in the PR.

It was fixed in r269059 which added a similar test, except mine does
not use inheritance and is a bit simpler. So I figured it wouldn't
hurt to cover more scenarios for this ICE.

I ran the test in my build directory and received 4 passes and 1
unsupported test, which was expected.
Bootstrapped/regtested on x86_64-linux, ok for trunk?

2019-06-10  Matthew Beliveau  
	PR c++/87250
	* g++.dg/cpp0x/pr87250.C: New test.

diff --git gcc/testsuite/g++.dg/cpp0x/pr87250.C gcc/testsuite/g++.dg/cpp0x/pr87250.C
new file mode 100644
index 000..fe4bf1407de
--- /dev/null
+++ gcc/testsuite/g++.dg/cpp0x/pr87250.C
@@ -0,0 +1,12 @@
+// PR c++/87250
+// { dg-do compile { target c++11 } }
+// { dg-options "-Os -fsyntax-only" }
+
+template  struct a {
+  constexpr a(int) {}
+};
+template  struct atomic;
+template <> struct atomic {
+  a b;
+  constexpr atomic(bool c) : b(c) {}
+};


Re: [PATCH] Improve PTA flow-sensitivity (for the return stmt)

2019-06-10 Thread Marc Glisse

On Wed, 5 Jun 2019, Richard Biener wrote:


The following was inspired by Marins work on escapes of locals
and the discussion there.  It teaches points-to analysis that
the point of function return is special and thus escapes through
that a) do not influence other points-to solutions, b) can be
pruned of all locals.

This is one example of reasonably simple "post-processing".

The effects are small, I've done statistics, counting the number
of variables we do not mark escaped only after this patch.  This
number is usually zero, sometimes one and a few cases more
(but never more than 11) during bootstrap:

0 95830
1 19268
2 19
3 2
5 2
6 1
8 1
11 1

so not sure if it is worth all the effort.  It does allow us
to do more DSE but that requires the accesses to be indirect
which is not often true for locals.


IIUC, if we did not have IPA and PT was used only to check for potential 
aliasing, we could skip return statements entirely. In that sense, it may 
sound worth working around the penalty imposed by the other uses, although 
after inlining the cases where this matters may be rare.


However, the patch doesn't really seem to disable much of the impact of a 
return statement. If I randomly try


int g;
int*f(int**x){
  int*p=*x;
  int*q=__builtin_malloc(4);
  *p=4;*q=5;g=*p;*p=6;
#ifdef OK
  int volatile i=*q;
  int*volatile v=q;
  return 0;
#else
  return q;
#endif
}

With -DOK, q does not escape, we know that p and q do not alias, and we 
simplify quite a bit. Without -DOK, q does escape, and we simplify 
nothing. Replacing malloc with alloca works, but returning a pointer to a 
local variable is not really an interesting case...


Maintaining 2 escaped sets (with/without returns) would be overkill for 
this, unless it was part of a wider flow-sensitivity strategy.


--
Marc Glisse


Go patch committed: Make escape analysis work with imported functions

2019-06-10 Thread Ian Lance Taylor
This patch by Cherry Zhang fixes the Go frontend to make escape
analysis work with imported inlineable functions.

The escape analysis pass was written before we imported inlineable
function bodies, and in some places it skipped functions that are not
in the local package.  Now that there are imported function bodies,
make the escape analysis work with them.

Note that it is necessary for the escape analysis to run on imported
function bodies, even if they are already tagged.  The tags only have
the information of the parameters (receiver, results), but not the
internal nodes, e.g. local variables.  We still need to do the
analysis to get all the information.  (In the future maybe we could
export/import escape info for internal nodes also, then we don't need
to redo the analysis.)

Also add assertions to ensure that if we analyze the same function in
multiple places, they'd better agree with each other.

Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 272055)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-b79e9e79fddc9040ab58c7c518eb08454f308def
+a32739aadf0c7a65fcd5d5b6d0a0d206bff24a4f
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/escape.cc
===
--- gcc/go/gofrontend/escape.cc (revision 271983)
+++ gcc/go/gofrontend/escape.cc (working copy)
@@ -2773,15 +2773,8 @@ Gogo::assign_connectivity(Escape_context
   if (!p->type()->has_pointer())
 continue;
 
-  // External function?  Parameters must escape unless //go:noescape is 
set.
-  // TODO(cmang): Implement //go:noescape directive.
-  if (fn->package() != NULL)
-   param_node->set_encoding(Node::ESCAPE_HEAP);
-  else
-{
-  param_node->set_encoding(Node::ESCAPE_NONE);
-  context->track(param_node);
-}
+  param_node->set_encoding(Node::ESCAPE_NONE);
+  context->track(param_node);
 }
 
   Escape_analysis_loop el;
@@ -3319,9 +3312,6 @@ Escape_analysis_tag::tag(Named_object* f
 {
   // External functions are assumed unsafe
   // unless //go:noescape is given before the declaration.
-  if (fn->package() != NULL)
-return;
-
   if (fn->is_function_declaration())
 {
   Function_declaration* fdcl = fn->func_declaration_value();
Index: gcc/go/gofrontend/types.h
===
--- gcc/go/gofrontend/types.h   (revision 271983)
+++ gcc/go/gofrontend/types.h   (working copy)
@@ -1494,7 +1494,12 @@ class Typed_identifier
   // Set the escape note.
   void
   set_note(const std::string& note)
-  { this->note_ = new std::string(note); }
+  {
+if (this->note_ != NULL)
+  go_assert(*this->note_ == note);
+else
+  this->note_ = new std::string(note);
+  }
 
  private:
   // Identifier name.


Re: [PATCH] include MEM_REF type in tree dumps (PR 90676)

2019-06-10 Thread Jakub Jelinek
On Mon, Jun 10, 2019 at 01:23:28PM -0600, Martin Sebor wrote:
> +  else if (integer_zerop (TREE_OPERAND (node, 1))
> +/* Dump the types of INTEGER_CSTs explicitly, for we can't
> +   infer them and MEM_ATTR caching will share MEM_REFs
> +   with differently-typed op0s.  */
> +&& TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
> +/* Released SSA_NAMES have no TREE_TYPE.  */
> +&& TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
> +/* Same pointer types, but ignoring POINTER_TYPE vs.
> +   REFERENCE_TYPE.  */
> +&& (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
> +== TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1
> +&& (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
> +== TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1
> +&& (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
> +== TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1
> +/* Same value types ignoring qualifiers.  */
> +&& (TYPE_MAIN_VARIANT (TREE_TYPE (node))
> +== TYPE_MAIN_VARIANT
> +(TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)

You should be using types_compatible_p rather than type equality, that is
all GIMPLE cares about.

Jakub


Re: [PATCH] include MEM_REF type in tree dumps (PR 90676)

2019-06-10 Thread Martin Sebor

The attached update adds the MEM_REF type in pointy braces like
in the -gimple format, but without the access size:

  MEM  [(char *)] = 1;

Martin

On 6/4/19 4:57 AM, Richard Biener wrote:

On Mon, Jun 3, 2019 at 5:13 PM Martin Sebor  wrote:


On 6/3/19 4:34 AM, Richard Biener wrote:

On Mon, Jun 3, 2019 at 10:57 AM Jakub Jelinek  wrote:


On Mon, Jun 03, 2019 at 10:36:42AM +0200, Richard Biener wrote:

To avoid this confusion the attached patch adds to the dump
a cast to the MEM_REF type for accesses whose size is not equal
to the size of the operand (when the sizes are the same no new
cast is prepended).  The effect is that with store merging in
effect, the dump for the above becomes

 MEM[(short int *)(char *)] = 1;


I think this is confusing syntax.  Iff you absolutely refuse to
make the -gimple dump the default for MEM_REF and you insist
on fixing this issue then please follow how we dump VIEW_CONVERT_EXPR
which is the only other tree code we dump the access type, thus


I must say I prefer the current MEM[ over the -gimple for human readable
dumps.


Sure, but then why ask for all information to be present when in the cases
you are curious you can look at -gimple dumps?  A similar thing I've
hacked the pretty printer locally for debugging in the past is alignment info.


   MEM[(char *)] = 1;


Wouldn't that be
MEM[(char *)] instead?


Err, yes.


Couldn't we do it only if the TREE_TYPE (TREE_TYPE (TREE_OPERAND (mem, 1)))
is not compatible with TREE_TYPE (mem), so keep what we were doing in most
cases?


We could.  Like we dump MEM_REF as * in some cases.

The question is still why fix things half-way if a complete solution
is already there?


Because it restores the important detail for those of us who
are accustomed to the "legacy" format.  That's without a doubt
the majority of users.  Note that godbolt.org only exposes
the classic dumps and doesn't make it possible to select
the -gimple form.

Those with a preference for the -gimple syntax are presumably
already using the -gimple dumps so they shouldn't be bothered
by a change to the legacy format.

But those with a preference for the traditional syntax will
not appreciate having the syntax changed.  Scripts that parse
those dumps (like GCC's own test harness) have a reasonable
chance of continuing to be able to parse the syntax even with
the additional cast.  They will certainly not be able to parse
it if it changes to MEM(...)).

But if you refuse to accept the patch as is and insist on
the syntax with the pointy brackets please let me know.  I
think it's more important get the size of the access restored
than the details of the syntax so I'm willing to spend the time
to adjust the fix, even at the risk of breaking scripts and
making some users unhappy.


I think introducing inconsistencies (and I find two "casts"
confusing as well) with existing VIEW_CONVERT_EXPR
dumping isn't good.  So yes, I'd rather prefer

MEM  [(alias-pointer-type) ptr]

note access-type isn't a pointer type to the access type.

I can definitely live with this incremental but consistent change.
Also consider eliding access-type dumping as Jakub suggested
(when equal to *alias-pointer-type).

As said in the PR dump format changes have the chance
to make testcases testing for sth _not_ to appear no longer
testing what they want to test for (one reason those testcases
are broken).  A quick grep for MEM on a scan-*-dump-not
might reveal candidates that could need a second look.

Note that it was pure laziness on my side that I didn't change
the "legacy" format for the way the GIMPLE FE likes it :/
And I feel sorry about that.

Richard.


Martin



Btw, VIEW_CONVERT dumping uses () instead of [], that I used
[] when I introduced MEM_REF was probably a mistake...
Is it just the parens kind you dislike?

Richard.



  Jakub




PR middle-end/90676 - default GIMPLE dumps lack information

gcc/ChangeLog:

	PR middle-end/90676
	* tree-pretty-print.c (dump_mem_ref): New function.  Include
	MEM_REF type in output when different size than operand.
	(dump_generic_node): Move code to dump_mem_ref and call it.

gcc/testsuite/ChangeLog:

	PR middle-end/90676
	* gcc.dg/tree-ssa/dump-6.c: New test.
	* g++.dg/tree-ssa/pr19807.C: Adjust expected output.
	* g++.dg/tree-ssa/ssa-dse-1.C: Same.
	* gcc.dg/tree-prof/stringop-2.c
	* gcc.dg/tree-ssa/pr30375.c: Same.
	* gcc.dg/tree-ssa/slsr-27.c (f): Same.
	* gcc.dg/tree-ssa/slsr-28.c (f): Same.
	* gcc.dg/tree-ssa/slsr-29.c (f): Same.
	* gcc.dg/tree-ssa/ssa-dse-24.c: Same.

diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr19807.C b/gcc/testsuite/g++.dg/tree-ssa/pr19807.C
index cbe06b4ce62..10de295e14d 100644
--- a/gcc/testsuite/g++.dg/tree-ssa/pr19807.C
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr19807.C
@@ -11,7 +11,8 @@ void foo(void)
 	z = 1 + [1];
 }
 
-/* { dg-final { scan-tree-dump-times "\\\[\\\(void .\\\) \\\+ 8B\\\]" 3 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "\\\[\\\(void .\\\) \\\+ 8B\\\]" 3 "optimized" { target { 

[PATCH, i386]: Improve and modernize ABS/NEG patterns

2019-06-10 Thread Uros Bizjak
Attached patch improves ABS/NEG expander to emit clobber that enables
ABS/NEG with integer registers also when SSE is disabled. The patch
modernizes ABS/NEG insn patterns and splitters to use absneg code
iterator and relevant mode iterators. Additionally, the patch enables
three operand AVX instructions with SSE registers.

2019-06-10  Uroš Bizjak  

* config/i386/i386-protos.h (ix86_split_fp_absneg_operator):
New prototype.
* config/i386/i386-expand.c (ix86_expand_fp_absneg_operator):
Emit clobber also for non-sse operations.
(ix86_split_fp_absneg_operator): New function.
* config/i386/i386.md (SSEMODEF): New mode iterator.
(ssevecmodef): New mode attribute.
(tf2): Use absneg code iterator.
(*tf2_1): Rename from *absnegtf3_sse. Use absneg code iterator.
Add three-operand AVX alternatives.
(*2_i387_1): Rename from *absnegxf2_i387.
Use absneg code iterator and X87MODEF mode iterator.
(absneg fp_reg non-sse splitter): Call absneg code iterator
and X87MODEF mode iterator.
(absneg general_reg non-sse splitter): Use absneg code iterator
and X87MODEF mode iterator.  Use ix86_split_fp_absneg_operator.
(*2_1): Rename from *absneg2.  Use absneg
code iterator.  Add three-operand AVX alternative.
(absneg sse_reg splitter): Use absneg code iterator
and SSEMODEF mode iterator.  Handle AVX operands.
(absneg fp_reg splitter): Use absneg code iterator
and MODEF mode iterator.
(absneg general_reg splitter): Merge splitters using MODEF mode
iterator.  Use absneg code iterator.  Call
ix86_split_fp_absneg_operator.
(*2_i387): Rename from *2_1.
Do not enable for non-sse modes before reload.
(CSGNMODE): Remove.
(CSGNVMODE): Ditto.
(copysing3): Use SSEMODEF instead of CSGNMODE and
ssevecmodef mode attribute instaed of CSGNVMODE.
(copysign3_const): Ditto.
(copysign3_var): Ditto.
* config/i386/i386.md (*2): Rename from *absneg2.
Use absneg code iterator.  Simplify code using std::swap.
* config/i386/predicates.md (absneg_operator): Remove.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Committed to mainline SVN.

Uros.
Index: config/i386/i386-expand.c
===
--- config/i386/i386-expand.c   (revision 272119)
+++ config/i386/i386-expand.c   (working copy)
@@ -1704,10 +1704,11 @@ void
 ix86_expand_fp_absneg_operator (enum rtx_code code, machine_mode mode,
rtx operands[])
 {
-  rtx mask, set, dst, src;
+  rtx set, dst, src;
   bool use_sse = false;
   bool vector_mode = VECTOR_MODE_P (mode);
   machine_mode vmode = mode;
+  rtvec par;
 
   if (vector_mode)
 use_sse = true;
@@ -1722,13 +1723,6 @@ ix86_expand_fp_absneg_operator (enum rtx_code code
vmode = V2DFmode;
 }
 
-  /* NEG and ABS performed with SSE use bitwise mask operations.
- Create the appropriate mask now.  */
-  if (use_sse)
-mask = ix86_build_signbit_mask (vmode, vector_mode, code == ABS);
-  else
-mask = NULL_RTX;
-
   dst = operands[0];
   src = operands[1];
 
@@ -1735,11 +1729,13 @@ ix86_expand_fp_absneg_operator (enum rtx_code code
   set = gen_rtx_fmt_e (code, mode, src);
   set = gen_rtx_SET (dst, set);
 
-  if (mask)
+  if (use_sse)
 {
-  rtx use, clob;
-  rtvec par;
+  rtx mask, use, clob;
 
+  /* NEG and ABS performed with SSE use bitwise mask operations.
+Create the appropriate mask now.  */
+  mask = ix86_build_signbit_mask (vmode, vector_mode, code == ABS);
   use = gen_rtx_USE (VOIDmode, mask);
   if (vector_mode)
par = gen_rtvec (2, set, use);
@@ -1748,12 +1744,106 @@ ix86_expand_fp_absneg_operator (enum rtx_code code
   clob = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (CCmode, FLAGS_REG));
  par = gen_rtvec (3, set, use, clob);
 }
-  emit_insn (gen_rtx_PARALLEL (VOIDmode, par));
 }
   else
-emit_insn (set);
+{
+  rtx clob;
+
+  /* Changing of sign for FP values is doable using integer unit too.  */
+  clob = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (CCmode, FLAGS_REG));
+  par = gen_rtvec (2, set, clob);
+}
+
+  emit_insn (gen_rtx_PARALLEL (VOIDmode, par));
 }
 
+/* Deconstruct a floating point ABS or NEG operation
+   with integer registers into integer operations.  */
+
+void
+ix86_split_fp_absneg_operator (enum rtx_code code, machine_mode mode,
+  rtx operands[])
+{
+  enum rtx_code absneg_op;
+  rtx dst, set;
+
+  gcc_assert (operands_match_p (operands[0], operands[1]));
+
+  switch (mode)
+{
+case E_SFmode:
+  dst = gen_lowpart (SImode, operands[0]);
+
+  if (code == ABS)
+   {
+ set = gen_int_mode (0x7fff, SImode);
+ absneg_op = AND;
+   }
+  else
+   {
+ set = gen_int_mode (0x8000, SImode);
+ absneg_op = XOR;
+   }
+  set = gen_rtx_fmt_ee (absneg_op, SImode, dst, 

Re: [PATCH][RFC] Sanitize equals and hash functions in hash-tables.

2019-06-10 Thread Jason Merrill
On Mon, Jun 10, 2019 at 3:08 AM Martin Liška  wrote:
> On 6/7/19 11:43 PM, Jason Merrill wrote:
> > On Fri, Jun 7, 2019 at 8:14 AM Martin Liška  wrote:
> >> On 6/7/19 2:09 PM, Richard Biener wrote:
> >>> On Fri, Jun 7, 2019 at 2:03 PM Martin Liška  wrote:
>  On 6/7/19 10:57 AM, Richard Biener wrote:
> > On Mon, Jun 3, 2019 at 3:35 PM Martin Liška  wrote:
> >> On 6/1/19 12:06 AM, Jeff Law wrote:
> >>> On 5/22/19 3:13 AM, Martin Liška wrote:
>  On 5/21/19 1:51 PM, Richard Biener wrote:
> > On Tue, May 21, 2019 at 1:02 PM Martin Liška  wrote:
> >>
> >> On 5/21/19 11:38 AM, Richard Biener wrote:
> >>> On Tue, May 21, 2019 at 12:07 AM Jeff Law  wrote:
> 
>  On 5/13/19 1:41 AM, Martin Liška wrote:
> > On 11/8/18 9:56 AM, Martin Liška wrote:
> >> On 11/7/18 11:23 PM, Jeff Law wrote:
> >>> On 10/30/18 6:28 AM, Martin Liška wrote:
>  On 10/30/18 11:03 AM, Jakub Jelinek wrote:
> > On Mon, Oct 29, 2018 at 04:14:21PM +0100, Martin Liška 
> > wrote:
> >> +hashtab_chk_error ()
> >> +{
> >> +  fprintf (stderr, "hash table checking failed: "
> >> +   "equal operator returns true for a pair "
> >> +   "of values with a different hash value");
> > BTW, either use internal_error here, or at least if using 
> > fprintf
> > terminate with \n, in your recent mail I saw:
> > ...different hash valueduring RTL pass: vartrack
> > ^^
>  Sure, fixed in attached patch.
> 
>  Martin
> 
> >> +  gcc_unreachable ();
> >> +}
> >   Jakub
> >
>  0001-Sanitize-equals-and-hash-functions-in-hash-tables.patch
> 
>  From 0d9c979c845580a98767b83c099053d36eb49bb9 Mon Sep 17 
>  00:00:00 2001
>  From: marxin 
>  Date: Mon, 29 Oct 2018 09:38:21 +0100
>  Subject: [PATCH] Sanitize equals and hash functions in 
>  hash-tables.
> 
>  ---
>   gcc/hash-table.h | 40 
>  +++-
>   1 file changed, 39 insertions(+), 1 deletion(-)
> 
>  diff --git a/gcc/hash-table.h b/gcc/hash-table.h
>  index bd83345c7b8..694eedfc4be 100644
>  --- a/gcc/hash-table.h
>  +++ b/gcc/hash-table.h
>  @@ -503,6 +503,7 @@ private:
> 
> value_type *alloc_entries (size_t n CXX_MEM_STAT_INFO) 
>  const;
> value_type *find_empty_slot_for_expand (hashval_t);
>  +  void verify (const compare_type , hashval_t 
>  hash);
> bool too_empty_p (unsigned int);
> void expand ();
> static bool is_deleted (value_type )
>  @@ -882,8 +883,12 @@ hash_table
> if (insert == INSERT && m_size * 3 <= m_n_elements * 4)
>   expand ();
> 
>  -  m_searches++;
>  +#if ENABLE_EXTRA_CHECKING
>  +if (insert == INSERT)
>  +  verify (comparable, hash);
>  +#endif
> 
>  +  m_searches++;
> value_type *first_deleted_slot = NULL;
> hashval_t index = hash_table_mod1 (hash, 
>  m_size_prime_index);
> hashval_t hash2 = hash_table_mod2 (hash, 
>  m_size_prime_index);
>  @@ -930,6 +935,39 @@ hash_table
> return _entries[index];
>   }
> 
>  +#if ENABLE_EXTRA_CHECKING
>  +
>  +/* Report a hash table checking error.  */
>  +
>  +ATTRIBUTE_NORETURN ATTRIBUTE_COLD
>  +static void
>  +hashtab_chk_error ()
>  +{
>  +  fprintf (stderr, "hash table checking failed: "
>  + "equal operator returns true for a pair "
>  + "of values with a different hash value\n");
>  +  gcc_unreachable ();
>  +}
> >>> I think an internal_error here is probably still better than 
> >>> a simple
> >>> fprintf, even if the fprintf is terminated with a \n :-)
> >> Fully agree with that, but I see a lot of build errors when 
> >> using internal_error.
> >>

Fix build with inhibit_libc (was Re: [PATCH 2/4] Implement N disk counters for single value and indirect call counters.)

2019-06-10 Thread Jakub Jelinek
On Fri, Jun 07, 2019 at 11:10:59AM +0200, Martin Liška wrote:
> libgcc/ChangeLog:
> 
> 2019-06-04  Martin Liska  
> 
>   * Makefile.in: Add __gcov_one_value_profiler_v2,
>   __gcov_one_value_profiler_v2_atomic and
>   __gcov_indirect_call_profiler_v4.
>   * libgcov-merge.c (__gcov_merge_single): Change
>   function signature.

> diff --git a/libgcc/libgcov-merge.c b/libgcc/libgcov-merge.c
> index 702a69f8349..42416341b4d 100644
> --- a/libgcc/libgcov-merge.c
> +++ b/libgcc/libgcov-merge.c
> @@ -34,8 +34,9 @@ void __gcov_merge_add (gcov_type *counters  __attribute__ 
> ((unused)),
>  #endif
>  
>  #ifdef L_gcov_merge_single
> -void __gcov_merge_single (gcov_type *counters  __attribute__ ((unused)),
> -  unsigned n_counters __attribute__ ((unused))) {}
> +void __gcov_merge_single (gcov_type *counters  __attribute__ ((unused)))
> +{
> +}
>  #endif
>  
>  #else

This change broke build without target libc.

../../../../libgcc/libgcov-merge.c:37:6: error: conflicting types for 
‘__gcov_merge_single’
   37 | void __gcov_merge_single (gcov_type *counters  __attribute__ ((unused)))
  |  ^~~
In file included from ../../../../libgcc/libgcov-merge.c:26:
../../../../libgcc/libgcov.h:263:13: note: previous declaration of 
‘__gcov_merge_single’ was here
  263 | extern void __gcov_merge_single (gcov_type *, unsigned) 
ATTRIBUTE_HIDDEN;
  | ^~~

It is unclear why it has been changed, when the callers haven't been
adjusted, nor the prototype.

So, I'd like to revert this hunk.  Tested with x86_64-linux -> nvptx-none
cross build, ok for trunk?

2019-06-10  Jakub Jelinek  

* libgcov-merge.c (__gcov_merge_single): Revert previous change.

--- libgcc/libgcov-merge.c.jj   2019-06-10 19:39:29.291363550 +0200
+++ libgcc/libgcov-merge.c  2019-06-10 19:58:36.731524778 +0200
@@ -34,9 +34,8 @@ void __gcov_merge_add (gcov_type *counte
 #endif
 
 #ifdef L_gcov_merge_single
-void __gcov_merge_single (gcov_type *counters  __attribute__ ((unused)))
-{
-}
+void __gcov_merge_single (gcov_type *counters  __attribute__ ((unused)),
+ unsigned n_counters __attribute__ ((unused))) {}
 #endif
 
 #else


Jakub


[patch][aarch64]: add intrinsics for vld1(q)_x4 and vst1(q)_x4

2019-06-10 Thread Sylvia Taylor
Greetings,

This patch adds the intrinsic functions for:
- vld1__x4
- vst1__x4
- vld1q__x4
- vst1q__x4

Bootstrapped and tested on aarch64-none-linux-gnu.

Ok for trunk? If yes, I don't have any commit rights, so can someone 
please commit it on my behalf.

Cheers,
Syl

gcc/ChangeLog:

2019-06-10  Sylvia Taylor  

* config/aarch64/aarch64-simd-builtins.def:
(ld1x4): New.
(st1x4): Likewise.
* config/aarch64/aarch64-simd.md:
(aarch64_ld1x4): New pattern.
(aarch64_st1x4): Likewise.
(aarch64_ld1_x4_): Likewise.
(aarch64_st1_x4_): Likewise.
* config/aarch64/arm_neon.h:
(vld1_s8_x4): New function.
(vld1q_s8_x4): Likewise.
(vld1_s16_x4): Likewise.
(vld1q_s16_x4): Likewise.
(vld1_s32_x4): Likewise.
(vld1q_s32_x4): Likewise.
(vld1_u8_x4): Likewise.
(vld1q_u8_x4): Likewise.
(vld1_u16_x4): Likewise.
(vld1q_u16_x4): Likewise.
(vld1_u32_x4): Likewise.
(vld1q_u32_x4): Likewise.
(vld1_f16_x4): Likewise.
(vld1q_f16_x4): Likewise.
(vld1_f32_x4): Likewise.
(vld1q_f32_x4): Likewise.
(vld1_p8_x4): Likewise.
(vld1q_p8_x4): Likewise.
(vld1_p16_x4): Likewise.
(vld1q_p16_x4): Likewise.
(vld1_s64_x4): Likewise.
(vld1_u64_x4): Likewise.
(vld1_p64_x4): Likewise.
(vld1q_s64_x4): Likewise.
(vld1q_u64_x4): Likewise.
(vld1q_p64_x4): Likewise.
(vld1_f64_x4): Likewise.
(vld1q_f64_x4): Likewise.
(vst1_s8_x4): Likewise.
(vst1q_s8_x4): Likewise.
(vst1_s16_x4): Likewise.
(vst1q_s16_x4): Likewise.
(vst1_s32_x4): Likewise.
(vst1q_s32_x4): Likewise.
(vst1_u8_x4): Likewise.
(vst1q_u8_x4): Likewise.
(vst1_u16_x4): Likewise.
(vst1q_u16_x4): Likewise.
(vst1_u32_x4): Likewise.
(vst1q_u32_x4): Likewise.
(vst1_f16_x4): Likewise.
(vst1q_f16_x4): Likewise.
(vst1_f32_x4): Likewise.
(vst1q_f32_x4): Likewise.
(vst1_p8_x4): Likewise.
(vst1q_p8_x4): Likewise.
(vst1_p16_x4): Likewise.
(vst1q_p16_x4): Likewise.
(vst1_s64_x4): Likewise.
(vst1_u64_x4): Likewise.
(vst1_p64_x4): Likewise.
(vst1q_s64_x4): Likewise.
(vst1q_u64_x4): Likewise.
(vst1q_p64_x4): Likewise.
(vst1_f64_x4): Likewise.
(vst1q_f64_x4): Likewise.

gcc/testsuite/ChangeLog:

2019-06-10  Sylvia Taylor  

* gcc.target/aarch64/advsimd-intrinsics/vld1x4.c: New test.
* gcc.target/aarch64/advsimd-intrinsics/vst1x4.c: New test.
diff --git a/gcc/config/aarch64/aarch64-simd-builtins.def 
b/gcc/config/aarch64/aarch64-simd-builtins.def
index 
17bb0c4869b12ede2fc51a8f89d841ded8fac230..f6c096b9186448972f440a70d8ac396a9aeaf004
 100644
--- a/gcc/config/aarch64/aarch64-simd-builtins.def
+++ b/gcc/config/aarch64/aarch64-simd-builtins.def
@@ -465,12 +465,18 @@
   /* Implemented by aarch64_ld1x3.  */
   BUILTIN_VALLDIF (LOADSTRUCT, ld1x3, 0)
 
+  /* Implemented by aarch64_ld1x4.  */
+  BUILTIN_VALLDIF (LOADSTRUCT, ld1x4, 0)
+
   /* Implemented by aarch64_st1x2.  */
   BUILTIN_VALLDIF (STORESTRUCT, st1x2, 0)
 
   /* Implemented by aarch64_st1x3.  */
   BUILTIN_VALLDIF (STORESTRUCT, st1x3, 0)
 
+  /* Implemented by aarch64_st1x4.  */
+  BUILTIN_VALLDIF (STORESTRUCT, st1x4, 0)
+
   /* Implemented by fma4.  */
   BUILTIN_VHSDF (TERNOP, fma, 4)
   VAR1 (TERNOP, fma, 4, hf)
diff --git a/gcc/config/aarch64/aarch64-simd.md 
b/gcc/config/aarch64/aarch64-simd.md
index 
eeed08e71ca0b96726cb28743ef38487a8287600..f62d4df97b433214c0211dcc0877ec6424925d14
 100644
--- a/gcc/config/aarch64/aarch64-simd.md
+++ b/gcc/config/aarch64/aarch64-simd.md
@@ -5271,6 +5271,28 @@
   [(set_attr "type" "neon_load1_3reg")]
 )
 
+(define_expand "aarch64_ld1x4"
+  [(match_operand:XI 0 "register_operand" "=w")
+   (match_operand:DI 1 "register_operand" "r")
+   (unspec:VALLDIF [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
+  "TARGET_SIMD"
+{
+  rtx mem = gen_rtx_MEM (XImode, operands[1]);
+  emit_insn (gen_aarch64_ld1_x4_ (operands[0], mem));
+  DONE;
+})
+
+(define_insn "aarch64_ld1_x4_"
+  [(set (match_operand:XI 0 "register_operand" "=w")
+   (unspec:XI
+ [(match_operand:XI 1 "aarch64_simd_struct_operand" "Utv")
+  (unspec:VALLDIF [(const_int 4)] UNSPEC_VSTRUCTDUMMY)]
+   UNSPEC_LD1))]
+  "TARGET_SIMD"
+  "ld1\\t{%S0. - %V0.}, %1"
+  [(set_attr "type" "neon_load1_4reg")]
+)
+
 (define_expand "aarch64_st1x2"
   [(match_operand:DI 0 "register_operand" "")
(match_operand:OI 1 "register_operand" "")
@@ -5313,6 +5335,28 @@
   [(set_attr "type" "neon_store1_3reg")]
 )
 
+(define_expand "aarch64_st1x4"
+  [(match_operand:DI 0 "register_operand" "")
+   (match_operand:XI 1 "register_operand" "")
+   (unspec:VALLDIF [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
+  "TARGET_SIMD"
+{
+  rtx mem = gen_rtx_MEM (XImode, 

Re: [Patch, fortran] PR90786 - [7/8/9/10 Regression] ICE on procedure pointer assignment to function with class pointer result

2019-06-10 Thread Thomas Koenig

Hi Paul,


I cannot see anything wrong with the optimized code and valgrind gives
a clean bill of health on x86_64.

We need help of somebody with access to an arm/aarch64 device.


I'm currently running a bootstrap on an aarch64 machine.  These
are not known to be the fastest of machines, but it should
be done sometime today.

Regards

Thomas


Re: [Patch, fortran] PR90786 - [7/8/9/10 Regression] ICE on procedure pointer assignment to function with class pointer result

2019-06-10 Thread Paul Richard Thomas
Hi Christophe,

I cannot see anything wrong with the optimized code and valgrind gives
a clean bill of health on x86_64.

We need help of somebody with access to an arm/aarch64 device.

Cheers

Paul

On Mon, 10 Jun 2019 at 14:37, Christophe Lyon
 wrote:
>
> On Mon, 10 Jun 2019 at 13:05, Paul Richard Thomas
>  wrote:
> >
> > Hi Christophe,
> >
> > I'll have a think about this tonight. Is valgrind or some similar
> > available for arm/aarch64?
>
> Yes, valgrind is available. I don't know if it's installed on the
> machines in the GCC computer farm though.
>
> Christophe
>
>
> >
> > Many thanks for flagging it up.
> >
> > Paul
> >
> > On Mon, 10 Jun 2019 at 10:07, Christophe Lyon
> >  wrote:
> > >
> > > On Sat, 8 Jun 2019 at 18:25, Andrew Benson  
> > > wrote:
> > > >
> > > > Thanks Paul for the quick fix!
> > > >
> > > > On Saturday, June 8, 2019 4:56:46 PM PDT Paul Richard Thomas wrote:
> > > > > Committed as obvious in revision 272084.
> > > > >
> > > > > The problem was that the lhs symbol itself was not being checked as a
> > > > > proc_pointer - just the expression component.
> > > > >
> > > > > I will get on with backporting tomorrow.
> > > > >
> > > > > Cheers
> > > > >
> > > > > Paul
> > > > >
> > > > > 2019-06-08  Paul Thomas  
> > > > >
> > > > > PR fortran/90786
> > > > > * trans-expr.c (pointer_assignment_is_proc_pointer) Remove as
> > > > > it is very simple and only called from one place.
> > > > > (gfc_trans_pointer_assignment): Rename non_proc_pointer_assign
> > > > > as non_proc_ptr_assign. Assign to it directly, rather than call
> > > > > to above, deleted function and use gfc_expr_attr instead of
> > > > > only checking the reference chain.
> > > > >
> > > > > 2019-06-08  Paul Thomas  
> > > > >
> > > > > PR fortran/90786
> > > > > * gfortran.dg/proc_ptr_51.f90 : New test.
> > > >
> > > >
> > >
> > > Hi,
> > >
> > > I've noticed that this new test fails on arm/aarch64:
> > > FAIL:gfortran.dg/proc_ptr_51.f90   -O2  execution test
> > > FAIL:gfortran.dg/proc_ptr_51.f90   -O3 -fomit-frame-pointer
> > > -funroll-loops -fpeel-loops -ftracer -finline-functions  execution
> > > test
> > > FAIL:gfortran.dg/proc_ptr_51.f90   -O3 -g  execution test
> > >
> > > the logs say:
> > > Program received signal SIGSEGV: Segmentation fault - invalid memory 
> > > reference.
> > >
> > > Backtrace for this error:
> > > #0  0xa938f66b in ???
> > > #1  0x0 in ???
> > >
> > > Christophe
> > >
> > > > --
> > > >
> > > > * Andrew Benson: 
> > > > http://users.obs.carnegiescience.edu/abenson/contact.html
> > > >
> > > > * Galacticus: https://bitbucket.org/galacticusdev/galacticus
> > > >
> >
> >
> >
> > --
> > "If you can't explain it simply, you don't understand it well enough"
> > - Albert Einstein



-- 
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein


Re: [C++ PATCH] PR c++/90449 - add -Winaccessible-base option.

2019-06-10 Thread Matthew Beliveau
Hello,

i changed the doc/invoke.texi like you suggested. Let me know If I
missed anything!

Thank you,
Matthew Beliveau

On Mon, Jun 10, 2019 at 11:39 AM Martin Sebor  wrote:
>
> On 6/7/19 2:10 PM, Matthew Beliveau wrote:
> > This patch adds a new warning option: Winaccessible-base, so that
> > users are able to selectively control the warning. The warning is
> > enabled by default; however, for the virtual bases' warning, it only
> > triggers with -Wextra flag.
>
> With few exceptions the rest of the manual tends to refer to base
> classes.  I would suggest to do the same in this update as well:
>
> @@ -4800,6 +4801,22 @@ is only active when
> @option{-fdelete-null-pointer-checks} is active,
>   which is enabled by optimizations in most targets.  The precision of
>   the warnings depends on the optimization options used.
>
> +@item -Winaccessible-base @r{(C++, Objective-C++ only)}
> +@opindex Winaccessible-base
> +@opindex Wno-inaccessible-base
> +Warn when a base is inaccessible in derived due to ambiguity.  The
> warning is
> +enabled by default.  Note the warning for virtual bases is enabled by the
> +@option{-Wextra} option.
>
>
> I.e.,
>
>Warn when a base class is inaccessible in a class derived from
>it due to ambiguity.
>
> Martin
Bootstrapped/regtested on x86_64-linux, ok for trunk?

2019-06-10  Matthew Beliveau  

   PR c++/90449 - add -Winaccessible-base option.
   * doc/invoke.texi (Winaccessible-base): Document.

   * c.opt (Winaccessible-base): Added new option.

   * class.c (warn_about_ambiguous_bases): Changed name to:
   maybe_warn_about_inaccessible_bases.
   (maybe_warn_about_inaccessible_bases):  Implemented new
   Winaccessible-base warning option for both direct and virtual
   base warnings.
   (layout_class_type): Call to warn_about_ambiguous_bases changed to fit
   new name.

   	* g++.dg/warn/Winaccessible-base-1.C: New file.
   	* g++.dg/warn/Winaccessible-base-2.C: New file.
   	* g++.dg/warn/Winaccessible-virtual-base-1.C: New file.
   	* g++.dg/warn/Winaccessible-virtual-base-2.C: New file.

diff --git gcc/c-family/c.opt gcc/c-family/c.opt
index 046d489f7eb..144f6da15d6 100644
--- gcc/c-family/c.opt
+++ gcc/c-family/c.opt
@@ -625,6 +625,10 @@ Wignored-attributes
 C C++ Var(warn_ignored_attributes) Init(1) Warning
 Warn whenever attributes are ignored.

+Winaccessible-base
+C++ ObjC++ Var(warn_inaccessible_base) Init(1) Warning
+Warn when a base is inaccessible in derived due to ambiguity.
+
 Wincompatible-pointer-types
 C ObjC Var(warn_incompatible_pointer_types) Init(1) Warning
 Warn when there is a conversion between pointers that have incompatible types.
diff --git gcc/cp/class.c gcc/cp/class.c
index a2585a61f96..9884cedc997 100644
--- gcc/cp/class.c
+++ gcc/cp/class.c
@@ -199,7 +199,7 @@ static int walk_subobject_offsets (tree, subobject_offset_fn,
 static int layout_conflict_p (tree, tree, splay_tree, int);
 static int splay_tree_compare_integer_csts (splay_tree_key k1,
 	splay_tree_key k2);
-static void warn_about_ambiguous_bases (tree);
+static void maybe_warn_about_inaccessible_bases (tree);
 static bool type_requires_array_cookie (tree);
 static bool base_derived_from (tree, tree);
 static int empty_base_at_nonzero_offset_p (tree, tree, splay_tree);
@@ -6017,7 +6017,7 @@ end_of_class (tree t, bool include_virtuals_p)
subobjects of U.  */

 static void
-warn_about_ambiguous_bases (tree t)
+maybe_warn_about_inaccessible_bases (tree t)
 {
   int i;
   vec *vbases;
@@ -6025,6 +6025,10 @@ warn_about_ambiguous_bases (tree t)
   tree binfo;
   tree base_binfo;

+  /* If not checking for warning then return early.  */
+  if (!warn_inaccessible_base)
+return;
+
   /* If there are no repeated bases, nothing can be ambiguous.  */
   if (!CLASSTYPE_REPEATED_BASE_P (t))
 return;
@@ -6036,8 +6040,8 @@ warn_about_ambiguous_bases (tree t)
   basetype = BINFO_TYPE (base_binfo);

   if (!uniquely_derived_from_p (basetype, t))
-	warning (0, "direct base %qT inaccessible in %qT due to ambiguity",
-		 basetype, t);
+	warning (OPT_Winaccessible_base, "direct base %qT inaccessible "
+		 "in %qT due to ambiguity", basetype, t);
 }

   /* Check for ambiguous virtual bases.  */
@@ -6048,8 +6052,8 @@ warn_about_ambiguous_bases (tree t)
 	basetype = BINFO_TYPE (binfo);

 	if (!uniquely_derived_from_p (basetype, t))
-	  warning (OPT_Wextra, "virtual base %qT inaccessible in %qT due "
-		   "to ambiguity", basetype, t);
+	  warning (OPT_Winaccessible_base, "virtual base %qT inaccessible in "
+		   "%qT due to ambiguity", basetype, t);
   }
 }

@@ -6455,7 +6459,7 @@ layout_class_type (tree t, tree *virtuals_p)
 error ("size of type %qT is too large (%qE bytes)", t, TYPE_SIZE_UNIT (t));

   /* Warn about bases that can't be talked about due to ambiguity.  */
-  warn_about_ambiguous_bases (t);
+  maybe_warn_about_inaccessible_bases (t);

   /* Now that we're done with layout, give the base fields 

Re: [PATCH] Fix up g++.dg/cpp*/feat-cxx*.C tests (PR testsuite/90772, take 2, was: [PATCH] Avoid unnecessary inclusion of header)

2019-06-10 Thread Jonathan Wakely

On 06/06/19 22:34 +0200, Jakub Jelinek wrote:

On Thu, Jun 06, 2019 at 10:19:52PM +0200, Jakub Jelinek wrote:

Not only those, but apparently also ::size_t or std::plus; this broke
FAIL: g++.dg/cpp1y/feat-cxx14.C   (test for excess errors)
FAIL: g++.dg/cpp1z/feat-cxx1z.C  -std=gnu++17 (test for excess errors)
FAIL: g++.dg/cpp1z/pr85569.C  -std=c++17 (test for excess errors)
FAIL: g++.dg/cpp2a/feat-cxx2a.C   (test for excess errors)

Fixed thusly, tested on x86_64-linux with check-c++-all, ok for trunk?


Bill has mentioned two other tests that are failing for similar reasons, so
here is an updated patch to cover those two too.  Tested again on
x86_64-linux with check-c++-all, ok for trunk?


This looks good to me. I checked to see if any of them could actually
use a smaller header, but the ones you've added are the right ones.




Re: [C++ PATCH] PR c++/90449 - add -Winaccessible-base option.

2019-06-10 Thread Martin Sebor

On 6/7/19 2:10 PM, Matthew Beliveau wrote:

This patch adds a new warning option: Winaccessible-base, so that
users are able to selectively control the warning. The warning is
enabled by default; however, for the virtual bases' warning, it only
triggers with -Wextra flag.


With few exceptions the rest of the manual tends to refer to base
classes.  I would suggest to do the same in this update as well:

@@ -4800,6 +4801,22 @@ is only active when 
@option{-fdelete-null-pointer-checks} is active,

 which is enabled by optimizations in most targets.  The precision of
 the warnings depends on the optimization options used.

+@item -Winaccessible-base @r{(C++, Objective-C++ only)}
+@opindex Winaccessible-base
+@opindex Wno-inaccessible-base
+Warn when a base is inaccessible in derived due to ambiguity.  The 
warning is

+enabled by default.  Note the warning for virtual bases is enabled by the
+@option{-Wextra} option.


I.e.,

  Warn when a base class is inaccessible in a class derived from
  it due to ambiguity.

Martin


Re: [PATCH] PR other/90695 reduce testcase to remove library dependency

2019-06-10 Thread Jason Merrill

On 6/6/19 6:52 PM, Jonathan Wakely wrote:

This reproduces the original ICE fixed by r178857 (tested at r178852 and
r178860), without depending on a libstdc++ header that keeps changing.

The number of errors differs between C++14 and C++17 modes, so the fixed
test uses dg-excess-errors to match any number of them. The precise
errors aren't what's being tested for here anyway, the point of the test
is to verify the ICE in PR 50391 is fixed.

 PR other/90695
 * g++.dg/cpp0x/noexcept15.C: Remove dependency on library header.

Tested x86_64-linux. OK for trunk?


OK, thanks.

Jason




Re: [C++ PATCH] PR c++/90449 - add -Winaccessible-base option.

2019-06-10 Thread Marek Polacek
On Mon, Jun 10, 2019 at 10:19:51AM -0400, Matthew Beliveau wrote:
> Hello,
> 
> I've changed the name of warn_about_ambiguous_bases to
> maybe_warn_about_inaccessible_bases.
> 
> I've attached the new patch below.
> 
> Best,
> Matthew Beliveau
> 
> On Fri, Jun 7, 2019 at 4:42 PM Paolo Carlini  wrote:
> >
> > Hi,
> >
> > On 07/06/19 22:31, Marek Polacek wrote:
> > > On Fri, Jun 07, 2019 at 10:20:02PM +0200, Paolo Carlini wrote:
> > >> Hi,
> > >>
> > >> On 07/06/19 22:10, Matthew Beliveau wrote:
> > >>> @@ -6025,6 +6025,10 @@ warn_about_ambiguous_bases (tree t)
> > >> Just a nit, but it seems weird to me that the function implementing
> > >> warn_inaccessible_base is named warn_about_ambiguous_bases.
> > > Maybe, but we want to keep the warning's name in sync with clang, and
> > > renaming the function seems like unnecessary noise.  I could go either
> > > way.
> >
> > It's definitely a minor issue. But, given that we have a rationale for
> > inaccessible_base - I didn't know that - I vote for renaming the
> > function. A maybe_* name would be appropriate in that case, because the
> > function doesn't always warn.
> >
> > Paolo.
> >

> Bootstrapped/regtested on x86_64-linux, ok for trunk?
> 
> 2019-06-10  Matthew Beliveau  
> 
>PR c++/90449 - add -Winaccessible-base option.
>* doc/invoke.texi (Winaccessible-base): Document.
> 
>* c.opt (Winaccessible-base): Added new option.
> 
>* class.c (warn_about_ambiguous_bases): Changed name to:
>maybe_warn_about_inaccessible_bases.
>(maybe_warn_about_inaccessible_bases):  Implemented new
>Winaccessible-base warning option for both direct and virtual
>base warnings.
>(layout_class_type): Call to warn_about_ambiguous_bases changed to fit
>new name.
> 
>   * g++.dg/warn/Winaccessible-base-1.C: New file.
>   * g++.dg/warn/Winaccessible-base-2.C: New file.
>   * g++.dg/warn/Winaccessible-virtual-base-1.C: New file.
>   * g++.dg/warn/Winaccessible-virtual-base-2.C: New file.

Looks fine to me except the small issues with whitespaces in the CL entry.

Marek


[committed, obvious] gcov-tool: Mark {merge,rewrite}_usage with noreturn attribute

2019-06-10 Thread Vladislav Ivanishin
This makes similar functions merge_usage, rewrite_usage, and
overlap_usage all have ATTRIBUTE_NORETURN.  (The latter was marked with
it in r264562, the other two were not).

Checked in as r272119.

Index: gcc/ChangeLog
===
--- gcc/ChangeLog   (revision 272118)
+++ gcc/ChangeLog   (working copy)
@@ -1,3 +1,8 @@
+2019-06-10  Vladislav Ivanishin  
+
+   * gcov-tool.c (merge_usage, rewrite_usage): Mark with
+   ATTRIBUTE_NORETURN thus making consistent with overlap_usage.
+
 2019-06-10  Jakub Jelinek  

* tree.def (OMP_SCAN): New tree code.
Index: gcc/gcov-tool.c
===
--- gcc/gcov-tool.c (revision 272118)
+++ gcc/gcov-tool.c (working copy)
@@ -188,7 +188,7 @@

 /* Print merge usage and exit.  */

-static void
+static void ATTRIBUTE_NORETURN
 merge_usage (void)
 {
   fnotice (stderr, "Merge subcomand usage:");
@@ -284,7 +284,7 @@

 /* Print profile rewrite usage and exit.  */

-static void
+static void ATTRIBUTE_NORETURN
 rewrite_usage (void)
 {
   fnotice (stderr, "Rewrite subcommand usage:");


-- 
Vlad


Re: [C++ PATCH] PR c++/90449 - add -Winaccessible-base option.

2019-06-10 Thread Matthew Beliveau
Hello,

I've changed the name of warn_about_ambiguous_bases to
maybe_warn_about_inaccessible_bases.

I've attached the new patch below.

Best,
Matthew Beliveau

On Fri, Jun 7, 2019 at 4:42 PM Paolo Carlini  wrote:
>
> Hi,
>
> On 07/06/19 22:31, Marek Polacek wrote:
> > On Fri, Jun 07, 2019 at 10:20:02PM +0200, Paolo Carlini wrote:
> >> Hi,
> >>
> >> On 07/06/19 22:10, Matthew Beliveau wrote:
> >>> @@ -6025,6 +6025,10 @@ warn_about_ambiguous_bases (tree t)
> >> Just a nit, but it seems weird to me that the function implementing
> >> warn_inaccessible_base is named warn_about_ambiguous_bases.
> > Maybe, but we want to keep the warning's name in sync with clang, and
> > renaming the function seems like unnecessary noise.  I could go either
> > way.
>
> It's definitely a minor issue. But, given that we have a rationale for
> inaccessible_base - I didn't know that - I vote for renaming the
> function. A maybe_* name would be appropriate in that case, because the
> function doesn't always warn.
>
> Paolo.
>
Bootstrapped/regtested on x86_64-linux, ok for trunk?

2019-06-10  Matthew Beliveau  

   PR c++/90449 - add -Winaccessible-base option.
   * doc/invoke.texi (Winaccessible-base): Document.

   * c.opt (Winaccessible-base): Added new option.

   * class.c (warn_about_ambiguous_bases): Changed name to:
   maybe_warn_about_inaccessible_bases.
   (maybe_warn_about_inaccessible_bases):  Implemented new
   Winaccessible-base warning option for both direct and virtual
   base warnings.
   (layout_class_type): Call to warn_about_ambiguous_bases changed to fit
   new name.

   	* g++.dg/warn/Winaccessible-base-1.C: New file.
   	* g++.dg/warn/Winaccessible-base-2.C: New file.
   	* g++.dg/warn/Winaccessible-virtual-base-1.C: New file.
   	* g++.dg/warn/Winaccessible-virtual-base-2.C: New file.

diff --git gcc/c-family/c.opt gcc/c-family/c.opt
index 046d489f7eb..144f6da15d6 100644
--- gcc/c-family/c.opt
+++ gcc/c-family/c.opt
@@ -625,6 +625,10 @@ Wignored-attributes
 C C++ Var(warn_ignored_attributes) Init(1) Warning
 Warn whenever attributes are ignored.

+Winaccessible-base
+C++ ObjC++ Var(warn_inaccessible_base) Init(1) Warning
+Warn when a base is inaccessible in derived due to ambiguity.
+
 Wincompatible-pointer-types
 C ObjC Var(warn_incompatible_pointer_types) Init(1) Warning
 Warn when there is a conversion between pointers that have incompatible types.
diff --git gcc/cp/class.c gcc/cp/class.c
index a2585a61f96..9884cedc997 100644
--- gcc/cp/class.c
+++ gcc/cp/class.c
@@ -199,7 +199,7 @@ static int walk_subobject_offsets (tree, subobject_offset_fn,
 static int layout_conflict_p (tree, tree, splay_tree, int);
 static int splay_tree_compare_integer_csts (splay_tree_key k1,
 	splay_tree_key k2);
-static void warn_about_ambiguous_bases (tree);
+static void maybe_warn_about_inaccessible_bases (tree);
 static bool type_requires_array_cookie (tree);
 static bool base_derived_from (tree, tree);
 static int empty_base_at_nonzero_offset_p (tree, tree, splay_tree);
@@ -6017,7 +6017,7 @@ end_of_class (tree t, bool include_virtuals_p)
subobjects of U.  */

 static void
-warn_about_ambiguous_bases (tree t)
+maybe_warn_about_inaccessible_bases (tree t)
 {
   int i;
   vec *vbases;
@@ -6025,6 +6025,10 @@ warn_about_ambiguous_bases (tree t)
   tree binfo;
   tree base_binfo;

+  /* If not checking for warning then return early.  */
+  if (!warn_inaccessible_base)
+return;
+
   /* If there are no repeated bases, nothing can be ambiguous.  */
   if (!CLASSTYPE_REPEATED_BASE_P (t))
 return;
@@ -6036,8 +6040,8 @@ warn_about_ambiguous_bases (tree t)
   basetype = BINFO_TYPE (base_binfo);

   if (!uniquely_derived_from_p (basetype, t))
-	warning (0, "direct base %qT inaccessible in %qT due to ambiguity",
-		 basetype, t);
+	warning (OPT_Winaccessible_base, "direct base %qT inaccessible "
+		 "in %qT due to ambiguity", basetype, t);
 }

   /* Check for ambiguous virtual bases.  */
@@ -6048,8 +6052,8 @@ warn_about_ambiguous_bases (tree t)
 	basetype = BINFO_TYPE (binfo);

 	if (!uniquely_derived_from_p (basetype, t))
-	  warning (OPT_Wextra, "virtual base %qT inaccessible in %qT due "
-		   "to ambiguity", basetype, t);
+	  warning (OPT_Winaccessible_base, "virtual base %qT inaccessible in "
+		   "%qT due to ambiguity", basetype, t);
   }
 }

@@ -6455,7 +6459,7 @@ layout_class_type (tree t, tree *virtuals_p)
 error ("size of type %qT is too large (%qE bytes)", t, TYPE_SIZE_UNIT (t));

   /* Warn about bases that can't be talked about due to ambiguity.  */
-  warn_about_ambiguous_bases (t);
+  maybe_warn_about_inaccessible_bases (t);

   /* Now that we're done with layout, give the base fields the real types.  */
   for (field = TYPE_FIELDS (t); field; field = DECL_CHAIN (field))
diff --git gcc/doc/invoke.texi gcc/doc/invoke.texi
index 3e4f012b4fa..862ee794773 100644
--- gcc/doc/invoke.texi
+++ gcc/doc/invoke.texi
@@ -317,6 +317,7 @@ 

Re: [Patch, fortran] PR90786 - [7/8/9/10 Regression] ICE on procedure pointer assignment to function with class pointer result

2019-06-10 Thread Christophe Lyon
On Mon, 10 Jun 2019 at 13:05, Paul Richard Thomas
 wrote:
>
> Hi Christophe,
>
> I'll have a think about this tonight. Is valgrind or some similar
> available for arm/aarch64?

Yes, valgrind is available. I don't know if it's installed on the
machines in the GCC computer farm though.

Christophe


>
> Many thanks for flagging it up.
>
> Paul
>
> On Mon, 10 Jun 2019 at 10:07, Christophe Lyon
>  wrote:
> >
> > On Sat, 8 Jun 2019 at 18:25, Andrew Benson  
> > wrote:
> > >
> > > Thanks Paul for the quick fix!
> > >
> > > On Saturday, June 8, 2019 4:56:46 PM PDT Paul Richard Thomas wrote:
> > > > Committed as obvious in revision 272084.
> > > >
> > > > The problem was that the lhs symbol itself was not being checked as a
> > > > proc_pointer - just the expression component.
> > > >
> > > > I will get on with backporting tomorrow.
> > > >
> > > > Cheers
> > > >
> > > > Paul
> > > >
> > > > 2019-06-08  Paul Thomas  
> > > >
> > > > PR fortran/90786
> > > > * trans-expr.c (pointer_assignment_is_proc_pointer) Remove as
> > > > it is very simple and only called from one place.
> > > > (gfc_trans_pointer_assignment): Rename non_proc_pointer_assign
> > > > as non_proc_ptr_assign. Assign to it directly, rather than call
> > > > to above, deleted function and use gfc_expr_attr instead of
> > > > only checking the reference chain.
> > > >
> > > > 2019-06-08  Paul Thomas  
> > > >
> > > > PR fortran/90786
> > > > * gfortran.dg/proc_ptr_51.f90 : New test.
> > >
> > >
> >
> > Hi,
> >
> > I've noticed that this new test fails on arm/aarch64:
> > FAIL:gfortran.dg/proc_ptr_51.f90   -O2  execution test
> > FAIL:gfortran.dg/proc_ptr_51.f90   -O3 -fomit-frame-pointer
> > -funroll-loops -fpeel-loops -ftracer -finline-functions  execution
> > test
> > FAIL:gfortran.dg/proc_ptr_51.f90   -O3 -g  execution test
> >
> > the logs say:
> > Program received signal SIGSEGV: Segmentation fault - invalid memory 
> > reference.
> >
> > Backtrace for this error:
> > #0  0xa938f66b in ???
> > #1  0x0 in ???
> >
> > Christophe
> >
> > > --
> > >
> > > * Andrew Benson: http://users.obs.carnegiescience.edu/abenson/contact.html
> > >
> > > * Galacticus: https://bitbucket.org/galacticusdev/galacticus
> > >
>
>
>
> --
> "If you can't explain it simply, you don't understand it well enough"
> - Albert Einstein


[PATCH V2] Find constant definition for by-ref argument using dominance information (PR ipa/90401)

2019-06-10 Thread Feng Xue OS


---
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 526ed45be89..469b54ddf93 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2019-06-04  Feng Xue  
+
+   PR ipa/90401
+   * ipa-prop.c (add_to_agg_contents_list): New function.
+   (clobber_by_agg_contents_list_p): Likewise.
+   (extract_mem_content): Likewise.
+   (get_place_in_agg_contents_list): Delete.
+   (determine_known_aggregate_parts): Renamed from
+   determine_locally_known_aggregate_parts. New parameter
+   aa_walk_budget_p.
+
 2019-06-04  Segher Boessenkool  
 
* config/rs6000/constraints.md (define_register_constraint "wp"):
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index d86c2f3db55..1cb0626eeff 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -1458,7 +1458,7 @@ get_ssa_def_if_simple_copy (tree rhs)
   return rhs;
 }
 
-/* Simple linked list, describing known contents of an aggregate beforere
+/* Simple linked list, describing known contents of an aggregate before
call.  */
 
 struct ipa_known_agg_contents_list
@@ -1471,41 +1471,48 @@ struct ipa_known_agg_contents_list
   struct ipa_known_agg_contents_list *next;
 };
 
-/* Find the proper place in linked list of ipa_known_agg_contents_list
-   structures where to put a new one with the given LHS_OFFSET and LHS_SIZE,
-   unless there is a partial overlap, in which case return NULL, or such
-   element is already there, in which case set *ALREADY_THERE to true.  */
+/* Add a known content item into a linked list of ipa_known_agg_contents_list
+   structure, in which all elements are sorted ascendingly by offset. */
 
-static struct ipa_known_agg_contents_list **
-get_place_in_agg_contents_list (struct ipa_known_agg_contents_list **list,
-   HOST_WIDE_INT lhs_offset,
-   HOST_WIDE_INT lhs_size,
-   bool *already_there)
+static inline void
+add_to_agg_contents_list (struct ipa_known_agg_contents_list **plist,
+  struct ipa_known_agg_contents_list *item)
 {
-  struct ipa_known_agg_contents_list **p = list;
-  while (*p && (*p)->offset < lhs_offset)
+  struct ipa_known_agg_contents_list *list = *plist;
+
+  for (; list; list = list->next)
 {
-  if ((*p)->offset + (*p)->size > lhs_offset)
-   return NULL;
-  p = &(*p)->next;
+  if (list->offset >= item->offset)
+break;
+
+  plist = >next;
 }
 
-  if (*p && (*p)->offset < lhs_offset + lhs_size)
+  item->next = list;
+  *plist = item;
+}
+
+/* Check whether a given known content is clobbered by certain element in
+   a linked list of ipa_known_agg_contents_list. */
+
+static inline bool
+clobber_by_agg_contents_list_p (struct ipa_known_agg_contents_list *list,
+struct ipa_known_agg_contents_list *item)
+{
+  for (; list; list = list->next)
 {
-  if ((*p)->offset == lhs_offset && (*p)->size == lhs_size)
-   /* We already know this value is subsequently overwritten with
-  something else.  */
-   *already_there = true;
-  else
-   /* Otherwise this is a partial overlap which we cannot
-  represent.  */
-   return NULL;
+  if (list->offset >= item->offset)
+return list->offset < item->offset + item->size;
+
+  if (list->offset + list->size > item->offset)
+return true;
 }
-  return p;
+
+  return false;
 }
 
 /* Build aggregate jump function from LIST, assuming there are exactly
-   CONST_COUNT constant entries there and that th offset of the passed argument
+   CONST_COUNT constant entries there and that offset of the passed argument
is ARG_OFFSET and store it into JFUNC.  */
 
 static void
@@ -1528,26 +1535,79 @@ build_agg_jump_func_from_list (struct 
ipa_known_agg_contents_list *list,
 }
 }
 
+/* If STMT is a memory store to the object whose address is BASE, extract
+   information (offset, size, and value) into CONTENT, and return true,
+   otherwise we conservatively assume the whole object is modified with
+   unknown content, and return false. CHECK_REF means that access to object
+   is expected to be in form of MEM_REF expression. */
+
+static bool
+extract_mem_content (gimple *stmt, tree base, bool check_ref,
+ struct ipa_known_agg_contents_list *content)
+{
+  HOST_WIDE_INT lhs_offset, lhs_size;
+  tree lhs, rhs, lhs_base;
+  bool reverse;
+
+  if (!gimple_assign_single_p (stmt))
+return false;
+
+  lhs = gimple_assign_lhs (stmt);
+  rhs = gimple_assign_rhs1 (stmt);
+
+  if (!is_gimple_reg_type (TREE_TYPE (rhs))
+  || TREE_CODE (lhs) == BIT_FIELD_REF
+  || contains_bitfld_component_ref_p (lhs))
+return false;
+
+  lhs_base = get_ref_base_and_extent_hwi (lhs, _offset,
+  _size, );
+  if (!lhs_base)
+return false;
+
+  if (check_ref)
+{
+  if (TREE_CODE (lhs_base) != MEM_REF
+  || TREE_OPERAND (lhs_base, 0) != base
+  || 

[PATCH] Disable htable sanitization in pt.c (PR c++/87847).

2019-06-10 Thread Martin Liška
Hi.

The patch is about disablement of hash_table sanitization in pt.c.
It's a workaround and I hope Jason can look deeper at the issue.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

gcc/ChangeLog:

2019-06-10  Martin Liska  

PR c++/87847
* hash-table.h: Extend create_gcc, add one parameter
that is passed into hash_table::hash_table.

gcc/cp/ChangeLog:

2019-06-10  Martin Liska  

PR c++/87847
* pt.c (init_template_processing): Disable hash table
sanitization for decl_specializations and type_specializations.
---
 gcc/cp/pt.c  | 5 +++--
 gcc/hash-table.h | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)


diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index d2cf3458253..a7c9635187a 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -28311,8 +28311,9 @@ declare_integer_pack (void)
 void
 init_template_processing (void)
 {
-  decl_specializations = hash_table::create_ggc (37);
-  type_specializations = hash_table::create_ggc (37);
+  /* FIXME: enable sanitization (PR87847) */
+  decl_specializations = hash_table::create_ggc (37, false);
+  type_specializations = hash_table::create_ggc (37, false);
 
   if (cxx_dialect >= cxx11)
 declare_integer_pack ();
diff --git a/gcc/hash-table.h b/gcc/hash-table.h
index 6c1fca3459b..4f5e150a0ac 100644
--- a/gcc/hash-table.h
+++ b/gcc/hash-table.h
@@ -386,10 +386,10 @@ public:
 
   /* Create a hash_table in gc memory.  */
   static hash_table *
-  create_ggc (size_t n CXX_MEM_STAT_INFO)
+  create_ggc (size_t n, bool sanitize_eq_and_hash = true CXX_MEM_STAT_INFO)
   {
 hash_table *table = ggc_alloc ();
-new (table) hash_table (n, true, true, GATHER_STATISTICS,
+new (table) hash_table (n, true, sanitize_eq_and_hash, GATHER_STATISTICS,
 			HASH_TABLE_ORIGIN PASS_MEM_STAT);
 return table;
   }



Handle structural equality of pointers in same_type_for_tbaa_p

2019-06-10 Thread Jan Hubicka
Hi,
this is kind of minimal patch to handle pointers in access paths.
I do not include logic for arrays nor attempt to deal better with incomparable
pointers (such as pointers to two different incomplete record types).

A lazy way would be to simply compare alias sets, but I want to handle more
because our rules for globbing pointers are not transitive. For example void *
is equivalent to pointer to any incomplete type.  But we can still say that
pointer to record is different from pointer to function which helps in practice 
since propagating pointers to functions is rather important.

Alias sets of pointer to record and pointer to function are both same as void *
because we have no way to distinguish multiple pointers of same kind and we
special case only void * alias set.  Here we can work bit better without much
of extra hassle and we also catch most of cases (since most accesses are to
types w/o pointers which we disambiguate this way).

Number of disambiguations on tramp3d via access path grows from 1000 to 

Alias oracle query stats:
  refs_may_alias_p: 3025065 disambiguations, 3321073 queries
  ref_maybe_used_by_call_p: 7118 disambiguations, 3050683 queries
  call_may_clobber_ref_p: 817 disambiguations, 817 queries
  aliasing_component_ref_p: 8703 disambiguations, 24495 queries
  TBAA oracle: 1429175 disambiguations 2934191 queries
   552425 are in alias set 0
   573848 queries asked about the same object
   0 queries asked about the same alias set
   0 access volatile
   257310 are dependent in the DAG
   121433 are aritificially in conflict with void *

So about 8x more.

lto-bootstrapped/regtested x86_64 with all languages, OK?

* gcc.dg/lto/alias-access-path-3_0.c: New testcase.
* tree-ssa-alias.c (same_type_for_tbaa): Look into pointed-to types
to test structural equivalence of pointer types.

Index: testsuite/gcc.dg/lto/alias-access-path-3_0.c
===
--- testsuite/gcc.dg/lto/alias-access-path-3_0.c(nonexistent)
+++ testsuite/gcc.dg/lto/alias-access-path-3_0.c(working copy)
@@ -0,0 +1,37 @@
+/* { dg-lto-do run } */
+/* { dg-lto-options { { -O3 -flto -fno-early-inlining } } } */
+#include 
+
+/* We should disambiguate
+ int *
+   and
+ struct a *
+   despite the fact they get same alias set because struct a is incomplete.  */
+
+typedef int (*fnptr) ();
+
+__attribute__ ((used))
+struct
+{
+  int *a;
+} a, *aptr = 
+
+struct a **bptr;
+
+static void
+inline_me_late (int argc)
+{
+  if (argc == -1)
+*bptr = (void *)(size_t)1;
+}
+
+int
+main (int argc)
+{
+  typeof (aptr) aptr2 = aptr;
+  aptr2->a = 0;
+  inline_me_late (argc);
+  if (!__builtin_constant_p (aptr2->a == 0))
+__builtin_abort ();
+  return 0;
+}
Index: tree-ssa-alias.c
===
--- tree-ssa-alias.c(revision 272037)
+++ tree-ssa-alias.c(working copy)
@@ -791,10 +791,39 @@ same_type_for_tbaa (tree type1, tree typ
   if (type1 == type2)
 return 1;
 
+  /* For LTO we do not define canonical types of pointers.  Look into
+ corresponding pointed-to-types.  To speed non-LTO checks,
+ do not bother to do that if canonical types are defined though.  */
+  while (POINTER_TYPE_P (type1) && POINTER_TYPE_P (type2)
+ && (TYPE_STRUCTURAL_EQUALITY_P (type1)
+ || TYPE_STRUCTURAL_EQUALITY_P (type2)))
+{
+  type1 = TREE_TYPE (type1);
+  type2 = TREE_TYPE (type2);
+  /* As an extension, we consider void pointer TBAA compatible with all
+other pointer types.  This is especially importnat in LTO where
+non-C languages may want to bind to C pointers via void *.  */
+  if (VOID_TYPE_P (type1) || VOID_TYPE_P (type2))
+   return 1;
+}
+
   /* If we would have to do structural comparison bail out.  */
   if (TYPE_STRUCTURAL_EQUALITY_P (type1)
   || TYPE_STRUCTURAL_EQUALITY_P (type2))
-return -1;
+{
+  /* If type1 and type2 are diferent kinds, return 0.
+This is important espcially when we hit incomplete types or
+function/method types after walking pointed-to types above.
+
+??? As a special case we want to consider ARRAY_TYPE possibly
+same as its base type to solve some issues with Fortran frontend.  */
+  if (TREE_CODE (type1) != ARRAY_TYPE
+ && TREE_CODE (type2) != ARRAY_TYPE
+ && tree_code_for_canonical_type_merging (TREE_CODE (type1))
+!= tree_code_for_canonical_type_merging (TREE_CODE (type2)))
+   return 0;
+  return -1;
+}
 
   /* Compare the canonical types.  */
   if (TYPE_CANONICAL (type1) == TYPE_CANONICAL (type2))


Re: C++ PATCH to implement deferred parsing of noexcept-specifiers (c++/86476, c++/52869)

2019-06-10 Thread Marek Polacek
Ping.

On Mon, Jun 03, 2019 at 09:01:37PM -0400, Marek Polacek wrote:
> On Tue, May 28, 2019 at 11:46:53AM -0400, Jason Merrill wrote:
> > > @@ -20515,7 +20524,13 @@ cp_parser_init_declarator (cp_parser* parser,
> > >   /*asmspec=*/NULL_TREE,
> > >   attr_chainon (attributes, prefix_attributes));
> > > if (decl && TREE_CODE (decl) == FUNCTION_DECL)
> > > - cp_parser_save_default_args (parser, decl);
> > > + {
> > > +   cp_parser_save_default_args (parser, decl);
> > > +   /* Remember if there is a noexcept-specifier to post process.  */
> > > +   tree spec = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (decl));
> > > +   if (UNPARSED_NOEXCEPT_SPEC_P (spec))
> > > + vec_safe_push (unparsed_noexcepts, decl);
> > 
> > Can we handle this in cp_parser_save_default_args rather than all its
> > callers?
> 
> Yes, done.
> 
> > > +/* Make sure that any member-function parameters are in scope.
> > > +   For instance, a function's noexcept-specifier can use the function's
> > > +   parameters:
> > > +
> > > +   struct S {
> > > + void fn (int p) noexcept(noexcept(p));
> > > +   };
> > > +
> > > +   so we need to make sure name lookup can find them.  This is used
> > > +   when we delay parsing of the noexcept-specifier.  */
> > > +
> > > +static void
> > > +inject_parm_decls (tree decl)
> > > +{
> > > +  begin_scope (sk_function_parms, decl);
> > > +  tree args = DECL_ARGUMENTS (decl);
> > > +  args = nreverse (args);
> > > +
> > > +  tree next;
> > > +  for (tree parm = args; parm; parm = next)
> > > +{
> > > +  next = DECL_CHAIN (parm);
> > > +  if (TREE_CODE (parm) == PARM_DECL)
> > > + pushdecl (parm);
> > > +}
> > > +  /* Get the decls in their original chain order and record in the
> > > + function.  This is all and only the PARM_DECLs that were
> > > + pushed into scope by the loop above.  */
> > > +  DECL_ARGUMENTS (decl) = get_local_decls ();
> > > +}
> > 
> > Can we share this code with store_parm_decls instead of having two copies?
> 
> Makes sense, the nreverse logic is tricky enough not to duplicate it.  I named
> the new function do_push_parm_decls.
> 
> > > @@ -25227,6 +25431,18 @@ cp_parser_noexcept_specification_opt (cp_parser* 
> > > parser,
> > > +  /* [class.mem]/6 says that a noexcept-specifer (within the
> > > +  member-specification of the class) is a complete-class context of
> > > +  a class.  So, if the noexcept-specifier has the optional expression,
> > > +  just save the tokens, and reparse this after we're done with the
> > > +  class.  */
> > > +  if (cp_lexer_peek_nth_token (parser->lexer, 2)->type == 
> > > CPP_OPEN_PAREN
> > > +   && at_class_scope_p ()
> > > +   && TYPE_BEING_DEFINED (current_class_type)
> > > +   && !LAMBDA_TYPE_P (current_class_type))
> > > + return cp_parser_save_noexcept (parser);
> > 
> > We might optimize the noexcept() case, which should be pretty
> > common.
> 
> Yeah, it's worth it.  Added for numbers/false/true.
> 
> > > +maybe_check_throw_specifier (tree overrider, tree basefn)
> > 
> > maybe_check_overriding_exception_spec
> 
> Changed.
> 
> > > diff --git gcc/cp/typeck2.c gcc/cp/typeck2.c
> > > index df002a1664c..8cbc48fb44f 100644
> > > --- gcc/cp/typeck2.c
> > > +++ gcc/cp/typeck2.c
> > > @@ -2393,6 +2393,12 @@ merge_exception_specifiers (tree list, tree add)
> > > if (list == error_mark_node || add == error_mark_node)
> > >   return error_mark_node;
> > > +  /* We don't want to lose the unparsed operand lest we miss 
> > > diagnostics.  */
> > > +  if (UNPARSED_NOEXCEPT_SPEC_P (list))
> > > +return list;
> > > +  else if (UNPARSED_NOEXCEPT_SPEC_P (add))
> > > +return add;
> > 
> > Here you're throwing away the other side, which seems wrong.
> 
> I sort of ended up going down a rathole, but then I realized we don't need to
> delay parsing of noexcept-specifiers of member friend function declarations,
> because they aren't members of the class.  This was a huge relief because
> member friend function declarations can be redeclared, so we'd have to make
> sure to check if their noexcept-specifiers match.  But member function decls
> can't be redeclared.  I updated the comment to better reflect why what I'm
> doing there is correct, along with an assert.
> 
> noexcept47.C tests various cases with friend declarations.
> 
> Thanks,
> 
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
> 
> 2019-06-03  Marek Polacek  
> 
>   PR c++/86476 - noexcept-specifier is a complete-class context.
>   PR c++/52869
>   * cp-tree.def (DEFAULT_ARG): Update commentary.
>   * cp-tree.h (DEFARG_DECL, DEFARG_NOEXCEPT_P, UNPARSED_NOEXCEPT_SPEC_P):
>   New macros.
>   (tree_default_arg): Add a tree field, make the last two fields into a
>   union.  Add GTY markers.
>   (check_redeclaration_exception_specification, do_push_parm_decls,
>   maybe_check_overriding_exception_spec): Declare.
>   * decl.c 

[committed] Add parsing and diagnostics for #pragma omp scan and reduction(inscan, ...)

2019-06-10 Thread Jakub Jelinek
Hi!

The following patch does parsing and diagnostics for C/C++ #pragma omp scan
and reduction(inscan, ...) clauses.  omp-low.c and further handling is not
implemented so far, we just sorry_at on those constructs if we don't
diagnose any errors on those.

Tested on x86_64-linux, committed to trunk.

Trying to handle it in simd constructs will be my next task.

2019-06-10  Jakub Jelinek  

* tree.def (OMP_SCAN): New tree code.
* tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_INCLUSIVE and
OMP_CLAUSE_EXCLUSIVE.
* tree.h (OMP_CLAUSES): Use OMP_SCAN instead of OMP_TASKGROUP.
(OMP_SCAN_BODY, OMP_SCAN_CLAUSES): Define.
* tree.c (omp_clause_num_ops, omp_clause_code_name): Add entries for
OMP_CLAUSE_{IN,EX}CLUSIVE.
(walk_tree_1): Handle OMP_CLAUSE_{IN,EX}CLUSIVE.
* tree-nested.c (convert_nonlocal_reference_stmt,
convert_local_reference_stmt, convert_gimple_call): Handle
GIMPLE_OMP_SCAN.
* tree-pretty-print.c (dump_omp_clause): Handle
OMP_CLAUSE_{IN,EX}CLUSIVE.
(dump_generic_node): Handle OMP_SCAN.
* gimple.def (GIMPLE_OMP_SCAN): New gimple code.
* gimple.h (gomp_scan): New type.
(is_a_helper ::test,
is_a_helper ::test): New templates.
(gimple_build_omp_scan): Declare.
(gimple_omp_scan_clauses, gimple_omp_scan_clauses_ptr,
gimple_omp_scan_set_clauses): New inline functions.
(CASE_GIMPLE_OMP): Add case GIMPLE_OMP_SCAN:.
* gimple.c (gimple_build_omp_scan): New function.
(gimple_copy): Handle GIMPLE_OMP_SCAN.
* gimple-walk.c (walk_gimple_op, walk_gimple_stmt): Likewise.
* gimple-pretty-print.c (dump_gimple_omp_block): Don't handle
GIMPLE_OMP_TASKGROUP.
(dump_gimple_omp_scan): New function.
(pp_gimple_stmt_1): Handle GIMPLE_OMP_SCAN.
* gimple-low.c (lower_stmt): Handle GIMPLE_OMP_SCAN.
* tree-inline.c (remap_gimple_stmt, estimate_num_insns): Likewise.
* gimplify.c (enum gimplify_omp_var_data): Add GOVD_REDUCTION_INSCAN.
(is_gimple_stmt): Handle OMP_SCAN.
(gimplify_scan_omp_clauses): Reject inscan reductions on constructs
other than OMP_FOR or OMP_SIMD.  Handle OMP_CLAUSE_{IN,EX}CLUSIVE.
(gimplify_adjust_omp_clauses): Diagnose inscan reductions not
mentioned in nested #pragma omp scan.  Handle
OMP_CLAUSE_{IN,EX}CLUSIVE.
(gimplify_expr): Handle OMP_SCAN.
* omp-low.c (check_omp_nesting_restrictions): For parent context,
look through GIMPLE_OMP_SCAN context.  Allow #pragma omp scan in
simd constructs.
(scan_omp_1_stmt, lower_omp_1, diagnose_sb_1, diagnose_sb_2): Handle
GIMPLE_OMP_SCAN.
c-family/
* c-pragma.h (enum pragma_kind): Add PRAGMA_OMP_SCAN.
* c-pragma.c (omp_pragmas_simd): Add #pragma omp scan.
* c-omp.c (c_omp_split_clauses): Diagnose inscan reductions on
combined/composite constructs where it is not allowed.  Copy over
OMP_CLAUSE_REDUCTION_INSCAN.
c/
* c-parser.c (c_parser_pragma): Reject PRAGMA_OMP_SCAN.
(c_parser_omp_clause_reduction): Don't sorry_at on inscan reductions.
(c_parser_omp_scan_loop_body): New function.
(c_parser_omp_for_loop): Call c_parser_omp_scan_loop_body if there are
inscan reduction clauses.
* c-typeck.c (c_finish_omp_clauses): Reject mixing inscan with
non-inscan reductions on the same construct, or inscan reductions with
ordered or schedule clauses, or inscan array reductions.
cp/
* parser.c (cp_parser_omp_clause_reduction): Don't sorry_at on inscan
reductions.
(cp_parser_omp_scan_loop_body): New function.
(cp_parser_omp_for_loop): Call cp_parser_omp_scan_loop_body if there
are inscan reduction clauses.
(cp_parser_pragma): Reject PRAGMA_OMP_SCAN.
* semantics.c (finish_omp_clauses): Reject mixing inscan with
non-inscan reductions on the same construct, or inscan reductions with
ordered or schedule clauses, or inscan array reductions.
* pt.c (tsubst_omp_clauses): Handle OMP_CLAUSE_{IN,EX}CLUSIVE.
(tsubst_expr): Handle OMP_SCAN.
testsuite/
* c-c++-common/gomp/scan-1.c: New test.
* c-c++-common/gomp/scan-2.c: New test.
* c-c++-common/gomp/scan-3.c: New test.
* c-c++-common/gomp/scan-4.c: New test.

--- gcc/tree.def.jj 2019-06-07 16:55:05.817651838 +0200
+++ gcc/tree.def2019-06-07 18:20:48.952775949 +0200
@@ -1191,6 +1191,11 @@ DEFTREECODE (OMP_SINGLE, "omp_single", t
Operand 1: OMP_SINGLE_CLAUSES: List of clauses.  */
 DEFTREECODE (OMP_TASKGROUP, "omp_taskgroup", tcc_statement, 2)
 
+/* OpenMP - #pragma omp scan
+   Operand 0: OMP_SCAN_BODY: Scan body.
+   Operand 1: OMP_SCAN_CLAUSES: List of clauses.  */
+DEFTREECODE (OMP_SCAN, "omp_scan", tcc_statement, 2)
+
 /* OpenMP - #pragma omp section
Operand 0: 

[PATCH][OBVIOUS] Update __gcov_* scanned function name in a test-case.

2019-06-10 Thread Martin Liška
Hi.

The patch is fixing scanned name of a function in a test-case.
The patch fixes the test-case.

Martin

gcc/testsuite/ChangeLog:

2019-06-10  Martin Liska  

* gcc.dg/no_profile_instrument_function-attr-1.c: Fix
function name.
---
 gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


diff --git a/gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-1.c b/gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-1.c
index 41d745532fa..0c7e0961824 100644
--- a/gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-1.c
+++ b/gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-1.c
@@ -19,6 +19,6 @@ int main ()
 }
 
 /* { dg-final { scan-tree-dump-times "__gcov0\\.main.* = PROF_edge_counter" 1 "optimized"} } */
-/* { dg-final { scan-tree-dump-times "__gcov_indirect_call_profiler_v3" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "__gcov_indirect_call_profiler_v" 1 "optimized" } } */
 /* { dg-final { scan-tree-dump-times "__gcov_time_profiler_counter = " 1 "optimized" } } */
 /* { dg-final { scan-tree-dump-times "__gcov_init" 1 "optimized" } } */



Allow conversions in X/[ex]4 < Y/[ex]4

2019-06-10 Thread Marc Glisse

Hello,

if we compare for instance size() and capacity() for a std::vector, we get 
this kind of pattern. I started with just nop conversions and got a bit 
carried away handling all those cases.


Bootstrap+regtest on x86_64-pc-linux-gnu.

2019-06-11  Marc Glisse  

gcc/
* match.pd (X/[ex]4Index: gcc/match.pd
===
--- gcc/match.pd	(revision 272105)
+++ gcc/match.pd	(working copy)
@@ -1496,25 +1496,40 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 	&& TYPE_UNSIGNED (TREE_TYPE (@0))
 	&& TYPE_PRECISION (TREE_TYPE (@0)) > 1
 	&& (wi::to_wide (@2)
 	== wi::max_value (TYPE_PRECISION (TREE_TYPE (@0)), SIGNED) - 1))
 (with { tree stype = signed_type_for (TREE_TYPE (@0)); }
  (icmp (convert:stype @0) { build_int_cst (stype, 0); })
 
 /* X / 4 < Y / 4 iff X < Y when the division is known to be exact.  */
 (for cmp (simple_comparison)
  (simplify
-  (cmp (exact_div @0 INTEGER_CST@2) (exact_div @1 @2))
-  (if (wi::gt_p (wi::to_wide (@2), 0, TYPE_SIGN (TREE_TYPE (@2
-   (cmp @0 @1)
+  (cmp (convert?@3 (exact_div @0 INTEGER_CST@2)) (convert? (exact_div @1 @2)))
+  (if (element_precision (TREE_TYPE (@3)) >= element_precision (TREE_TYPE (@0))
+   && types_match (TREE_TYPE (@0), TREE_TYPE (@1)))
(if (wi::lt_p (wi::to_wide (@2), 0, TYPE_SIGN (TREE_TYPE (@2
-(cmp @1 @0)
+(if (!TYPE_UNSIGNED (TREE_TYPE (@3)))
+ (cmp @1 @0)
+ (if (tree_expr_nonzero_p (@0) && tree_expr_nonzero_p (@1))
+  (with
+   {
+	tree utype = unsigned_type_for (TREE_TYPE (@0));
+   }
+   (cmp (convert:utype @1) (convert:utype @0)
+(if (wi::gt_p (wi::to_wide (@2), 1, TYPE_SIGN (TREE_TYPE (@2
+ (if (TYPE_UNSIGNED (TREE_TYPE (@0)) || !TYPE_UNSIGNED (TREE_TYPE (@3)))
+  (cmp @0 @1)
+  (with
+   {
+	tree utype = unsigned_type_for (TREE_TYPE (@0));
+   }
+   (cmp (convert:utype @0) (convert:utype @1)
 
 /* X / C1 op C2 into a simple range test.  */
 (for cmp (simple_comparison)
  (simplify
   (cmp (trunc_div:s @0 INTEGER_CST@1) INTEGER_CST@2)
   (if (INTEGRAL_TYPE_P (TREE_TYPE (@0))
&& integer_nonzerop (@1)
&& !TREE_OVERFLOW (@1)
&& !TREE_OVERFLOW (@2))
(with { tree lo, hi; bool neg_overflow;
Index: gcc/testsuite/gcc.dg/tree-ssa/cmpexactdiv-5.c
===
--- gcc/testsuite/gcc.dg/tree-ssa/cmpexactdiv-5.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/tree-ssa/cmpexactdiv-5.c	(working copy)
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-optimized-raw" } */
+
+int f(int *a, int *b, int *c){
+  if(sizeof(__SIZE_TYPE__) != sizeof(__PTRDIFF_TYPE__)) return 2;
+  __SIZE_TYPE__ s = b - a;
+  __SIZE_TYPE__ t = c - a;
+  return s < t;
+}
+
+/* { dg-final { scan-tree-dump-not "exact_div_expr" "optimized" } } */


Re: [Patch, fortran] PR90786 - [7/8/9/10 Regression] ICE on procedure pointer assignment to function with class pointer result

2019-06-10 Thread Paul Richard Thomas
Hi Christophe,

I'll have a think about this tonight. Is valgrind or some similar
available for arm/aarch64?

Many thanks for flagging it up.

Paul

On Mon, 10 Jun 2019 at 10:07, Christophe Lyon
 wrote:
>
> On Sat, 8 Jun 2019 at 18:25, Andrew Benson  
> wrote:
> >
> > Thanks Paul for the quick fix!
> >
> > On Saturday, June 8, 2019 4:56:46 PM PDT Paul Richard Thomas wrote:
> > > Committed as obvious in revision 272084.
> > >
> > > The problem was that the lhs symbol itself was not being checked as a
> > > proc_pointer - just the expression component.
> > >
> > > I will get on with backporting tomorrow.
> > >
> > > Cheers
> > >
> > > Paul
> > >
> > > 2019-06-08  Paul Thomas  
> > >
> > > PR fortran/90786
> > > * trans-expr.c (pointer_assignment_is_proc_pointer) Remove as
> > > it is very simple and only called from one place.
> > > (gfc_trans_pointer_assignment): Rename non_proc_pointer_assign
> > > as non_proc_ptr_assign. Assign to it directly, rather than call
> > > to above, deleted function and use gfc_expr_attr instead of
> > > only checking the reference chain.
> > >
> > > 2019-06-08  Paul Thomas  
> > >
> > > PR fortran/90786
> > > * gfortran.dg/proc_ptr_51.f90 : New test.
> >
> >
>
> Hi,
>
> I've noticed that this new test fails on arm/aarch64:
> FAIL:gfortran.dg/proc_ptr_51.f90   -O2  execution test
> FAIL:gfortran.dg/proc_ptr_51.f90   -O3 -fomit-frame-pointer
> -funroll-loops -fpeel-loops -ftracer -finline-functions  execution
> test
> FAIL:gfortran.dg/proc_ptr_51.f90   -O3 -g  execution test
>
> the logs say:
> Program received signal SIGSEGV: Segmentation fault - invalid memory 
> reference.
>
> Backtrace for this error:
> #0  0xa938f66b in ???
> #1  0x0 in ???
>
> Christophe
>
> > --
> >
> > * Andrew Benson: http://users.obs.carnegiescience.edu/abenson/contact.html
> >
> > * Galacticus: https://bitbucket.org/galacticusdev/galacticus
> >



-- 
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein


Re: [PATCH] Construct ipa_reduced_postorder always for overwritable (PR ipa/89009).

2019-06-10 Thread Jan Hubicka
> Hi.
> 
> IPA pure const should always construct ipa_reduced_postorder with
> possibility to cross AVAIL_INTERPOSABLE boundary. The pass itself
> can then properly stop propagation on these symbols.
> 
> The patch is pre-approved by Honza.
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
> 
> Thanks,
> Martin
> 
> gcc/ChangeLog:
> 
> 2019-02-08  Martin Liska  
> 
>   PR ipa/89009
>   * ipa-cp.c (build_toporder_info): Remove usage of a param.
>   * ipa-inline.c (inline_small_functions): Likewise.
>   * ipa-pure-const.c (propagate_pure_const): Likewise.
>   (propagate_nothrow): Likewise.
>   * ipa-reference.c (propagate): Likewise.
>   * ipa-utils.c (struct searchc_env): Remove unused field.
>   (searchc): Always search across AVAIL_INTERPOSABLE.
>   (ipa_reduced_postorder): Always allow AVAIL_INTERPOSABLE as
>   the only called IPA pure const can properly not propagate
>   across interposable boundary.
>   * ipa-utils.h (ipa_reduced_postorder): Remove param.

OK,
thanks!

Honza


[C++ Patch] More grokdeclarator locations fixes

2019-06-10 Thread Paolo Carlini

Hi,

this one requires my last patch, uses id_loc in a few additional places 
in the last part of the function.


Most of the changes should be straightforward, I only want to mention 
the "typedef name may not be a nested-name-specifier" change, where, not 
using input_location means that for a test like 
g++.old-deja/g++.jason/crash10.C:


struct A {
  enum foo { bar };
};

typedef A::foo A::foo;

the location is under the 'A' of the second 'A::foo'. The EDG front-end 
does exactly the same; clang points to the 'f' but then has the wavy 
thing reaching back to 'A' (a while ago I already mentioned that we 
don't have that option). Tested x86_64-linux.


Thanks, Paolo.

/

/cp
2019-06-10  Paolo Carlini  

* decl.c (grokdeclarator): Use id_loc in five additional places
in the last part of the function.

/testsuite
2019-06-10  Paolo Carlini  

* g++.dg/diagnostic/variably-modified-type-1.C: New.
* g++.dg/cpp0x/alias-decl-1.C: Test the location too.
* g++.dg/other/pr84792-1.C: Likewise.
* g++.dg/other/pr84792-2.C: Likewise.
* g++.dg/parse/error24.C: Likewise.
* g++.dg/parse/error32.C: Likewise.
* g++.dg/parse/error33.C: Likewise.
* g++.dg/parse/saved1.C: Likewise.
* g++.dg/template/operator6.C: Likewise.
* g++.dg/template/pr61745.C: Likewise.
* g++.dg/template/typedef41.C: Likewise.
* g++.old-deja/g++.jason/crash10.C: Likewise.
Index: cp/decl.c
===
--- cp/decl.c   (revision 272105)
+++ cp/decl.c   (working copy)
@@ -12000,9 +12000,11 @@ grokdeclarator (const cp_declarator *declarator,
   && variably_modified_type_p (type, NULL_TREE))
 {
   if (decl_context == FIELD)
-   error ("data member may not have variably modified type %qT", type);
+   error_at (id_loc,
+ "data member may not have variably modified type %qT", type);
   else
-   error ("parameter may not have variably modified type %qT", type);
+   error_at (id_loc,
+ "parameter may not have variably modified type %qT", type);
   type = error_mark_node;
 }
 
@@ -12106,7 +12108,7 @@ grokdeclarator (const cp_declarator *declarator,
 
   if (id_declarator && declarator->u.id.qualifying_scope)
{
- error ("typedef name may not be a nested-name-specifier");
+ error_at (id_loc, "typedef name may not be a nested-name-specifier");
  type = error_mark_node;
}
 
@@ -12130,7 +12132,7 @@ grokdeclarator (const cp_declarator *declarator,
}
   else if (current_class_type
   && constructor_name_p (unqualified_id, current_class_type))
-   permerror (input_location, "ISO C++ forbids nested type %qD with same 
name "
+   permerror (id_loc, "ISO C++ forbids nested type %qD with same name "
   "as enclosing class",
   unqualified_id);
 
@@ -12288,7 +12290,7 @@ grokdeclarator (const cp_declarator *declarator,
   /* Only functions may be declared using an operator-function-id.  */
   if (dname && IDENTIFIER_ANY_OP_P (dname))
{
- error ("declaration of %qD as non-function", dname);
+ error_at (id_loc, "declaration of %qD as non-function", dname);
  return error_mark_node;
}
 
Index: testsuite/g++.dg/cpp0x/alias-decl-1.C
===
--- testsuite/g++.dg/cpp0x/alias-decl-1.C   (revision 272105)
+++ testsuite/g++.dg/cpp0x/alias-decl-1.C   (working copy)
@@ -11,5 +11,6 @@ template  using Ptr = U*;
 template struct Ptr {}; // { dg-error "specialization" }
 
 struct A {
-using A = int;//{ dg-error "nested|has|same name as|class|in 
which|declared" }
+using A = int;  // { dg-error "11:ISO C\\+\\+ forbids nested type .A." }
+// { dg-error "same name as" "" { target c++11 } .-1 }  
 };
Index: testsuite/g++.dg/diagnostic/variably-modified-type-1.C
===
--- testsuite/g++.dg/diagnostic/variably-modified-type-1.C  (nonexistent)
+++ testsuite/g++.dg/diagnostic/variably-modified-type-1.C  (working copy)
@@ -0,0 +1,12 @@
+// { dg-options "" }
+
+void foo ()
+{
+  int n;
+  typedef int X[n];
+  struct Z
+  {
+X x __attribute__((unused)); // { dg-error "7:data member may not have 
variably modified type" }
+void bar (X x __attribute__((unused))); // { dg-error "17:parameter may 
not have variably modified type" }
+  };
+}
Index: testsuite/g++.dg/other/pr84792-1.C
===
--- testsuite/g++.dg/other/pr84792-1.C  (revision 272105)
+++ testsuite/g++.dg/other/pr84792-1.C  (working copy)
@@ -3,4 +3,4 @@ struct A {};
 typedef struct
 {
   virtual void foo() {}
-} A::B;  // { dg-error "typedef" }
+} A::B;  // { dg-error "3:typedef" }
Index: testsuite/g++.dg/other/pr84792-2.C

[PATCH][OBVIOUS] Add missing ATTR_UNUSED (PR bootstrap/90808).

2019-06-10 Thread Martin Liška
Hi.

This is addition of a missing ATTRIBUTE_UNUSED that is needed
as the usage is conditional (#ifdef).

I'm going to install the patch.

Thanks,
Martin

libgcc/ChangeLog:

2019-06-10  Martin Liska  

PR bootstrap/90808
* libgcov.h: Add ATTRIBUTE_UNUSED.
---
 libgcc/libgcov.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


diff --git a/libgcc/libgcov.h b/libgcc/libgcov.h
index 144b4817a37..7f316146d49 100644
--- a/libgcc/libgcov.h
+++ b/libgcc/libgcov.h
@@ -328,7 +328,7 @@ gcov_get_counter (void)
when read value is equal to IGNORE_SCALING.  */
 
 static inline gcov_type
-gcov_get_counter_ignore_scaling (gcov_type ignore_scaling)
+gcov_get_counter_ignore_scaling (gcov_type ignore_scaling ATTRIBUTE_UNUSED)
 {
 #ifndef IN_GCOV_TOOL
   /* This version is for reading count values in libgcov runtime:



Re: RFA: Synchronize top level files with binutils

2019-06-10 Thread Nick Clifton
Hi Richard,

  OK, here is a resubmission of my patch with just the addition of the
  libctf patches this time.  (Sorry about the previous bad patch).
  Tested with a bootstrap and a normal build.  OK to apply ?

Cheers
  Nick

2019-06-07  Nick Clifton  

Import these changes from the binutils/gdb repository:

2019-05-28  Nick Alcock  

* Makefile.def (dependencies): configure-libctf depends on all-bfd
and all its deps.
* Makefile.in: Regenerated.

2019-05-28  Nick Alcock  

* Makefile.def (host_modules): Add libctf.
* Makefile.def (dependencies): Likewise.
libctf depends on zlib, libiberty, and bfd.
* Makefile.in: Regenerated.
* configure.ac (host_libs): Add libctf.
* configure: Regenerated.

Index: Makefile.def
===
--- Makefile.def(revision 272111)
+++ Makefile.def(working copy)
@@ -4,7 +4,7 @@
 // Makefile.in is generated from Makefile.tpl by 'autogen Makefile.def'.
 // This file was originally written by Nathanael Nerode.
 //
-//   Copyright 2002-2013 Free Software Foundation
+//   Copyright 2002-2019 Free Software Foundation
 //
 // This file is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -128,6 +128,8 @@
extra_make_flags='@extra_linker_plugin_flags@'; };
 host_modules= { module= libcc1; extra_configure_flags=--enable-shared; };
 host_modules= { module= gotools; };
+host_modules= { module= libctf; no_install=true; no_check=true;
+   bootstrap=true; };
 
 target_modules = { module= libstdc++-v3;
   bootstrap=true;
@@ -428,6 +430,7 @@
 dependencies = { module=all-binutils; on=all-build-bison; };
 dependencies = { module=all-binutils; on=all-intl; };
 dependencies = { module=all-binutils; on=all-gas; };
+dependencies = { module=all-binutils; on=all-libctf; };
 
 // We put install-opcodes before install-binutils because the installed
 // binutils might be on PATH, and they might need the shared opcodes
@@ -518,6 +521,14 @@
 dependencies = { module=all-fastjar; on=all-zlib; };
 dependencies = { module=all-fastjar; on=all-build-texinfo; };
 dependencies = { module=all-fastjar; on=all-libiberty; };
+dependencies = { module=all-libctf; on=all-libiberty; hard=true; };
+dependencies = { module=all-libctf; on=all-bfd; };
+dependencies = { module=all-libctf; on=all-zlib; };
+// So that checking for ELF support in BFD from libctf configure is possible.
+dependencies = { module=configure-libctf; on=all-bfd; };
+dependencies = { module=configure-libctf; on=all-intl; };
+dependencies = { module=configure-libctf; on=all-zlib; };
+dependencies = { module=configure-libctf; on=all-libiconv; };
 
 // Warning, these are not well tested.
 dependencies = { module=all-bison; on=all-intl; };
Index: configure.ac
===
--- configure.ac(revision 272111)
+++ configure.ac(working copy)
@@ -131,7 +131,7 @@
 
 # these libraries are used by various programs built for the host environment
 #f
-host_libs="intl libiberty opcodes bfd readline tcl tk itcl libgui zlib 
libbacktrace libcpp libdecnumber gmp mpfr mpc isl libelf libiconv"
+host_libs="intl libiberty opcodes bfd readline tcl tk itcl libgui zlib 
libbacktrace libcpp libdecnumber gmp mpfr mpc isl libelf libiconv libctf"
 
 # these tools are built for the host environment
 # Note, the powerpc-eabi build depends on sim occurring before gdb in order to


[PATCH][gcc] libgccjit: check result_type in gcc_jit_context_new_binary_op

2019-06-10 Thread Andrea Corallo
Hi all,
I would like to propose this patch to check for the return type of
binary operators to be a numeric type.
Not doing so can lead the compiler into funny crashes.

Does not introduce regressions running make check-jit.

OK for trunk?

Bests
  Andrea

2019-06-09  Andrea Corallo  andrea.cora...@arm.com

* libgccjit.c (gcc_jit_context_new_binary_op): Check result_type to be a
numeric type.
diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
index e4f17f8..95a2c02 100644
--- a/gcc/jit/libgccjit.c
+++ b/gcc/jit/libgccjit.c
@@ -1345,6 +1345,10 @@ gcc_jit_context_new_binary_op (gcc_jit_context *ctxt,
 a->get_type ()->get_debug_string (),
 b->get_debug_string (),
 b->get_type ()->get_debug_string ());
+  RETURN_NULL_IF_FAIL_PRINTF1 (
+result_type->is_numeric (), ctxt, loc,
+"result_type type: %s is not numeric",
+result_type->get_debug_string ());
 
   return (gcc_jit_rvalue *)ctxt->new_binary_op (loc, op, result_type, a, b);
 }


Re: [Patch, fortran] PR90786 - [7/8/9/10 Regression] ICE on procedure pointer assignment to function with class pointer result

2019-06-10 Thread Christophe Lyon
On Sat, 8 Jun 2019 at 18:25, Andrew Benson  wrote:
>
> Thanks Paul for the quick fix!
>
> On Saturday, June 8, 2019 4:56:46 PM PDT Paul Richard Thomas wrote:
> > Committed as obvious in revision 272084.
> >
> > The problem was that the lhs symbol itself was not being checked as a
> > proc_pointer - just the expression component.
> >
> > I will get on with backporting tomorrow.
> >
> > Cheers
> >
> > Paul
> >
> > 2019-06-08  Paul Thomas  
> >
> > PR fortran/90786
> > * trans-expr.c (pointer_assignment_is_proc_pointer) Remove as
> > it is very simple and only called from one place.
> > (gfc_trans_pointer_assignment): Rename non_proc_pointer_assign
> > as non_proc_ptr_assign. Assign to it directly, rather than call
> > to above, deleted function and use gfc_expr_attr instead of
> > only checking the reference chain.
> >
> > 2019-06-08  Paul Thomas  
> >
> > PR fortran/90786
> > * gfortran.dg/proc_ptr_51.f90 : New test.
>
>

Hi,

I've noticed that this new test fails on arm/aarch64:
FAIL:gfortran.dg/proc_ptr_51.f90   -O2  execution test
FAIL:gfortran.dg/proc_ptr_51.f90   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution
test
FAIL:gfortran.dg/proc_ptr_51.f90   -O3 -g  execution test

the logs say:
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0xa938f66b in ???
#1  0x0 in ???

Christophe

> --
>
> * Andrew Benson: http://users.obs.carnegiescience.edu/abenson/contact.html
>
> * Galacticus: https://bitbucket.org/galacticusdev/galacticus
>


Re: [PATCH 1/2] [ARC] Improve code gen when compiling for size

2019-06-10 Thread Claudiu Zissulescu
Committed with your feedback taken into account. Thank you for your review,
Claudiu

On Sat, Jun 8, 2019 at 12:57 AM Jeff Law  wrote:
>
> On 6/6/19 1:42 AM, Claudiu Zissulescu wrote:
> > When optimizing for size, try to avoid using long immediate by
> > employing alternative (short) instructions.
> >
> > Ok to apply?
> > Claudiu
> >
> > gcc/
> > -xx-xx  Claudiu Zissulescu  
> >
> >   * config/arc/arc-protos.h (arc_check_ior_const): Declare.
> >   (arc_split_ior): Likewise.
> >   (arc_check_mov_const): Likewise.
> >   (arc_split_mov_const): Likewise.
> >   * config/arc/arc.c (arc_print_operand): Fix 'z' letter.
> >   (arc_rtx_costs): Replace check Crr with Cax constraint.
> >   (prepare_move_operands): Cleanup, remove unused code.
> >   (arc_split_ior): New function.
> >   (arc_check_ior_const): Likewise.
> >   (arc_split_mov_const): Likewise.
> >   (arc_check_mov_const): Likewise.
> >   * config/arc/arc.md (movsi_insn): Restructure it, and convert it
> >   in define_insn_and_split pattern.
> >   (iorsi3): Likewise.
> >   (mulsi3_v2): Add new matching variant.
> >   (andsi3_i): Cleanup pattern.
> >   (rotrsi3_cnt1): Update pattern.
> >   (rotrsi3_cnt8): New pattern.
> >   (ashlsi2_cnt8): Likewise.
> >   (ashlsi2_cnt16): Likewise.
> >   * config/arc/constraints.md (C0p): Update constraint.
> >   (Crr): Remove it.
> >   (C0x): New pattern.
> >   (Cax): New pattern.
> >
> > testsuite/
> > -xx-xx  Claudiu Zissulescu  
> >
> >   * gcc.target/arc/and-cnst-size.c: New test.
> >   * gcc.target/arc/mov-cnst-size.c: Likewise.
> >   * gcc.target/arc/or-cnst-size.c: Likewise.
> >   * gcc.target/arc/store-merge-1.c: Update test.
> >   * gcc.target/arc/arc700-stld-hazard.c: Likewise.
> >   * gcc.target/arc/cmem-1.c: Likewise.
> >   * gcc.target/arc/cmem-2.c: Likewise.
> >   * gcc.target/arc/cmem-3.c: Likewise.
> >   * gcc.target/arc/cmem-4.c: Likewise.
> >   * gcc.target/arc/cmem-5.c: Likewise.
> >   * gcc.target/arc/cmem-6.c: Likewise.
> >   * gcc.target/arc/loop-4.c: Likewise.
> >   * gcc.target/arc/movh_cl-1.c: Likewise.
> >   * gcc.target/arc/sdata-3.c: Likewise.
> > ---
> >
> > diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
> > index b49f2539408..f398c4a0086 100644
> > --- a/gcc/config/arc/arc.c
> > +++ b/gcc/config/arc/arc.c
> > @@ -11457,6 +11429,198 @@ arc_memory_move_cost (machine_mode mode,
> >return (2 * GET_MODE_SIZE (mode));
> >  }
> >
> > +/* Split an OR instruction into multiple BSET/OR instructions in a
> > +   tentative to avoid long immediate constants.  The next strategies
> > +   are employed when destination is 'q' reg.
> s/tentative/attempt/ ?
>
> > +
> > +   1. if there are up to three bits set in the mask, a succesion of
> s/succesion/succession/
>
> OK with the nits fixed.
>
> jeff


Re: [PATCH 2/2] [ARC] Update RTX costs.

2019-06-10 Thread Claudiu Zissulescu
Thank you for your review! Patch committed,
Claudiu

On Sat, Jun 8, 2019 at 12:57 AM Jeff Law  wrote:
>
> On 6/6/19 1:42 AM, Claudiu Zissulescu wrote:
> > Update RTX costs to reflect better the ARC architecture.
> >
> > Ok to apply?
> > Claudiu
> >
> > gcc/
> > -xx-xx  Claudiu Zissulescu  
> >
> >   * config/arc/arc.c (arc_rtx_costs): Update costs.
> >
> > /gcc/testsuite
> > -xx-xx  Claudiu Zissulescu  
> >
> >   * gcc.target/arc/jumptables.c: Update test.
> OK
> jeff


Re: [PATCH 2/4] Implement N disk counters for single value and indirect call counters.

2019-06-10 Thread Martin Liška
On 6/7/19 3:58 PM, Jan Hubicka wrote:
>>
>> Because I removed hist->hvalue.counters[2] where we stored total number of 
>> executions.
>> It's back again so that _atomic suffix version makes sense again.
> 
> OK and we do not care about race conditions on the other two counters?

We do care, but one can't probably implement that without a locking of the 
critical section:

   117  static inline void
   118  __gcov_one_value_profiler_body (gcov_type *counters, gcov_type value,
   119  int use_atomic)
   120  {
   121if (value == counters[1])
   122  counters[2]++;
   123else if (counters[2] == 0)
   124  {
   125counters[2] = 1;
   126counters[1] = value;
   127  }
   128else
   129  counters[2]--;

Here you operate with 2 values which can change during a parallel execution.

>>
>> After we discussed that I decided to live with all counters in memory. 
>> Reason is that
>> in write_one_data we would have to allocate temporary buffers and fill up 
>> them here:
>>
>>304tag = gcov_read_unsigned ();
>>305length = gcov_read_unsigned ();
>>306if (tag != GCOV_TAG_FOR_COUNTER (t_ix)
>>307|| length != GCOV_TAG_COUNTER_LENGTH (ci_ptr->num))
>>308  goto read_mismatch;
>>309(*merge) (ci_ptr->values, ci_ptr->num);
>>310ci_ptr++;
>>
>> It would be quite nasty and I would like to mitigate libgcov profile crashes.
> 
> Hmm, I see, if code was organized to directly write the output, it would
> be easier.  I guess it is not overly important.
> 
> Patch is OK

Thanks for the approval.

Martin

> Honza
> 



[PATCH, testsuite, obvious] Require alias support in a test using it.

2019-06-10 Thread Iain Sandoe
attr-copy-6.c fails on Darwin which doesn’t have alias support.
Fixed by adding the dg-requires line.
tested on x86_64-darwin16, x86_64-linux-gnu
applied as obvious to mainline.
thanks
Iain


2019-06-10  Iain Sandoe  

* gcc.dg/attr-copy-6.c: Require alias support.

diff --git a/gcc/testsuite/gcc.dg/attr-copy-6.c 
b/gcc/testsuite/gcc.dg/attr-copy-6.c
index 010db0d..d1a2865 100644
--- a/gcc/testsuite/gcc.dg/attr-copy-6.c
+++ b/gcc/testsuite/gcc.dg/attr-copy-6.c
@@ -2,6 +2,7 @@
{ dg-do compile }
{ dg-skip-if "Attributes not supported" { { hppa*-*-hpux* } && { ! lp64 } } 
}
{ dg-options "-O2 -Wall" }
+   { dg-require-alias "" }
{ dg-require-weak "" } */
 
 #define ATTR(...)   __attribute__ ((__VA_ARGS__))



Re: [doc] extend.texi -- clarify no_sanitize

2019-06-10 Thread Martin Liška
On 6/9/19 5:42 PM, Gerald Pfeifer wrote:
> In some interpretations "not...of all" may not be seen as 
> 100% clear, so I propose to use "not...of any".
> 
> On the way fix the grammar in the next sentence.
> 
> Sandra, and Martin as the original author, does this makes 
> sense for you?

I'm fine with the Gerald. Thank you for it.

Martin

> 
> Gerald
> 
> 
> 2019-06-09  Gerald Pfeifer  
> 
>   * doc/extend.texi (Common Function Attributes): Clarify
>   no_sanitize.  Fix grammar.
> 
> Index: doc/extend.texi
> ===
> --- doc/extend.texi   (revision 272089)
> +++ doc/extend.texi   (working copy)
> @@ -3215,9 +3215,9 @@ marked symbols.
>  @item no_sanitize ("@var{sanitize_option}")
>  @cindex @code{no_sanitize} function attribute
>  The @code{no_sanitize} attribute on functions is used
> -to inform the compiler that it should not do sanitization of all options
> +to inform the compiler that it should not do sanitization of any option
>  mentioned in @var{sanitize_option}.  A list of values acceptable by
> -@option{-fsanitize} option can be provided.
> +the @option{-fsanitize} option can be provided.
>  
>  @smallexample
>  void __attribute__ ((no_sanitize ("alignment", "object-size")))
> 



Re: [PATCH][RFC] Sanitize equals and hash functions in hash-tables.

2019-06-10 Thread Martin Liška
On 6/7/19 11:43 PM, Jason Merrill wrote:
> On Fri, Jun 7, 2019 at 8:14 AM Martin Liška  wrote:
>>
>> On 6/7/19 2:09 PM, Richard Biener wrote:
>>> On Fri, Jun 7, 2019 at 2:03 PM Martin Liška  wrote:

 On 6/7/19 10:57 AM, Richard Biener wrote:
> On Mon, Jun 3, 2019 at 3:35 PM Martin Liška  wrote:
>>
>> On 6/1/19 12:06 AM, Jeff Law wrote:
>>> On 5/22/19 3:13 AM, Martin Liška wrote:
 On 5/21/19 1:51 PM, Richard Biener wrote:
> On Tue, May 21, 2019 at 1:02 PM Martin Liška  wrote:
>>
>> On 5/21/19 11:38 AM, Richard Biener wrote:
>>> On Tue, May 21, 2019 at 12:07 AM Jeff Law  wrote:

 On 5/13/19 1:41 AM, Martin Liška wrote:
> On 11/8/18 9:56 AM, Martin Liška wrote:
>> On 11/7/18 11:23 PM, Jeff Law wrote:
>>> On 10/30/18 6:28 AM, Martin Liška wrote:
 On 10/30/18 11:03 AM, Jakub Jelinek wrote:
> On Mon, Oct 29, 2018 at 04:14:21PM +0100, Martin Liška wrote:
>> +hashtab_chk_error ()
>> +{
>> +  fprintf (stderr, "hash table checking failed: "
>> +   "equal operator returns true for a pair "
>> +   "of values with a different hash value");
> BTW, either use internal_error here, or at least if using 
> fprintf
> terminate with \n, in your recent mail I saw:
> ...different hash valueduring RTL pass: vartrack
> ^^
 Sure, fixed in attached patch.

 Martin

>> +  gcc_unreachable ();
>> +}
>   Jakub
>
 0001-Sanitize-equals-and-hash-functions-in-hash-tables.patch

 From 0d9c979c845580a98767b83c099053d36eb49bb9 Mon Sep 17 
 00:00:00 2001
 From: marxin 
 Date: Mon, 29 Oct 2018 09:38:21 +0100
 Subject: [PATCH] Sanitize equals and hash functions in 
 hash-tables.

 ---
  gcc/hash-table.h | 40 +++-
  1 file changed, 39 insertions(+), 1 deletion(-)

 diff --git a/gcc/hash-table.h b/gcc/hash-table.h
 index bd83345c7b8..694eedfc4be 100644
 --- a/gcc/hash-table.h
 +++ b/gcc/hash-table.h
 @@ -503,6 +503,7 @@ private:

value_type *alloc_entries (size_t n CXX_MEM_STAT_INFO) 
 const;
value_type *find_empty_slot_for_expand (hashval_t);
 +  void verify (const compare_type , hashval_t 
 hash);
bool too_empty_p (unsigned int);
void expand ();
static bool is_deleted (value_type )
 @@ -882,8 +883,12 @@ hash_table
if (insert == INSERT && m_size * 3 <= m_n_elements * 4)
  expand ();

 -  m_searches++;
 +#if ENABLE_EXTRA_CHECKING
 +if (insert == INSERT)
 +  verify (comparable, hash);
 +#endif

 +  m_searches++;
value_type *first_deleted_slot = NULL;
hashval_t index = hash_table_mod1 (hash, 
 m_size_prime_index);
hashval_t hash2 = hash_table_mod2 (hash, 
 m_size_prime_index);
 @@ -930,6 +935,39 @@ hash_table
return _entries[index];
  }

 +#if ENABLE_EXTRA_CHECKING
 +
 +/* Report a hash table checking error.  */
 +
 +ATTRIBUTE_NORETURN ATTRIBUTE_COLD
 +static void
 +hashtab_chk_error ()
 +{
 +  fprintf (stderr, "hash table checking failed: "
 + "equal operator returns true for a pair "
 + "of values with a different hash value\n");
 +  gcc_unreachable ();
 +}
>>> I think an internal_error here is probably still better than a 
>>> simple
>>> fprintf, even if the fprintf is terminated with a \n :-)
>> Fully agree with that, but I see a lot of build errors when 
>> using internal_error.
>>
>>> The question then becomes can we bootstrap with this stuff 
>>> enabled and
>>> if not, are we likely to soon?  It'd be a shame to put it into
>>> EXTRA_CHECKING, but then not be able to really use 
>>> EXTRA_CHECKING

[PATCH][OBVIOUS] Fix build with --enable-gather-detailed-mem-stats.

2019-06-10 Thread Martin Liška
Hi.

This is one more fix of the hash_table where I forgot to pass
a new parameter in hash_table::hash_table.

I'm going to install it as obvious.
Martin

gcc/ChangeLog:

2019-06-10  Martin Liska  

* hash-map.h: Pass default value to hash_table ctor.
* hash-table.h: Add default value to call of a ctor.
---
 gcc/hash-map.h   | 6 --
 gcc/hash-table.h | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)


diff --git a/gcc/hash-map.h b/gcc/hash-map.h
index a3ef283a1f9..a8eb42d5a03 100644
--- a/gcc/hash-map.h
+++ b/gcc/hash-map.h
@@ -120,12 +120,14 @@ public:
   explicit hash_map (size_t n = 13, bool ggc = false,
 		 bool gather_mem_stats = GATHER_STATISTICS
 		 CXX_MEM_STAT_INFO)
-: m_table (n, ggc, gather_mem_stats, HASH_MAP_ORIGIN PASS_MEM_STAT) {}
+: m_table (n, ggc, true, gather_mem_stats, HASH_MAP_ORIGIN PASS_MEM_STAT)
+  {
+  }
 
   explicit hash_map (const hash_map , bool ggc = false,
 		 bool gather_mem_stats = GATHER_STATISTICS
 		 CXX_MEM_STAT_INFO)
-: m_table (h.m_table, ggc, gather_mem_stats,
+: m_table (h.m_table, ggc, true, gather_mem_stats,
 	   HASH_MAP_ORIGIN PASS_MEM_STAT) {}
 
   /* Create a hash_map in ggc memory.  */
diff --git a/gcc/hash-table.h b/gcc/hash-table.h
index 686a13dbd4b..6c1fca3459b 100644
--- a/gcc/hash-table.h
+++ b/gcc/hash-table.h
@@ -389,7 +389,7 @@ public:
   create_ggc (size_t n CXX_MEM_STAT_INFO)
   {
 hash_table *table = ggc_alloc ();
-new (table) hash_table (n, true, GATHER_STATISTICS,
+new (table) hash_table (n, true, true, GATHER_STATISTICS,
 			HASH_TABLE_ORIGIN PASS_MEM_STAT);
 return table;
   }



Re: Test for C++20 p0858 - ConstexprIterator requirements.

2019-06-10 Thread Ville Voutilainen
On Mon, 10 Jun 2019 at 02:53, Ed Smith-Rowland <3dw...@verizon.net> wrote:

> Darn it, I had those constexpr lib patches in tree.
> Attached are what I just committed to gcc-9 and passes there. Those
> std::copy didn't really add anything anyway.

They added a test that *i++ = *j++ works, and that i != j works.