public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] New flag for dumping information about constexpr function calls memoization (GCC 5.2.0)
@ 2016-01-28 20:20 Andres Tiraboschi
  2016-01-28 20:54 ` Joseph Myers
  0 siblings, 1 reply; 4+ messages in thread
From: Andres Tiraboschi @ 2016-01-28 20:20 UTC (permalink / raw)
  To: GCC Patches

Hi,

This patch adds a flag (-fdump-memoization-hits) in order to dump
information about wich constexpr functions calls are memoized.
This is patch is for gcc-5.2.0.
If OK, please commit it for me since I don't have write access.

patch:

diff --git a/gcc/common.opt b/gcc/common.opt
index 1218a71..bf0c7df 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1168,6 +1168,10 @@ fdump-passes
 Common Var(flag_dump_passes) Init(0)
 Dump optimization passes

+fdump-memoization-hits
+Common Var(flag_dump_memoization_hits) Init(0)
+Dump info about constexpr calls memoized.
+
 fdump-unnumbered
 Common Report Var(flag_dump_unnumbered)
 Suppress output of instruction numbers, line number notes and
addresses in debugging dumps
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index e250726..41ae5b3 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -42,6 +42,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "builtins.h"
 #include "tree-inline.h"
 #include "ubsan.h"
+#include "tree-pretty-print.h"
+#include "dumpfile.h"

 static bool verify_constant (tree, bool, bool *, bool *);
 #define VERIFY_CONSTANT(X)                        \
@@ -1173,6 +1175,14 @@ cx_error_context (void)
   return r;
 }

+static void
+dump_memoization_hit (FILE *file, tree call, int flags)
+{
+  fprintf(file, "Memoized call:\n");
+  print_generic_decl(file, call, flags);
+  fprintf(file, "\n");
+}
+
 /* Subroutine of cxx_eval_constant_expression.
    Evaluate the call expression tree T in the context of OLD_CALL expression
    evaluation.  */
@@ -1338,7 +1348,11 @@ cxx_eval_call_expression (const constexpr_ctx
*ctx, tree t,
       entry->result = result = error_mark_node;
     }
       else
-    result = entry->result;
+    {
+      if (flag_dump_memoization_hits)
+          dump_memoization_hit(stderr, t, 0);
+      result = entry->result;
+    }
     }

   if (!depth_ok)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] New flag for dumping information about constexpr function calls memoization (GCC 5.2.0)
  2016-01-28 20:20 [PATCH] New flag for dumping information about constexpr function calls memoization (GCC 5.2.0) Andres Tiraboschi
@ 2016-01-28 20:54 ` Joseph Myers
  2016-01-29 14:46   ` Andres Tiraboschi
  0 siblings, 1 reply; 4+ messages in thread
From: Joseph Myers @ 2016-01-28 20:54 UTC (permalink / raw)
  To: Andres Tiraboschi; +Cc: GCC Patches

Any patch adding a new option needs to add documentation for it to 
invoke.texi (both substantive documentation, and inclusion in the summary 
lists of options).

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] New flag for dumping information about constexpr function calls memoization (GCC 5.2.0)
  2016-01-28 20:54 ` Joseph Myers
@ 2016-01-29 14:46   ` Andres Tiraboschi
  2016-02-12 22:06     ` Daniel Gutson
  0 siblings, 1 reply; 4+ messages in thread
From: Andres Tiraboschi @ 2016-01-29 14:46 UTC (permalink / raw)
  To: GCC Patches, Joseph Myers

2016-01-28 17:54 GMT-03:00 Joseph Myers <joseph@codesourcery.com>:
> Any patch adding a new option needs to add documentation for it to
> invoke.texi (both substantive documentation, and inclusion in the summary
> lists of options).
>
> --
> Joseph S. Myers
> joseph@codesourcery.com

Hi,

Thanks for the feedback, I've just updated the documentation.

patch:


diff --git a/gcc/common.opt b/gcc/common.opt
index 1218a71..bf0c7df 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1168,6 +1168,10 @@ fdump-passes
 Common Var(flag_dump_passes) Init(0)
 Dump optimization passes

+fdump-memoization-hits
+Common Var(flag_dump_memoization_hits) Init(0)
+Dump info about constexpr calls memoized.
+
 fdump-unnumbered
 Common Report Var(flag_dump_unnumbered)
 Suppress output of instruction numbers, line number notes and
addresses in debugging dumps
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index e250726..41ae5b3 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -42,6 +42,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "builtins.h"
 #include "tree-inline.h"
 #include "ubsan.h"
+#include "tree-pretty-print.h"
+#include "dumpfile.h"

 static bool verify_constant (tree, bool, bool *, bool *);
 #define VERIFY_CONSTANT(X)                        \
@@ -1173,6 +1175,14 @@ cx_error_context (void)
   return r;
 }

+static void
+dump_memoization_hit (FILE *file, tree call, int flags)
+{
+  fprintf(file, "Memoized call:\n");
+  print_generic_decl(file, call, flags);
+  fprintf(file, "\n");
+}
+
 /* Subroutine of cxx_eval_constant_expression.
    Evaluate the call expression tree T in the context of OLD_CALL expression
    evaluation.  */
@@ -1338,7 +1348,11 @@ cxx_eval_call_expression (const constexpr_ctx
*ctx, tree t,
       entry->result = result = error_mark_node;
     }
       else
