From: Xinliang David Li <davidxl@google.com>
To: Richard Guenther <richard.guenther@gmail.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: -fdump-passes -fenable-xxx=func_name_list
Date: Wed, 01 Jun 2011 19:29:00 -0000 [thread overview]
Message-ID: <BANLkTimQd7HYT=Ex3ngFvu4UMHWNeHsDDx+4h5ahB6GupUxq1A@mail.gmail.com> (raw)
In-Reply-To: <BANLkTi=9ipuRzyenO-1bHVpsx5EKmG+V=HXJ2NOipAwre6MgbA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2184 bytes --]
The attached is patch-2 (-fdump-passes) and a sample output:
Ok for trunk?
David
On Wed, Jun 1, 2011 at 9:16 AM, Xinliang David Li <davidxl@google.com> wrote:
> On Wed, Jun 1, 2011 at 1:51 AM, Richard Guenther
> <richard.guenther@gmail.com> wrote:
>> On Wed, Jun 1, 2011 at 1:34 AM, Xinliang David Li <davidxl@google.com> wrote:
>>> The following patch implements the a new option that dumps gcc PASS
>>> configuration. The sample output is attached. There is one
>>> limitation: some placeholder passes that are named with '*xxx' are
>>> note registered thus they are not listed. They are not important as
>>> they can not be turned on/off anyway.
>>>
>>> The patch also enhanced -fenable-xxx and -fdisable-xx to allow a list
>>> of function assembler names to be specified.
>>>
>>> Ok for trunk?
>>
>> Please split the patch.
>>
>> I'm not too happy how you dump the pass configuration. Why not simply,
>> at a _single_ place, walk the pass tree? Instead of doing pieces of it
>> at pass execution time when it's not already dumped - that really looks
>> gross.
>
> Yes, that was the original plan -- but it has problems
> 1) the dumper needs to know the root pass lists -- which can change
> frequently -- it can be a long term maintanance burden;
> 2) the centralized dumper needs to be done after option processing
> 3) not sure if gate functions have any side effects or have dependencies on cfun
>
> The proposed solutions IMHO is not that intrusive -- just three hooks
> to do the dumping and tracking indentation.
>
>>
>> The documentation should also link this option to the -fenable/disable
>> options as obviously the pass names in that dump are those to be
>> used for those flags (and not readily available anywhere else).
>
> Ok.
>
>>
>> I also think that it would be way more useful to note in the individual
>> dump files the functions (at the place they would usually appear) that
>> have the pass explicitly enabled/disabled.
>
> Ok -- for ipa passes or tree/rtl passes where all functions are
> explicitly disabled.
>
> Thanks,
>
> David
>
>>
>> Richard.
>>
>>> Thanks,
>>>
>>> David
>>>
>>
>
[-- Attachment #2: dump-pass2.p --]
[-- Type: text/x-pascal, Size: 7868 bytes --]
Index: doc/invoke.texi
===================================================================
--- doc/invoke.texi (revision 174535)
+++ doc/invoke.texi (working copy)
@@ -291,6 +291,7 @@ Objective-C and Objective-C++ Dialects}.
-fdump-translation-unit@r{[}-@var{n}@r{]} @gol
-fdump-class-hierarchy@r{[}-@var{n}@r{]} @gol
-fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline @gol
+-fdump-passes @gol
-fdump-statistics @gol
-fdump-tree-all @gol
-fdump-tree-original@r{[}-@var{n}@r{]} @gol
@@ -5060,7 +5061,8 @@ seperated list of function ranges. Each
The range is inclusive in both ends. If the range is trivial, the number pair can be
simplified a a single number. If the function's cgraph node's @var{uid} is falling
within one of the specified ranges, the @var{pass} is disabled for that function.
-The @var{uid} is shown in the function header of a dump file.
+The @var{uid} is shown in the function header of a dump file, and pass names can be
+dumped by using option @option{-fdump-passes}.
@item -fdisable-tree-@var{pass}
@item -fdisable-tree-@var{pass}=@var{range-list}
@@ -5483,6 +5485,11 @@ Dump after function inlining.
@end table
+@item -fdump-passes
+@opindex fdump-passes
+Dump the list of optimization passes that are turned on and off by
+the current command line options.
+
@item -fdump-statistics-@var{option}
@opindex fdump-statistics
Enable and control dumping of pass statistics in a separate file. The
Index: common.opt
===================================================================
--- common.opt (revision 174535)
+++ common.opt (working copy)
@@ -1012,6 +1012,10 @@ fdump-noaddr
Common Report Var(flag_dump_noaddr)
Suppress output of addresses in debugging dumps
+fdump-passes
+Common Var(flag_dump_passes) Init(0)
+Dump optimization passes
+
fdump-unnumbered
Common Report Var(flag_dump_unnumbered)
Suppress output of instruction numbers, line number notes and addresses in debugging dumps
Index: passes.c
===================================================================
--- passes.c (revision 174536)
+++ passes.c (working copy)
@@ -478,7 +478,7 @@ passr_eq (const void *p1, const void *p2
return !strcmp (s1->unique_name, s2->unique_name);
}
-static htab_t pass_name_tab = NULL;
+static htab_t name_to_pass_map = NULL;
/* Register PASS with NAME. */
@@ -488,11 +488,11 @@ register_pass_name (struct opt_pass *pas
struct pass_registry **slot;
struct pass_registry pr;
- if (!pass_name_tab)
- pass_name_tab = htab_create (256, passr_hash, passr_eq, NULL);
+ if (!name_to_pass_map)
+ name_to_pass_map = htab_create (256, passr_hash, passr_eq, NULL);
pr.unique_name = name;
- slot = (struct pass_registry **) htab_find_slot (pass_name_tab, &pr, INSERT);
+ slot = (struct pass_registry **) htab_find_slot (name_to_pass_map, &pr, INSERT);
if (!*slot)
{
struct pass_registry *new_pr;
@@ -506,6 +506,117 @@ register_pass_name (struct opt_pass *pas
return; /* Ignore plugin passes. */
}
+typedef struct {
+ /* Pass name with kind prefix and instance number suffix. */
+ const char *pass_name;
+ /* Flag indicating if the pass info has been dumped. */
+ bool dumped;
+} pass_info;
+
+DEF_VEC_O(pass_info);
+DEF_VEC_ALLOC_O(pass_info, heap);
+static VEC(pass_info, heap) *pass_tab = NULL;
+
+/* Callback function for traversing NAME_TO_PASS_MAP. */
+
+static int
+pass_traverse (void **slot, void *data)
+{
+ int* tab_size = (int *)data;
+ struct pass_registry **p = (struct pass_registry **)slot;
+ struct opt_pass *pass = (*p)->pass;
+ pass_info *pd;
+
+ gcc_assert (pass->static_pass_number > 0);
+ if (tab_size)
+ {
+ if (pass->static_pass_number > *tab_size)
+ *tab_size = pass->static_pass_number;
+
+ return 1;
+ }
+
+ gcc_assert (pass_tab);
+ pd = VEC_index (pass_info, pass_tab, pass->static_pass_number);
+ pd->pass_name = (*p)->unique_name;
+ pd->dumped = false;
+
+ return 1;
+}
+
+/* The function traverses NAME_TO_PASS_MAP and creates a pass info
+ table for dumping purpose. */
+
+static void
+create_pass_tab (void)
+{
+ int tab_size = 0;
+
+ if (!flag_dump_passes || pass_tab)
+ return;
+
+ htab_traverse (name_to_pass_map, pass_traverse, &tab_size);
+ VEC_safe_grow_cleared (pass_info, heap,
+ pass_tab, tab_size + 1);
+ htab_traverse (name_to_pass_map, pass_traverse, NULL);
+}
+
+
+static int pass_indent = 0;
+
+/* Tracks pass dumping indentation. */
+
+static inline void
+enter_pass_list (void)
+{
+ pass_indent++;
+}
+
+/* Tracks pass dumping indentation. */
+
+static inline void
+exit_pass_list (void)
+{
+ pass_indent--;
+}
+
+/* Dump the instantiated name for PASS. IS_ON indicates if PASS
+ is turned on or not. */
+
+static void
+dump_one_pass (struct opt_pass *pass, bool is_on, bool is_really_on)
+{
+ pass_info *pi;
+ int indent = 3 * pass_indent;
+ static int uid_range_dumped = false;
+
+ if (!uid_range_dumped)
+ {
+ fprintf (stderr, "MAX_UID = %d\n", cgraph_max_uid);
+ uid_range_dumped = true;
+ }
+
+ create_pass_tab();
+ gcc_assert (pass_tab);
+
+ if (pass->static_pass_number <= 0)
+ return;
+
+ pi = VEC_index (pass_info, pass_tab,
+ pass->static_pass_number);
+ if (pi->dumped)
+ return;
+
+ fprintf (stderr, "%*s%-35s%*s:%s%s\n", indent, " ",
+ pi->pass_name,
+ (10 - indent < 0 ? 0 : 10 - indent), " ",
+ is_on ? " ON" : " OFF",
+ ((!is_on) == (!is_really_on) ? ""
+ : (is_really_on ? " (FORCED_ON)" : " (FORCED_OFF)")));
+ pi->dumped = true;
+}
+
+
/* Returns the pass with NAME. */
static struct opt_pass *
@@ -513,9 +624,9 @@ get_pass_by_name (const char *name)
{
struct pass_registry **slot, pr;
- gcc_assert (pass_name_tab);
+ gcc_assert (name_to_pass_map);
pr.unique_name = name;
- slot = (struct pass_registry **) htab_find_slot (pass_name_tab,
+ slot = (struct pass_registry **) htab_find_slot (name_to_pass_map,
&pr, NO_INSERT);
if (!slot || !*slot)
@@ -1807,7 +1918,7 @@ execute_one_pass (struct opt_pass *pass)
bool initializing_dump;
unsigned int todo_after = 0;
- bool gate_status;
+ bool gate_status0, gate_status;
/* IPA passes are executed on whole program, so cfun should be NULL.
Other passes need function context set. */
@@ -1820,8 +1931,11 @@ execute_one_pass (struct opt_pass *pass)
/* Check whether gate check should be avoided.
User controls the value of the gate through the parameter "gate_status". */
- gate_status = (pass->gate == NULL) ? true : pass->gate();
- gate_status = override_gate_status (pass, current_function_decl, gate_status);
+ gate_status0 = (pass->gate == NULL) ? true : pass->gate();
+ gate_status = override_gate_status (pass, current_function_decl, gate_status0);
+
+ if (flag_dump_passes)
+ dump_one_pass (pass, gate_status0, gate_status);
/* Override gate with plugin. */
invoke_plugin_callbacks (PLUGIN_OVERRIDE_GATE, &gate_status);
@@ -1910,6 +2024,7 @@ execute_one_pass (struct opt_pass *pass)
void
execute_pass_list (struct opt_pass *pass)
{
+ enter_pass_list ();
do
{
gcc_assert (pass->type == GIMPLE_PASS
@@ -1919,6 +2034,7 @@ execute_pass_list (struct opt_pass *pass
pass = pass->next;
}
while (pass);
+ exit_pass_list ();
}
/* Same as execute_pass_list but assume that subpasses of IPA passes
@@ -2221,6 +2337,7 @@ ipa_read_optimization_summaries (void)
void
execute_ipa_pass_list (struct opt_pass *pass)
{
+ enter_pass_list ();
do
{
gcc_assert (!current_function_decl);
@@ -2246,6 +2363,7 @@ execute_ipa_pass_list (struct opt_pass *
pass = pass->next;
}
while (pass);
+ exit_pass_list ();
}
/* Execute stmt fixup hooks of all passes in PASS for NODE and STMTS. */
[-- Attachment #3: out --]
[-- Type: application/octet-stream, Size: 10765 bytes --]
cc1: note: disable pass ipa-inline for functions in the range of [0, 4294967295]
cc1: note: enable pass tree-unswitch for functions in the range of [0, 4294967295]
MAX_UID = 4
tree-mudflap1 : OFF
tree-omplower : ON
tree-lower : ON
tree-ehopt : OFF
tree-eh : ON
tree-cfg : ON
ipa-visibility : ON
ipa-early_local_cleanups : ON
tree-ompexp : OFF
tree-ssa : ON
tree-veclower : ON
tree-inline_param1 : ON
tree-einline : ON
tree-early_optimizations : ON
tree-copyrename1 : ON
tree-ccp1 : ON
tree-forwprop1 : ON
tree-ealias : ON
tree-esra : ON
tree-fre1 : ON
tree-copyprop1 : ON
tree-mergephi1 : ON
tree-cddce1 : ON
tree-eipa_sra : ON
tree-tailr1 : ON
tree-switchconv : ON
tree-ehcleanup1 : OFF
tree-profile_estimate : ON
tree-local-pure-const1 : ON
tree-fnsplit : ON
tree-release_ssa : ON
tree-inline_param2 : ON
ipa-profile : OFF
ipa-increase_alignment : OFF
ipa-matrix-reorg : OFF
ipa-emutls : OFF
ipa-whole-program : ON
ipa-profile_estimate : ON
ipa-cp : ON
ipa-cdtor : OFF
ipa-inline : ON (FORCED_OFF)
ipa-pure-const : ON
ipa-static-var : ON
ipa-pta : OFF
tree-ehdisp : OFF
tree-copyrename2 : ON
tree-cunrolli : ON
tree-ccp2 : ON
tree-forwprop2 : ON
tree-cdce : ON
tree-alias : ON
tree-retslot : ON
tree-phiprop : ON
tree-fre2 : ON
tree-copyprop2 : ON
tree-mergephi2 : ON
tree-vrp1 : ON
tree-dce1 : ON
tree-cselim : ON
tree-ifcombine : ON
tree-phiopt1 : ON
tree-tailr2 : ON
tree-ch : ON
tree-stdarg : OFF
tree-cplxlower : ON
tree-sra : ON
tree-copyrename3 : ON
tree-dom1 : ON
tree-phicprop1 : ON
tree-dse1 : ON
tree-reassoc1 : ON
tree-dce2 : ON
tree-forwprop3 : ON
tree-phiopt2 : ON
tree-objsz : ON
tree-ccp3 : ON
tree-copyprop3 : ON
tree-sincos : ON
tree-bswap : ON
tree-crited : ON
tree-pre : ON
tree-sink : ON
tree-loop : ON
tree-loopinit : ON
tree-lim1 : ON
tree-copyprop4 : ON
tree-dceloop1 : ON
tree-unswitch : OFF (FORCED_ON)
tree-sccp : ON
tree-ckdd : OFF
tree-ldist : OFF
tree-copyprop5 : ON
tree-graphite0 : OFF
tree-ivcanon : ON
tree-ifcvt : OFF
tree-vect : OFF
tree-pcom : OFF
tree-cunroll : ON
tree-slp : OFF
tree-parloops : OFF
tree-aprefetch : OFF
tree-ivopts : ON
tree-loopdone : ON
tree-recip : OFF
tree-reassoc2 : ON
tree-vrp2 : ON
tree-dom2 : ON
tree-phicprop2 : ON
tree-cddce2 : ON
tree-tracer : OFF
tree-uninit : OFF
tree-dse2 : ON
tree-forwprop4 : ON
tree-phiopt3 : ON
tree-fab : ON
tree-widening_mul : ON
tree-tailc : ON
tree-copyrename4 : ON
tree-uncprop : ON
tree-local-pure-const2 : ON
tree-cplxlower0 : OFF
tree-ehcleanup2 : OFF
tree-resx : OFF
tree-nrv : ON
tree-mudflap2 : OFF
tree-optimized : ON
rtl-expand : ON
rtl-sibling : ON
rtl-rtl_eh : OFF
rtl-initvals : ON
rtl-unshare : ON
rtl-vregs : ON
rtl-into_cfglayout : ON
rtl-jump : ON
rtl-subreg1 : ON
rtl-dfinit : ON
rtl-cse1 : ON
rtl-fwprop1 : ON
rtl-cprop1 : ON
rtl-rtl pre : ON
rtl-hoist : OFF
rtl-cprop2 : ON
rtl-store_motion : OFF
rtl-cse_local : OFF
rtl-ce1 : ON
rtl-reginfo : ON
rtl-loop2 : ON
rtl-loop2_init : ON
rtl-loop2_invariant : ON
rtl-loop2_unswitch : OFF
rtl-loop2_unroll : OFF
rtl-loop2_doloop : OFF
rtl-loop2_done : ON
rtl-web : OFF
rtl-cprop3 : ON
rtl-cse2 : ON
rtl-dse1 : ON
rtl-fwprop2 : ON
rtl-auto_inc_dec : OFF
rtl-init-regs : ON
rtl-ud_dce : ON
rtl-combine : ON
rtl-ce2 : ON
rtl-bbpart : OFF
rtl-regmove : ON
rtl-outof_cfglayout : ON
rtl-split1 : ON
rtl-subreg2 : ON
rtl-no-opt dfinit : OFF
rtl-mode_sw : ON
rtl-asmcons : ON
rtl-sms : OFF
rtl-sched1 : OFF
rtl-ira : ON
rtl-postreload : ON
rtl-gcse2 : OFF
rtl-split2 : ON
rtl-zee : ON
rtl-cmpelim : OFF
rtl-btl1 : OFF
rtl-pro_and_epilogue : ON
rtl-dse2 : ON
rtl-csa : ON
rtl-peephole2 : ON
rtl-ce3 : ON
rtl-rnreg : OFF
rtl-cprop_hardreg : ON
rtl-rtl_dce : ON
rtl-bbro : ON
rtl-btl2 : OFF
rtl-split4 : ON
rtl-sched2 : ON
rtl-split3 : OFF
rtl-stack : ON
rtl-alignments : ON
rtl-compgotos : ON
rtl-vartrack : OFF
rtl-mach : ON
rtl-barriers : ON
rtl-dbr : OFF
rtl-split5 : OFF
rtl-eh_ranges : OFF
rtl-shorten : ON
rtl-nothrow : ON
rtl-final : ON
rtl-dfinish : ON
prev parent reply other threads:[~2011-06-01 19:29 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <BANLkTikXRUTmZZokg4OtJA5fBrWUG+7yZux3=CLDBox1Q+Qhtw@mail.gmail.com>
2011-06-01 8:51 ` Richard Guenther
2011-06-01 16:17 ` Xinliang David Li
2011-06-01 17:24 ` Xinliang David Li
2011-06-05 17:25 ` Xinliang David Li
2011-06-06 11:22 ` Richard Guenther
2011-06-06 15:54 ` Xinliang David Li
2011-06-06 15:59 ` Richard Guenther
2011-06-06 19:21 ` Xinliang David Li
2011-06-07 10:11 ` Richard Guenther
2011-06-01 19:29 ` Richard Guenther
2011-06-01 19:46 ` Xinliang David Li
2011-06-02 7:13 ` Xinliang David Li
2011-06-05 17:25 ` Xinliang David Li
2011-06-06 11:38 ` Richard Guenther
2011-06-06 16:00 ` Xinliang David Li
2011-06-06 19:23 ` Xinliang David Li
2011-06-07 10:10 ` Richard Guenther
2011-06-07 16:24 ` Xinliang David Li
2011-06-07 19:09 ` Xinliang David Li
2011-06-07 20:39 ` Xinliang David Li
2011-06-08 9:06 ` Richard Guenther
2011-06-08 8:54 ` Richard Guenther
2011-06-09 22:16 ` H.J. Lu
2011-06-09 22:24 ` Carrot Wei
2011-06-09 22:32 ` Xinliang David Li
2011-06-09 22:51 ` Xinliang David Li
2011-06-09 23:28 ` Xinliang David Li
2011-06-10 9:10 ` Richard Guenther
2011-06-10 16:37 ` Xinliang David Li
2011-06-01 19:29 ` Xinliang David Li [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='BANLkTimQd7HYT=Ex3ngFvu4UMHWNeHsDDx+4h5ahB6GupUxq1A@mail.gmail.com' \
--to=davidxl@google.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=richard.guenther@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).