This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Implement -fcallgraph-info option


On Fri, Oct 29, 2010 at 12:43 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> Hi,
>
> this is again something that has been for a while in our tree and appears to
> be of interest to some other people:
> ?http://gcc.gnu.org/ml/gcc/2010-10/msg00179.html
>
> The command line option -fcallgraph-info is added and makes the compiler
> generate another output file (xxx.ci) for each compilation unit, which is a
> valid VCG file (you can launch your favorite VCG viewer on it unmodified) and
> contains the "final" callgraph of the unit. ?"final" is a bit of a misnomer
> as this is actually the callgraph at RTL expansion time, but since most
> high-level optimizations are done at the Tree level and RTL doesn't usually
> fiddle with calls, it's final in almost all cases. ?Moreover, the nodes can
> be decorated with additional info: -fcallgraph-info=su adds stack usage info
> and -fcallgraph-info=da dynamic allocation info.
>
> This is again strictly orthogonal to code and debug info generation. ?There
> are a few non-obvious changes to libfuncs.h, builtins.c, expr.c and optabs.c
> to deal with quirks of the RTL expander, but this mostly removes dead code.
> I can submit them separately if this is deemed better.
>
> I've also attached an example of .ci file and its conversion to PNG format,
> obtained by compiling unwind-dw2.c with -fcallgraph-info=su on x86-64/Linux,
> as well as a small Perl script to manipulate/analyze them.
>
> Tested on x86_64-suse-linux, OK for mainline?

