Re: [PATCH v26 00/23] Optimize type traits compilation performance

2023-12-20 Thread Ken Matsui
On Wed, Dec 20, 2023 at 7:56 AM Patrick Palka  wrote:
>
> On Tue, 19 Dec 2023, Sandra Loosemore wrote:
>
> > On 12/6/23 22:11, Ken Matsui wrote:
> > > This patch series optimizes type traits compilation performance by
> > > implementing built-in type traits and using them in libstdc++.
> >
> > I'm finding that all the new g++.dg/ext/is_*.C testcases added by this patch
> > series are failing due
> > to the "#include ".  If that is supposed to refer to the 
> > file
> > of that name in the libstdc++ testcase, there's no gcc option being passed 
> > to
> > add that location to the include search path.  That .h file includes other
> > header files from the libstdc++ testsuite so just copying it into the same
> > directory as the new g++ tests doesn't work.  Can you fix this, somehow?
>
> Looks like the testcases only use the trivial definition of
> __gnu_test::ClassType from the header, so perhaps we can just define it
> locally and remove this header include (which IIUC is intended to be
> used for library tests run by the libstdc++ test harness, not front-end
> tests).
>
> Ken, do you want to submit a patch for that?  (A full bootstrap +
> regtest wouldn't be necessary, it should suffice to re-run the changed
> tests via e.g. make check RUNTESTFLAGS="dg.exp=*ext*")
>

Sure!  Let me fix this problem :)

> >
> > Target is nios2-elf, if that matters.
> >
> > -Sandra
> >
> >
>


Re: [PATCH v26 00/23] Optimize type traits compilation performance

2023-12-20 Thread Patrick Palka
On Tue, 19 Dec 2023, Sandra Loosemore wrote:

> On 12/6/23 22:11, Ken Matsui wrote:
> > This patch series optimizes type traits compilation performance by
> > implementing built-in type traits and using them in libstdc++.
> 
> I'm finding that all the new g++.dg/ext/is_*.C testcases added by this patch
> series are failing due
> to the "#include ".  If that is supposed to refer to the file
> of that name in the libstdc++ testcase, there's no gcc option being passed to
> add that location to the include search path.  That .h file includes other
> header files from the libstdc++ testsuite so just copying it into the same
> directory as the new g++ tests doesn't work.  Can you fix this, somehow?

Looks like the testcases only use the trivial definition of
__gnu_test::ClassType from the header, so perhaps we can just define it
locally and remove this header include (which IIUC is intended to be
used for library tests run by the libstdc++ test harness, not front-end
tests).

Ken, do you want to submit a patch for that?  (A full bootstrap +
regtest wouldn't be necessary, it should suffice to re-run the changed
tests via e.g. make check RUNTESTFLAGS="dg.exp=*ext*")

> 
> Target is nios2-elf, if that matters.
> 
> -Sandra
> 
> 



Re: [PATCH v26 00/23] Optimize type traits compilation performance

2023-12-19 Thread Sandra Loosemore

On 12/6/23 22:11, Ken Matsui wrote:

This patch series optimizes type traits compilation performance by
implementing built-in type traits and using them in libstdc++.


I'm finding that all the new g++.dg/ext/is_*.C testcases added by this patch 
series are failing due
to the "#include ".  If that is supposed to refer to the file 
of that name in the libstdc++ testcase, there's no gcc option being passed to 
add that location to the include search path.  That .h file includes other 
header files from the libstdc++ testsuite so just copying it into the same 
directory as the new g++ tests doesn't work.  Can you fix this, somehow?


Target is nios2-elf, if that matters.

-Sandra


Re: [PATCH v26 00/23] Optimize type traits compilation performance

2023-12-16 Thread Ken Matsui
On Sat, Dec 16, 2023 at 8:40 AM Jonathan Wakely  wrote:
>
> On Sun, 10 Dec 2023 at 18:19, Jason Merrill wrote:
> >
> > On 12/7/23 00:11, Ken Matsui wrote:
> > > This patch series optimizes type traits compilation performance by
> > > implementing built-in type traits and using them in libstdc++.
> > >
> > > Changes in v26:
> > >
> > >   * Rebased on top of trunk.
> > >   * Moved is_function_v under is_const_v.
> > >   * Isolated patches for is_const, is_volatile, is_pointer, and
> > >   is_unbounded_array, which contain performance regression, from
> > >   this patch series since they are not ready for review yet.
> >
> > I've applied all the compiler patches, with a few small tweaks,
> > including this one as a separate commit.  One other was a formatting
> > fix, the lats was using TYPE_PTRDATAMEM_P for CPTK_IS_MEMBER_OBJECT_POINTER.
> >
> > I'm leaving the library patches for library folks to apply.
>
> I've reviewed all the library patches in v26 and they are all OK for
> trunk. Please push (or Patrick can do so).
>
> Thanks, Ken! Great work, I'm really happy to see this land in GCC trunk.
>
> +Reviewed-by: Jonathan Wakely 
>

