Message ID | CAJZwELnwQJYJ3StGL7vXwvYo=ktbEFPv2sDsMZED1oTao8waxA@mail.gmail.com |
---|---|
State | New |
Headers | show |
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
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