Hm, the patch looks a bit excessive for just a dumping facility ... can't we
simply incrementally output the VCG (and I'd prefer DOT here)?  After
inline clone materialization the graph edges to the callees are final and
you can add properties in final.c for stack size.  So I dont' really see the
need for the additional final cgraph structures.

Not to say that either a plugin or a simple gdb python script would be
the prefered way to implement all this (or a postprocessing script for
the .000i cgraph dump we already have).

Richard.

>
> 2010-10-29 ?Eric Botcazou ?<ebotcazou@adacore.com>
>
> ? ? ? ?Callgraph info support
> ? ? ? ?* common.opt (-fcallgraph-info[=]): New option.
> ? ? ? ?* doc/invoke.texi (Debugging options): Document it.
> ? ? ? ?* flags.h (flag_stack_usage_info): New flag.
> ? ? ? ?(flag_callgraph_info): Likewise.
> ? ? ? ?* opts.c (common_handle_option): Handle -fcallgraph-info[=].
> ? ? ? ?Set flag_stack_usage_info to 1 if -fstack-usage.
> ? ? ? ?* builtins.c (set_builtin_user_assembler_name): Do not initialize
> ? ? ? ?memcpy_libfunc and memset_libfunc.
> ? ? ? ?* calls.c (expand_call): If -fcallgraph-info, record the call. ?Turn
> ? ? ? ?flag_stack_usage into flag_stack_usage_info.
> ? ? ? ?(emit_library_call_value_1): Likewise.
> ? ? ? ?* cgraph.h (struct cgraph_final_info): New structure.
> ? ? ? ?(struct cgraph_dynamic_alloc): Likewise.
> ? ? ? ?(cgraph_final_edge): Likewise.
> ? ? ? ?(cgraph_node): Add 'final' field.
> ? ? ? ?(dump_cgraph_final_vcg): Declare.
> ? ? ? ?(cgraph_final_record_call): Likewise.
> ? ? ? ?(cgraph_final_record_dynamic_alloc): Likewise.
> ? ? ? ?(cgraph_final_info): Likewise.
> ? ? ? ?* cgraph.c (cgraph_create_node): Initialize 'final' field.
> ? ? ? ?(final_create_edge): New static function.
> ? ? ? ?(cgraph_final_record_call): New global function.
> ? ? ? ?(cgraph_final_record_dynamic_alloc): Likewise.
> ? ? ? ?(cgraph_final_info): Likewise.
> ? ? ? ?(dump_cgraph_final_indirect_call_node_vcg): New static function.
> ? ? ? ?(dump_cgraph_final_edge_vcg): Likewise.
> ? ? ? ?(dump_cgraph_final_node_vcg): Likewise.
> ? ? ? ?(external_node_needed_p): Likewise.
> ? ? ? ?(dump_cgraph_final_vcg): New global function.
> ? ? ? ?* explow.c (allocate_dynamic_stack_space): Turn flag_stack_usage into
> ? ? ? ?flag_stack_usage_info.
> ? ? ? ?* expr.c (emit_block_move_via_libcall): Set input_location on the call.
> ? ? ? ?(set_storage_via_libcall): Likewise.
> ? ? ? ?(block_move_fn): Make global.
> ? ? ? ?(block_clear_fn): Likewise.
> ? ? ? ?Do not include gt-expr.h.
> ? ? ? ?* function.c (instantiate_virtual_regs): Turn flag_stack_usage into
> ? ? ? ?flag_stack_usage_info.
> ? ? ? ?(prepare_function_start): Likewise.
> ? ? ? ?(rest_of_handle_thread_prologue_and_epilogue): Likewise.
> ? ? ? ?* gimplify.c (gimplify_decl_expr): Record dynamically-allocated object
> ? ? ? ?by calling cgraph_final_record_dynamic_alloc if -fcallgraph-info=da.
> ? ? ? ?* libfuncs.h (libfunc_index): Remove LTI_memcpy and LTI_memset.
> ? ? ? ?(memcpy_libfunc): Delete.
> ? ? ? ?(memset_libfunc): Likewise.
> ? ? ? ?* optabs.c (init_one_libfunc): Do not zap the SYMBOL_REF_DECL.
> ? ? ? ?(init_optabs): Do not initialize memcpy_libfunc and memset_libfunc.
> ? ? ? ?* print-tree.c (print_decl_identifier): New function.
> ? ? ? ?* toplev.h (stack_usage_qual): Declare.
> ? ? ? ?* toplev.c (flag_callgraph_info): New flag.
> ? ? ? ?(flag_stack_usage_info): Likewise.
> ? ? ? ?(callgraph_info_file): New file pointer.
> ? ? ? ?(stack_usage_qual): New global variable.
> ? ? ? ?(output_stack_usage): If -fcallgraph-info=su, set stack_usage_kind
> ? ? ? ?and stack_usage of associated callgraph node. ?If -fstack-usage, use
> ? ? ? ?print_decl_identifier for pretty-printing.
> ? ? ? ?(lang_dependent_init): Open file if -fcallgraph-info.
> ? ? ? ?(finalize): If callgraph_info_file is not null, invoke dump_cgraph_vcg
> ? ? ? ?and close file.
> ? ? ? ?* tree.h (print_decl_identifier): Declare it.
> ? ? ? ?(PRINT_DECL_ORIGIN, PRINT_DECL_NAME, PRINT_DECL_UNIQUE_NAME): New.
> ? ? ? ?(block_move_fn): Declare.
> ? ? ? ?(block_clear_fn): Likewise.
> ? ? ? ?* Makefile.in (expr.o): Remove gt-expr.h.
> ? ? ? ?* config/alpha/alpha.c (alpha_expand_prologue): Turn flag_stack_usage
> ? ? ? ?into flag_stack_usage_info.
> ? ? ? ?* config/avr/avr.c (expand_prologue): Likewise.
> ? ? ? ?* config/i386/i386.c (ix86_expand_prologue): Likewise.
> ? ? ? ?* config/ia64/ia64.c (ia64_expand_prologue): Likewise.
> ? ? ? ?* config/mips/mips.c (mips_expand_prologue): Likewise.
> ? ? ? ?* config/pa/pa.c (hppa_expand_prologue): Likewise.
> ? ? ? ?* config/rs6000/rs6000.c (rs6000_emit_prologue): Likewise.
> ? ? ? ?* config/sh/sh.c (sh_expand_prologue): Likewise.
> ? ? ? ?* config/sparc/sparc.c (sparc_expand_prologue): Likewise.
> ? ? ? ?* config/picochip/picochip.c: Do not include libfuncs.h.
> ? ? ? ?* config/m68hc11/m68hc11.c (m68hc11_init_libfuncs): Do not initialize
> ? ? ? ?memcpy_libfunc and memset_libfunc.
> ? ? ? ?* config/vms/vms-crtl.h (MEM_LIBFUNCS_INIT): Likewise.
> ? ? ? ?* config/vms/vms-crtl-64.h (MEM_LIBFUNCS_INIT): Likewise.
> ada/
> ? ? ? ?* gcc-interface/misc.c (callgraph_info_file): Delete.
>
> --
> Eric Botcazou
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]