On Sun, 27 Oct 2019, Alexandre Oliva wrote: > On Oct 26, 2019, Alexandre Oliva <ol...@adacore.com> wrote: > > > E.g., the reason we gather expanded calls rather than just use > > cgraph_edges is that the latter would dump several "calls" that are > > builtins expanded internally by the compiler, and would NOT dump other > > ops that are expanded as (lib)calls. > > It occurred to me that we could reuse most cgraph edges and avoid > duplicating them in the callees vec, namely those that aren't builtins > or libcalls. Those that are builtins might or might not become actual > calls, so we disregard the cgraph_edges and record them in the vec > instead. Those that are libcalls (builtins in a different sense) > introduced during expand are not even present in the cgraph edges, so we > record them in the vec as well. Here's the patch that implements this. > > Regstrapped on x86_64-linux-gnu. Ok to install?
<...> > --- a/gcc/common.opt > +++ b/gcc/common.opt > @@ -1091,6 +1091,14 @@ fbtr-bb-exclusive > Common Ignore > Does nothing. Preserved for backward compatibility. > > +fcallgraph-info > +Common Report RejectNegative Var(flag_callgraph_info) > Init(NO_CALLGRAPH_INFO); > +Output callgraph information on a per-file basis > + > +fcallgraph-info= > +Common Report RejectNegative Joined > +Output callgraph information on a per-file basis with decorations > + > fcall-saved- > Common Joined RejectNegative Var(common_deferred_options) Defer > -fcall-saved-<register> Mark <register> as being preserved across > functions. > diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi > index 1407d019d1404..545b842eade71 100644 > --- a/gcc/doc/invoke.texi > +++ b/gcc/doc/invoke.texi > @@ -583,8 +583,9 @@ Objective-C and Objective-C++ Dialects}. > @item Developer Options > @xref{Developer Options,,GCC Developer Options}. > @gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion @gol > --dumpfullversion -fchecking -fchecking=@var{n} -fdbg-cnt-list @gol > --fdbg-cnt=@var{counter-value-list} @gol > +-dumpfullversion -fcallgraph-info@r{[}=su,da@r{]} > +-fchecking -fchecking=@var{n} > +-fdbg-cnt-list @gol -fdbg-cnt=@var{counter-value-list} @gol > -fdisable-ipa-@var{pass_name} @gol > -fdisable-rtl-@var{pass_name} @gol > -fdisable-rtl-@var{pass-name}=@var{range-list} @gol > @@ -14533,6 +14534,18 @@ The files are created in the directory of the output > file. > > @table @gcctabopt > > +@item -fcallgraph-info > +@itemx -fcallgraph-info=@var{MARKERS} > +@opindex fcallgraph-info > +Makes the compiler output callgraph information for the program, on a > +per-file basis. The information is generated in the common VCG format. I guess you need to elaborate on 'per-file'. With LTO as far as I understand you'll get the graph per LTRANS unit (did you check where the output is generated?). Is this mainly a debugging tool or does it serve a different purpose? Otherwise OK. Thanks, Richard. > +It can be decorated with additional, per-node and/or per-edge information, > +if a list of comma-separated markers is additionally specified. When the > +@code{su} marker is specified, the callgraph is decorated with stack usage > +information; it is equivalent to @option{-fstack-usage}. When the @code{da} > +marker is specified, the callgraph is decorated with information about > +dynamically allocated objects.