[PATCH] c++, v2: Fix up floating point complex handling in build_zero_init_1 [PR98353]

2020-12-22 Thread Jakub Jelinek via Gcc-patches
On Tue, Dec 22, 2020 at 09:56:03AM -0500, Jason Merrill via Gcc-patches wrote:
> > Not exactly sure why we just don't call build_zero_cst (type); for the > 
> > scalar types
> 
> I don't know either.  Want to test that?

The following passed bootstrap/regtested on x86_64-linux and i686-linux too.
And the function comment even confirms the behavior we need for
build_zero_init_1:
/* Build 0 constant of type TYPE.  This is used by constructor folding
   and thus the constant should be represented in memory by
   zero(es).  */
Ok for trunk?

2020-12-23  Jakub Jelinek  

PR c++/98353
* init.c (build_zero_init_1): Use build_zero_cst for SCALAR_TYPE_P
zero initializers.

--- gcc/cp/init.c.jj2020-12-09 09:03:38.270054654 +0100
+++ gcc/cp/init.c   2020-12-21 13:51:57.353332652 +0100
@@ -187,7 +187,7 @@ build_zero_init_1 (tree type, tree nelts
   else if (NULLPTR_TYPE_P (type))
 init = build_int_cst (type, 0);
   else if (SCALAR_TYPE_P (type))
-init = fold (convert (type, integer_zero_node));
+init = build_zero_cst (type);
   else if (RECORD_OR_UNION_CODE_P (TREE_CODE (type)))
 {
   tree field;


Jakub



Re: [PATCH] ira: Skip some pseudos in move_unallocated_pseudos

2020-12-22 Thread Kewen.Lin via Gcc-patches
Hi Segher,

on 2020/12/22 下午9:55, Segher Boessenkool wrote:
> Hi!
> 
> Just a dumb formatting comment:
> 
> On Tue, Dec 22, 2020 at 04:05:39PM +0800, Kewen.Lin wrote:
>> This patch is to make move_unallocated_pseudos consistent
>> to what we have in function find_moveable_pseudos, where we
>> record the original pseudo into pseudo_replaced_reg only if
>> validate_change succeeds with newreg.  To ensure every
>> unallocated pseudo in move_unallocated_pseudos has expected
>> information, it's better to add a check and skip it if it's
>> unexpected.  This avoids possible ICEs in future.
>>
>> btw, I happened to found this in the bootstrapping for one
>> experimental local patch, which is considered as impractical.
> 
>> --- a/gcc/ira.c
>> +++ b/gcc/ira.c
>> @@ -5111,6 +5111,11 @@ move_unallocated_pseudos (void)
>>{
>>  int idx = i - first_moveable_pseudo;
>>  rtx other_reg = pseudo_replaced_reg[idx];
>> +/* If there is no appropriate pseudo in pseudo_replaced_reg, it
>> +   means validate_change fails for this new pseudo in function
>> +   find_moveable_pseudos, then bypass it here.*/
> 
> Dot space space.

Good catch, thanks!  I forgot to reformat after polishing the comments.
Will fix it with other potential comments.

> 
> The patch sounds fine to me.  Hard to tell without seeing the patch that
> exposed the problem (for onlookers like me who do not know this code
> well, anyway ;-) )

The patch which made this issue exposed looks like:

+; Like *rotl3_insert_3 but work with nonzero_bits rather than
+; explicit AND.
+(define_insn "*rotl3_insert_8"
+  [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
+(ior:GPR (ashift:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
+ (match_operand:SI 2 "u6bit_cint_operand" "n"))
+ (match_operand:GPR 3 "gpc_reg_operand" "0")))]
+  "HOST_WIDE_INT_1U << INTVAL (operands[2])
+   > nonzero_bits (operands[3], mode)"
+{
+  if (mode == SImode)
+return "rlwimi %0,%1,%h2,0,31-%h2";
+  else
+return "rldimi %0,%1,%H2,0";
+}
+  [(set_attr "type" "insert")])

Some insn matches this pattern in combine, later ira tries to introduce
one new pseudo since it meets the checks in find_moveable_pseudos, but
it fails in the call to validate_change since the nonzero_bits is more
rough and can't satisfy the pattern condition, leaving the unexpected
entry in pseudo_replaced_reg.

BR,
Kewen


[RFC] Enable CET in libffi

2020-12-22 Thread H.J. Lu via Gcc-patches
Hi,

I have 2 patches to enable CET in libffi on users/hjl/cet/master branch at:

https://gitlab.com/x86-gcc/gcc/-/commits/users/hjl/cet/master

They use FFI_EXEC_TRAMPOLINE_TABLE to avoid changing libffi ABI.
I tested it on Tiger Lake with

CC="cc" CXX="g++"
RUNTESTFLAGS="--target_board='unix{-fcf-protection,-m32\
-fcf-protection\ -mx32\ -fcf-protection}'"
/export/gnu/import/git/gitlab/x86-gcc/configure --enable-cet
--with-demangler-in-ld  --prefix=/usr/gcc-11.0.0-cet-x32
--with-local-prefix=/usr/local --enable-gnu-indirect-function
--enable-clocale=gnu --with-system-zlib --with-target-system-zlib
--with-fpmath=sse --with-multilib-list=m32,m64,mx32
--enable-linker-build-id --enable-gnu-unique-object
--with-build-config=bootstrap-cet --with-multilib-list=m64,mx32,m32
--enable-languages=c,c++,fortran,go

Test results look reasonable.  Should I submit them for GCC 11?

-- 
H.J.


Ping ^ 3: [PATCH 3/4] rs6000: Enable vec_insert for P8 with rs6000_expand_vector_set_var_p8

2020-12-22 Thread Xionghu Luo via Gcc-patches

Ping^3 for stage 3.

And this followed patch:
[PATCH 4/4] rs6000: Update testcases' instruction count.

Thanks:)


On 2020/12/3 22:16, Xionghu Luo via Gcc-patches wrote:

Ping. Thanks.


On 2020/11/27 09:04, Xionghu Luo via Gcc-patches wrote:

Hi Segher,
Thanks for the approval of [PATCH 1/4] and [PATCH 2/4], what's your
opinion of this [PATCH 3/4] for P8, please?  xxinsertw only exists since
v3.0, so we had to implement by another way.


Xionghu


On 2020/10/10 16:08, Xionghu Luo wrote:

gcc/ChangeLog:

2020-10-10  Xionghu Luo  

* config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin):
Generate ARRAY_REF(VIEW_CONVERT_EXPR) for P8 and later
platforms.
* config/rs6000/rs6000.c (rs6000_expand_vector_set_var): Update
to call different path for P8 and P9.
(rs6000_expand_vector_set_var_p9): New function.
(rs6000_expand_vector_set_var_p8): New function.

gcc/testsuite/ChangeLog:

2020-10-10  Xionghu Luo  

* gcc.target/powerpc/pr79251.p8.c: New test.
---
   gcc/config/rs6000/rs6000-c.c  |  27 +++-
   gcc/config/rs6000/rs6000.c    | 117 
+-

   gcc/testsuite/gcc.target/powerpc/pr79251.p8.c |  17 +++
   3 files changed, 155 insertions(+), 6 deletions(-)
   create mode 100644 gcc/testsuite/gcc.target/powerpc/pr79251.p8.c

diff --git a/gcc/config/rs6000/rs6000-c.c b/gcc/config/rs6000/rs6000-c.c
index 5551a21d738..4bea8001ec6 100644
--- a/gcc/config/rs6000/rs6000-c.c
+++ b/gcc/config/rs6000/rs6000-c.c
@@ -1599,10 +1599,29 @@ altivec_resolve_overloaded_builtin 
(location_t loc, tree fndecl,

 SET_EXPR_LOCATION (stmt, loc);
 stmt = build1 (COMPOUND_LITERAL_EXPR, arg1_type, stmt);
   }
-  stmt = build_array_ref (loc, stmt, arg2);
-  stmt = fold_build2 (MODIFY_EXPR, TREE_TYPE (arg0), stmt,
-  convert (TREE_TYPE (stmt), arg0));
-  stmt = build2 (COMPOUND_EXPR, arg1_type, stmt, decl);
+
+  if (TARGET_P8_VECTOR)
+    {
+  stmt = build_array_ref (loc, stmt, arg2);
+  stmt = fold_build2 (MODIFY_EXPR, TREE_TYPE (arg0), stmt,
+  convert (TREE_TYPE (stmt), arg0));
+  stmt = build2 (COMPOUND_EXPR, arg1_type, stmt, decl);
+    }
+  else
+    {
+  tree arg1_inner_type;
+  tree innerptrtype;
+  arg1_inner_type = TREE_TYPE (arg1_type);
+  innerptrtype = build_pointer_type (arg1_inner_type);
+
+  stmt = build_unary_op (loc, ADDR_EXPR, stmt, 0);
+  stmt = convert (innerptrtype, stmt);
+  stmt = build_binary_op (loc, PLUS_EXPR, stmt, arg2, 1);
+  stmt = build_indirect_ref (loc, stmt, RO_NULL);
+  stmt = build2 (MODIFY_EXPR, TREE_TYPE (stmt), stmt,
+ convert (TREE_TYPE (stmt), arg0));
+  stmt = build2 (COMPOUND_EXPR, arg1_type, stmt, decl);
+    }
 return stmt;
   }
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 96f76c7a74c..33ca839cb28 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -6806,10 +6806,10 @@ rs6000_expand_vector_set (rtx target, rtx 
val, rtx elt_rtx)

   }
   /* Insert VAL into IDX of TARGET, VAL size is same of the vector 
element, IDX

-   is variable and also counts by vector element size.  */
+   is variable and also counts by vector element size for p9 and 
above.  */

   void
-rs6000_expand_vector_set_var (rtx target, rtx val, rtx idx)
+rs6000_expand_vector_set_var_p9 (rtx target, rtx val, rtx idx)
   {
 machine_mode mode = GET_MODE (target);
@@ -6852,6 +6852,119 @@ rs6000_expand_vector_set_var (rtx target, rtx 
val, rtx idx)

 emit_insn (perml);
   }
