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: Thu, 02 Jun 2011 07:13:00 -0000 [thread overview]
Message-ID: <BANLkTimKpnPxF7iFWq7D01U-KZV0RL9Lew@mail.gmail.com> (raw)
In-Reply-To: <BANLkTi=y6cr4auzTps9eakr0Uo8X3zxHennB8cCENh8SdFP+mg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3386 bytes --]
This is the version of the patch that walks through pass lists.
Ok with this one?
David
On Wed, Jun 1, 2011 at 12:45 PM, Xinliang David Li <davidxl@google.com> wrote:
> On Wed, Jun 1, 2011 at 12:29 PM, Richard Guenther
> <richard.guenther@gmail.com> wrote:
>> On Wed, Jun 1, 2011 at 6:16 PM, 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.
>>
>> Well, if you have a CU that is empty or optimized to nothing at some point
>> you will not get a complete pass list. I suppose optimize attributes might
>> also confuse output. Your solution might not be that intrusive
>> but it is still ugly. I don't see 1) as an issue, for 2) you can just call the
>> dumping from toplev_main before calling do_compile (), 3) gate functions
>> shouldn't have side-effects, but as they could gate on optimize_for_speed ()
>> your option summary output will be bogus anyway.
>>
>> So - what is the output intended for if it isn't reliable?
>
> This needs to be cleaned up at some point -- the gate function should
> behave the same for all functions and per-function decisions need to
> be pushed down to the executor body. I will try to rework the patch
> as you suggested to see if there are problems.
>
> David
>
>
>>
>> Richard.
>>
>>>>
>>>> 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-pass3.p --]
[-- Type: application/octet-stream, Size: 7243 bytes --]
Index: doc/invoke.texi
===================================================================
--- doc/invoke.texi (revision 174550)
+++ 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: tree-pass.h
===================================================================
--- tree-pass.h (revision 174550)
+++ tree-pass.h (working copy)
@@ -639,5 +639,6 @@ extern void do_per_function_toporder (vo
extern void disable_pass (const char *);
extern void enable_pass (const char *);
+extern void dump_passes (void);
#endif /* GCC_TREE_PASS_H */
Index: cgraphunit.c
===================================================================
--- cgraphunit.c (revision 174550)
+++ cgraphunit.c (working copy)
@@ -1112,6 +1112,9 @@ cgraph_finalize_compilation_unit (void)
fflush (stderr);
}
+ if (flag_dump_passes)
+ dump_passes ();
+
/* Gimplify and lower all functions, compute reachability and
remove unreachable nodes. */
cgraph_analyze_functions ();
Index: common.opt
===================================================================
--- common.opt (revision 174550)
+++ 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 174550)
+++ 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,127 @@ register_pass_name (struct opt_pass *pas
return; /* Ignore plugin passes. */
}
+/* Map from pass id to canonicalized pass name. */
+
+typedef const char *char_ptr;
+DEF_VEC_P(char_ptr);
+DEF_VEC_ALLOC_P(char_ptr, heap);
+static VEC(char_ptr, heap) *pass_tab = NULL;
+
+/* Callback function for traversing NAME_TO_PASS_MAP. */
+
+static int
+pass_traverse (void **slot, void *data ATTRIBUTE_UNUSED)
+{
+ struct pass_registry **p = (struct pass_registry **)slot;
+ struct opt_pass *pass = (*p)->pass;
+
+ gcc_assert (pass->static_pass_number > 0);
+ gcc_assert (pass_tab);
+
+ VEC_replace (char_ptr, pass_tab, pass->static_pass_number,
+ (*p)->unique_name);
+
+ return 1;
+}
+
+/* The function traverses NAME_TO_PASS_MAP and creates a pass info
+ table for dumping purpose. */
+
+static void
+create_pass_tab (void)
+{
+ if (!flag_dump_passes)
+ return;
+
+ VEC_safe_grow_cleared (char_ptr, heap,
+ pass_tab, passes_by_id_size + 1);
+ htab_traverse (name_to_pass_map, pass_traverse, NULL);
+}
+
+static bool override_gate_status (struct opt_pass *, tree, bool);
+
+/* 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, int pass_indent)
+{
+ int indent = 3 * pass_indent;
+ const char *pn;
+ bool is_on, is_really_on;
+
+ is_on = (pass->gate == NULL) ? true : pass->gate();
+ is_really_on = override_gate_status (pass, current_function_decl, is_on);
+
+ if (pass->static_pass_number <= 0)
+ pn = pass->name;
+ else
+ pn = VEC_index (char_ptr, pass_tab, pass->static_pass_number);
+
+ fprintf (stderr, "%*s%-40s%*s:%s%s\n", indent, " ", pn,
+ (15 - indent < 0 ? 0 : 15 - indent), " ",
+ is_on ? " ON" : " OFF",
+ ((!is_on) == (!is_really_on) ? ""
+ : (is_really_on ? " (FORCED_ON)" : " (FORCED_OFF)")));
+}
+
+/* Dump pass list PASS with indentation INDENT. */
+
+static void
+dump_pass_list (struct opt_pass *pass, int indent)
+{
+ do
+ {
+ dump_one_pass (pass, indent);
+ if (pass->sub)
+ dump_pass_list (pass->sub, indent + 1);
+ pass = pass->next;
+ }
+ while (pass);
+}
+
+/* Dump all optimization passes. */
+
+void
+dump_passes (void)
+{
+ struct cgraph_node *n, *node = NULL;
+ tree save_fndecl = current_function_decl;
+
+ fprintf (stderr, "MAX_UID = %d\n", cgraph_max_uid);
+
+ create_pass_tab();
+ gcc_assert (pass_tab);
+
+ n = cgraph_nodes;
+ while (n)
+ {
+ if (DECL_STRUCT_FUNCTION (n->decl))
+ {
+ node = n;
+ break;
+ }
+ n = n->next;
+ }
+
+ if (!node)
+ return;
+
+ push_cfun (DECL_STRUCT_FUNCTION (node->decl));
+ current_function_decl = node->decl;
+
+ dump_pass_list (all_lowering_passes, 1);
+ dump_pass_list (all_small_ipa_passes, 1);
+ dump_pass_list (all_regular_ipa_passes, 1);
+ dump_pass_list (all_lto_gen_passes, 1);
+ dump_pass_list (all_passes, 1);
+
+ pop_cfun ();
+ current_function_decl = save_fndecl;
+}
+
+
/* Returns the pass with NAME. */
static struct opt_pass *
@@ -513,9 +634,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)
[-- Attachment #3: out --]
[-- Type: application/octet-stream, Size: 14902 bytes --]
cc1: note: enable pass tree-unswitch for functions in the range of [0, 4294967295]
cc1: note: disable pass ipa-inline for functions in the range of [0, 4294967295]
MAX_UID = 4
*warn_unused_result : ON
*diagnose_omp_blocks : OFF
tree-mudflap1 : OFF
tree-omplower : ON
tree-lower : ON
tree-ehopt : OFF
tree-eh : ON
tree-cfg : ON
*warn_function_return : ON
*build_cgraph_edges : ON
*free_lang_data : ON
ipa-visibility : ON
ipa-early_local_cleanups : ON
*free_cfg_annotations : ON
*init_datastructures : ON
tree-ompexp : OFF
*referenced_vars : ON
tree-ssa : ON
tree-veclower : ON
*early_warn_uninitialized : OFF
*rebuild_cgraph_edges : ON
tree-inline_param1 : ON
tree-einline : ON
tree-early_optimizations : ON
*remove_cgraph_callee_edges : 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
*rebuild_cgraph_edges : ON
tree-inline_param2 : ON
ipa-profile : OFF
tree-feedback_fnsplit : 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
ipa-lto_gimple_out : OFF
ipa-lto_decls_out : OFF
tree-ehdisp : OFF
*all_optimizations : ON
*remove_cgraph_callee_edges : ON
*strip_predict_hints : ON
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
*record_bounds : ON
tree-ckdd : OFF
tree-ldist : OFF
tree-copyprop5 : ON
tree-graphite0 : OFF
tree-graphite : OFF
tree-lim2 : ON
tree-copyprop6 : ON
tree-dceloop2 : ON
tree-ivcanon : ON
tree-ifcvt : OFF
tree-vect : OFF
tree-veclower2 : OFF
tree-dceloop3 : ON
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 : ON
tree-ehcleanup2 : OFF
tree-resx : OFF
tree-nrv : ON
tree-mudflap2 : OFF
tree-optimized : ON
*warn_function_noreturn : OFF
rtl-expand : ON
*rest_of_compilation : ON
*init_function : 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
*stack_ptr_mod : ON
rtl-mode_sw : ON
rtl-asmcons : ON
rtl-sms : OFF
rtl-sched1 : OFF
rtl-ira : ON
*all-postreload : OFF
rtl-postreload : OFF
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
*leaf_regs : ON
rtl-split4 : ON
rtl-sched2 : ON
*stack_regs : ON
rtl-split3 : OFF
rtl-stack : ON
rtl-alignments : ON
rtl-compgotos : ON
rtl-vartrack : OFF
*free_cfg : ON
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
*clean_state : ON
next prev parent reply other threads:[~2011-06-02 7:13 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 [this message]
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
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=BANLkTimKpnPxF7iFWq7D01U-KZV0RL9Lew@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).