-    result = entry->result;
+    {
+      if (flag_dump_memoization_hits)
+          dump_memoization_hit(stderr, t, 0);
+      result = entry->result;
+    }
     }

   if (!depth_ok)
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index f84a199..b78bd4b 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -322,6 +322,7 @@ Objective-C and Objective-C++ Dialects}.
 -fdump-class-hierarchy@r{[}-@var{n}@r{]} @gol
 -fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline @gol
 -fdump-passes @gol
+-fdump-memoization-hits @gol
 -fdump-statistics @gol
 -fdump-tree-all @gol
 -fdump-tree-original@r{[}-@var{n}@r{]}  @gol
@@ -6771,6 +6772,10 @@ Dump after function inlining.
 Dump the list of optimization passes that are turned on and off by
 the current command-line options.

+@item -fdump-memoization-hits
+@opindex fdump-memoization-hits
+Dump the list of constexpr function calls that were memoized.
+
 @item -fdump-statistics-@var{option}
 @opindex fdump-statistics
 Enable and control dumping of pass statistics in a separate file.  The

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] New flag for dumping information about constexpr function calls memoization (GCC 5.2.0)
  2016-01-29 14:46   ` Andres Tiraboschi
@ 2016-02-12 22:06     ` Daniel Gutson
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Gutson @ 2016-02-12 22:06 UTC (permalink / raw)
  To: Andres Tiraboschi; +Cc: GCC Patches, Joseph Myers

On Fri, Jan 29, 2016 at 11:46 AM, Andres Tiraboschi
<andres.tiraboschi@tallertechnologies.com> wrote:
> 2016-01-28 17:54 GMT-03:00 Joseph Myers <joseph@codesourcery.com>:
>> Any patch adding a new option needs to add documentation for it to
>> invoke.texi (both substantive documentation, and inclusion in the summary
>> lists of options).
>>
>> --
>> Joseph S. Myers
>> joseph@codesourcery.com
>
> Hi,
>
> Thanks for the feedback, I've just updated the documentation.
>
> patch:

Ping, any chance to review this?

Thanks,

    Daniel.

>
>
> diff --git a/gcc/common.opt b/gcc/common.opt
> index 1218a71..bf0c7df 100644
> --- a/gcc/common.opt
> +++ b/gcc/common.opt
> @@ -1168,6 +1168,10 @@ fdump-passes
>  Common Var(flag_dump_passes) Init(0)
>  Dump optimization passes
>
> +fdump-memoization-hits
> +Common Var(flag_dump_memoization_hits) Init(0)
> +Dump info about constexpr calls memoized.
> +
>  fdump-unnumbered
>  Common Report Var(flag_dump_unnumbered)
>  Suppress output of instruction numbers, line number notes and
> addresses in debugging dumps
> diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
> index e250726..41ae5b3 100644
> --- a/gcc/cp/constexpr.c
> +++ b/gcc/cp/constexpr.c
> @@ -42,6 +42,8 @@ along with GCC; see the file COPYING3.  If not see
>  #include "builtins.h"
>  #include "tree-inline.h"
>  #include "ubsan.h"
> +#include "tree-pretty-print.h"
> +#include "dumpfile.h"
>
>  static bool verify_constant (tree, bool, bool *, bool *);
>  #define VERIFY_CONSTANT(X)                        \
> @@ -1173,6 +1175,14 @@ cx_error_context (void)
>    return r;
>  }
>
> +static void
> +dump_memoization_hit (FILE *file, tree call, int flags)
> +{
> +  fprintf(file, "Memoized call:\n");
> +  print_generic_decl(file, call, flags);
> +  fprintf(file, "\n");
> +}
> +
>  /* Subroutine of cxx_eval_constant_expression.
>     Evaluate the call expression tree T in the context of OLD_CALL expression
>     evaluation.  */
> @@ -1338,7 +1348,11 @@ cxx_eval_call_expression (const constexpr_ctx
> *ctx, tree t,
>        entry->result = result = error_mark_node;
>      }
>        else
> -    result = entry->result;
> +    {
> +      if (flag_dump_memoization_hits)
> +          dump_memoization_hit(stderr, t, 0);
> +      result = entry->result;
> +    }
>      }
>
>    if (!depth_ok)
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index f84a199..b78bd4b 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -322,6 +322,7 @@ Objective-C and Objective-C++ Dialects}.
>  -fdump-class-hierarchy@r{[}-@var{n}@r{]} @gol
>  -fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline @gol
>  -fdump-passes @gol
> +-fdump-memoization-hits @gol
>  -fdump-statistics @gol
>  -fdump-tree-all @gol
>  -fdump-tree-original@r{[}-@var{n}@r{]}  @gol
> @@ -6771,6 +6772,10 @@ Dump after function inlining.
>  Dump the list of optimization passes that are turned on and off by
>  the current command-line options.
>
> +@item -fdump-memoization-hits
> +@opindex fdump-memoization-hits
> +Dump the list of constexpr function calls that were memoized.
> +
>  @item -fdump-statistics-@var{option}
>  @opindex fdump-statistics
>  Enable and control dumping of pass statistics in a separate file.  The



-- 

Daniel F. Gutson
Chief Engineering Officer, SPD

San Lorenzo 47, 3rd Floor, Office 5
Córdoba, Argentina

Phone:   +54 351 4217888 / +54 351 4218211
Skype:    dgutson
LinkedIn: http://ar.linkedin.com/in/danielgutson

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-02-12 22:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-28 20:20 [PATCH] New flag for dumping information about constexpr function calls memoization (GCC 5.2.0) Andres Tiraboschi
2016-01-28 20:54 ` Joseph Myers
2016-01-29 14:46   ` Andres Tiraboschi
2016-02-12 22:06     ` Daniel Gutson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).