+/* Insert VAL into IDX of TARGET, VAL size is same of the vector 
element, IDX

+   is variable and also counts by vector element size for p8.  */
+
+void
+rs6000_expand_vector_set_var_p8 (rtx target, rtx val, rtx idx)
+{
+  machine_mode mode = GET_MODE (target);
+
+  gcc_assert (VECTOR_MEM_VSX_P (mode) && !CONST_INT_P (idx));
+
+  gcc_assert (GET_MODE (idx) == E_SImode);
+
+  machine_mode inner_mode = GET_MODE (val);
+  HOST_WIDE_INT mode_mask = GET_MODE_MASK (inner_mode);
+
+  rtx tmp = gen_reg_rtx (GET_MODE (idx));
+  int width = GET_MODE_SIZE (inner_mode);
+
+  gcc_assert (width >= 1 && width <= 4);
+
+  if (!BYTES_BIG_ENDIAN)
+    {
+  /*  idx = idx * width.  */
+  emit_insn (gen_mulsi3 (tmp, idx, GEN_INT (width)));
+  /*  idx = idx + 8.  */
+  emit_insn (gen_addsi3 (tmp, tmp, GEN_INT (8)));
+    }
+  else
+    {
+  emit_insn (gen_mulsi3 (tmp, idx, GEN_INT (width)));
+  emit_insn (gen_subsi3 (tmp, GEN_INT (24 - width), tmp));
+    }
+
+  /*  lxv vs33, mask.
+  DImode: 0x
+  SImode: 0x
+  HImode: 0x.
+  QImode: 0x00ff.  */
+  rtx mask = gen_reg_rtx (V16QImode);
+  rtx mask_v2di = gen_reg_rtx (V2DImode);
+  rtvec v = rtvec_alloc (2);
+  if (!BYTES_BIG_ENDIAN)
+    {
+  RTVEC_ELT (v, 0) = gen_rtx_CONST_INT 

[PR97714] final: accept markers at line 0

2020-12-22 Thread Alexandre Oliva via Gcc-patches


Back when I introduced debug markers, I seem to have been under the
impression that location line 0 would only ever occur for unknown and
builtin locations.

Though line 0 never comes up in normal processing of source files, and
debug info formats often cannot represent them, I suppose there's no
need to preemptively discard them during final.

Regstrapped on x86_64-linux-gnu.  Ok to install?


for  gcc/ChangeLog

PR debug/97714
* final.c (notice_source_line): Narrow down the condition to
skip a line-0 marker.

for  gcc/testsuite/ChangeLog

PR debug/97714
* gcc.dg/pr97714.c: New.
---
 gcc/final.c  |   11 +--
 gcc/testsuite/gcc.dg/debug/pr97714.c |   11 +++
 2 files changed, 16 insertions(+), 6 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/debug/pr97714.c

diff --git a/gcc/final.c b/gcc/final.c
index fc9a05e335f47..45f7f39f0885b 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -3250,12 +3250,11 @@ notice_source_line (rtx_insn *insn, bool *is_stmt)
 {
   location_t loc = NOTE_MARKER_LOCATION (insn);
   expanded_location xloc = expand_location (loc);
-  if (xloc.line == 0)
-   {
- gcc_checking_assert (LOCATION_LOCUS (loc) == UNKNOWN_LOCATION
-  || LOCATION_LOCUS (loc) == BUILTINS_LOCATION);
- return false;
-   }
+  if (xloc.line == 0
+ && (LOCATION_LOCUS (loc) == UNKNOWN_LOCATION
+ || LOCATION_LOCUS (loc) == BUILTINS_LOCATION))
+   return false;
+
   filename = xloc.file;
   linenum = xloc.line;
   columnnum = xloc.column;
diff --git a/gcc/testsuite/gcc.dg/debug/pr97714.c 
b/gcc/testsuite/gcc.dg/debug/pr97714.c
new file mode 100644
index 0..dba17831d6943
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/pr97714.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O -g" } */
+
+void
+function ()
+{
+  if (0)
+{
+#line 0 "whatever"
+}
+}

-- 
Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/
   Free Software Activist GNU Toolchain Engineer
Vim, Vi, Voltei pro Emacs -- GNUlius Caesar


RE: Optimize combination of comparisons to dec+compare

2020-12-22 Thread Eugene Rozenfeld via Gcc-patches
Re-sending my question and re-attaching the patch.

Richard, can you please clarify your feedback?

Thanks,

Eugene

-Original Message-
From: Gcc-patches  On Behalf Of Eugene 
Rozenfeld via Gcc-patches
Sent: Tuesday, December 15, 2020 2:06 PM
To: Richard Biener 
Cc: gcc-patches@gcc.gnu.org
Subject: [EXTERNAL] Re: Optimize combination of comparisons to dec+compare

Richard,

> Do we already handle x < y || x <= CST to x <= y - CST?

That is an invalid transformation: e.g., consider x=3, y=4, CST=2.
Can you please clarify?

Thanks,

Eugene

-Original Message-
From: Richard Biener  
Sent: Thursday, December 10, 2020 12:21 AM
To: Eugene Rozenfeld 
Cc: gcc-patches@gcc.gnu.org
Subject: Re: Optimize combination of comparisons to dec+compare

On Thu, Dec 10, 2020 at 1:52 AM Eugene Rozenfeld via Gcc-patches 
 wrote:
>
> This patch adds a pattern for optimizing x < y || x == XXX_MIN to x <= 
> y-1 if y is an integer with TYPE_OVERFLOW_WRAPS.

Do we already handle x < y || x <= CST to x <= y - CST?
That is, the XXX_MIN case is just a special-case of generic anti-range testing? 
 For anti-range testing with signed types we pun to unsigned when possible.

> This fixes pr96674.
>
> Tested on x86_64-pc-linux-gnu.
>
> For this function
>
> bool f(unsigned a, unsigned b)
> {
> return (b == 0) | (a < b);
> }
>
> the code without the patch is
>
> test   esi,esi
> sete   al
> cmpesi,edi
> seta   dl
> or eax,edx
> ret
>
> the code with the patch is
>
> subesi,0x1
> cmpesi,edi
> setae  al
> ret
>
> Eugene
>
> gcc/
> PR tree-optimization/96674
> * match.pd: New pattern x < y || x == XXX_MIN --> x <= y - 1
>
> gcc/testsuite
> * gcc.dg/pr96674.c: New test.
>


0001-Optimize-combination-of-comparisons-to-dec-compare.patch
Description: 0001-Optimize-combination-of-comparisons-to-dec-compare.patch


Re: C++ 20 modules

2020-12-22 Thread Gerald Pfeifer
On Mon, 21 Dec 2020, Nathan Sidwell wrote:
> Yes, this is good.  I already managed to commit some of this with 
> the 98412 patch.

I wasn't sure, but seeing that you had not applied this, I figured
this was approval and pushed the remaining portion this afternoon,
per the below.

Gerald

PS: I am really starting to like our use of git.


commit 7e63d383b89cd75b7775883d71ed09724b9ee73f
Author: Gerald Pfeifer 
Date:   Tue Dec 22 13:37:56 2020 +0100

c++: Fix build with clang

After the addition of libcody building with clang 10.0.1 would fail
as follows:

  In file included from .../libcody/cody.hh:24:
  In file included from /usr/include/c++/v1/memory:653:
  /usr/include/c++/v1/typeinfo:346:5: error: no member named 'fancy_abort'
  in namespace 'std::__1'; did you mean simply 'fancy_abort'?
_VSTD::abort();
^~~

mapper-client.cc and mapper-resolver.cc have addressed this already
by getting  and  included; do the same for module.cc.

gcc/cp:
2020-12-22  Gerald Pfeifer  

* module.cc (INCLUDE_STRING): Define.
(INCLUDE_VECTOR): Ditto.

diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 7e38293545f..ed3dbe244a3 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -207,6 +207,8 @@ Classes used:
 
 #define _DEFAULT_SOURCE 1 /* To get TZ field of struct tm, if available.  */
 #include "config.h"
+#define INCLUDE_STRING
+#define INCLUDE_VECTOR
 #include "system.h"
 #include "coretypes.h"
 #include "cp-tree.h"


Go patch committed: Initialize saw_send_stmt locals

2020-12-22 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend initializes a couple of saw_send_stmt
local variables that were incorrectly left uninitialized.  These are
variables in the compiler source, not in the generated code.  The C++
compiler wasn't warning because we take their address.  This fixes
https://golang.org/issue/43252.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
7b89979747684476c371208a274c77ec9e402caf
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index c70b60c657f..e67aa3622fb 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-d091cd25a5894ac751fe1868197648fc486cf322
+013a4ddcae2e8b840561c4411bab87f4f0f9ef42
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc
index 3b2e5a7aa86..1664fe36c28 100644
--- a/gcc/go/gofrontend/parse.cc
+++ b/gcc/go/gofrontend/parse.cc
@@ -4491,7 +4491,7 @@ Parse::switch_stat(Label* label)
 
   bool saw_simple_stat = false;
   Expression* switch_val = NULL;
-  bool saw_send_stmt;
+  bool saw_send_stmt = false;
   Type_switch type_switch;
   bool have_type_switch_block = false;
   if (this->simple_stat_may_start_here())
@@ -5326,7 +5326,7 @@ Parse::for_stat(Label* label)
{
  // We might be looking at a Condition, an InitStat, or a
  // RangeClause.
- bool saw_send_stmt;
+ bool saw_send_stmt = false;
  cond = this->simple_stat(false, _send_stmt, _clause, NULL);
  if (!this->peek_token()->is_op(OPERATOR_SEMICOLON))
{


Go patch committed: Eliminate the scase.kind field

2020-12-22 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend and libgo eliminates the scase.kind
field, saving some space on the stack when running a select statement.
Instead of using a kind, the compiler now sorts all the send cases
before the receive cases, and gives the default case a special index
of -1.  This is in preparation for updating to the Go 1.16beta1
release.  Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.
Committed to mainline.

Ian
ff3028b66d567b9afdcc9a5d12719e84e8516397
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index bb537f152b9..c70b60c657f 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-eca96e39cb895805b617e0e1f184f893ed3e46bb
+d091cd25a5894ac751fe1868197648fc486cf322
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/runtime.def b/gcc/go/gofrontend/runtime.def
index 4b606a6c00c..7ab94a3ffbc 100644
--- a/gcc/go/gofrontend/runtime.def
+++ b/gcc/go/gofrontend/runtime.def
@@ -195,8 +195,8 @@ DEF_GO_RUNTIME(CHANRECV2, "runtime.chanrecv2", P2(CHAN, 
POINTER), R1(BOOL))
 
 // Run a select, returning the index of the selected clause and
 // whether that channel received a value.
-DEF_GO_RUNTIME(SELECTGO, "runtime.selectgo", P3(POINTER, POINTER, INT),
-  R2(INT, BOOL))
+DEF_GO_RUNTIME(SELECTGO, "runtime.selectgo",
+  P5(POINTER, POINTER, INT, INT, BOOL), R2(INT, BOOL))
 
 // Non-blocking send a value on a channel, used for two-case select
 // statement with a default case.
diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc
index 398b8fd82f2..da0e0843a73 100644
--- a/gcc/go/gofrontend/statements.cc
+++ b/gcc/go/gofrontend/statements.cc
@@ -5291,22 +5291,23 @@ Select_clauses::Select_clause::traverse(Traverse* 
traverse)
 void
 Select_clauses::Select_clause::lower(Gogo* gogo, Named_object* function,
 Block* b, Temporary_statement* scases,
-size_t index, Temporary_statement* recvok)
+int index, Temporary_statement* recvok)
 {
   Location loc = this->location_;
 
-  Expression* scase = Expression::make_temporary_reference(scases, loc);
-  Expression* index_expr = Expression::make_integer_ul(index, NULL, loc);
-  scase = Expression::make_array_index(scase, index_expr, NULL, NULL, loc);
+  this->set_case_index(index);
 
   if (this->is_default_)
 {
   go_assert(this->channel_ == NULL && this->val_ == NULL);
-  this->lower_default(b, scase);
   this->is_lowered_ = true;
   return;
 }
 
+  Expression* scase = Expression::make_temporary_reference(scases, loc);
+  Expression* index_expr = Expression::make_integer_sl(index, NULL, loc);
+  scase = Expression::make_array_index(scase, index_expr, NULL, NULL, loc);
+
   // Evaluate the channel before the select statement.
   Temporary_statement* channel_temp = Statement::make_temporary(NULL,
this->channel_,
@@ -5326,15 +5327,6 @@ Select_clauses::Select_clause::lower(Gogo* gogo, 
Named_object* function,
   this->val_ = NULL;
 }
 
-// Lower a default clause in a select statement.
-
-void
-Select_clauses::Select_clause::lower_default(Block* b, Expression* scase)
-{
-  Location loc = this->location_;
-  this->set_case(b, scase, Expression::make_nil(loc), NULL, caseDefault);
-}
-
 // Lower a send clause in a select statement.
 
 void
@@ -5366,7 +5358,7 @@ Select_clauses::Select_clause::lower_send(Block* b, 
Expression* scase,
   Type* unsafe_pointer_type = Type::make_pointer_type(Type::make_void_type());
   valaddr = Expression::make_cast(unsafe_pointer_type, valaddr, loc);
 
-  this->set_case(b, scase, chanref, valaddr, caseSend);
+  this->set_case(b, scase, chanref, valaddr);
 }
 
 // Lower a receive clause in a select statement.
@@ -5392,7 +5384,7 @@ Select_clauses::Select_clause::lower_recv(Gogo* gogo, 
Named_object* function,
   Type* unsafe_pointer_type = Type::make_pointer_type(Type::make_void_type());
   valaddr = Expression::make_cast(unsafe_pointer_type, valaddr, loc);
 
-  this->set_case(b, scase, chanref, valaddr, caseRecv);
+  this->set_case(b, scase, chanref, valaddr);
 
   // If the block of statements is executed, arrange for the received
   // value to move from VAL to the place where the statements expect
@@ -5447,8 +5439,7 @@ void
 Select_clauses::Select_clause::set_case(Block* b,
Expression* scase,
Expression* chanref,
-   Expression* elem,
-   int kind)
+   Expression* elem)
 {
   Location loc = this->location_;
   Struct_type* scase_type = scase->type()->struct_type();
@@ -5469,14 +5460,6 @@ Select_clauses::Select_clause::set_case(Block* b,
   s = Statement::make_assignment(ref, 

make FOR_EACH_IMM_USE_STMT safe for early exits (was: Re: move sincos after pre)

2020-12-22 Thread Alexandre Oliva
On Oct 28, 2020, Richard Biener  wrote:

>> BTW, any reason why we are not (yet?) using something like:
>> 
>> #define FOR_EACH_IMM_USE_STMT(STMT, ITER, SSAVAR)   \
>> for (auto_end_imm_use_stmt_traverse auto_end  \
>> STMT) = first_imm_use_stmt (&(ITER), (SSAVAR))), \
>> &(ITER))); \
>> !end_imm_use_stmt_p (&(ITER));   \
>> (void) ((STMT) = next_imm_use_stmt (&(ITER

> Just laziness.  Or rather last time I remembered this I tried to do it
> more fancy via range-for but didn't get very far due to the nested
> iteration ...

Use a dtor to automatically remove ITER from IMM_USE list in
FOR_EACH_IMM_USE_STMT.

Regstrapped on x86_64-linux-gnu.  Ok to install?


for  gcc/ChangeLog

* ssa-iterators.h (end_imm_use_stmt_traverse): Forward
declare.
(auto_end_imm_use_stmt_traverse): New struct.
(FOR_EACH_IMM_USE_STMT): Use it.
---
 gcc/ssa-iterators.h |   29 -
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/gcc/ssa-iterators.h b/gcc/ssa-iterators.h
index 98724da14522d..817997aa952d4 100644
--- a/gcc/ssa-iterators.h
+++ b/gcc/ssa-iterators.h
@@ -77,16 +77,35 @@ struct imm_use_iterator
!end_readonly_imm_use_p (&(ITER));  \
(void) ((DEST) = next_readonly_imm_use (&(ITER
 
-/* Use this iterator to visit each stmt which has a use of SSAVAR.  */
+/* Forward declare for use in the class below.  */
+static inline void end_imm_use_stmt_traverse (imm_use_iterator *);
+
+/* arrange to automatically call, upon descruction, end_imm_use_stmt_traverse
+   with a given pointer to imm_use_iterator.  */
+struct auto_end_imm_use_stmt_traverse
+{
+  imm_use_iterator *imm;
+  auto_end_imm_use_stmt_traverse (imm_use_iterator *imm)
+  : imm (imm) {}
+  ~auto_end_imm_use_stmt_traverse ()
+  { end_imm_use_stmt_traverse (imm); }
+};
+
+/* Use this iterator to visit each stmt which has a use of SSAVAR.  The
+   destructor of the auto_end_imm_use_stmt_traverse object deals with removing
+   ITER from SSAVAR's IMM_USE list even when leaving the scope early.  */
 
 #define FOR_EACH_IMM_USE_STMT(STMT, ITER, SSAVAR)  \
-  for ((STMT) = first_imm_use_stmt (&(ITER), (SSAVAR));\
+  for (struct auto_end_imm_use_stmt_traverse   \
+ auto_end_imm_use_stmt_traverse\
+  STMT) = first_imm_use_stmt (&(ITER), (SSAVAR))), \
+&(ITER))); \
!end_imm_use_stmt_p (&(ITER));  \
(void) ((STMT) = next_imm_use_stmt (&(ITER
 
-/* Use this to terminate the FOR_EACH_IMM_USE_STMT loop early.  Failure to
-   do so will result in leaving a iterator marker node in the immediate
-   use list, and nothing good will come from that.   */
+/* These used to be needed to exit FOR_EACH_IMM_USE_STMT early, without leaving
+   ITER behind in the stmt lists.  This is now taken care of automatically, but
+   it doesn't hurt to use the macros for documentation purposes.  */
 #define BREAK_FROM_IMM_USE_STMT(ITER)  \
{   \
  end_imm_use_stmt_traverse (&(ITER));  \

-- 
Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/
   Free Software Activist GNU Toolchain Engineer
Vim, Vi, Voltei pro Emacs -- GNUlius Caesar


g++.dg/tls/pr79288.C: Skip on vxworks_kernel (TLS model not supported)

2020-12-22 Thread Alexandre Oliva


The only TLS model supported in VxWorks kernel mode is local-exec.

Regstrapped on x86_64-linux-gnu, and tested with -x-arm-wrs-vxworks7r2.
Ok to install?


from Jerome Lambourg 
for  gcc/testsuite/ChangeLog

* g++.dg/tls/pr79288.C: Skip on vxworks_kernel (TLS model
not supported).
---
 gcc/testsuite/g++.dg/tls/pr79288.C |1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/g++.dg/tls/pr79288.C 
b/gcc/testsuite/g++.dg/tls/pr79288.C
index da6751f5149d7..c41629d9d25ec 100644
--- a/gcc/testsuite/g++.dg/tls/pr79288.C
+++ b/gcc/testsuite/g++.dg/tls/pr79288.C
@@ -2,6 +2,7 @@
 // { dg-do compile { target { nonpic || pie_enabled } } }
 // { dg-require-effective-target tls }
 // { dg-options "-O2" }
+// { dg-skip-if "VxWorks kernel tls model is local-exec" { vxworks_kernel } }
 // { dg-final { scan-assembler-not "@tpoff" { target i?86-*-* x86_64-*-* } } }
 
 struct S


-- 
Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/
   Free Software Activist GNU Toolchain Engineer
Vim, Vi, Voltei pro Emacs -- GNUlius Caesar


compile gcc.target/arm/{pr78255-2.c, memset-inline-2.c} with -mno-long-calls

2020-12-22 Thread Alexandre Oliva


If the target is configured such that -mlong-call is passed
by default, the function calls these tests are trying to detect
by scanning the assembly file are performed using long calls,
like so:

| foo:
| @ memset-inline-2.c:12:   memset (a, -1, 14);
| mov r2, #14 @,
| mvn r1, #0  @,
| ldr r0, .L2 @,
| ldr r3, .L2+4   @ tmp112,
| bx  r3  @ tmp112

Looking at .L2 (and in particular at .L2+4):

| .L2:
| .word   a
| .word   memset   <<<---

This change adds -mno-long-calls to the list of compiler options
to make sure we generate short call code, allowing the assembly
matching to pass.

This is added unconditionally to the dg-options (as opposed to using
dg-additional-options) because this test is already specific to ARM
targets, and -mno-long-calls is available on all ARM targets.

Regstrapped on x86_64-linux-gnu, and tested with -x-arm-wrs-vxworks7r2.
Ok to install?


from Joel Brobecker 
for  gcc/testsuite/ChangeLog

* gcc.target/arm/memset-inline-2.c: Add -mno-long-calls to
the test's dg-options.
* gcc.target/arm/pr78255-2.c: Likewise.
---
 gcc/testsuite/gcc.target/arm/memset-inline-2.c |2 +-
 gcc/testsuite/gcc.target/arm/pr78255-2.c   |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.target/arm/memset-inline-2.c 
b/gcc/testsuite/gcc.target/arm/memset-inline-2.c
index b8195cab8a67c..ba1f7ed1f1e35 100644
--- a/gcc/testsuite/gcc.target/arm/memset-inline-2.c
+++ b/gcc/testsuite/gcc.target/arm/memset-inline-2.c
@@ -1,5 +1,5 @@
 /* { dg-do run } */
-/* { dg-options "-save-temps -Os -fno-inline" } */
+/* { dg-options "-save-temps -Os -fno-inline -mno-long-calls" } */
 
 #include 
 #include 
diff --git a/gcc/testsuite/gcc.target/arm/pr78255-2.c 
b/gcc/testsuite/gcc.target/arm/pr78255-2.c
index cc1c1801c37ee..fd379aecf9c75 100644
--- a/gcc/testsuite/gcc.target/arm/pr78255-2.c
+++ b/gcc/testsuite/gcc.target/arm/pr78255-2.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2" }  */
+/* { dg-options "-O2 -mno-long-calls" }  */
 
 extern int bar (void *);
 

-- 
Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/
   Free Software Activist GNU Toolchain Engineer
Vim, Vi, Voltei pro Emacs -- GNUlius Caesar


disable some aapcs/vfp*.c test if not arm_fp16_alternative_ok

2020-12-22 Thread Alexandre Oliva


The tests use -mfp16-format=alternative, and so should not be run
if that option isn't supported.

Regstrapped on x86_64-linux-gnu, and tested with -x-arm-wrs-vxworks7r2.
Ok to install?


from Joel Brobecker 
for  gcc/testsuite/ChangeLog

* lib/target-supports.exp
(check_effective_target_arm_fp16_alternative_ok_nocache):
Return zero for *-*-vxworks7r* targets.
* gcc.target/arm/aapcs/vfp22.c: Require arm_fp16_alternative_ok.
* gcc.target/arm/aapcs/vfp22.c: Likewise.
* gcc.target/arm/aapcs/vfp24.c: Likewise.
* gcc.target/arm/aapcs/vfp25.c: Likewise.
---
 gcc/testsuite/gcc.target/arm/aapcs/vfp22.c |1 +
 gcc/testsuite/gcc.target/arm/aapcs/vfp23.c |1 +
 gcc/testsuite/gcc.target/arm/aapcs/vfp24.c |1 +
 gcc/testsuite/gcc.target/arm/aapcs/vfp25.c |1 +
 gcc/testsuite/lib/target-supports.exp  |4 
 5 files changed, 8 insertions(+)

diff --git a/gcc/testsuite/gcc.target/arm/aapcs/vfp22.c 
b/gcc/testsuite/gcc.target/arm/aapcs/vfp22.c
index 1944bb592a869..fc22792eb7937 100644
--- a/gcc/testsuite/gcc.target/arm/aapcs/vfp22.c
+++ b/gcc/testsuite/gcc.target/arm/aapcs/vfp22.c
@@ -3,6 +3,7 @@
 /* { dg-do run { target arm_eabi } }  */
 /* { dg-require-effective-target arm_hard_vfp_ok }  */
 /* { dg-require-effective-target arm_fp16_hw }  */
+/* { dg-require-effective-target arm_fp16_alternative_ok } */
 /* { dg-add-options arm_fp16_alternative }  */
 
 #ifndef IN_FRAMEWORK
diff --git a/gcc/testsuite/gcc.target/arm/aapcs/vfp23.c 
b/gcc/testsuite/gcc.target/arm/aapcs/vfp23.c
index bcacf9f37c863..469aabd14a001 100644
--- a/gcc/testsuite/gcc.target/arm/aapcs/vfp23.c
+++ b/gcc/testsuite/gcc.target/arm/aapcs/vfp23.c
@@ -3,6 +3,7 @@
 /* { dg-do run { target arm_eabi } }  */
 /* { dg-require-effective-target arm_hard_vfp_ok }  */
 /* { dg-require-effective-target arm_fp16_hw }  */
+/* { dg-require-effective-target arm_fp16_alternative_ok } */
 /* { dg-add-options arm_fp16_alternative }  */
 
 #ifndef IN_FRAMEWORK
diff --git a/gcc/testsuite/gcc.target/arm/aapcs/vfp24.c 
b/gcc/testsuite/gcc.target/arm/aapcs/vfp24.c
index ef36bb7b52bc2..80a46821946f9 100644
--- a/gcc/testsuite/gcc.target/arm/aapcs/vfp24.c
+++ b/gcc/testsuite/gcc.target/arm/aapcs/vfp24.c
@@ -3,6 +3,7 @@
 /* { dg-do run { target arm_eabi } }  */
 /* { dg-require-effective-target arm_hard_vfp_ok }  */
 /* { dg-require-effective-target arm_fp16_hw }  */
+/* { dg-require-effective-target arm_fp16_alternative_ok } */
 /* { dg-add-options arm_fp16_alternative }  */
 
 #ifndef IN_FRAMEWORK
diff --git a/gcc/testsuite/gcc.target/arm/aapcs/vfp25.c 
b/gcc/testsuite/gcc.target/arm/aapcs/vfp25.c
index 3c796ca044ff5..649c1750f85b7 100644
--- a/gcc/testsuite/gcc.target/arm/aapcs/vfp25.c
+++ b/gcc/testsuite/gcc.target/arm/aapcs/vfp25.c
@@ -3,6 +3,7 @@
 /* { dg-do run { target arm_eabi } }  */
 /* { dg-require-effective-target arm_hard_vfp_ok }  */
 /* { dg-require-effective-target arm_fp16_hw }  */
+/* { dg-require-effective-target arm_fp16_alternative_ok } */
 /* { dg-add-options arm_fp16_alternative }  */
 
 #ifndef IN_FRAMEWORK
diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index 6b1d13b105da7..16252243aa980 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -4367,6 +4367,10 @@ proc add_options_for_aarch64_sve { flags } {
 # set et_arm_neon_fp16_flags to the best options to add.
 
 proc check_effective_target_arm_fp16_alternative_ok_nocache { } {
+if { [istarget *-*-vxworks7*] } {
+   # Not supported by the target system.
+   return 0
+}
 global et_arm_neon_fp16_flags
 set et_arm_neon_fp16_flags ""
 if { [check_effective_target_arm32] } {

-- 
Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/
   Free Software Activist GNU Toolchain Engineer
Vim, Vi, Voltei pro Emacs -- GNUlius Caesar


Fix testsuite/g++.old-deja/g++.mike/p658.C build failure on VxWorks RTP

2020-12-22 Thread Alexandre Oliva


The conflicting definition of OK is present in VxWorks RTP headers too.

Regstrapped on x86_64-linux-gnu, and tested with -x-arm-wrs-vxworks7r2.
Ok to install?


from Jerome Lambourg 
for  gcc/testsuite/ChangeLog

* g++.old-deja/g++.mike/p658.C: Also undefine OK on VxWorks RTP.
---
 gcc/testsuite/g++.old-deja/g++.mike/p658.C |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p658.C 
b/gcc/testsuite/g++.old-deja/g++.mike/p658.C
index 8fc7cd51b2be3..a6268a36fd76b 100644
--- a/gcc/testsuite/g++.old-deja/g++.mike/p658.C
+++ b/gcc/testsuite/g++.old-deja/g++.mike/p658.C
@@ -12,9 +12,9 @@
 #define TRUE true
 #endif
 
-// The VxWorks kernel-mode headers define a macro named "OK", which is not
+// The VxWorks headers define a macro named "OK", which is not
 // ISO-compliant, but is part of the VxWorks API.
-#if defined __vxworks && !defined __RTP__
+#if defined __vxworks
 #undef OK
 #endif
 


-- 
Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/
   Free Software Activist GNU Toolchain Engineer
Vim, Vi, Voltei pro Emacs -- GNUlius Caesar


Fix testsuite/g++.dg/opt/20050511-1.C compilation error on VxWorks 7

2020-12-22 Thread Alexandre Oliva


In VxWorks 7, UINT32 is defined in both modes, kernel and rtp.  Adjust
the work around accordingly.

Regstrapped on x86_64-linux-gnu, and tested with -x-arm-wrs-vxworks7r2.
Ok to install?


from Jerome Lambourg 
for  gcc/testsuite/ChangeLog

* g++.dg/opt/20050511-1.C: Work around UINT32 in vxworks rtp
headers too.
---
 gcc/testsuite/g++.dg/opt/20050511-1.C |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/g++.dg/opt/20050511-1.C 
b/gcc/testsuite/g++.dg/opt/20050511-1.C
index a840fb0db8e38..7041a48200175 100644
--- a/gcc/testsuite/g++.dg/opt/20050511-1.C
+++ b/gcc/testsuite/g++.dg/opt/20050511-1.C
@@ -5,7 +5,7 @@
 #include 
 
 // The VxWorks kernel headers define their own UINT32
-#if defined __vxworks && !defined __RTP__
+#if defined __vxworks
 #define UINT32 my_UINT32
 #endif
 

-- 
Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/
   Free Software Activist GNU Toolchain Engineer
Vim, Vi, Voltei pro Emacs -- GNUlius Caesar


Fix testsuite/g++.dg/cpp1y/constexpr-66093.C execution failure...

2020-12-22 Thread Alexandre Oliva


The constexpr iteration dereferenced an array element past the end of
the array.

Regstrapped on x86_64-linux-gnu, and tested with -x-arm-wrs-vxworks7r2.
Ok to install?


from Jerome Lambourg 
for  gcc/testsuite/ChangeLog

* g++.dg/cpp1y/constexpr-66093.C: Fix bounds issue.
---
 gcc/testsuite/g++.dg/cpp1y/constexpr-66093.C |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-66093.C 
b/gcc/testsuite/g++.dg/cpp1y/constexpr-66093.C
index ad3169210d29a..3d742cfebd83d 100644
--- a/gcc/testsuite/g++.dg/cpp1y/constexpr-66093.C
+++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-66093.C
@@ -19,7 +19,7 @@ private:
 
 constexpr A f() {
 A a{};
-for (int i = 1; i <= n; i++) {
+for (int i = 0; i < n; i++) {
 a[i] = i;
 }
 return a;

-- 
Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/
   Free Software Activist GNU Toolchain Engineer
Vim, Vi, Voltei pro Emacs -- GNUlius Caesar


Skip testsuite/g++.old-deja/g++.pt/const2.C on vxworks_kernel

2020-12-22 Thread Alexandre Oliva


Linking in vxworks kernel-mode is partial linking, so missing symbols
are not detected.

Regstrapped on x86_64-linux-gnu, and tested with -x-arm-wrs-vxworks7r2.
Ok to install?


from Jerome Lambourg 
for  gcc/testsuite/ChangeLog

* g++.old-deja/g++.pt/const2.C: Skip on vxworks kernel.
---
 gcc/testsuite/g++.old-deja/g++.pt/const2.C |1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/g++.old-deja/g++.pt/const2.C 
b/gcc/testsuite/g++.old-deja/g++.pt/const2.C
index 3ca4a532b1987..7340ff4e982ce 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/const2.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/const2.C
@@ -1,4 +1,5 @@
 // { dg-do link }
+// { dg-skip-if "VxWorks dkms use partial link" { vxworks_kernel } }
 // This test should get a linker error for the reference to A::i.
 // { dg-prune-output "ld: symbol" }
 // { dg-message "i" "" { target *-*-* } 0 }


-- 
Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/
   Free Software Activist GNU Toolchain Engineer
Vim, Vi, Voltei pro Emacs -- GNUlius Caesar


Remove VxWorks-specific test directives in g++.dg/warn/miss-format-1.C

2020-12-22 Thread Alexandre Oliva


These are no longer applicable.

Regstrapped on x86_64-linux-gnu, and tested with -x-arm-wrs-vxworks7r2.
Ok to install?


from Jerome Lambourg 
for  gcc/testsuite/ChangeLog

* g++.dg/warn/miss-format-1.C: Remove vxworks-specific test
directives.
---
 gcc/testsuite/g++.dg/warn/miss-format-1.C |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/gcc/testsuite/g++.dg/warn/miss-format-1.C 
b/gcc/testsuite/g++.dg/warn/miss-format-1.C
index 65a34282ad784..444afb64fcd1b 100644
--- a/gcc/testsuite/g++.dg/warn/miss-format-1.C
+++ b/gcc/testsuite/g++.dg/warn/miss-format-1.C
@@ -21,9 +21,7 @@ bar (const char *fmt, ...)
 {
   va_list ap;
   va_start (ap, fmt);
-  vscanf (fmt, ap); /* { dg-warning "candidate" "scanf attribute warning" { 
xfail *-*-vxworks* } } */
-  /* VxWorks does not provide vscanf, either in kernel or RTP mode.  */
-  /* { dg-error "not declared" "" { target *-*-vxworks* } .-2 } */
+  vscanf (fmt, ap); /* { dg-warning "candidate" "scanf attribute warning" } */
   va_end (ap);
 }
 

-- 
Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/
   Free Software Activist GNU Toolchain Engineer
Vim, Vi, Voltei pro Emacs -- GNUlius Caesar


Undefine ERROR in g++.dg/tree-ssa/copyprop.C

2020-12-22 Thread Alexandre Oliva


VxWorks headers define ERROR as a macro, which conflicts with the use
in the test.

Regstrapped on x86_64-linux-gnu, and tested with -x-arm-wrs-vxworks7r2.
Ok to install?


from Jerome Lambourg 
for  gcc/testsuite/ChangeLog

* g++.dg/tree-ssa/copyprop.C: Undefine ERROR if defined.
---
 gcc/testsuite/g++.dg/tree-ssa/copyprop.C |5 +
 1 file changed, 5 insertions(+)

diff --git a/gcc/testsuite/g++.dg/tree-ssa/copyprop.C 
b/gcc/testsuite/g++.dg/tree-ssa/copyprop.C
index 8c05895e45ec6..bc9167ad1201f 100644
--- a/gcc/testsuite/g++.dg/tree-ssa/copyprop.C
+++ b/gcc/testsuite/g++.dg/tree-ssa/copyprop.C
@@ -8,6 +8,11 @@
 #include 
 #include 
 #include 
+
+#ifdef ERROR
+#undef ERROR
+#endif
+
 using namespace std;
 template _FIter lower_bound(_FIter, _FIter, 
_Tp&);
 template struct hash { };

-- 
Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/
   Free Software Activist GNU Toolchain Engineer
Vim, Vi, Voltei pro Emacs -- GNUlius Caesar


skip testsuite/g++.dg/other/anon5.C on vxworks_kernel targets

2020-12-22 Thread Alexandre Oliva


The vxworks kernel-mode linking is partial linking, so it cannot
detect missing symbols.

Regstrapped on x86_64-linux-gnu, and tested with -x-arm-wrs-vxworks7r2.
Ok to install?


from Jerome Lambourg 
for  gcc/testsuite/ChangeLog

* g++.dg/other/anon5.C: Skip on vxworks kernel.
---
 gcc/testsuite/g++.dg/other/anon5.C |3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/testsuite/g++.dg/other/anon5.C 
b/gcc/testsuite/g++.dg/other/anon5.C
index dadd92ef9e4a1..09853d4c6515e 100644
--- a/gcc/testsuite/g++.dg/other/anon5.C
+++ b/gcc/testsuite/g++.dg/other/anon5.C
@@ -1,6 +1,9 @@
 // PR c++/34094
 // { dg-do link { target { ! { *-*-darwin* *-*-hpux* *-*-solaris2.* } } } }
 // { dg-require-effective-target nonpic }
+// Skip on vxworks kernel: The link being partial, the linker doesn't see
+// the undefined reference
+// { dg-skip-if "partial link" { vxworks_kernel } }
 // { dg-options "-gdwarf-2" }
 // Ignore additional message on powerpc-ibm-aix
 // { dg-prune-output "obtain more information" } */


-- 
Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/
   Free Software Activist GNU Toolchain Engineer
Vim, Vi, Voltei pro Emacs -- GNUlius Caesar


fix testsuite/g++.dg/init/new26.C for C++-14 and later

2020-12-22 Thread Alexandre Oliva


This test fails during the execution on VxWorks 7 when using
C++-14 and C++-17.

Regstrapped on x86_64-linux-gnu, and tested with -x-arm-wrs-vxworks7r2.
Ok to install?


from Jerome Lambourg 
for  gcc/testsuite/ChangeLog

* g++.dg/init/new26.C: Fix overriding of the delete operator
for c++14 profile.
---
 gcc/testsuite/g++.dg/init/new26.C |4 
 1 file changed, 4 insertions(+)

diff --git a/gcc/testsuite/g++.dg/init/new26.C 
b/gcc/testsuite/g++.dg/init/new26.C
index 541de3058e10a..75bdcb15074d5 100644
--- a/gcc/testsuite/g++.dg/init/new26.C
+++ b/gcc/testsuite/g++.dg/init/new26.C
@@ -16,8 +16,12 @@ inline void *operator new(__SIZE_TYPE__)
   return p;
 }
 
+// C++11 and earlier
 inline void operator delete (void*) {}
 
+// C++14 profile
+inline void operator delete (void*, __SIZE_TYPE__) {}
+
 int * __attribute__((noinline)) doit(int n)
 {
   float *q;

-- 
Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/
   Free Software Activist GNU Toolchain Engineer
Vim, Vi, Voltei pro Emacs -- GNUlius Caesar


Account for VxWorks headers in libstdc++ test on names

2020-12-22 Thread Alexandre Oliva


Undefine various macros unexpectedly defined by VxWorks headers.

Regstrapped on x86_64-linux-gnu, and tested with -x-arm-wrs-vxworks7r2.
Ok to install?


from Olivier Hainque 
for  libstdc++-v3/ChangeLog

* testsuite/17_intro/names.cc: Account for VxWorks headers.
---
 libstdc++-v3/testsuite/17_intro/names.cc |   41 ++
 1 file changed, 41 insertions(+)

diff --git a/libstdc++-v3/testsuite/17_intro/names.cc 
b/libstdc++-v3/testsuite/17_intro/names.cc
index 2c8bfff26e1ca..4760a9efd7991 100644
--- a/libstdc++-v3/testsuite/17_intro/names.cc
+++ b/libstdc++-v3/testsuite/17_intro/names.cc
@@ -211,4 +211,45 @@
 #undef ptr
 #endif
 
+#ifdef __VXWORKS__
+
+#include <_vxworks-versions.h>
+
+// Some VxWorks 6 or 7 headers are using those.
+
+// private/objLibP.h
+#undef u
+
+// arch/ppc/ffs/ArchLib.h
+#undef i
+#undef j
+
+// math.h
+#undef x
+#undef y
+
+// stdio.h
+#undef ptr
+
+// VxWorks >= 7 specificities
+
+#if _VXWORKS_MAJOR_GE(7)
+
+// regs.h regs structure has a field 'r'
+#undef r
+
+#ifndef __RTP__
+// in bootLib.h, bootParamCheck has parameters x, a-f
+#undef a
+#undef b
+#undef c
+#undef d
+#undef e
+#undef f
+#endif // __RTP__
+
+#endif // VxWorks Major >= 7
+
+#endif // __VXWORKS__
+
 #include 


-- 
Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/
   Free Software Activist GNU Toolchain Engineer
Vim, Vi, Voltei pro Emacs -- GNUlius Caesar


Add conditions on VxWorks versions for gcc.dg/vxworks/initpri?.c

2020-12-22 Thread Alexandre Oliva


Adjust vxworks initpri expectations, given that vxworks7 has switched
to .init_array.

Regstrapped on x86_64-linux-gnu, and tested with -x-arm-wrs-vxworks7r2.
Ok to install?


from Jerome Lambourg 
for  gcc/testsuite/ChangeLog

* gcc.dg/vxworks/initpri1.c: Tigthen VxWorks version check.
* gcc.dg/vxworks/initpri2.c: Likewise.
---
 gcc/testsuite/gcc.dg/vxworks/initpri1.c |1 +
 gcc/testsuite/gcc.dg/vxworks/initpri2.c |1 +
 2 files changed, 2 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/vxworks/initpri1.c 
b/gcc/testsuite/gcc.dg/vxworks/initpri1.c
index 555bffe738d90..1d26b0ecb8e6f 100644
--- a/gcc/testsuite/gcc.dg/vxworks/initpri1.c
+++ b/gcc/testsuite/gcc.dg/vxworks/initpri1.c
@@ -6,6 +6,7 @@
 /* The selector below excludes VxWorks AE because AE does not support
RTP mode.  */
 /* { dg-do compile { target { *-*-vxworks* && { ! *-*-vxworksae* } } } } */
+/* { dg-skip-if "vxworks7 SR06x0 now uses .init_array" { *-*-vxworks7r* } } */
 /* { dg-options "-mrtp" } */
 /* { dg-final { scan-assembler "ctors\.0" } } */
 /* { dg-final { scan-assembler "dtors\.0" } } */
diff --git a/gcc/testsuite/gcc.dg/vxworks/initpri2.c 
b/gcc/testsuite/gcc.dg/vxworks/initpri2.c
index 7f483efadb2bc..31b4e9b52028a 100644
--- a/gcc/testsuite/gcc.dg/vxworks/initpri2.c
+++ b/gcc/testsuite/gcc.dg/vxworks/initpri2.c
@@ -2,6 +2,7 @@
Instead, initialization is handled by munch.  */
 
 /* { dg-do compile { target vxworks_kernel } } */
+/* { dg-skip-if "vxworks7 SR06x0 now uses .init_array" { *-*-vxworks7r* } } */
 /* { dg-final { scan-assembler-not "\.ctors" } } */
 /* { dg-final { scan-assembler-not "\.dtors" } } */
 

-- 
Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/
   Free Software Activist GNU Toolchain Engineer
Vim, Vi, Voltei pro Emacs -- GNUlius Caesar


gcc.dg/intmax_t-1.c compiles without error on VxWorks 7 SR06x0

2020-12-22 Thread Alexandre Oliva


This test currently fails on VxWorks 7 SR06x0 targets when in kernel
mode, because it expects a discrepancy between built-in and system
intmax_t for all VxWorks targets when in kernel mode.  Fortunately,
this has now been fixed when targetting VxWorks 7 SR06x0, so this
commit adjusts the "dg-error" condition to exclude newer versions of
VxWorks 7.

Regstrapped on x86_64-linux-gnu, and tested with -x-arm-wrs-vxworks7r2.
Ok to install?


from Joel Brobecker 
for  gcc/testsuite/ChangeLog

* gcc.dg/intmax_t-1.c: Do not expect an error on *-*-vxworks7r*
targets.
---
 gcc/testsuite/gcc.dg/intmax_t-1.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/intmax_t-1.c 
b/gcc/testsuite/gcc.dg/intmax_t-1.c
index 00b503c250906..03d4266cc7b0a 100644
--- a/gcc/testsuite/gcc.dg/intmax_t-1.c
+++ b/gcc/testsuite/gcc.dg/intmax_t-1.c
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-Wall" } */
-/* { dg-error "" "" { target { { *arm*-*-*elf* xtensa*-*-elf* } || 
vxworks_kernel } } 0 } */
+/* { dg-error "" "" { target { { *arm*-*-*elf* xtensa*-*-elf* } || { 
vxworks_kernel && { ! *-*-vxworks7r* } } } } 0 } */
 
 /* Compile with -Wall to get a warning if built-in and system intmax_t don't
match.  */

-- 
Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/
   Free Software Activist GNU Toolchain Engineer
Vim, Vi, Voltei pro Emacs -- GNUlius Caesar


Fix VxWorks xfail filters on pthread-init-?.c

2020-12-22 Thread Alexandre Oliva


Match xfail on kernel instead of rtp mode.

Regstrapped on x86_64-linux-gnu, and tested with -x-arm-wrs-vxworks7r2.
Ok to install?


from Olivier Hainque 
for  gcc/testsuite/changeLog

* gcc.dg/pthread-init-1.c: Fix the VxWorks xfail filters.
* gcc.dg/pthread-init-2.c: Ditto.
---
 gcc/testsuite/gcc.dg/pthread-init-1.c |6 +++---
 gcc/testsuite/gcc.dg/pthread-init-2.c |3 +++
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/pthread-init-1.c 
b/gcc/testsuite/gcc.dg/pthread-init-1.c
index 8b600c3fb87bf..3346c926c8ee3 100644
--- a/gcc/testsuite/gcc.dg/pthread-init-1.c
+++ b/gcc/testsuite/gcc.dg/pthread-init-1.c
@@ -7,9 +7,9 @@
 /* { dg-do compile } */
 /* { dg-require-effective-target pthread_h } */
 /* { dg-options "-Wextra -Wall" } */
-/* The RTP definition of PTHREAD_MUTEX_INITIALIZER is missing an
- * initializer for mutexAttr.mutexAttrType.  */
-/* { dg-xfail-if "missing initializer" { vxworks_rtp } } */
+/* The definition of PTHREAD_MUTEX_INITIALIZER is missing an initializer for
+   mutexAttr.mutexAttrType in kernel mode for various VxWorks versions.  */
+/* { dg-xfail-if "missing initializer" { vxworks_kernel } } */
 
 #include "pthread-init-common.h"
 
diff --git a/gcc/testsuite/gcc.dg/pthread-init-2.c 
b/gcc/testsuite/gcc.dg/pthread-init-2.c
index 8ec0515ba26e1..d7cd66b5c0272 100644
--- a/gcc/testsuite/gcc.dg/pthread-init-2.c
+++ b/gcc/testsuite/gcc.dg/pthread-init-2.c
@@ -9,6 +9,9 @@
 /* { dg-options "-Wextra -Wall -ansi" } */
 /* { dg-options "-Wextra -Wall -ansi -D_POSIX_C_SOURCE=199506L" { target { 
*-*-hpux* } } } */
 /* { dg-options "-Wextra -Wall -ansi -D_XOPEN_SOURCE=500" { target { 
powerpc-ibm-aix* } } } */
+/* The definition of PTHREAD_MUTEX_INITIALIZER is missing an initializer for
+   mutexAttr.mutexAttrType in kernel mode for various VxWorks versions.  */
+/* { dg-xfail-if "missing initializer" { vxworks_kernel } } */
 
 #include "pthread-init-common.h"
 


-- 
Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/
   Free Software Activist GNU Toolchain Engineer
Vim, Vi, Voltei pro Emacs -- GNUlius Caesar


Add missing vxworks filters to lib/target-supports.exp functions

2020-12-22 Thread Alexandre Oliva


Explicitly disable some vxworks-missing features in the testsuite, that
the current feature tests detect as present.

Regstrapped on x86_64-linux-gnu, and tested with -x-arm-wrs-vxworks7r2.
Ok to install?


from Olivier Hainque 
for  gcc/testsuite/ChangeLog

* lib/target-supports.exp (check_weak_available,
check_fork_available, check_effective_target_lto,
check_effective_target_mempcpy): Add vxworks filters.
---
 gcc/testsuite/lib/target-supports.exp |   21 +
 1 file changed, 21 insertions(+)

diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index 11343d0192fcb..6b1d13b105da7 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -326,6 +326,12 @@ proc check_weak_available { } {
return 0
 }
 
+# VxWorks hardly supports it (vx7 RTPs only)
+
+if { [istarget *-*-vxworks*] } {
+   return 0
+}
+
 # ELF and ECOFF support it. a.out does with gas/gld but may also with
 # other linkers, so we should try it
 
@@ -2606,6 +2612,11 @@ proc check_function_available { function } {
 # Returns true iff "fork" is available on the target system.
 
 proc check_fork_available {} {
+if { [istarget *-*-vxworks*] } {
+   # VxWorks doesn't have fork but our way to test can't
+   # tell as we're doing partial links for kernel modules.
+   return 0
+ }
 return [check_function_available "fork"]
 }
 
@@ -9295,6 +9306,11 @@ proc check_effective_target_gld { } {
 # (LTO) support.
 
 proc check_effective_target_lto { } {
+if { [istarget *-*-vxworks*] } {
+   # No LTO on VxWorks, with kernel modules
+   # built with partial links
+   return 0
+}
 if { [istarget nvptx-*-*]
 || [istarget amdgcn-*-*] } {
return 0;
@@ -9514,6 +9530,11 @@ proc check_effective_target_run_expensive_tests { } {
 # Returns 1 if "mempcpy" is available on the target system.
 
 proc check_effective_target_mempcpy {} {
+if { [istarget *-*-vxworks*] } {
+   # VxWorks doesn't have mempcpy but our way to test fails
+   # to detect as we're doing partial links for kernel modules.
+   return 0
+ }
 return [check_function_available "mempcpy"]
 }
 


-- 
Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/
   Free Software Activist GNU Toolchain Engineer
Vim, Vi, Voltei pro Emacs -- GNUlius Caesar


Split wchars tests from the normal variant

2020-12-22 Thread Alexandre Oliva


This change extracts apart the wchar specific parts of character
conversion tests to allow conditonalizating these parts on actual
wchar support while applying the rest more generally.

This turned out useful during our work on the libstdc++ support
for VxWorks, to expose the problematic areas more precisely.

Regstrapped on x86_64-linux-gnu, and tested with -x-arm-wrs-vxworks7r2.
Ok to install?  (dg-requires-wchars is added by another patch by
Corentin, that I posted a few minutes ago)

While updating Corentin's patch for mainline, I brought over to the
split-out test even the preprocessor conditional that is present in the
current version of the test, but required/implied by dg-requires-wchars.
Maybe that's excessive.  Maybe the whole patch is excessive, given that
conditional, but I didn't want to just drop it without asking for
others' thoughts.


from Corentin Gay 
for  libstdc++-v3/ChangeLog

* testsuite/20_util/from_chars/1_neg.cc: Split wchar specific
part into...
* testsuite/20_util/from_chars/1_neg_wchar.cc: ... new file.
---
 libstdc++-v3/testsuite/20_util/from_chars/1_neg.cc |8 -
 .../testsuite/20_util/from_chars/1_neg_wchar.cc|   35 
 2 files changed, 35 insertions(+), 8 deletions(-)
 create mode 100644 libstdc++-v3/testsuite/20_util/from_chars/1_neg_wchar.cc

diff --git a/libstdc++-v3/testsuite/20_util/from_chars/1_neg.cc 
b/libstdc++-v3/testsuite/20_util/from_chars/1_neg.cc
index 0d2fe2b3e6594..a84b0f5efb075 100644
--- a/libstdc++-v3/testsuite/20_util/from_chars/1_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/from_chars/1_neg.cc
@@ -23,14 +23,6 @@
 void
 test01(const char* first, const char* last)
 {
-#if _GLIBCXX_USE_WCHAR_T
-  wchar_t wc;
-#else
-  enum W { } wc;
-#endif
-  std::from_chars(first, last, wc); // { dg-error "no matching" }
-  std::from_chars(first, last, wc, 10); // { dg-error "no matching" }
-
   char16_t c16;
   std::from_chars(first, last, c16); // { dg-error "no matching" }
   std::from_chars(first, last, c16, 10); // { dg-error "no matching" }
diff --git a/libstdc++-v3/testsuite/20_util/from_chars/1_neg_wchar.cc 
b/libstdc++-v3/testsuite/20_util/from_chars/1_neg_wchar.cc
new file mode 100644
index 0..2d736a28a2da7
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/from_chars/1_neg_wchar.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2017-2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// .
+
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++17 } }
+// { dg-require-wchars {} }
+
+#include 
+
+void
+test01(const char* first, const char* last)
+{
+#if _GLIBCXX_USE_WCHAR_T
+  wchar_t wc;
+#else
+  enum W { } wc;
+#endif
+
+  std::from_chars(first, last, wc); // { dg-error "no matching" }
+  std::from_chars(first, last, wc, 10); // { dg-error "no matching" }
+}

-- 
Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/
   Free Software Activist GNU Toolchain Engineer
Vim, Vi, Voltei pro Emacs -- GNUlius Caesar


mark some tests in gcc.target/arm as requiring "fpic" support

2020-12-22 Thread Alexandre Oliva


Require effective target fpic support in tests using pic flags.

Regstrapped on x86_64-linux-gnu, and tested with -x-arm-wrs-vxworks7r2.
I understand we have pre-approval for the addition of such pic
requirement markers, so I'm going to give this some 24 hours for any
objections to be raised, and proceed to install it otherwise.


from Joel Brobecker 
for  gcc/testsuite/ChangeLog

* gcc.target/arm/data-rel-1.c: Require "fpic" support.
* gcc.target/arm/data-rel-2.c: Likewise.
* gcc.target/arm/data-rel-3.c: Ditto.
* gcc.target/arm/pr44788.c: Ditto.
* gcc.target/arm/pr52006.c: Ditto.
* gcc.target/arm/pr59858.c: Ditto.
* gcc.target/arm/tlscall.c: Ditto.
* gcc.target/arm/require-pic-register-loc.c: Ditto.
Adjust line numbers.
---
 gcc/testsuite/gcc.target/arm/data-rel-1.c  |1 +
 gcc/testsuite/gcc.target/arm/data-rel-2.c  |1 +
 gcc/testsuite/gcc.target/arm/data-rel-3.c  |1 +
 gcc/testsuite/gcc.target/arm/pr44788.c |1 +
 gcc/testsuite/gcc.target/arm/pr52006.c |1 +
 gcc/testsuite/gcc.target/arm/pr59858.c |1 +
 .../gcc.target/arm/require-pic-register-loc.c  |   17 +
 gcc/testsuite/gcc.target/arm/tlscall.c |1 +
 8 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/gcc/testsuite/gcc.target/arm/data-rel-1.c 
b/gcc/testsuite/gcc.target/arm/data-rel-1.c
index a09e235c445ae..5931b44b9a6b1 100644
--- a/gcc/testsuite/gcc.target/arm/data-rel-1.c
+++ b/gcc/testsuite/gcc.target/arm/data-rel-1.c
@@ -1,5 +1,6 @@
 /* { dg-skip-if "-mpure-code and -fPIC incompatible" { *-*-* } { "-mpure-code" 
} } */
 /* { dg-options "-fPIC -mno-pic-data-is-text-relative" } */
+/* { dg-require-effective-target fpic } */
 /* { dg-final { scan-assembler-not "j-\\(.LPIC"  } } */
 /* { dg-final { scan-assembler-not "_GLOBAL_OFFSET_TABLE_-\\(.LPIC" } } */
 /* { dg-final { scan-assembler "j\\(GOT\\)" } } */
diff --git a/gcc/testsuite/gcc.target/arm/data-rel-2.c 
b/gcc/testsuite/gcc.target/arm/data-rel-2.c
index 56a54e818495b..3ed83e287f143 100644
--- a/gcc/testsuite/gcc.target/arm/data-rel-2.c
+++ b/gcc/testsuite/gcc.target/arm/data-rel-2.c
@@ -1,6 +1,7 @@
 /* { dg-skip-if "Not supported in FDPIC" { arm*-*-uclinuxfdpiceabi } "*" "" } 
*/
 /* { dg-skip-if "-mpure-code and -fPIC incompatible" { *-*-* } { "-mpure-code" 
} } */
 /* { dg-options "-fPIC -mno-pic-data-is-text-relative -mno-single-pic-base" } 
*/
+/* { dg-require-effective-target fpic } */
 /* { dg-final { scan-assembler-not "j-\\(.LPIC"  } } */
 /* { dg-final { scan-assembler "_GLOBAL_OFFSET_TABLE_-\\(.LPIC" } } */
 /* { dg-final { scan-assembler "j\\(GOT\\)" } } */
diff --git a/gcc/testsuite/gcc.target/arm/data-rel-3.c 
b/gcc/testsuite/gcc.target/arm/data-rel-3.c
index 4ce904802570c..5ab6ba7a12cc6 100644
--- a/gcc/testsuite/gcc.target/arm/data-rel-3.c
+++ b/gcc/testsuite/gcc.target/arm/data-rel-3.c
@@ -1,6 +1,7 @@
 /* { dg-skip-if "Not supported in FDPIC" { arm*-*-uclinuxfdpiceabi } "*" "" } 
*/
 /* { dg-skip-if "-mpure-code and -fPIC incompatible" { *-*-* } { "-mpure-code" 
} } */
 /* { dg-options "-fPIC -mpic-data-is-text-relative" } */
+/* { dg-require-effective-target fpic } */
 /* { dg-final { scan-assembler "j-\\(.LPIC"  } } */
 /* { dg-final { scan-assembler-not "_GLOBAL_OFFSET_TABLE_-\\(.LPIC" } } */
 /* { dg-final { scan-assembler-not "j\\(GOT\\)" } } */
diff --git a/gcc/testsuite/gcc.target/arm/pr44788.c 
b/gcc/testsuite/gcc.target/arm/pr44788.c
index e69bbc603ed1f..470db320eaea6 100644
--- a/gcc/testsuite/gcc.target/arm/pr44788.c
+++ b/gcc/testsuite/gcc.target/arm/pr44788.c
@@ -2,6 +2,7 @@
 /* { dg-skip-if "-mpure-code and -fPIC incompatible" { *-*-* } { "-mpure-code" 
} } */
 /* { dg-require-effective-target arm_thumb2_ok } */
 /* { dg-options "-Os -fno-strict-aliasing -fPIC -mthumb -march=armv7-a 
-mfpu=vfp3 -mfloat-abi=softfp" } */
+/* { dg-require-effective-target fpic } */
 
 extern void foo (float *);
 
diff --git a/gcc/testsuite/gcc.target/arm/pr52006.c 
b/gcc/testsuite/gcc.target/arm/pr52006.c
index 136a39d81ad8a..f818818608702 100644
--- a/gcc/testsuite/gcc.target/arm/pr52006.c
+++ b/gcc/testsuite/gcc.target/arm/pr52006.c
@@ -4,6 +4,7 @@
 /* { dg-skip-if "no support for hard-float VFP ABI" { arm_thumb1 } { 
"-march=*" } { "" } } */
 /* { dg-skip-if "-mpure-code and -fPIC incompatible" { *-*-* } { "-mpure-code" 
} } */
 /* { dg-options "-march=armv7-a+fp -mfloat-abi=hard -O2 -fPIC" } */
+/* { dg-require-effective-target fpic } */
 
 unsigned long a;
 static int b;
diff --git a/gcc/testsuite/gcc.target/arm/pr59858.c 
b/gcc/testsuite/gcc.target/arm/pr59858.c
index bcfd5d553e445..3360b48e85865 100644
--- a/gcc/testsuite/gcc.target/arm/pr59858.c
+++ b/gcc/testsuite/gcc.target/arm/pr59858.c
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-march=armv5te -fno-builtin -mfloat-abi=soft -mthumb 
-fno-stack-protector -Os -fno-tree-loop-optimize -fno-tree-dominator-opts 

Add conditional include of vxWorks.h for kernel mode

2020-12-22 Thread Alexandre Oliva


In kernel mode, an application must include vxWorks.h before any other
system header, this patch adds exactly that to the test that were
failing due to a missing declaration that was found in vxWorks.h.

Regstrapped on x86_64-linux-gnu, and tested with -x-arm-wrs-vxworks7r2.
Ok to install?


from Corentin Gay 
for  gcc/testsuite/ChangeLog

* gcc.c-torture/execute/ieee/fp-cmp-1.c: Adds conditional
include directive for VxWorks kernel mode.
* gcc.c-torture/execute/ieee/fp-cmp-2.c: Likewise.
* gcc.c-torture/execute/ieee/fp-cmp-3.c: Likewise.
* gcc.c-torture/execute/pr56982.c: Likewise.
* gcc.dg/vect/tree-vect.h: Add conditional #include of base
vxWorks header file required before inclusion of other
system header file, here signal.h.
* gcc.dg/c99-stdint-1.c: Likewise.
* gcc.dg/c99-stdint-2.c: Likewise.
* gcc.dg/c99-stdint-5.c: Likewise.
* gcc.dg/declspec-18.c: Likewise.
* gcc.dg/pr57287-2.c: Likewise.
* gcc.dg/pr57287.c: Likewise.
* gcc.dg/pr59920-1.c: Likewise.
* gcc.dg/pr63748.c: Likewise.
* gcc.dg/pr78582.c: Likewise.
* gcc.dg/setjmp-1.c: Likewise.
* gcc.dg/setjmp-3.c: Likewise.
* gcc.dg/setjmp-4.c: Likewise.
* gcc.dg/setjmp-5.c: Likewise.
* gcc.dg/setjmp-6.c: Likewise.
* gcc.dg/stdint-width-1.c: Likewise.
* gcc.dg/torture/pr48542.c: Likewise.
* gcc.dg/torture/pr59993.c: Likewise.
* gcc.dg/torture/pr63738.c: Likewise.
* gcc.dg/torture/pr64728.c: Likewise.
* gcc.dg/torture/pr66101.c: Likewise.
* gcc.dg/torture/stackalign/setjmp-3.c: Likewise.
* gcc.dg/torture/stackalign/setjmp-4.c: Likewise.
---
 .../gcc.c-torture/execute/ieee/fp-cmp-1.c  |6 ++
 .../gcc.c-torture/execute/ieee/fp-cmp-2.c  |7 +++
 .../gcc.c-torture/execute/ieee/fp-cmp-3.c  |7 +++
 gcc/testsuite/gcc.c-torture/execute/pr56982.c  |7 +++
 gcc/testsuite/gcc.dg/c99-stdint-1.c|6 ++
 gcc/testsuite/gcc.dg/c99-stdint-2.c|7 +++
 gcc/testsuite/gcc.dg/c99-stdint-5.c|6 ++
 gcc/testsuite/gcc.dg/declspec-18.c |6 ++
 gcc/testsuite/gcc.dg/pr57287-2.c   |6 ++
 gcc/testsuite/gcc.dg/pr57287.c |6 ++
 gcc/testsuite/gcc.dg/pr59920-1.c   |6 ++
 gcc/testsuite/gcc.dg/pr63748.c |6 ++
 gcc/testsuite/gcc.dg/pr78582.c |6 ++
 gcc/testsuite/gcc.dg/setjmp-1.c|6 ++
 gcc/testsuite/gcc.dg/setjmp-3.c|6 ++
 gcc/testsuite/gcc.dg/setjmp-4.c|6 ++
 gcc/testsuite/gcc.dg/setjmp-5.c|6 ++
 gcc/testsuite/gcc.dg/setjmp-6.c|6 ++
 gcc/testsuite/gcc.dg/stdint-width-1.c  |   14 +-
 gcc/testsuite/gcc.dg/torture/pr48542.c |6 ++
 gcc/testsuite/gcc.dg/torture/pr59993.c |6 ++
 gcc/testsuite/gcc.dg/torture/pr63738.c |6 ++
 gcc/testsuite/gcc.dg/torture/pr64728.c |6 ++
 gcc/testsuite/gcc.dg/torture/pr66101.c |6 ++
 gcc/testsuite/gcc.dg/torture/stackalign/setjmp-3.c |6 ++
 gcc/testsuite/gcc.dg/torture/stackalign/setjmp-4.c |6 ++
 gcc/testsuite/gcc.dg/vect/tree-vect.h  |8 
 gcc/testsuite/gcc.target/powerpc/pr87466.c |6 ++
 28 files changed, 181 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-1.c 
b/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-1.c
index 0655c73a1f8b8..4664d7258c06b 100644
--- a/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-1.c
@@ -1,3 +1,9 @@
+#if defined(__vxworks) && !defined(__RTP__)
+  /* A kernel module requires the inclusion of 
+ before any other system header.  */
+  #include 
+#endif
+
 #ifndef SIGNAL_SUPPRESS
 #include 
 #endif
diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-2.c 
b/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-2.c
index 0f4c6f145f1a2..60ca7461cd993 100644
--- a/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-2.c
+++ b/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-2.c
@@ -1,3 +1,10 @@
+
+#if defined(__vxworks) && !defined(__RTP__)
+  /* A kernel module requires the inclusion of 
+ before any other system header.  */
+  #include 
+#endif
+
 #ifndef SIGNAL_SUPPRESS
 #include 
 #endif
diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-3.c 
b/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-3.c
index 710b85ccb2a95..62de1f1fbf2a3 100644
--- a/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-3.c
+++ b/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-3.c
@@ -1,3 +1,10 @@
+
+#if defined(__vxworks) && 

Add dg-require-wchars to libstdc++ testsuite

2020-12-22 Thread Alexandre Oliva


Some tests uses structures from the libstdc++ that are present only if
the target has a wchar.h header.  However, those tests do not check
that the target supports those constructs before executing the tests.

The function dg-require-wchars checks that "_GLIBCXX_USE_WCHAR_T" is
defined by the configure of the libstdc++.  If it is not the case, the
test is not executed.

Regstrapped on x86_64-linux-gnu, and tested with -x-arm-wrs-vxworks7r2.
Ok to install?


from Corentin Gay 
for  libstdc++-v3/ChangeLog

* testsuite/lib/dg-options.exp: Add dg-require-wchars
function.
* testsuite/lib/libstdc++.exp: Add check_v3_target_wchars
function.
* testsuite/22_locale/codecvt/codecvt_utf16/79980.cc: Add
requirement.
* testsuite/22_locale/codecvt/codecvt_utf16/misaligned.cc:
Likewise.
* testsuite/22_locale/codecvt/codecvt_utf8/79980.cc: Likewise.
* testsuite/22_locale/codecvt/codecvt_utf8_utf16/79511.cc:
Likewise.
* testsuite/22_locale/conversions/buffer/1.cc: Likewise.
* testsuite/22_locale/conversions/buffer/2.cc: Likewise.
* testsuite/22_locale/conversions/buffer/3.cc: Likewise.
* testsuite/22_locale/conversions/buffer/requirements/typedefs.cc:
Likewise.
* testsuite/22_locale/conversions/string/1.cc: Likewise.
* testsuite/22_locale/conversions/string/2.cc: Likewise.
* testsuite/22_locale/conversions/string/3.cc: Likewise.
* testsuite/22_locale/conversions/string/66441.cc: Likewise.
* testsuite/22_locale/conversions/string/requirements/typedefs.cc:
Likewise.
* testsuite/22_locale/conversions/string/requirements/typedefs-2.cc:
Likewise.
---
 .../22_locale/codecvt/codecvt_utf16/79980.cc   |1 
 .../22_locale/codecvt/codecvt_utf16/misaligned.cc  |1 
 .../22_locale/codecvt/codecvt_utf8/79980.cc|1 
 .../22_locale/codecvt/codecvt_utf8_utf16/79511.cc  |1 
 .../testsuite/22_locale/conversions/buffer/1.cc|1 
 .../testsuite/22_locale/conversions/buffer/2.cc|1 
 .../testsuite/22_locale/conversions/buffer/3.cc|1 
 .../conversions/buffer/requirements/typedefs.cc|1 
 .../testsuite/22_locale/conversions/string/1.cc|1 
 .../testsuite/22_locale/conversions/string/2.cc|1 
 .../testsuite/22_locale/conversions/string/3.cc|1 
 .../22_locale/conversions/string/66441.cc  |1 
 .../conversions/string/requirements/typedefs-2.cc  |1 
 .../conversions/string/requirements/typedefs.cc|1 
 libstdc++-v3/testsuite/lib/dg-options.exp  |9 
 libstdc++-v3/testsuite/lib/libstdc++.exp   |   47 
 16 files changed, 70 insertions(+)

diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf16/79980.cc 
b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf16/79980.cc
index 8a092913a4c92..039bdd0322907 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf16/79980.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf16/79980.cc
@@ -16,6 +16,7 @@
 // .
 
 // { dg-do run { target c++11 } }
+// { dg-require-wchars "" }
 
 #include 
 #include 
diff --git 
a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf16/misaligned.cc 
b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf16/misaligned.cc
index 04cfc8d744bdd..3496e0e819e98 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf16/misaligned.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf16/misaligned.cc
@@ -16,6 +16,7 @@
 // .
 
 // { dg-do run { target c++11 } }
+// { dg-require-wchars "" }
 
 #include 
 #include 
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8/79980.cc 
b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8/79980.cc
index 68ae5af234ae5..fd69dd5c04de0 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8/79980.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8/79980.cc
@@ -16,6 +16,7 @@
 // .
 
 // { dg-do run { target c++11 } }
+// { dg-require-wchars "" }
 
 #include 
 #include 
diff --git 
a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8_utf16/79511.cc 
b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8_utf16/79511.cc
index 1f63e7218e7d2..590a3b73bfc41 100644
--- a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8_utf16/79511.cc
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8_utf16/79511.cc
@@ -16,6 +16,7 @@
 // .
 
 // { dg-do run { target c++11 } }
+// { dg-require-wchars "" }
 
 #include 
 #include 
diff --git a/libstdc++-v3/testsuite/22_locale/conversions/buffer/1.cc 
b/libstdc++-v3/testsuite/22_locale/conversions/buffer/1.cc
index 2855f7432d464..91bf2bf22160d 100644
--- a/libstdc++-v3/testsuite/22_locale/conversions/buffer/1.cc
+++ b/libstdc++-v3/testsuite/22_locale/conversions/buffer/1.cc
@@ -1,4 +1,5 

Re: [PATCH v2] C++ : Add the -stdlib= option.

2020-12-22 Thread Jason Merrill via Gcc-patches

On 12/22/20 3:39 PM, Iain Sandoe wrote:

Hi Jason,

Jason Merrill  wrote:


On 11/11/20 3:58 PM, Iain Sandoe wrote:



This option allows the user to specify alternate C++ runtime libraries,
for example when a platform uses libc++ as the installed C++ runtime.
It is the same spelling as a clang option that allows that to use libstdc++.
I have had this patch for some time now (more than a year) on Darwin
branches.




+  /* Which standard library to link.
+ 1 = libstdc++
+ 2 = libc++.  */
+  int which_library = 1;


Even if this variable is an int, let's introduce an enum for comparing it to 
specific values.


done - it is also noted that it must track the enum in the opt file.


@@ -264,6 +293,8 @@ lang_specific_driver (struct cl_decoded_option 
**in_decoded_options,
  /* Add one for shared_libgcc or extra static library.  */
  num_args = argc + added + need_math + (library > 0) * 4 + 1;
+  if (which_library > 1 && LIBCXXABI != NULL)
+num_args += 4;


Why does libc++ need more args than libstdc++?  Please add a comment.


done (JFTR, it’s because libc++ doesn’t include the abi library for most 
platforms, so that also has to be
appended to the link line).


+#ifdef GPLUSPLUS_LIBCXX_INCLUDE_DIR
+/* Pick up libc++ include files, if we have -stdlib=libc++.  */
+{ GPLUSPLUS_LIBCXX_INCLUDE_DIR, "G++", 2, 1,


If you're going to give cplusplus a non-boolean value, the comment in 
cppdefault.h needs to reflect that.


done.

(re-)tested on x86_64-darwin{11,16,17,19, 20} with the installed libc++ and 
x86_64-linux-gnu with an
LLVM-9 build.  Bootstrapped and smoke-tested for libc++ (regular testing for 
libstdc++).

OK for master now?


OK.


thanks
Iain

 revised patch


This option allows the user to specifiy alternate C++ runtime libraries,
for example when a platform uses libc++ as the installed C++ runtime.

We introduce the command line option: -stdlib= which is the user-facing
mechanism to select the C++ runtime to be used when compiling and linking
code.  This is the same option spelling as that used by clang to allow the
use of libstdc++.

The availability (and thus function) of the option are a configure-time
choice using the configuration control:
--with-gxx-libcxx-include-dir=

Specification of the path for the libc++ headers, enables the -stdlib=
option (using the path as given), default values are set when the path
is unconfigured.

If --with-gxx-libcxx-include-dir is given together with --with-sysroot=,
then we test to see if the include path starts with the sysroot and, if so,
record the sysroot-relative component as the local path.  At runtime, we
prepend the sysroot that is actually active.

At link time, we use the C++ runtime in force and (if that is libc++) also
append the libc++abi ABI library. As for other cases, if a target sets the
name pointer for the ABI library to NULL the G++ driver will omit it from
the link line.

gcc/ChangeLog:

* configure.ac: Add gxx-libcxx-include-dir handled
in the same way as the regular cxx header directory.
* Makefile.in: Regenerated.
* config.in: Likewise.
* configure: Likewise.
* cppdefault.c: Pick up libc++ headers if the option
is enabled.
* cppdefault.h (struct default_include): Amend comments
to reflect the extended use of the cplusplus field.
* incpath.c (add_standard_paths): Allow for multiple
c++ header include path variants.
* doc/invoke.texi: Document the -stdlib= option.

gcc/c-family/ChangeLog:

* c.opt: Add -stdlib= option and enumerations for
libstdc++ and libc++.

gcc/cp/ChangeLog:

* g++spec.c (LIBCXX, LIBCXX_PROFILE, LIBCXX_STATIC): New.
(LIBCXXABI, LIBCXXABI_PROFILE, LIBCXXABI_STATIC): New.
(enum stdcxxlib_kind): New.
(lang_specific_driver): Allow selection amongst multiple
c++ runtime libraries.
---
  gcc/Makefile.in |  6 
  gcc/c-family/c.opt  | 14 +
  gcc/config.in   |  6 
  gcc/configure   | 57 --
  gcc/configure.ac| 44 +++
  gcc/cp/g++spec.c| 74 -
  gcc/cppdefault.c|  5 +++
  gcc/cppdefault.h|  7 -
  gcc/doc/invoke.texi | 10 ++
  gcc/incpath.c   |  6 ++--
  10 files changed, 216 insertions(+), 13 deletions(-)

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 178e4eaa513..6847022f108 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -679,6 +679,9 @@ build_tooldir = $(exec_prefix)/$(target_noncanonical)
  # Directory in which the compiler finds target-independent g++ includes.
  gcc_gxx_include_dir = @gcc_gxx_include_dir@
  gcc_gxx_include_dir_add_sysroot = @gcc_gxx_include_dir_add_sysroot@
+# Directory in which the compiler finds libc++ includes.
+gcc_gxx_libcxx_include_dir = @gcc_gxx_libcxx_include_dir@
+gcc_gxx_libcxx_include_dir_add_sysroot = 
@gcc_gxx_libcxx_include_dir_add_sysroot@
  # Directory 

testsuite: C++ module tests

2020-12-22 Thread Nathan Sidwell

This adds most of the modules tests.  I do not include the tests that
excercise system & C++ library header files.  Those will be later.

gcc/testsuite/
* g++.dg/modules/*: Many tests.

--
Nathan Sidwell


tests.diff.gz
Description: application/gzip


c++: Module ICE fix

2020-12-22 Thread Nathan Sidwell

A missing check for decl lang specific has madeitself apparent.

gcc/cp/
* module.cc (has_definition): Check DECL_LANG_SPECIFIC.


(test in the next uber-patch)
--
Nathan Sidwell
diff --git i/gcc/cp/module.cc w/gcc/cp/module.cc
index ed3dbe244a3..19fe66346bd 100644
--- i/gcc/cp/module.cc
+++ w/gcc/cp/module.cc
@@ -11374,7 +11374,8 @@ has_definition (tree decl)
   break;
 
 case VAR_DECL:
-  if (DECL_TEMPLATE_INFO (decl)
+  if (DECL_LANG_SPECIFIC (decl)
+	  && DECL_TEMPLATE_INFO (decl)
 	  && DECL_USE_TEMPLATE (decl) < 2)
 	return DECL_INITIAL (decl);
   else


[PATCH v2] C++ : Add the -stdlib= option.

2020-12-22 Thread Iain Sandoe
Hi Jason,

Jason Merrill  wrote:

> On 11/11/20 3:58 PM, Iain Sandoe wrote:

>> This option allows the user to specify alternate C++ runtime libraries,
>> for example when a platform uses libc++ as the installed C++ runtime.
>> It is the same spelling as a clang option that allows that to use libstdc++.
>> I have had this patch for some time now (more than a year) on Darwin
>> branches.
>> 

>> +  /* Which standard library to link.
>> + 1 = libstdc++
>> + 2 = libc++.  */
>> +  int which_library = 1;
> 
> Even if this variable is an int, let's introduce an enum for comparing it to 
> specific values.

done - it is also noted that it must track the enum in the opt file.

>> @@ -264,6 +293,8 @@ lang_specific_driver (struct cl_decoded_option 
>> **in_decoded_options,
>>  /* Add one for shared_libgcc or extra static library.  */
>>  num_args = argc + added + need_math + (library > 0) * 4 + 1;
>> +  if (which_library > 1 && LIBCXXABI != NULL)
>> +num_args += 4;
> 
> Why does libc++ need more args than libstdc++?  Please add a comment.

done (JFTR, it’s because libc++ doesn’t include the abi library for most 
platforms, so that also has to be
appended to the link line).

>> +#ifdef GPLUSPLUS_LIBCXX_INCLUDE_DIR
>> +/* Pick up libc++ include files, if we have -stdlib=libc++.  */
>> +{ GPLUSPLUS_LIBCXX_INCLUDE_DIR, "G++", 2, 1,
> 
> If you're going to give cplusplus a non-boolean value, the comment in 
> cppdefault.h needs to reflect that.

done.

(re-)tested on x86_64-darwin{11,16,17,19, 20} with the installed libc++ and 
x86_64-linux-gnu with an
LLVM-9 build.  Bootstrapped and smoke-tested for libc++ (regular testing for 
libstdc++).

OK for master now?
thanks
Iain

 revised patch


This option allows the user to specifiy alternate C++ runtime libraries,
for example when a platform uses libc++ as the installed C++ runtime.

We introduce the command line option: -stdlib= which is the user-facing
mechanism to select the C++ runtime to be used when compiling and linking
code.  This is the same option spelling as that used by clang to allow the
use of libstdc++.

The availability (and thus function) of the option are a configure-time
choice using the configuration control:
--with-gxx-libcxx-include-dir=

Specification of the path for the libc++ headers, enables the -stdlib=
option (using the path as given), default values are set when the path
is unconfigured.

If --with-gxx-libcxx-include-dir is given together with --with-sysroot=,
then we test to see if the include path starts with the sysroot and, if so,
record the sysroot-relative component as the local path.  At runtime, we
prepend the sysroot that is actually active.

At link time, we use the C++ runtime in force and (if that is libc++) also
append the libc++abi ABI library. As for other cases, if a target sets the
name pointer for the ABI library to NULL the G++ driver will omit it from
the link line.

gcc/ChangeLog:

* configure.ac: Add gxx-libcxx-include-dir handled
in the same way as the regular cxx header directory.
* Makefile.in: Regenerated.
* config.in: Likewise.
* configure: Likewise.
* cppdefault.c: Pick up libc++ headers if the option
is enabled.
* cppdefault.h (struct default_include): Amend comments
to reflect the extended use of the cplusplus field.
* incpath.c (add_standard_paths): Allow for multiple
c++ header include path variants.
* doc/invoke.texi: Document the -stdlib= option.

gcc/c-family/ChangeLog:

* c.opt: Add -stdlib= option and enumerations for
libstdc++ and libc++.

gcc/cp/ChangeLog:

* g++spec.c (LIBCXX, LIBCXX_PROFILE, LIBCXX_STATIC): New.
(LIBCXXABI, LIBCXXABI_PROFILE, LIBCXXABI_STATIC): New.
(enum stdcxxlib_kind): New.
(lang_specific_driver): Allow selection amongst multiple
c++ runtime libraries.
---
 gcc/Makefile.in |  6 
 gcc/c-family/c.opt  | 14 +
 gcc/config.in   |  6 
 gcc/configure   | 57 --
 gcc/configure.ac| 44 +++
 gcc/cp/g++spec.c| 74 -
 gcc/cppdefault.c|  5 +++
 gcc/cppdefault.h|  7 -
 gcc/doc/invoke.texi | 10 ++
 gcc/incpath.c   |  6 ++--
 10 files changed, 216 insertions(+), 13 deletions(-)

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 178e4eaa513..6847022f108 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -679,6 +679,9 @@ build_tooldir = $(exec_prefix)/$(target_noncanonical)
 # Directory in which the compiler finds target-independent g++ includes.
 gcc_gxx_include_dir = @gcc_gxx_include_dir@
 gcc_gxx_include_dir_add_sysroot = @gcc_gxx_include_dir_add_sysroot@
+# Directory in which the compiler finds libc++ includes.
+gcc_gxx_libcxx_include_dir = @gcc_gxx_libcxx_include_dir@
+gcc_gxx_libcxx_include_dir_add_sysroot = 
@gcc_gxx_libcxx_include_dir_add_sysroot@
 # Directory to 

libgo patch committed: Add a success field to the sudog structure

2020-12-22 Thread Ian Lance Taylor via Gcc-patches
This libgo patch adds a success field to the sudog structure used to
manage select statements.  This is a step toward enabling some
compiler changes as part of upgrading to the Go 1.16beta1 release.
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
3b2d8145a4c349058d76ce299ea7eea605572004
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index a7df8433403..bb537f152b9 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-d0e56e82bb298268ec0f306fef99a715c892d4a7
+eca96e39cb895805b617e0e1f184f893ed3e46bb
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/go/runtime/chan.go b/libgo/go/runtime/chan.go
index 8e104f14140..1b20aff6ea3 100644
--- a/libgo/go/runtime/chan.go
+++ b/libgo/go/runtime/chan.go
@@ -285,18 +285,19 @@ func chansend(c *hchan, ep unsafe.Pointer, block bool, 
callerpc uintptr) bool {
}
gp.waiting = nil
gp.activeStackChans = false
-   if gp.param == nil {
-   if c.closed == 0 {
-   throw("chansend: spurious wakeup")
-   }
-   panic(plainError("send on closed channel"))
-   }
+   closed := !mysg.success
gp.param = nil
if mysg.releasetime > 0 {
blockevent(mysg.releasetime-t0, 2)
}
mysg.c = nil
releaseSudog(mysg)
+   if closed {
+   if c.closed == 0 {
+   throw("chansend: spurious wakeup")
+   }
+   panic(plainError("send on closed channel"))
+   }
return true
 }
 
@@ -333,6 +334,7 @@ func send(c *hchan, sg *sudog, ep unsafe.Pointer, unlockf 
func(), skip int) {
gp := sg.g
unlockf()
gp.param = unsafe.Pointer(sg)
+   sg.success = true
if sg.releasetime != 0 {
sg.releasetime = cputicks()
}
@@ -406,7 +408,8 @@ func closechan(c *hchan) {
sg.releasetime = cputicks()
}
gp := sg.g
-   gp.param = nil
+   gp.param = unsafe.Pointer(sg)
+   sg.success = false
if raceenabled {
raceacquireg(gp, c.raceaddr())
}
@@ -424,7 +427,8 @@ func closechan(c *hchan) {
sg.releasetime = cputicks()
}
gp := sg.g
-   gp.param = nil
+   gp.param = unsafe.Pointer(sg)
+   sg.success = false
if raceenabled {
raceacquireg(gp, c.raceaddr())
}
@@ -607,11 +611,11 @@ func chanrecv(c *hchan, ep unsafe.Pointer, block bool) 
(selected, received bool)
if mysg.releasetime > 0 {
blockevent(mysg.releasetime-t0, 2)
}
-   closed := gp.param == nil
+   success := mysg.success
gp.param = nil
mysg.c = nil
releaseSudog(mysg)
-   return true, !closed
+   return true, success
 }
 
 // recv processes a receive operation on a full channel c.
@@ -664,6 +668,7 @@ func recv(c *hchan, sg *sudog, ep unsafe.Pointer, unlockf 
func(), skip int) {
gp := sg.g
unlockf()
gp.param = unsafe.Pointer(sg)
+   sg.success = true
if sg.releasetime != 0 {
sg.releasetime = cputicks()
}
diff --git a/libgo/go/runtime/runtime2.go b/libgo/go/runtime/runtime2.go
index bf3fbac14c8..f30d1bcde6e 100644
--- a/libgo/go/runtime/runtime2.go
+++ b/libgo/go/runtime/runtime2.go
@@ -354,6 +354,12 @@ type sudog struct {
// g.selectDone must be CAS'd to win the wake-up race.
isSelect bool
 
+   // success indicates whether communication over channel c
+   // succeeded. It is true if the goroutine was awoken because a
+   // value was delivered over channel c, and false if awoken
+   // because c was closed.
+   success bool
+
parent   *sudog // semaRoot binary tree
waitlink *sudog // g.waiting list or semaRoot
waittail *sudog // semaRoot
diff --git a/libgo/go/runtime/select.go b/libgo/go/runtime/select.go
index d5087fbc045..c31aa344b55 100644
--- a/libgo/go/runtime/select.go
+++ b/libgo/go/runtime/select.go
@@ -235,10 +235,10 @@ func selectgo(cas0 *scase, order0 *uint16, ncases int) 
(int, bool) {
nextp  **sudog
)
 
-loop:
// pass 1 - look for something already waiting
var casi int
var cas *scase
+   var caseSuccess bool
var caseReleaseTime int64 = -1
var recvOK bool
for _, casei := range pollorder {
@@ -335,6 +335,7 @@ loop:
// We singly-linked up the SudoGs in lock order.
casi = -1
cas = nil
+   caseSuccess = false
sglist = gp.waiting
// Clear all elem before unlinking from gp.waiting.
for sg1 := gp.waiting; sg1 != nil; sg1 = sg1.waitlink {
@@ 

libgo patch committed: Omit nil-channel cases from selectgo order slices

2020-12-22 Thread Ian Lance Taylor via Gcc-patches
This patch to libgo omits the nil-channel cases from the order slices
used in the selectgo function.  This is a simplification for future
work.  This is being brought in here as part of updating to the Go
1.16beta1 release.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
48357ce4f22c8298ea5fb01d6873bc7bf56180e5
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index bfc7856cce5..a7df8433403 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-c8456995b0118a92820c6c1d8f996d4b1adf55c2
+d0e56e82bb298268ec0f306fef99a715c892d4a7
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/go/runtime/select.go b/libgo/go/runtime/select.go
index 81e00ec5a4e..d5087fbc045 100644
--- a/libgo/go/runtime/select.go
+++ b/libgo/go/runtime/select.go
@@ -41,7 +41,7 @@ func sellock(scases []scase, lockorder []uint16) {
var c *hchan
for _, o := range lockorder {
c0 := scases[o].c
-   if c0 != nil && c0 != c {
+   if c0 != c {
c = c0
lock()
}
@@ -57,11 +57,8 @@ func selunlock(scases []scase, lockorder []uint16) {
// the G that calls select runnable again and schedules it for 
execution.
// When the G runs on another M, it locks all the locks and frees sel.
// Now if the first M touches sel, it will access freed memory.
-   for i := len(scases) - 1; i >= 0; i-- {
+   for i := len(lockorder) - 1; i >= 0; i-- {
c := scases[lockorder[i]].c
-   if c == nil {
-   break
-   }
if i > 0 && c == scases[lockorder[i-1]].c {
continue // will unlock it on the next iteration
}
@@ -138,15 +135,6 @@ func selectgo(cas0 *scase, order0 *uint16, ncases int) 
(int, bool) {
pollorder := order1[:ncases:ncases]
lockorder := order1[ncases:][:ncases:ncases]
 
-   // Replace send/receive cases involving nil channels with
-   // caseNil so logic below can assume non-nil channel.
-   for i := range scases {
-   cas := [i]
-   if cas.c == nil && cas.kind != caseDefault {
-   *cas = scase{}
-   }
-   }
-
var t0 int64
if blockprofilerate > 0 {
t0 = cputicks()
@@ -166,15 +154,31 @@ func selectgo(cas0 *scase, order0 *uint16, ncases int) 
(int, bool) {
}
 
// generate permuted order
-   for i := 1; i < ncases; i++ {
-   j := fastrandn(uint32(i + 1))
-   pollorder[i] = pollorder[j]
+   dfli := -1
+   norder := 0
+   for i := range scases {
+   cas := [i]
+
+   // Omit cases without channels from the poll and lock orders.
+   if cas.c == nil {
+   if cas.kind == caseDefault {
+   dfli = i
+   }
+   cas.elem = nil // allow GC
+   continue
+   }
+
+   j := fastrandn(uint32(norder + 1))
+   pollorder[norder] = pollorder[j]
pollorder[j] = uint16(i)
+   norder++
}
+   pollorder = pollorder[:norder]
+   lockorder = lockorder[:norder]
 
// sort the cases by Hchan address to get the locking order.
// simple heap sort, to guarantee n log n time and constant stack 
footprint.
-   for i := 0; i < ncases; i++ {
+   for i := range lockorder {
j := i
// Start with the pollorder to permute cases on the same 
channel.
c := scases[pollorder[i]].c
@@ -185,7 +189,7 @@ func selectgo(cas0 *scase, order0 *uint16, ncases int) 
(int, bool) {
}
lockorder[j] = pollorder[i]
}
-   for i := ncases - 1; i >= 0; i-- {
+   for i := len(lockorder) - 1; i >= 0; i-- {
o := lockorder[i]
c := scases[o].c
lockorder[i] = lockorder[0]
@@ -209,7 +213,7 @@ func selectgo(cas0 *scase, order0 *uint16, ncases int) 
(int, bool) {
}
 
if debugSelect {
-   for i := 0; i+1 < ncases; i++ {
+   for i := 0; i+1 < len(lockorder); i++ {
if scases[lockorder[i]].c.sortkey() > 
scases[lockorder[i+1]].c.sortkey() {
print("i=", i, " x=", lockorder[i], " y=", 
lockorder[i+1], "\n")
throw("select: broken sort")
@@ -233,21 +237,16 @@ func selectgo(cas0 *scase, order0 *uint16, ncases int) 
(int, bool) {
 
 loop:
// pass 1 - look for something already waiting
-   var dfli int
-   var dfl *scase
var casi int
var cas *scase
var caseReleaseTime int64 = -1
var recvOK bool
-   

Go patch committed: Remove the scase.releasetime field

2020-12-22 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend and libgo removes the scase.releasetime
field.  This is a step toward updating libgo to the Go1.16beta1
release.  Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.
Committed to mainline.

Ian
9f5d0bc8ace6b8d386ed40fd8ff904251912be5c
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 81deef2cb79..bfc7856cce5 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-f9e44c6e510df9f047dbe28eb5fa19642e350f8f
+c8456995b0118a92820c6c1d8f996d4b1adf55c2
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc
index ecb93b099db..12e783010db 100644
--- a/gcc/go/gofrontend/types.cc
+++ b/gcc/go/gofrontend/types.cc
@@ -8908,11 +8908,10 @@ Channel_type::select_case_type()
   Type* uint16_type = Type::lookup_integer_type("uint16");
   Type* int64_type = Type::lookup_integer_type("int64");
   scase_type =
-   Type::make_builtin_struct_type(4,
+   Type::make_builtin_struct_type(3,
   "c", unsafe_pointer_type,
   "elem", unsafe_pointer_type,
-  "kind", uint16_type,
-  "releasetime", int64_type);
+  "kind", uint16_type);
   scase_type->set_is_struct_incomparable();
 }
   return scase_type;
diff --git a/libgo/go/runtime/select.go b/libgo/go/runtime/select.go
index c8910b8dc23..81e00ec5a4e 100644
--- a/libgo/go/runtime/select.go
+++ b/libgo/go/runtime/select.go
@@ -32,10 +32,9 @@ const (
 // Known to compiler.
 // Changes here must also be made in src/cmd/internal/gc/select.go's scasetype.
 type scase struct {
-   c   *hchan // chan
-   elemunsafe.Pointer // data element
-   kinduint16
-   releasetime int64
+   c*hchan // chan
+   elem unsafe.Pointer // data element
+   kind uint16
 }
 
 func sellock(scases []scase, lockorder []uint16) {
@@ -151,9 +150,6 @@ func selectgo(cas0 *scase, order0 *uint16, ncases int) 
(int, bool) {
var t0 int64
if blockprofilerate > 0 {
t0 = cputicks()
-   for i := 0; i < ncases; i++ {
-   scases[i].releasetime = -1
-   }
}
 
// The compiler rewrites selects that statically have
@@ -241,6 +237,7 @@ loop:
var dfl *scase
var casi int
var cas *scase
+   var caseReleaseTime int64 = -1
var recvOK bool
for i := 0; i < ncases; i++ {
casi = int(pollorder[i])
@@ -361,13 +358,13 @@ loop:
if k.kind == caseNil {
continue
}
-   if sglist.releasetime > 0 {
-   k.releasetime = sglist.releasetime
-   }
if sg == sglist {
// sg has already been dequeued by the G that woke us 
up.
casi = int(casei)
cas = k
+   if sglist.releasetime > 0 {
+   caseReleaseTime = sglist.releasetime
+   }
} else {
c = k.c
if k.kind == caseSend {
@@ -465,8 +462,8 @@ send:
goto retc
 
 retc:
-   if cas.releasetime > 0 {
-   blockevent(cas.releasetime-t0, 1)
+   if caseReleaseTime > 0 {
+   blockevent(caseReleaseTime-t0, 1)
}
 
// Check preemption, since unlike gc we don't check on every call.


Re: [PATCH v3] arm: subdivide the type attribute "alu_shfit_imm"

2020-12-22 Thread Richard Sandiford via Gcc-patches
"Qian, Jianhua"  writes:
> Hi Richard
>
> Thanks for reviewing again.
> I have updated the patch to v3.

Thanks, pushed to master now that the copyright assignment is on file.

Richard


Re: [PATCH] Add pytest for a GCOV test-case

2020-12-22 Thread David Malcolm via Gcc-patches
On Tue, 2020-12-22 at 12:39 +0100, Martin Liška wrote:
> Hello.
> 
> The patch adds a new test for an existing GCOV test-case. Newly
> added run-gcov-pytest parses JSON format produced by GCOV and
> runs pytest on it.
> 
> Patch can bootstrap on x86_64-linux-gnu and survives regression
> tests.

At a high level, this patch calls out to Python 3, allowing for test
logic to be written in Python, rather than Tcl.  Are we doing this
anywhere else in our test suite?  I'm in favor of this (I'm much more
comfortable in Python than in Tcl, I dread anytime I have to touch the
Tcl code).

The test implicitly requires python3, and the 3rd party pytest module
installed within it.  What happens if these aren't installed?  (ideally
an UNSUPPORTED at the DejaGnu level, I think).

Some further comments inline below...

> Ready to be installed?
> Thanks,
> Martin
> 
> gcc/testsuite/ChangeLog:
> 
>   PR gcov-profile/98273
>   * lib/gcov.exp: Add run-gcov-pytest function which runs pytest.
>   * g++.dg/gcov/pr98273.C: New test.
>   * g++.dg/gcov/gcov.py: New test.
>   * g++.dg/gcov/test-pr98273.py: New test.
> ---
>   gcc/testsuite/g++.dg/gcov/gcov.py | 10 
>   gcc/testsuite/g++.dg/gcov/pr98273.C   | 24 +++
>   gcc/testsuite/g++.dg/gcov/test-pr98273.py | 27
> ++
>   gcc/testsuite/lib/gcov.exp| 28
> +++
>   4 files changed, 89 insertions(+)
>   create mode 100644 gcc/testsuite/g++.dg/gcov/gcov.py
>   create mode 100644 gcc/testsuite/g++.dg/gcov/pr98273.C
>   create mode 100644 gcc/testsuite/g++.dg/gcov/test-pr98273.py
> 
> diff --git a/gcc/testsuite/g++.dg/gcov/gcov.py
> b/gcc/testsuite/g++.dg/gcov/gcov.py
> new file mode 100644
> index 000..a8c4ea9ae71
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/gcov/gcov.py
> @@ -0,0 +1,10 @@
> +import gzip
> +import json
> +import os
> +
> +
> +def gcov_from_env():
> +# return parsed JSON content a GCOV_PATH file
> +json_filename = os.environ['GCOV_PATH'] + '.gcov.json.gz'
> +json_data = gzip.open(json_filename).read()
> +return json.loads(json_data)
> diff --git a/gcc/testsuite/g++.dg/gcov/pr98273.C
> b/gcc/testsuite/g++.dg/gcov/pr98273.C
> new file mode 100644
> index 000..bfa83cbe4d0
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/gcov/pr98273.C
> @@ -0,0 +1,24 @@
> +/* PR gcov-profile/98273 */
> +
> +/* { dg-options "--coverage -std=c++11" } */
> +/* { dg-do run { target native } } */
> +
> +int
> +main ()
> +{
> +  int i = 42;
> +  {
> +auto f = [] () {
> +  auto g = [] () {};
> +  g ();
> +  g ();
> +};
> +f ();
> +  }
> +  ++i;
> +  ++i;
> +  ++i;
> +  return 45 - i;
> +}
> +
> +/* { dg-final { run-gcov-pytest pr98273.C "test-pr98273.py" } } */
> diff --git a/gcc/testsuite/g++.dg/gcov/test-pr98273.py
> b/gcc/testsuite/g++.dg/gcov/test-pr98273.py
> new file mode 100644
> index 000..6cb39d10c1e
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/gcov/test-pr98273.py

I had an idea, not sure if a good one: if all of the test logic is
moved from the .C file to a python script, then perhaps the script
should be the name of the .C file with a .py suffix i.e. here it could
be "pr98273.C.py"

Or would there be cases where different scripts could be called for the
same .C file?  Would scripts get reused between different source files?

(not sure)

> @@ -0,0 +1,27 @@
> +from gcov import gcov_from_env
> +
> +import pytest
> +
> +
> +@pytest.fixture(scope='function', autouse=True)
> +def gcov():
> +return gcov_from_env()
> +
> +
> +def test_basics(gcov):
> +files = gcov['files']
> +assert len(files) == 1
> +functions = files[0]['functions']
> +assert len(functions) == 3
> +
> +
> +def test_lines(gcov):
> +lines = gcov['files'][0]['lines']
> +linesdict = {}
> +for line in lines:
> +linesdict[int(line['line_number'])] = line
> +
> +assert linesdict[21]['function_name'] == 'main'
> +assert linesdict[15]['function_name'] == '_ZZ4mainENKUlvE_clEv'
> +assert (linesdict[12]['function_name']
> +== '_ZZZ4mainENKUlvE_clEvENKUlvE_clEv')
> diff --git a/gcc/testsuite/lib/gcov.exp b/gcc/testsuite/lib/gcov.exp
> index 9276aead06b..dd589d4dd8a 100644
> --- a/gcc/testsuite/lib/gcov.exp
> +++ b/gcc/testsuite/lib/gcov.exp
> @@ -247,6 +247,34 @@ proc verify-calls { testname testcase file } {
>   return $failed
>   }
>   
> +proc run-gcov-pytest { args } {

I think this function needs a leading comment, talking about what is
invoked, and the kinds of lines that are parsed.

What happens if an exception is raised by the script?  e.g. if there's
a SyntaxError in the script, ideally it should "bubble up" through the
Tcl layer into a DejaGnu "ERROR" I think, rather than being silently
dropped.

> +global GCOV
> +global srcdir subdir
> +# Extract the test file name from the arguments.
> +set testcase [lindex $args 0]
> +
> +verbose "Running $GCOV $testcase in 

Re: [PATCH] c++: Handle array members in build_comparison_op [PR93480]

2020-12-22 Thread Jason Merrill via Gcc-patches

On 12/21/20 3:12 AM, Jakub Jelinek wrote:

Hi!

http://eel.is/c++draft/class.compare.default#6 says for the
expanded list of subobjects:
"In that list, any subobject of array type is recursively expanded
to the sequence of its elements, in the order of increasing subscript."
but build_comparison_op just tried to compare the whole arrays, which
failed and therefore the defaulted comparison was deleted.

The following patch instead compares the array elements, and
if info.defining, adds runtime loops around it so that it iterates
over increasing subscripts.

For flexible array members it punts, we don't know how large those will be,
for zero sized arrays it doesn't even try to compare the elements,
because if there are no elements, there is nothing to compare, and
for [1] arrays it will not emit a loop because it is enough to use
[0] array ref to cover everything.

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


Please add a comment somewhere describing the meaning of the different 
fields of this TREE_LIST.  OK with that change.



2020-12-21  Jakub Jelinek  

PR c++/93480
* method.c (common_comparison_type): If comps[i] is a TREE_LIST,
use its TREE_VALUE instead.
(build_comparison_op): Handle array members.

* g++.dg/cpp2a/spaceship-synth10.C: New test.
* g++.dg/cpp2a/spaceship-synth-neg5.C: New test.

--- gcc/cp/method.c.jj  2020-12-09 00:00:27.047344706 +0100
+++ gcc/cp/method.c 2020-12-20 15:14:03.048393226 +0100
@@ -1230,6 +1230,8 @@ common_comparison_type (vec 
for (unsigned i = 0; i < comps.length(); ++i)
  {
tree comp = comps[i];
+  if (TREE_CODE (comp) == TREE_LIST)
+   comp = TREE_VALUE (comp);
tree ctype = TREE_TYPE (comp);
comp_cat_tag tag = cat_tag_for (ctype);
/* build_comparison_op already checked this.  */
@@ -1419,10 +1421,47 @@ build_comparison_op (tree fndecl, tsubst
  continue;
}
  
-	  tree lhs_mem = build3 (COMPONENT_REF, expr_type, lhs, field,

-NULL_TREE);
- tree rhs_mem = build3 (COMPONENT_REF, expr_type, rhs, field,
-NULL_TREE);
+ tree lhs_mem = build3_loc (field_loc, COMPONENT_REF, expr_type, lhs,
+field, NULL_TREE);
+ tree rhs_mem = build3_loc (field_loc, COMPONENT_REF, expr_type, rhs,
+field, NULL_TREE);
+ tree loop_indexes = NULL_TREE;
+ while (TREE_CODE (expr_type) == ARRAY_TYPE)
+   {
+ /* Flexible array member.  */
+ if (TYPE_DOMAIN (expr_type) == NULL_TREE
+ || TYPE_MAX_VALUE (TYPE_DOMAIN (expr_type)) == NULL_TREE)
+   {
+ if (complain & tf_error)
+   inform (field_loc, "cannot default compare "
+  "flexible array member");
+ bad = true;
+ break;
+   }
+ tree maxval = TYPE_MAX_VALUE (TYPE_DOMAIN (expr_type));
+ /* [0] array.  No subobjects to compare, just skip it.  */
+ if (integer_all_onesp (maxval))
+   break;
+ tree idx;
+ /* [1] array, no loop needed, just add [0] ARRAY_REF.
+Similarly if !info.defining.  */
+ if (integer_zerop (maxval) || !info.defining)
+   idx = size_zero_node;
+ /* Some other array, will need runtime loop.  */
+ else
+   {
+ idx = force_target_expr (sizetype, maxval, complain);
+ loop_indexes = tree_cons (idx, NULL_TREE, loop_indexes);
+   }
+ expr_type = TREE_TYPE (expr_type);
+ lhs_mem = build4_loc (field_loc, ARRAY_REF, expr_type, lhs_mem,
+   idx, NULL_TREE, NULL_TREE);
+ rhs_mem = build4_loc (field_loc, ARRAY_REF, expr_type, rhs_mem,
+   idx, NULL_TREE, NULL_TREE);
+   }
+ if (TREE_CODE (expr_type) == ARRAY_TYPE)
+   continue;
+
  tree overload = NULL_TREE;
  tree comp = build_new_op (field_loc, code, flags, lhs_mem, rhs_mem,
NULL_TREE, ,
@@ -1486,6 +1525,11 @@ build_comparison_op (tree fndecl, tsubst
  bad = true;
  continue;
}
+ if (loop_indexes)
+   {
+ TREE_VALUE (loop_indexes) = comp;
+ comp = loop_indexes;
+   }
  comps.safe_push (comp);
}
if (code == SPACESHIP_EXPR && is_auto (rettype))
@@ -1502,8 +1546,35 @@ build_comparison_op (tree fndecl, tsubst
{
  tree comp = comps[i];
  tree eq, retval = NULL_TREE, if_ = NULL_TREE;
+ tree loop_indexes = NULL_TREE;
  if (info.defining)
-   if_ = begin_if_stmt ();
+   {
+ if 

[PATCH] i386: Fix __builtin_floor with FE_DOWNWARD rounding direction [PR96793]

2020-12-22 Thread Uros Bizjak via Gcc-patches
x86_expand_floorceil expander uses x86_sse_copysign_to_positive, which
is unable to change the sign from - to +.  When FE_DOWNWARD rounding
direction is in effect, the expanded sequence that involves subtraction
can trigger x - x = -0.0 special rule.  x86_sse_copysign_to_positive
fails to change the sign of the intermediate value, assumed to always
be positive, back to positive.

The patch adds one extra fabs that strips the sign from the intermediate
value when flag_rounding_math is in effect.

2020-12-22  Uroš Bizjak  

gcc/
PR target/96793
* config/i386/i386-expand.c (ix86_expand_floorceil):
Remove the sign of the intermediate value for flag_rounding_math.
(ix86_expand_floorceildf_32): Ditto.

gcc/testsuite/
PR target/96793
* gcc.target/i386/pr96793.c: New test.

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

Pushed to mainline, will be backported to other release branches.

Uros.
diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c
index 7c31cc7daac..f838112783c 100644
--- a/gcc/config/i386/i386-expand.c
+++ b/gcc/config/i386/i386-expand.c
@@ -16352,12 +16352,14 @@ ix86_expand_floorceil (rtx operand0, rtx operand1, 
bool do_floor)
 if (!isless (xa, TWO52))
   return x;
x2 = (double)(long)x;
+
  Compensate.  Floor:
if (x2 > x)
  x2 -= 1;
  Compensate.  Ceil:
if (x2 < x)
  x2 += 1;
+
if (HONOR_SIGNED_ZEROS (mode))
  return copysign (x2, x);
return x2;
@@ -16392,10 +16394,15 @@ ix86_expand_floorceil (rtx operand0, rtx operand1, 
bool do_floor)
   emit_insn (gen_rtx_SET (tmp, gen_rtx_AND (mode, one, tmp)));
   tmp = expand_simple_binop (mode, do_floor ? MINUS : PLUS,
 xa, tmp, NULL_RTX, 0, OPTAB_DIRECT);
-  emit_move_insn (res, tmp);
-
   if (HONOR_SIGNED_ZEROS (mode))
-ix86_sse_copysign_to_positive (res, res, force_reg (mode, operand1), mask);
+{
+  /* Remove the sign with FE_DOWNWARD, where x - x = -0.0.  */
+  if (do_floor && flag_rounding_math)
+   tmp = ix86_expand_sse_fabs (tmp, NULL);
+
+  ix86_sse_copysign_to_positive (tmp, tmp, res, mask);
+}
+  emit_move_insn (res, tmp);
 
   emit_label (label);
   LABEL_NUSES (label) = 1;
@@ -16415,12 +16422,14 @@ ix86_expand_floorceildf_32 (rtx operand0, rtx 
operand1, bool do_floor)
   return x;
 xa = xa + TWO52 - TWO52;
 x2 = copysign (xa, x);
+
  Compensate.  Floor:
 if (x2 > x)
   x2 -= 1;
  Compensate.  Ceil:
 if (x2 < x)
   x2 += 1;
+
if (HONOR_SIGNED_ZEROS (mode))
  x2 = copysign (x2, x);
return x2;
@@ -16457,8 +16466,14 @@ ix86_expand_floorceildf_32 (rtx operand0, rtx 
operand1, bool do_floor)
   emit_insn (gen_rtx_SET (tmp, gen_rtx_AND (mode, one, tmp)));
   tmp = expand_simple_binop (mode, do_floor ? MINUS : PLUS,
 xa, tmp, NULL_RTX, 0, OPTAB_DIRECT);
-  if (!do_floor && HONOR_SIGNED_ZEROS (mode))
-ix86_sse_copysign_to_positive (tmp, tmp, res, mask);
+  if (HONOR_SIGNED_ZEROS (mode))
+{
+  /* Remove the sign with FE_DOWNWARD, where x - x = -0.0.  */
+  if (do_floor && flag_rounding_math)
+   tmp = ix86_expand_sse_fabs (tmp, NULL);
+
+  ix86_sse_copysign_to_positive (tmp, tmp, res, mask);
+}
   emit_move_insn (res, tmp);
 
   emit_label (label);
diff --git a/gcc/testsuite/gcc.target/i386/pr96793.c 
b/gcc/testsuite/gcc.target/i386/pr96793.c
new file mode 100644
index 000..4a96478e31e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr96793.c
@@ -0,0 +1,28 @@
+/* PR target/96793 */
+/* { dg-do run { target sse2_runtime } } */
+/* { dg-require-effective-target fenv } */
+/* { dg-options "-O2 -frounding-math -msse2 -mno-sse4 -mfpmath=sse" } */
+
+#include 
+
+double
+__attribute__((noinline))
+test (double value)
+{
+  return __builtin_floor (value);
+}
+
+int
+main ()
+{
+  double result;
+
+  fesetround (FE_DOWNWARD);
+
+  result = test (0.25);
+
+  if (__builtin_signbit (result) != 0)
+__builtin_abort ();
+
+  return 0;
+}


Re: [RFC] Run pass_sink_code once more after ivopts/fre

2020-12-22 Thread Richard Biener
On December 21, 2020 10:03:43 AM GMT+01:00, Xiong Hu Luo  
wrote:
>Here comes another case that requires run a pass once more, as this is
>not the common suggested direction to solve problems, not quite sure
>whether it is still a reasonble fix here.  Source code is something
>like:
>
>ref = ip + *hslot;
>while (ip < in_end - 2) {
>  unsigned int len = 2;
>  len++;
>for ()   {
>  do len++;
>  while (len < maxlen && ref[len] == ip[len]); //sink code here.
>  break;
>}
>  len -= 2;
>  ip++;
>  ip += len + 1;
>  if (ip >= in_end - 2)
>break;
>}
>
>Before ivopts, the gimple for inner while loop is xxx.c.172t.slp1:
>
>   [local count: 75120046]:
>  # len_160 = PHI 
>  len_189 = len_160 + 1;
>  _423 = (sizetype) len_189;
>  _424 = ip_229 + _423;
>  if (maxlen_186 > len_189)
>goto ; [94.50%]
>  else
>goto ; [5.50%]
>
>   [local count: 70988443]:
>  _84 = *_424;
>  _86 = ref_182 + _423;
>  _87 = *_86;
>  if (_84 == _87)
>goto ; [94.50%]
>  else
>goto ; [5.50%]
>
>   [local count: 67084079]:
>  goto ; [100.00%]
>
>   [local count: 14847855]:
>  # len_263 = PHI 
>  # _262 = PHI <_423(32), _423(31)>
>  # _264 = PHI <_424(32), _424(31)>
>  len_190 = len_263 + 4294967295;
>  if (len_190 <= 6)
>goto ; [0.00%]
>  else
>goto ; [100.00%]
>
>Then in ivopts, instructions are updated to xxx.c.174t.ivopts:
>
>   [local count: 75120046]:
>  # ivtmp.30_29 = PHI 
>  _34 = (unsigned int) ivtmp.30_29;
>  len_160 = _34 + 4294967295;
>  _423 = ivtmp.30_29;
>  _35 = (unsigned long) ip_229;
>  _420 = ivtmp.30_29 + _35;
>  _419 = (uint8_t *) _420;
>  _424 = _419;
>  len_418 = (unsigned int) ivtmp.30_29;
>  if (maxlen_186 > len_418)
>goto ; [94.50%]
>  else
>goto ; [5.50%]
>
>   [local count: 70988443]:
>  _84 = MEM[(uint8_t *)ip_229 + ivtmp.30_29 * 1];
>  ivtmp.30_31 = ivtmp.30_29 + 1;
>  _417 = ref_182 + 18446744073709551615;
>  _87 = MEM[(uint8_t *)_417 + ivtmp.30_31 * 1];
>  if (_84 == _87)
>goto ; [94.50%]
>  else
>goto ; [5.50%]
>
>   [local count: 67084079]:
>  goto ; [100.00%]
>
>   [local count: 14847855]:
>  # len_263 = PHI 
>  # _262 = PHI <_423(32), _423(31)>
>  # _264 = PHI <_424(32), _424(31)>
>  len_190 = len_263 + 4294967295;
>  if (len_190 <= 6)
>goto ; [0.00%]
>  else
>goto ; [100.00%]
>
>Some instructions in BB 31 are not used in the loop and could be sinked
>out of loop to reduce the computation, but they are not sinked
>throughout all passes later.  Run the sink_code pass once more at least
>after fre5 could improve this typical case performance 23% due to few
>instructions exausted in loop.
>xxx.c.209t.sink2:
>
>Sinking _419 = (uint8_t *) _420;
> from bb 31 to bb 89
>Sinking _420 = ivtmp.30_29 + _35;
> from bb 31 to bb 89
>Sinking _35 = (unsigned long) ip_229;
> from bb 31 to bb 89
>Sinking len_160 = _34 + 4294967295;
> from bb 31 to bb 33
>
>I also tested the SPEC2017 performance on P8LE, 544.nab_r is improved
>by 2.43%, but no big changes to other cases, GEOMEAN is improved quite
>small with 0.25%.
>
>The reason why it should be run after fre5 is fre would do some phi
>optimization to expose the optimization.  The patch put it after
>pass_modref is due to my guess that some gimple optimizations like
>thread_jumps, dse, dce etc. could provide more opportunities for
>sinking code.  Not sure it is the correct place to put.  I also
>verified this issue exists in both X86 and ARM64.
>Any comments?  Thanks.

It definitely should be before uncprop (but context stops there). And yes, 
re-running passes isn't the very, very best thing to do without explaining it 
cannot be done in other ways. Not for late stage 3 anyway. 

Richard. 

>---
> gcc/passes.def  | 1 +
> gcc/tree-ssa-sink.c | 1 +
> 2 files changed, 2 insertions(+)
>
>diff --git a/gcc/passes.def b/gcc/passes.def
>index 21b2e2af0f7..69106615729 100644
>--- a/gcc/passes.def
>+++ b/gcc/passes.def
>@@ -355,6 +355,7 @@ along with GCC; see the file COPYING3.  If not see
>   NEXT_PASS (pass_uncprop);
>   NEXT_PASS (pass_local_pure_const);
>   NEXT_PASS (pass_modref);
>+  NEXT_PASS (pass_sink_code);
>   POP_INSERT_PASSES ()
>   NEXT_PASS (pass_all_optimizations_g);
>   PUSH_INSERT_PASSES_WITHIN (pass_all_optimizations_g)
>diff --git a/gcc/tree-ssa-sink.c b/gcc/tree-ssa-sink.c
>index b0abf4147d6..824659f3919 100644
>--- a/gcc/tree-ssa-sink.c
>+++ b/gcc/tree-ssa-sink.c
>@@ -819,6 +819,7 @@ public:
>   /* opt_pass methods: */
>   virtual bool gate (function *) { return flag_tree_sink != 0; }
>   virtual unsigned int execute (function *);
>+  opt_pass *clone (void) { return new pass_sink_code (m_ctxt); }
> 
> }; // class pass_sink_code
> 



Re: [PATCH][DOC] Document my changes in GCC 11.

2020-12-22 Thread Jonathan Wakely via Gcc-patches
On Tue, 22 Dec 2020 at 14:55, Martin Liška  wrote:
>
> On 12/22/20 1:54 PM, Jonathan Wakely wrote:
> > That seems good to me, but I think this reads a little better: "The
> > GCOV data file format outputs smaller files by representing zero
> > counters in a more compact way." ",
>
> All right. Thank you for all the suggestions and I have the following now:
>
> diff --git a/htdocs/gcc-11/changes.html b/htdocs/gcc-11/changes.html
> index 1a9e72c1..aa385c6b 100644
> --- a/htdocs/gcc-11/changes.html
> +++ b/htdocs/gcc-11/changes.html
> @@ -116,6 +116,28 @@ a work-in-progress.
> option (which defaults to 8 spaces per tab stop).
>   
> 
> +  A new warning  href="https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wtsan;>-Wtsan,
>  enabled by default,
> +  warns about unsupported features in ThreadSanitizer (currently 
> std::atomic_thread_fence).
> +  A series of conditional expressions that compare the same variable can 
> be transformed into a switch statement
> +  can be transformed into a switch statement if each of them contains a 
> comparison expression.  Example:

can be transformed into a switch statement can be transformed into a
switch statement


> +  
> +int IsHTMLWhitespace(int aChar) {
> +  return aChar == 0x0009 || aChar == 0x000A ||
> + aChar == 0x000C || aChar == 0x000D ||
> + aChar == 0x0020;
> +}
> +   
> +   This statement can be transformed into a switch statement and then 
> expanded into a bit-test.
> +  
> +  
> +New command-line options:
> +
> + href="https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fno-bit-tests;>-fbit-tests,
>  enabled by default, can be used to enable or disable switch expansion using 
> bit-tests.
> +
> +  
> +  GCOV data file format outputs smaller files by representing zero 
> counters in a more compact way.
> +  Some short options of the gcov tool have been renamed: 
> -i to -j
> +  and -j to -H.
>   
>
>   
> @@ -149,6 +171,12 @@ a work-in-progress.
>
>   C family
>   
> +  New attribute:
> +
> +The no_stack_protector attribute has been added to 
> mark functions which should not be instrumented
> +with stack protection (-fstack-protector).
> +
> +  
> New warnings:
>   
> -Wsizeof-array-div, enabled by -Wall, 
> warns


Re: [PATCH] c++: Fix up floating point complex handling in build_zero_init_1 [PR98353]

2020-12-22 Thread Jason Merrill via Gcc-patches

On 12/21/20 6:10 PM, Jakub Jelinek wrote:

Hi!

While the gimplifier patch I've just committed fixed an ICE, in some cases
like on the committed testcase cp folding doesn't happen after
build_zero_init_1 because it is called already during gimplification.

Not exactly sure why we just don't call build_zero_cst (type); for the > scalar 
types


I don't know either.  Want to test that?

, but if we want to use convert, the problem with complex floats

is that it returns a COMPLEX_EXPR with FLOAT_EXPR arguments which have
INTEGER_CST 0 as argument.  As fold isn't recursive, it doesn't do anything
in that case, we need to first fold those FLOAT_EXPRs to REAL_CST 0.0 and
only afterwards the COMPLEX_EXPR can be folded into COMPLEX_CST with 0.0
arguments.

The following patch calls cp_fold_rvalue in that case which does the
recursive folding.

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

2020-12-21  Jakub Jelinek  

PR c++/98353
* init.c (build_zero_init_1): Use cp_fold_rvalue instead of fold
for SCALAR_TYPE_P zero initializers.

--- gcc/cp/init.c.jj2020-12-09 09:03:38.270054654 +0100
+++ gcc/cp/init.c   2020-12-21 13:51:57.353332652 +0100
@@ -187,7 +187,7 @@ build_zero_init_1 (tree type, tree nelts
else if (NULLPTR_TYPE_P (type))
  init = build_int_cst (type, 0);
else if (SCALAR_TYPE_P (type))
-init = fold (convert (type, integer_zero_node));
+init = cp_fold_rvalue (convert (type, integer_zero_node));
else if (RECORD_OR_UNION_CODE_P (TREE_CODE (type)))
  {
tree field;

Jakub





Re: [PATCH][DOC] Document my changes in GCC 11.

2020-12-22 Thread Martin Liška

On 12/22/20 1:54 PM, Jonathan Wakely wrote:

That seems good to me, but I think this reads a little better: "The
GCOV data file format outputs smaller files by representing zero
counters in a more compact way." ",


All right. Thank you for all the suggestions and I have the following now:

diff --git a/htdocs/gcc-11/changes.html b/htdocs/gcc-11/changes.html
index 1a9e72c1..aa385c6b 100644
--- a/htdocs/gcc-11/changes.html
+++ b/htdocs/gcc-11/changes.html
@@ -116,6 +116,28 @@ a work-in-progress.
   option (which defaults to 8 spaces per tab stop).
 
   
+  A new warning https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wtsan;>-Wtsan,
 enabled by default,
+  warns about unsupported features in ThreadSanitizer (currently 
std::atomic_thread_fence).
+  A series of conditional expressions that compare the same variable can 
be transformed into a switch statement
+  can be transformed into a switch statement if each of them contains a 
comparison expression.  Example:
+  
+int IsHTMLWhitespace(int aChar) {
+  return aChar == 0x0009 || aChar == 0x000A ||
+ aChar == 0x000C || aChar == 0x000D ||
+ aChar == 0x0020;
+}
+   
+   This statement can be transformed into a switch statement and then 
expanded into a bit-test.
+  
+  
+New command-line options:
+
+https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fno-bit-tests;>-fbit-tests,
 enabled by default, can be used to enable or disable switch expansion using bit-tests.
+
+  
+  GCOV data file format outputs smaller files by representing zero counters in a 
more compact way.
+  Some short options of the gcov tool have been renamed: -i 
to -j
+  and -j to -H.
 
 
 

@@ -149,6 +171,12 @@ a work-in-progress.
 
 C family

 
+  New attribute:
+
+The no_stack_protector attribute has been added to 
mark functions which should not be instrumented
+with stack protection (-fstack-protector).
+
+  
   New warnings:
 
   -Wsizeof-array-div, enabled by -Wall, warns


Re: [PATCH] ira: Skip some pseudos in move_unallocated_pseudos

2020-12-22 Thread Segher Boessenkool
Hi!

Just a dumb formatting comment:

On Tue, Dec 22, 2020 at 04:05:39PM +0800, Kewen.Lin wrote:
> This patch is to make move_unallocated_pseudos consistent
> to what we have in function find_moveable_pseudos, where we
> record the original pseudo into pseudo_replaced_reg only if
> validate_change succeeds with newreg.  To ensure every
> unallocated pseudo in move_unallocated_pseudos has expected
> information, it's better to add a check and skip it if it's
> unexpected.  This avoids possible ICEs in future.
> 
> btw, I happened to found this in the bootstrapping for one
> experimental local patch, which is considered as impractical.

> --- a/gcc/ira.c
> +++ b/gcc/ira.c
> @@ -5111,6 +5111,11 @@ move_unallocated_pseudos (void)
>{
>   int idx = i - first_moveable_pseudo;
>   rtx other_reg = pseudo_replaced_reg[idx];
> + /* If there is no appropriate pseudo in pseudo_replaced_reg, it
> +means validate_change fails for this new pseudo in function
> +find_moveable_pseudos, then bypass it here.*/

Dot space space.

The patch sounds fine to me.  Hard to tell without seeing the patch that
exposed the problem (for onlookers like me who do not know this code
well, anyway ;-) )


Segher


Re: Add libcody

2020-12-22 Thread Sebastian Huber

On 21/12/2020 20:47, Nathan Sidwell wrote:


On 12/21/20 1:23 PM, Sebastian Huber wrote:

Hello Nathan,




../../gnu-mirror-gcc-cf22f78/gcc/../libcody/cody.hh:24:
In file included from /usr/include/c++/v1/memory:654:
/usr/include/c++/v1/typeinfo:231:5: error: no member named 
'fancy_abort' in namespace 'std::__1'; did you mean simply 
'fancy_abort'?

 _VSTD::abort();
 ^~~
/usr/include/c++/v1/__config:816:15: note: expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_ABI_NAMESPACE
   ^
../../gnu-mirror-gcc-cf22f78/gcc/system.h:769:13: note: 'fancy_abort' 
declared here

extern void fancy_abort (const char *, int, const char *)


can you try with Gerald Pfeifer's patch setting INCLUDE_$X?  Some ot 
that's committed but not all. 


Thanks, with

commit 7e63d383b89cd75b7775883d71ed09724b9ee73f
Author: Gerald Pfeifer 
Date:   Tue Dec 22 13:37:56 2020 +0100

the GCC builds now again on FreeBSD 12.

--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.hu...@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/



Re: [PATCH][DOC] Document my changes in GCC 11.

2020-12-22 Thread Jonathan Wakely via Gcc-patches
On Tue, 22 Dec 2020 at 12:01, Martin Liška  wrote:
>
> On 12/22/20 12:46 PM, Jonathan Wakely wrote:
> > On Tue, 22 Dec 2020 at 08:29, Martin Liška  wrote:
> >>
> >> Hello.
> >>
> >> May I please ask a native speaker for a correction of my wording?
> >>
> >> Thanks,
> >> Martin
> >>
> >> ---
> >>htdocs/gcc-11/changes.html | 28 
> >>1 file changed, 28 insertions(+)
> >>
> >> diff --git a/htdocs/gcc-11/changes.html b/htdocs/gcc-11/changes.html
> >> index 1a9e72c1..badc9e12 100644
> >> --- a/htdocs/gcc-11/changes.html
> >> +++ b/htdocs/gcc-11/changes.html
> >> @@ -116,6 +116,28 @@ a work-in-progress.
> >>  option (which defaults to 8 spaces per tab stop).
> >>
> >>  
> >> +  New warning  >> href="https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wtsan;>-Wtsan,
> >>  enabled by default,
> >
> > "A new warning" or "The new warning". My preference would be "a new 
> > warning".
> >
> >> +  warns about unsupported features in ThreadSanitizer 
> >> (std::atomic_thread_fence).
> >> +  Series of if conditions, sharing a common index variable, can be 
> >> transformed into a switch statement if each
> >
> > There is no "if" condition in your example, and I don't know what the
> > "index variable" is either.
> >
> > "A series of conditional expressions that compare the same variable
> > can be transformed into a switch statement" seems to be what you want
> > to say.
>
> I like the wording.
>
> >
> >> +  of them contains a comparison expession.  Example:
> >> +  
> >> +int IsHTMLWhitespace(int aChar) {
> >> +  return aChar == 0x0009 || aChar == 0x000A ||
> >> + aChar == 0x000C || aChar == 0x000D ||
> >> + aChar == 0x0020;
> >> +}
> >> +   
> >> +   The statement is transformed into a GIMPLE switch statement that 
> >> is later effectively expanded as bit-test.
> >
> > Do users know or care about GIMPLE? I'm unsure what "effectively
> > expanded as bit-test" means.
>
> They don't care. I wanted to express that such transformation can lead in a 
> faster
> code eventually. Do you have a suggesting for wording?

Maybe "This statement can be transformed into a switch statement and
then expanded into a bit-test." ?

>
> >
> >
> >> +  
> >> +  
> >> +New command-line options:
> >> +
> >> + >> href="https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fno-bit-tests;>-fbit-tests,
> >>  enabled by default, can be used to enable or disable switch expansion 
> >> using bit-tests.
> >> +
> >> +  
> >> +  GCOV data file format can effectively store a group of counters 
> >> that are all zero.
> >
> > What does "effectively" mean here? It can have two slightly different
> > meanings in English, it can mean "doing a good job" or "not
> > officially, but in practice".
>
> It means doing a good job :)
> What about: "The GCOV data file format outputs smaller files as zero counters 
> can be represented in a compact way." ?

That seems good to me, but I think this reads a little better: "The
GCOV data file format outputs smaller files by representing zero
counters in a more compact way." ",

Or use Martin J's suggestion: "The GCOV data file format can more
efficiently store a group of counters that are all zero."


Re: [PATCH][DOC] Document my changes in GCC 11.

2020-12-22 Thread Martin Jambor
On Tue, Dec 22 2020, Martin Liška wrote:
> On 12/22/20 12:46 PM, Jonathan Wakely wrote:
>> On Tue, 22 Dec 2020 at 08:29, Martin Liška  wrote:

[...]

>>> +  
>>> +  
>>> +New command-line options:
>>> +
>>> +>> href="https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fno-bit-tests;>-fbit-tests,
>>>  enabled by default, can be used to enable or disable switch expansion 
>>> using bit-tests.
>>> +
>>> +  
>>> +  GCOV data file format can effectively store a group of counters that 
>>> are all zero.
>> 
>> What does "effectively" mean here? It can have two slightly different
>> meanings in English, it can mean "doing a good job" or "not
>> officially, but in practice".
>
> It means doing a good job :)

So perhaps it should have been "efficiently?" 

Martin

> What about: "The GCOV data file format outputs smaller files as zero counters 
> can be represented in a compact way." ?
>
> Thanks,
> Martin
>


Re: [PATCH][DOC] Document my changes in GCC 11.

2020-12-22 Thread Martin Liška

On 12/22/20 12:46 PM, Jonathan Wakely wrote:

On Tue, 22 Dec 2020 at 08:29, Martin Liška  wrote:


Hello.

May I please ask a native speaker for a correction of my wording?

Thanks,
Martin

---
   htdocs/gcc-11/changes.html | 28 
   1 file changed, 28 insertions(+)

diff --git a/htdocs/gcc-11/changes.html b/htdocs/gcc-11/changes.html
index 1a9e72c1..badc9e12 100644
--- a/htdocs/gcc-11/changes.html
+++ b/htdocs/gcc-11/changes.html
@@ -116,6 +116,28 @@ a work-in-progress.
 option (which defaults to 8 spaces per tab stop).
   
 
+  New warning https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wtsan;>-Wtsan,
 enabled by default,


"A new warning" or "The new warning". My preference would be "a new warning".


+  warns about unsupported features in ThreadSanitizer 
(std::atomic_thread_fence).
+  Series of if conditions, sharing a common index variable, can be 
transformed into a switch statement if each


There is no "if" condition in your example, and I don't know what the
"index variable" is either.

"A series of conditional expressions that compare the same variable
can be transformed into a switch statement" seems to be what you want
to say.


I like the wording.




+  of them contains a comparison expession.  Example:
+  
+int IsHTMLWhitespace(int aChar) {
+  return aChar == 0x0009 || aChar == 0x000A ||
+ aChar == 0x000C || aChar == 0x000D ||
+ aChar == 0x0020;
+}
+   
+   The statement is transformed into a GIMPLE switch statement that is 
later effectively expanded as bit-test.


Do users know or care about GIMPLE? I'm unsure what "effectively
expanded as bit-test" means.


They don't care. I wanted to express that such transformation can lead in a 
faster
code eventually. Do you have a suggesting for wording?





+  
+  
+New command-line options:
+
+https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fno-bit-tests;>-fbit-tests,
 enabled by default, can be used to enable or disable switch expansion using bit-tests.
+
+  
+  GCOV data file format can effectively store a group of counters that are all 
zero.


What does "effectively" mean here? It can have two slightly different
meanings in English, it can mean "doing a good job" or "not
officially, but in practice".


It means doing a good job :)
What about: "The GCOV data file format outputs smaller files as zero counters can be 
represented in a compact way." ?

Thanks,
Martin





+  Some gcov tool options are renamed: 
-i,--json-format to


s/are/have been/ ?


+  -j,--json-format and -j,--human-readable to 
-H,--human-readable.
   





Re: [PATCH][DOC] Document my changes in GCC 11.

2020-12-22 Thread Jonathan Wakely via Gcc-patches
On Tue, 22 Dec 2020 at 08:29, Martin Liška  wrote:
>
> Hello.
>
> May I please ask a native speaker for a correction of my wording?
>
> Thanks,
> Martin
>
> ---
>   htdocs/gcc-11/changes.html | 28 
>   1 file changed, 28 insertions(+)
>
> diff --git a/htdocs/gcc-11/changes.html b/htdocs/gcc-11/changes.html
> index 1a9e72c1..badc9e12 100644
> --- a/htdocs/gcc-11/changes.html
> +++ b/htdocs/gcc-11/changes.html
> @@ -116,6 +116,28 @@ a work-in-progress.
> option (which defaults to 8 spaces per tab stop).
>   
> 
> +  New warning  href="https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wtsan;>-Wtsan,
>  enabled by default,

"A new warning" or "The new warning". My preference would be "a new warning".

> +  warns about unsupported features in ThreadSanitizer 
> (std::atomic_thread_fence).
> +  Series of if conditions, sharing a common index variable, can be 
> transformed into a switch statement if each

There is no "if" condition in your example, and I don't know what the
"index variable" is either.

"A series of conditional expressions that compare the same variable
can be transformed into a switch statement" seems to be what you want
to say.

> +  of them contains a comparison expession.  Example:
> +  
> +int IsHTMLWhitespace(int aChar) {
> +  return aChar == 0x0009 || aChar == 0x000A ||
> + aChar == 0x000C || aChar == 0x000D ||
> + aChar == 0x0020;
> +}
> +   
> +   The statement is transformed into a GIMPLE switch statement that is 
> later effectively expanded as bit-test.

Do users know or care about GIMPLE? I'm unsure what "effectively
expanded as bit-test" means.


> +  
> +  
> +New command-line options:
> +
> + href="https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fno-bit-tests;>-fbit-tests,
>  enabled by default, can be used to enable or disable switch expansion using 
> bit-tests.
> +
> +  
> +  GCOV data file format can effectively store a group of counters that 
> are all zero.

What does "effectively" mean here? It can have two slightly different
meanings in English, it can mean "doing a good job" or "not
officially, but in practice".


> +  Some gcov tool options are renamed: 
> -i,--json-format to

s/are/have been/ ?

> +  -j,--json-format and -j,--human-readable to 
> -H,--human-readable.
>   
>


Re: [PATCH][DOC] Document my changes in GCC 11.

2020-12-22 Thread Gerald Pfeifer
On Tue, 22 Dec 2020, Martin Liška wrote:
> May I please ask a native speaker for a correction of my wording?

That excludes myself ;), but let me give it a pass, and perhaps
you can then post an updated patch (for Jonathan or another native
speaker to go through)?


> +  New warning  href="https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wtsan;>-Wtsan,
> enabled by default,
> +  warns about unsupported features in ThreadSanitizer
> (std::atomic_thread_fence).

Is this atomic_thread_fence the only one and there may be different
ones in the future?

In that case maybe write something like "(currently ...).

> +  Series of if conditions, sharing a common index variable, can be
> transformed into a switch statement if each

"A series of" 

> +  of them contains a comparison expession.  Example:

"expression"

> +  GCOV data file format can effectively store a group of counters that
> are all zero.

"The GCOV data..."

> +  Some gcov tool options are renamed:
> -i,--json-format to
> +  -j,--json-format and -j,--human-readable to
> -H,--human-readable.

I suggest "have been renamed".

Are -i and --json-format the short and long forms of the same
option?  If so, how about saying something like "Some short options
of the gcov tool..."?

And then 

  -i (--json-format) to j
  and -j (--json-format) to -H...

> +The no_stack_protector attribute has been added
> to mark functions which should not be instrumented

That line is a little very long. ;-)


This is okay modulo the notes above.

Thank you,
Gerald


[PATCH] Add pytest for a GCOV test-case

2020-12-22 Thread Martin Liška

Hello.

The patch adds a new test for an existing GCOV test-case. Newly
added run-gcov-pytest parses JSON format produced by GCOV and
runs pytest on it.

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

Ready to be installed?
Thanks,
Martin

gcc/testsuite/ChangeLog:

PR gcov-profile/98273
* lib/gcov.exp: Add run-gcov-pytest function which runs pytest.
* g++.dg/gcov/pr98273.C: New test.
* g++.dg/gcov/gcov.py: New test.
* g++.dg/gcov/test-pr98273.py: New test.
---
 gcc/testsuite/g++.dg/gcov/gcov.py | 10 
 gcc/testsuite/g++.dg/gcov/pr98273.C   | 24 +++
 gcc/testsuite/g++.dg/gcov/test-pr98273.py | 27 ++
 gcc/testsuite/lib/gcov.exp| 28 +++
 4 files changed, 89 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/gcov/gcov.py
 create mode 100644 gcc/testsuite/g++.dg/gcov/pr98273.C
 create mode 100644 gcc/testsuite/g++.dg/gcov/test-pr98273.py

diff --git a/gcc/testsuite/g++.dg/gcov/gcov.py 
b/gcc/testsuite/g++.dg/gcov/gcov.py
new file mode 100644
index 000..a8c4ea9ae71
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gcov/gcov.py
@@ -0,0 +1,10 @@
+import gzip
+import json
+import os
+
+
+def gcov_from_env():
+# return parsed JSON content a GCOV_PATH file
+json_filename = os.environ['GCOV_PATH'] + '.gcov.json.gz'
+json_data = gzip.open(json_filename).read()
+return json.loads(json_data)
diff --git a/gcc/testsuite/g++.dg/gcov/pr98273.C 
b/gcc/testsuite/g++.dg/gcov/pr98273.C
new file mode 100644
index 000..bfa83cbe4d0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gcov/pr98273.C
@@ -0,0 +1,24 @@
+/* PR gcov-profile/98273 */
+
+/* { dg-options "--coverage -std=c++11" } */
+/* { dg-do run { target native } } */
+
+int
+main ()
+{
+  int i = 42;
+  {
+auto f = [] () {
+  auto g = [] () {};
+  g ();
+  g ();
+};
+f ();
+  }
+  ++i;
+  ++i;
+  ++i;
+  return 45 - i;
+}
+
+/* { dg-final { run-gcov-pytest pr98273.C "test-pr98273.py" } } */
diff --git a/gcc/testsuite/g++.dg/gcov/test-pr98273.py 
b/gcc/testsuite/g++.dg/gcov/test-pr98273.py
new file mode 100644
index 000..6cb39d10c1e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gcov/test-pr98273.py
@@ -0,0 +1,27 @@
+from gcov import gcov_from_env
+
+import pytest
+
+
+@pytest.fixture(scope='function', autouse=True)
+def gcov():
+return gcov_from_env()
+
+
+def test_basics(gcov):
+files = gcov['files']
+assert len(files) == 1
+functions = files[0]['functions']
+assert len(functions) == 3
+
+
+def test_lines(gcov):
+lines = gcov['files'][0]['lines']
+linesdict = {}
+for line in lines:
+linesdict[int(line['line_number'])] = line
+
+assert linesdict[21]['function_name'] == 'main'
+assert linesdict[15]['function_name'] == '_ZZ4mainENKUlvE_clEv'
+assert (linesdict[12]['function_name']
+== '_ZZZ4mainENKUlvE_clEvENKUlvE_clEv')
diff --git a/gcc/testsuite/lib/gcov.exp b/gcc/testsuite/lib/gcov.exp
index 9276aead06b..dd589d4dd8a 100644
--- a/gcc/testsuite/lib/gcov.exp
+++ b/gcc/testsuite/lib/gcov.exp
@@ -247,6 +247,34 @@ proc verify-calls { testname testcase file } {
 return $failed
 }
 
+proc run-gcov-pytest { args } {

+global GCOV
+global srcdir subdir
+# Extract the test file name from the arguments.
+set testcase [lindex $args 0]
+
+verbose "Running $GCOV $testcase in $srcdir/$subdir" 2
+set testcase [remote_download host $testcase]
+set result [remote_exec host $GCOV "$testcase -i"]
+
+set pytest_script [lindex $args 1]
+setenv GCOV_PATH $testcase
+verbose "pytest_script: $pytest_script" 2
+spawn -noecho python3 -m pytest --color=no -rA -s --tb=no 
$srcdir/$subdir/$pytest_script
+
+set prefix "\[^\r\n\]*"
+expect {
+  -re "FAILED($prefix)\[^\r\n\]+\r\n" {
+   fail "$expect_out(1,string)"
+   exp_continue
+  }
+  -re "PASSED($prefix)\[^\r\n\]+\r\n" {
+   pass "$expect_out(1,string)"
+   exp_continue
+  }
+}
+}
+
 # Called by dg-final to run gcov and analyze the results.
 #
 # ARGS consists of the optional strings "branches" and/or "calls",
--
2.29.2



Re: [patch] libstdc++/testsuite: Tweak dg-prune-output regex for out-of-tree contexts

2020-12-22 Thread Olivier Hainque



> On 21 Dec 2020, at 12:40, Jonathan Wakely  wrote:

>> Probably more robust, I agree. This still works
>> both with build tree (tested on mainline) and install
>> tree (tested on our gcc-10 branch).
>> 
>> Same ChangeLog.
> 
> OK to commit like that then, thanks.

Sure, will do. Thanks for your feedback,

Cheers,

Olivier



Re: The defaulted default constructor defined as deleted when one of variant member has a default member initializer

2020-12-22 Thread Jakub Jelinek via Gcc-patches
On Tue, Dec 22, 2020 at 03:57:56PM +0800, jim x via Gcc-patches wrote:
> struct A{
> A(){}
> };
> union C{
>A a;
>int b = 0;
> };
> int main(){
> C c;
> }
> 
> GCC reports the default constructor for union `C` is defined as
> deleted.  However, the relevant rule in the current c++ standard says
> that:
> > A defaulted default constructor for class X is defined as deleted if:
> >> X is a union that has a variant member with a non-trivial default 
> >> constructor and no variant member of X has a default member initializer,
> >> X is a non-union class that has a variant member M with a non-trivial 
> >> default constructor and no variant member of the anonymous union 
> >> containing M has a default member initializer

That would mean GCC (but neither clang++ nor ICC too) doesn't implement
CWG2084 properly.
Why are you mailing gcc-patches though when you don't have a patch?
TThis should be filed into https://gcc.gnu.org/bugzilla/

Jakub



[PATCH] libstdc++: gdb pretty printer fails from c frame

2020-12-22 Thread Rae Kim via Gcc-patches
Pretty prining c++ object from c frame fails with python exception. The
bug filed in gdb bugzilla shows very simple example.

- https://sourceware.org/bugzilla/show_bug.cgi?id=27021

  main.cc:
  #include 
  #include 

  std::map foo_map;

  int main()
  {
foo_map[1] = 10;
foo_map[2] = 20;
abort();
  }

  repros:
  > g++ -g main.cc
  > gdb a.out
  (gdb) run
  (gdb) print foo_map
  !!  Python Exception  'NoneType' object has no 
attribute 'pointer':
  $4 = std::map with 2 elements

  (gdb) frame 2
  (gdb) print foo_map
  $5 = std::map with 2 elements = {[1] = 10, [2] = 20}

When str(gdb.Type) is called(implicitly or explicitly) gdb returns type
name differently depending on currently selected frame's language. In
c++ frame, it will return just type name. But in c frame, the type name
will be prepended with "class ", "union ", "enum ", and etc.

e.g)
# c frame
(gdb) frame 0
(gdb) python print(gdb.lookup_symbol('foo_map')[0].value().type)
class std::map, std::allocator > >
^

# c++ frame
(gdb) frame 2
(gdb) python print(gdb.lookup_symbol('foo_map')[0].value().type)
std::map, std::allocator 
> >
^

The prepended "class " is the root causes problem. But this can be
easily mitigated by getting the type name explicitly by using
gdb.Type.name or gdb.Type.tag. I think gdb.Type.tag is prefered because
according to gdb documentation:

"...The tag name is the name after struct, union, or enum in C and C++..."

e.g.)
# c frame
(gdb) frame 0
(gdb) python print(gdb.lookup_symbol('foo_map')[0].value().type.tag)
std::map, std::allocator 
> >
^

libstdc++-v3/ChangeLog:

2020-12-22  Rae Kim  

* python/libstdcxx/v6/printers.py (find_type): Use Type.tag.
(lookup_templ_spec): likewise.
---
 libstdc++-v3/python/libstdcxx/v6/printers.py | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py 
b/libstdc++-v3/python/libstdcxx/v6/printers.py
index 9c6393712a0..9f7a16174a8 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -86,7 +86,7 @@ def find_type(orig, name):
 typ = orig.strip_typedefs()
 while True:
 # Strip cv-qualifiers.  PR 67440.
-search = '%s::%s' % (typ.unqualified(), name)
+search = '%s::%s' % (typ.unqualified().tag, name)
 try:
 return gdb.lookup_type(search)
 except RuntimeError:
@@ -106,7 +106,14 @@ def lookup_templ_spec(templ, *args):
 """
 Lookup template specialization templ
 """
-t = '{}<{}>'.format(templ, ', '.join([str(a) for a in args]))
+args_str = []
+for a in args:
+if isinstance(a, gdb.Type):
+args_str.append(a.tag)
+else:
+args_str.append(str(a))
+
+t = '{}<{}>'.format(templ, ', '.join(args_str))
 try:
 return gdb.lookup_type(t)
 except gdb.error as e:
-- 
2.29.2



[PATCH][DOC] Document my changes in GCC 11.

2020-12-22 Thread Martin Liška

Hello.

May I please ask a native speaker for a correction of my wording?

Thanks,
Martin

---
 htdocs/gcc-11/changes.html | 28 
 1 file changed, 28 insertions(+)

diff --git a/htdocs/gcc-11/changes.html b/htdocs/gcc-11/changes.html
index 1a9e72c1..badc9e12 100644
--- a/htdocs/gcc-11/changes.html
+++ b/htdocs/gcc-11/changes.html
@@ -116,6 +116,28 @@ a work-in-progress.
   option (which defaults to 8 spaces per tab stop).
 
   
+  New warning https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wtsan;>-Wtsan,
 enabled by default,
+  warns about unsupported features in ThreadSanitizer 
(std::atomic_thread_fence).
+  Series of if conditions, sharing a common index variable, can be 
transformed into a switch statement if each
+  of them contains a comparison expession.  Example:
+  
+int IsHTMLWhitespace(int aChar) {
+  return aChar == 0x0009 || aChar == 0x000A ||
+ aChar == 0x000C || aChar == 0x000D ||
+ aChar == 0x0020;
+}
+   
+   The statement is transformed into a GIMPLE switch statement that is 
later effectively expanded as bit-test.
+  
+  
+New command-line options:
+
+https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fno-bit-tests;>-fbit-tests,
 enabled by default, can be used to enable or disable switch expansion using bit-tests.
+
+  
+  GCOV data file format can effectively store a group of counters that are all 
zero.
+  Some gcov tool options are renamed: 
-i,--json-format to
+  -j,--json-format and -j,--human-readable to 
-H,--human-readable.
 
 
 

@@ -149,6 +171,12 @@ a work-in-progress.
 
 C family

 
+  New attribute:
+
+The no_stack_protector attribute has been added to 
mark functions which should not be instrumented
+with stack protection (-fstack-protector).
+
+  
   New warnings:
 
   -Wsizeof-array-div, enabled by -Wall, warns
--
2.29.2



[PATCH] rs6000: Use rldimi for vec init instead of shift + ior

2020-12-22 Thread Kewen.Lin via Gcc-patches
Hi,

This patch is to make unsigned int vector init go with
rldimi to merge two integers instead of shift and ior.

I tried to use nonzero_bits in md file to make it more
general, but the testing shows it isn't doable.  The
reason is that some passes would replace some pseudos
with other pseudos and do the recog again, but at that
time the nonzero_bits could get rough information and
lead the recog fails unexpectedly.

btw, the test case would reply on the combine patch[1].

Bootstrapped/regtested on powerpc64le-linux-gnu P9.

BR,
Kewen

[1] https://gcc.gnu.org/pipermail/gcc-patches/2020-December/561413.html

gcc/ChangeLog:

* config/rs6000/rs6000.md (*rotl3_insert_3): Renamed to...
(rotl3_insert_3): ...this.
* config/rs6000/vsx.md (vsx_init_v4si): Use gen_rotldi3_insert_3
for integer merging.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/vec-init-10.c: New test.

-
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 0e799198a50..3529b79d35d 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -4067,7 +4067,7 @@
   [(set_attr "type" "insert")])
 
 ; There are also some forms without one of the ANDs.
-(define_insn "*rotl3_insert_3"
+(define_insn "rotl3_insert_3"
   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
(ior:GPR (and:GPR (match_operand:GPR 3 "gpc_reg_operand" "0")
  (match_operand:GPR 4 "const_int_operand" "n"))
diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md
index 947631d83ee..37105a5aabf 100644
--- a/gcc/config/rs6000/vsx.md
+++ b/gcc/config/rs6000/vsx.md
@@ -3008,28 +3008,22 @@
(use (match_operand:SI 4 "gpc_reg_operand"))]
"VECTOR_MEM_VSX_P (V4SImode) && TARGET_DIRECT_MOVE_64BIT"
 {
-  rtx a = gen_reg_rtx (DImode);
-  rtx b = gen_reg_rtx (DImode);
-  rtx c = gen_reg_rtx (DImode);
-  rtx d = gen_reg_rtx (DImode);
-  emit_insn (gen_zero_extendsidi2 (a, operands[1]));
-  emit_insn (gen_zero_extendsidi2 (b, operands[2]));
-  emit_insn (gen_zero_extendsidi2 (c, operands[3]));
-  emit_insn (gen_zero_extendsidi2 (d, operands[4]));
+  rtx a = gen_lowpart_SUBREG (DImode, operands[1]);
+  rtx b = gen_lowpart_SUBREG (DImode, operands[2]);
+  rtx c = gen_lowpart_SUBREG (DImode, operands[3]);
+  rtx d = gen_lowpart_SUBREG (DImode, operands[4]);
   if (!BYTES_BIG_ENDIAN)
 {
   std::swap (a, b);
   std::swap (c, d);
 }
 
-  rtx aa = gen_reg_rtx (DImode);
   rtx ab = gen_reg_rtx (DImode);
-  rtx cc = gen_reg_rtx (DImode);
   rtx cd = gen_reg_rtx (DImode);
-  emit_insn (gen_ashldi3 (aa, a, GEN_INT (32)));
-  emit_insn (gen_ashldi3 (cc, c, GEN_INT (32)));
-  emit_insn (gen_iordi3 (ab, aa, b));
-  emit_insn (gen_iordi3 (cd, cc, d));
+  emit_insn (gen_rotldi3_insert_3 (ab, a, GEN_INT (32), b,
+  GEN_INT (0x)));
+  emit_insn (gen_rotldi3_insert_3 (cd, c, GEN_INT (32), d,
+  GEN_INT (0x)));
 
   rtx abcd = gen_reg_rtx (V2DImode);
   emit_insn (gen_vsx_concat_v2di (abcd, ab, cd));
diff --git a/gcc/testsuite/gcc.target/powerpc/vec-init-10.c 
b/gcc/testsuite/gcc.target/powerpc/vec-init-10.c
new file mode 100644
index 000..680538e67f3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/vec-init-10.c
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target lp64 } */
+/* { dg-require-effective-target powerpc_p8vector_ok } */
+/* { dg-options "-O2 -mdejagnu-cpu=power8" } */
+
+/* Check that we can optimize sldi + or to rldimi for vector int init.  */
+
+vector unsigned int
+testu (unsigned int i1, unsigned int i2, unsigned int i3, unsigned int i4)
+{
+  vector unsigned int v = {i1, i2, i3, i4};
+  return v;
+}
+
+vector signed int
+tests (signed int i1, signed int i2, signed int i3, signed int i4)
+{
+  vector signed int v = {i1, i2, i3, i4};
+  return v;
+}
+
+/* { dg-final { scan-assembler-not "sldi" } } */
+/* { dg-final { scan-assembler-not "or" } } */
+/* { dg-final { scan-assembler-times {\mrldimi\M} 4 } } */


[PATCH] ira: Skip some pseudos in move_unallocated_pseudos

2020-12-22 Thread Kewen.Lin via Gcc-patches
Hi,

This patch is to make move_unallocated_pseudos consistent
to what we have in function find_moveable_pseudos, where we
record the original pseudo into pseudo_replaced_reg only if
validate_change succeeds with newreg.  To ensure every
unallocated pseudo in move_unallocated_pseudos has expected
information, it's better to add a check and skip it if it's
unexpected.  This avoids possible ICEs in future.

btw, I happened to found this in the bootstrapping for one
experimental local patch, which is considered as impractical.

Bootstrapped/regtested on powerpc64le-linux-gnu P9.

BR,
Kewen

gcc/ChangeLog:

* ira.c (move_unallocated_pseudos): Check other_reg and skip if
it isn't set.
diff --git a/gcc/ira.c b/gcc/ira.c
index 89b5df4003d..472fcf52aad 100644
--- a/gcc/ira.c
+++ b/gcc/ira.c
@@ -5111,6 +5111,11 @@ move_unallocated_pseudos (void)
   {
int idx = i - first_moveable_pseudo;
rtx other_reg = pseudo_replaced_reg[idx];
+   /* If there is no appropriate pseudo in pseudo_replaced_reg, it
+  means validate_change fails for this new pseudo in function
+  find_moveable_pseudos, then bypass it here.*/
+   if (!other_reg)
+ continue;
rtx_insn *def_insn = DF_REF_INSN (DF_REG_DEF_CHAIN (i));
/* The use must follow all definitions of OTHER_REG, so we can
   insert the new definition immediately after any of them.  */