Thank you so much for taking the time to review my patches and for
your kind support!  I will push :)


Re: [PATCH v26 00/23] Optimize type traits compilation performance

2023-12-16 Thread Jonathan Wakely
On Sun, 10 Dec 2023 at 18:19, Jason Merrill wrote:
>
> On 12/7/23 00:11, Ken Matsui wrote:
> > This patch series optimizes type traits compilation performance by
> > implementing built-in type traits and using them in libstdc++.
> >
> > Changes in v26:
> >
> >   * Rebased on top of trunk.
> >   * Moved is_function_v under is_const_v.
> >   * Isolated patches for is_const, is_volatile, is_pointer, and
> >   is_unbounded_array, which contain performance regression, from
> >   this patch series since they are not ready for review yet.
>
> I've applied all the compiler patches, with a few small tweaks,
> including this one as a separate commit.  One other was a formatting
> fix, the lats was using TYPE_PTRDATAMEM_P for CPTK_IS_MEMBER_OBJECT_POINTER.
>
> I'm leaving the library patches for library folks to apply.

I've reviewed all the library patches in v26 and they are all OK for
trunk. Please push (or Patrick can do so).

Thanks, Ken! Great work, I'm really happy to see this land in GCC trunk.

+Reviewed-by: Jonathan Wakely 



Re: [PATCH v26 00/23] Optimize type traits compilation performance

2023-12-10 Thread Ken Matsui
On Sun, Dec 10, 2023 at 10:19 AM Jason Merrill  wrote:
>
> On 12/7/23 00:11, Ken Matsui wrote:
> > This patch series optimizes type traits compilation performance by
> > implementing built-in type traits and using them in libstdc++.
> >
> > Changes in v26:
> >
> >   * Rebased on top of trunk.
> >   * Moved is_function_v under is_const_v.
> >   * Isolated patches for is_const, is_volatile, is_pointer, and
> >   is_unbounded_array, which contain performance regression, from
> >   this patch series since they are not ready for review yet.
>
> I've applied all the compiler patches, with a few small tweaks,
> including this one as a separate commit.  One other was a formatting
> fix, the lats was using TYPE_PTRDATAMEM_P for CPTK_IS_MEMBER_OBJECT_POINTER.
>
> I'm leaving the library patches for library folks to apply.
>
> Thanks!
>

Thank you so much for your review and support!

> Jason
>
>


Re: [PATCH v26 00/23] Optimize type traits compilation performance

2023-12-10 Thread Jason Merrill

On 12/7/23 00:11, Ken Matsui wrote:

This patch series optimizes type traits compilation performance by
implementing built-in type traits and using them in libstdc++.

Changes in v26:

* Rebased on top of trunk.
* Moved is_function_v under is_const_v.
* Isolated patches for is_const, is_volatile, is_pointer, and
is_unbounded_array, which contain performance regression, from
this patch series since they are not ready for review yet.


I've applied all the compiler patches, with a few small tweaks, 
including this one as a separate commit.  One other was a formatting 
fix, the lats was using TYPE_PTRDATAMEM_P for CPTK_IS_MEMBER_OBJECT_POINTER.


I'm leaving the library patches for library folks to apply.

Thanks!

Jason


From e410303f768fa7b020e46f3bd7d28381144e5340 Mon Sep 17 00:00:00 2001
From: Jason Merrill 
Date: Fri, 8 Dec 2023 15:55:49 -0500
Subject: [PATCH 01/11] c++: trait patch tweak
To: gcc-patches@gcc.gnu.org

As Patrick suggested elsewhere, let's move this into the default case.

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_simple_type_specifier): Move trait
	handling to default label.
---
 gcc/cp/parser.cc | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 9e76426566b..b987324f669 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -20164,22 +20164,22 @@ cp_parser_simple_type_specifier (cp_parser* parser,
   return type;
 
 default:
+  /* If token is a type-yielding built-in traits, parse it.  */
+  const cp_trait* trait = cp_lexer_peek_trait_type (parser->lexer);
+  if (trait)
+	{
+	  type = cp_parser_trait (parser, trait);
+	  if (decl_specs)
+	cp_parser_set_decl_spec_type (decl_specs, type,
+	  token,
+	  /*type_definition_p=*/false);
+
+	  return type;
+	}
+
   break;
 }
 
-  /* If token is a type-yielding built-in traits, parse it.  */
-  const cp_trait* trait = cp_lexer_peek_trait_type (parser->lexer);
-  if (trait)
-{
-  type = cp_parser_trait (parser, trait);
-  if (decl_specs)
-	cp_parser_set_decl_spec_type (decl_specs, type,
-  token,
-  /*type_definition_p=*/false);
-
-  return type;
-}
-
   /* If token is an already-parsed decltype not followed by ::,
  it's a simple-type-specifier.  */
   if (token->type == CPP_DECLTYPE
-- 
2.39.3



[PATCH v26 00/23] Optimize type traits compilation performance

2023-12-06 Thread Ken Matsui
This patch series optimizes type traits compilation performance by
implementing built-in type traits and using them in libstdc++.

Changes in v26:

* Rebased on top of trunk.
* Moved is_function_v under is_const_v.
* Isolated is_const, is_volatile, is_pointer, and
is_unbounded_array patches, which contain performance regression,
from this patch series.

Changes in v25:

* Optimized the __is_pointer implementation in cpp_type_traits.h.
* Fix compilation error in cpp_type_traits.h with Clang 16.
* Wrapped commit messages at 75 columns.
* Used & instead of && for the new IDENTIFIER_TRAIT_P macro.
* Made cp_lexer_peek_trait not to take cp_token.
* Fixed indentation error in cp_lexer_peek_trait.

Changes in v24:

* Fixed the way to handle an incomplete type error from __is_invocable
in the test cases so that we can correctly test both the use of
built-in and vice-versa.

Changes in v23:

* Improved the comment in cp-tree.h.
* Moved the definition of cp_traits to lex.cc from parser.cc.
* Implemented __is_invocable built-in trait.

Changes in v22:

* Included a missing patch in v21.

Changes in v21:

* Used _GLIBCXX_USE_BUILTIN_TRAIT instead of __has_builtin in
cpp_type_traits.h.
* Added const char* name to struct cp_trait, and loop over cp_traits
in init_cp_traits to get the name.
* Isolated patches for integral-related built-in traits from
this patch series since they are not ready for review yet.
* Implemented __is_object built-in trait.

Changes in v20:

* Used identifier node instead of gperf to look up built-in
traits.

Changes in v19:

* Fixed a typo.
* Rebased on top of trunk.
* Improved clarity of the commit message.

Changes in v18:

* Removed all RID values for built-in traits and used cik_trait
instead.
* Improved to handle the use of non-function-like built-in trait
identifiers.
* Reverted all changes to conflicted identifiers with new built-ins
in the existing code base.

Changes in v17:

* Rebased on top of trunk.
* Improved clarity of the commit message.
* Simplified Make-lang.in.
* Made ridpointers for RID_TRAIT_EXPR and RID_TRAIT_TYPE empty.

Changes in v16:

* Rebased on top of trunk.
* Improved clarity of the commit message.
* Simplified Make-lang.in and gperf struct.
* Supply -k option to gperf to support older versions than 2.8.

Changes in v15:

* Rebased on top of trunk.
* Use gperf to look up traits instead of enum rid.

Changes in v14:

* Added padding calculation to the commit message.

Changes in v13:

* Fixed ambiguous commit message and comment.

Changes in v12:

* Evaluated all paddings affected by the enum rid change.

Changes in v11:

* Merged all patches into one patch series.
* Rebased on top of trunk.
* Unified commit message style.
* Used _GLIBCXX_USE_BUILTIN_TRAIT.

Ken Matsui (23):
  c++: Sort built-in traits alphabetically
  c-family, c++: Look up built-in traits via identifier node
  c++: Accept the use of built-in trait identifiers
  c++: Implement __is_array built-in trait
  libstdc++: Optimize std::is_array compilation performance
  c++: Implement __is_bounded_array built-in trait
  libstdc++: Optimize std::is_bounded_array compilation performance
  c++: Implement __is_scoped_enum built-in trait
  libstdc++: Optimize std::is_scoped_enum compilation performance
  c++: Implement __is_member_pointer built-in trait
  libstdc++: Optimize std::is_member_pointer compilation performance
  c++: Implement __is_member_function_pointer built-in trait
  libstdc++: Optimize std::is_member_function_pointer compilation
performance
  c++: Implement __is_member_object_pointer built-in trait
  libstdc++: Optimize std::is_member_object_pointer compilation
performance
  c++: Implement __is_reference built-in trait
  libstdc++: Optimize std::is_reference compilation performance
  c++: Implement __is_function built-in trait
  libstdc++: Optimize std::is_function compilation performance
  c++: Implement __is_object built-in trait
  libstdc++: Optimize std::is_object compilation performance
  c++: Implement __remove_pointer built-in trait
  libstdc++: Optimize std::remove_pointer compilation performance

 gcc/c-family/c-common.cc  |   7 -
 gcc/c-family/c-common.h   |   5 -
 gcc/cp/constraint.cc  |  95 +++-
 gcc/cp/cp-objcp-common.cc |   8 +-
 gcc/cp/cp-trait.def   |  20 ++-
 gcc/cp/cp-tree.h  |  32 +++--
 gcc/cp/lex.cc |  34 +
 gcc/cp/parser.cc  | 120 

[PATCH v26 00/23] Optimize type traits compilation performance

2023-12-06 Thread Ken Matsui
This patch series optimizes type traits compilation performance by
implementing built-in type traits and using them in libstdc++.

Changes in v26:

* Rebased on top of trunk.
* Moved is_function_v under is_const_v.
* Isolated patches for is_const, is_volatile, is_pointer, and
is_unbounded_array, which contain performance regression, from
this patch series since they are not ready for review yet.

Changes in v25:

* Optimized the __is_pointer implementation in cpp_type_traits.h.
* Fix compilation error in cpp_type_traits.h with Clang 16.
* Wrapped commit messages at 75 columns.
* Used & instead of && for the new IDENTIFIER_TRAIT_P macro.
* Made cp_lexer_peek_trait not to take cp_token.
* Fixed indentation error in cp_lexer_peek_trait.

Changes in v24:

* Fixed the way to handle an incomplete type error from __is_invocable
in the test cases so that we can correctly test both the use of
built-in and vice-versa.

Changes in v23:

* Improved the comment in cp-tree.h.
* Moved the definition of cp_traits to lex.cc from parser.cc.
* Implemented __is_invocable built-in trait.

Changes in v22:

* Included a missing patch in v21.

Changes in v21:

* Used _GLIBCXX_USE_BUILTIN_TRAIT instead of __has_builtin in
cpp_type_traits.h.
* Added const char* name to struct cp_trait, and loop over cp_traits
in init_cp_traits to get the name.
* Isolated patches for integral-related built-in traits from
this patch series since they are not ready for review yet.
* Implemented __is_object built-in trait.

Changes in v20:

* Used identifier node instead of gperf to look up built-in
traits.

Changes in v19:

* Fixed a typo.
* Rebased on top of trunk.
* Improved clarity of the commit message.

Changes in v18:

* Removed all RID values for built-in traits and used cik_trait
instead.
* Improved to handle the use of non-function-like built-in trait
identifiers.
* Reverted all changes to conflicted identifiers with new built-ins
in the existing code base.

Changes in v17:

* Rebased on top of trunk.
* Improved clarity of the commit message.
* Simplified Make-lang.in.
* Made ridpointers for RID_TRAIT_EXPR and RID_TRAIT_TYPE empty.

Changes in v16:

* Rebased on top of trunk.
* Improved clarity of the commit message.
* Simplified Make-lang.in and gperf struct.
* Supply -k option to gperf to support older versions than 2.8.

Changes in v15:

* Rebased on top of trunk.
* Use gperf to look up traits instead of enum rid.

Changes in v14:

* Added padding calculation to the commit message.

Changes in v13:

* Fixed ambiguous commit message and comment.

Changes in v12:

* Evaluated all paddings affected by the enum rid change.

Changes in v11:

* Merged all patches into one patch series.
* Rebased on top of trunk.
* Unified commit message style.
* Used _GLIBCXX_USE_BUILTIN_TRAIT.

Ken Matsui (23):
  c++: Sort built-in traits alphabetically
  c-family, c++: Look up built-in traits via identifier node
  c++: Accept the use of built-in trait identifiers
  c++: Implement __is_array built-in trait
  libstdc++: Optimize std::is_array compilation performance
  c++: Implement __is_bounded_array built-in trait
  libstdc++: Optimize std::is_bounded_array compilation performance
  c++: Implement __is_scoped_enum built-in trait
  libstdc++: Optimize std::is_scoped_enum compilation performance
  c++: Implement __is_member_pointer built-in trait
  libstdc++: Optimize std::is_member_pointer compilation performance
  c++: Implement __is_member_function_pointer built-in trait
  libstdc++: Optimize std::is_member_function_pointer compilation
performance
  c++: Implement __is_member_object_pointer built-in trait
  libstdc++: Optimize std::is_member_object_pointer compilation
performance
  c++: Implement __is_reference built-in trait
  libstdc++: Optimize std::is_reference compilation performance
  c++: Implement __is_function built-in trait
  libstdc++: Optimize std::is_function compilation performance
  c++: Implement __is_object built-in trait
  libstdc++: Optimize std::is_object compilation performance
  c++: Implement __remove_pointer built-in trait
  libstdc++: Optimize std::remove_pointer compilation performance

 gcc/c-family/c-common.cc  |   7 -
 gcc/c-family/c-common.h   |   5 -
 gcc/cp/constraint.cc  |  95 +++-
 gcc/cp/cp-objcp-common.cc |   8 +-
 gcc/cp/cp-trait.def   |  20 ++-
 gcc/cp/cp-tree.h  |  32 +++--
 gcc/cp/lex.cc |  34 +
 gcc/cp/parser.cc