<div dir="ltr">No I didn't.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 21, 2019 at 10:52 AM Andrew Grieve via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Just wanted to check in on this - did your patches make it past the prototype phase?</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Mar 5, 2019 at 2:41 AM Fāng-ruì Sòng via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">> One thing a dependency graph might not capture is the order in which events occur, this can be very useful when debugging problems caused by library selection order.<br>
<br>
The event stream sounds like a more fine-grained --trace (-t).<br>
<br>
> (<from input section>, <symbol>, <to input section>)<br>
<br>
In --no-gc-sections mode and in some analysis, the file name part of<br>
the input section should be good enough.<br>
<br>
> section size and other section/symbol attributes<br>
<br>
If such customization is favored and the complexity isn't a big issue,<br>
it can probably be implemented as format specifiers (I'm thinking of<br>
printf, ps -o, date, ...). The design of<br>
<a href="https://github.com/Juniper/libxo" rel="noreferrer" target="_blank">https://github.com/Juniper/libxo</a> can be used for reference.<br>
<br>
We shall flesh out the possible vertex/edge types and additional<br>
information that users may expect.<br>
<br>
On Fri, Mar 1, 2019 at 1:18 PM Peter Collingbourne via llvm-dev<br>
<<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
><br>
> You might have realized this already but it's probably not a good idea to use InputSection::Relocations for this because that ends up missing anything that becomes a dynamic relocation. I reckon that the code should be doing exactly what MarkLive.cpp is doing.<br>
><br>
> Peter<br>
><br>
> On Thu, Feb 28, 2019 at 5:15 PM Rui Ueyama via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
>><br>
>> I hacked up a patch to make lld output a dependency graph in the graphviz "dot" format.<br>
>><br>
>> <a href="https://gist.github.com/rui314/4eab9f328a5568b682d11c84d328cdaa" rel="noreferrer" target="_blank">https://gist.github.com/rui314/4eab9f328a5568b682d11c84d328cdaa</a> -- this is a patch, which is just visiting all input sections and relocations. Note that this is far from completion but just a proof-of-concept.<br>
>><br>
>> <a href="https://gist.github.com/rui314/5e85c559835ecddad46dcf02fe3ffafc" rel="noreferrer" target="_blank">https://gist.github.com/rui314/5e85c559835ecddad46dcf02fe3ffafc</a> is a result of static-linking a "hello world" program.<br>
>><br>
>> <a href="https://rui314.github.io/hello.svg" rel="noreferrer" target="_blank">https://rui314.github.io/hello.svg</a> -- I rendered the above dot file with graphviz `sfdp` engine. The rendered graph is too large and very hard to read. Apparently, I need a better visualization tool.<br>
>><br>
>> On Wed, Feb 27, 2019 at 7:56 PM Zachary Turner <<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>> wrote:<br>
>>><br>
>>> +1 for graphviz dot format, so that it can be consumed by any one of many existing graph visualization tools.<br>
>>><br>
>>> On Wed, Feb 27, 2019 at 7:29 PM Shi, Steven via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
>>>><br>
>>>> >To summarise, I think we may<br>
>>>> > be able to do quite well with some very simple extra analysis in LLD,<br>
>>>> > a machine readable dependency graph would also be very useful for the<br>
>>>> > more complex cases.<br>
>>>><br>
>>>> Strongly agree. The linker based dependency graph would be very useful for Uefi firmware. Below are my usage examples:<br>
>>>> 1. I need to detect the redundant code in my firmware, and I once wrote a analysis tool to compare the IR level symbols and call graph info before any optimization and after full optimization (e.g. LTO). But the IR level info does not support assembly code info well. So, there are many dependency information missing and false positive in my analysis tool. It will be more sound if the linker can help output complete and accurate dependency graph for final executable.<br>
>>>> 2. I need a tool to analyze and track the firmware module accurate dependency for build cache soundness. Build performance is now a pain point in our CI system because every patch need to verify on many build targets in our side. We hope to enable the build cache (both module level and file level) to accelerate the build time. For module level build cache enabling, a very important problem is how to know the module's accurate dependency efficiently. I'm looking forward to the linker based dependency graph feature.<br>
>>>><br>
>>>><br>
>>>> Thanks<br>
>>>> Steven<br>
>>>> > -----Original Message-----<br>
>>>> > From: llvm-dev [mailto:<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>] On Behalf Of Peter<br>
>>>> > Smith via llvm-dev<br>
>>>> > Sent: Wednesday, February 27, 2019 6:37 PM<br>
>>>> > To: Michael Spencer <<a href="mailto:bigcheesegs@gmail.com" target="_blank">bigcheesegs@gmail.com</a>><br>
>>>> > Cc: llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
>>>> > Subject: Re: [llvm-dev] Linker option to dump dependency graph<br>
>>>> ><br>
>>>> > Hello,<br>
>>>> ><br>
>>>> > I think outputting a dependency graph is a good idea and would enable<br>
>>>> > some offline analysis. I think that there is some advantage to<br>
>>>> > building some of the simpler ones in, particularly those that would<br>
>>>> > need heavy annotations to the dependency graph, in particular unless<br>
>>>> > we write a sample analysis tool that ships with the release, many<br>
>>>> > users are going to miss out on useful features as they aren't going to<br>
>>>> > have the time to build one. I've put some comments inline:<br>
>>>> ><br>
>>>> > On Wed, 27 Feb 2019 at 00:31, Michael Spencer via llvm-dev<br>
>>>> > <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
>>>> > ><br>
>>>> > > On Tue, Feb 26, 2019 at 4:06 PM Rui Ueyama <<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>> wrote:<br>
>>>> > >><br>
>>>> > >> On Tue, Feb 26, 2019 at 3:31 PM Michael Spencer<br>
>>>> > <<a href="mailto:bigcheesegs@gmail.com" target="_blank">bigcheesegs@gmail.com</a>> wrote:<br>
>>>> > >>><br>
>>>> > >>> On Tue, Feb 26, 2019 at 2:23 PM Rui Ueyama via llvm-dev <llvm-<br>
>>>> > <a href="mailto:dev@lists.llvm.org" target="_blank">dev@lists.llvm.org</a>> wrote:<br>
>>>> > >>>><br>
>>>> > >>>> Hi,<br>
>>>> > >>>><br>
>>>> > >>>> I've heard people say that they want to analyze dependencies between<br>
>>>> > object files at the linker level so that they can run a whole-program analysis<br>
>>>> > which cannot be done at the compiler that works for one compilation unit at<br>
>>>> > a time. I'd like to start a discussion as to what we can do with it and how to<br>
>>>> > make it possible. I'm also sharing my idea about how to make it possible.<br>
>>>> > >>>><br>
>>>> > >>>> Dependency analyses<br>
>>>> > >>>> First, let me start with a few examples of analyses I'm heard of or<br>
>>>> > thinking about. Dependencies between object files can be represented as a<br>
>>>> > graph where vertices are input sections and edges are symbols and<br>
>>>> > relocations. Analyses would work on the dependency graph. Examples of<br>
>>>> > analyses include but not limited to the following:<br>
>>>> > >>>><br>
>>>> > >>>> - Figure out why some library or an object file gets linked.<br>
>>>> > >>>><br>
>>>> ><br>
>>>> > Arm's proprietary linker has a very helpful feature in verbose mode<br>
>>>> > where it will report on object loading: global/weak definitions and<br>
>>>> > global/weak references. For libraries you'd get a message like<br>
>>>> > selecting member.o from library.a to define symbol S. This resulted in<br>
>>>> > quite an effective trace of the linker output that could answer most<br>
>>>> > "why did this library and object file get loaded question?" One thing<br>
>>>> > a dependency graph might not capture is the order in which events<br>
>>>> > occur, this can be very useful when debugging problems caused by<br>
>>>> > library selection order.<br>
>>>> ><br>
>>>> > >>>> - Finding a candidate to eliminate dependency by finding a "weak" link<br>
>>>> > to a library. We can for example say the dependency to a library is weak if<br>
>>>> > the library in the graph can be unreachable if we remove N edges from the<br>
>>>> > graph (which is likely to correspond to removing N function calls from the<br>
>>>> > code), where N is a small number.<br>
>>>> > >>>><br>
>>>> > >>>> - Understanding which of new dependencies increase the executable<br>
>>>> > size the most, compare to a previous build.<br>
>>>> > >>>><br>
>>>> ><br>
>>>> > Arm's linker, being focused on embedded systems has a useful feature<br>
>>>> > that summarises the amount of content taken from each object broken<br>
>>>> > down into code, ro-data, rw-date etc. This can be helpful in the face<br>
>>>> > of comdat group elimination and optimisations such as garbage<br>
>>>> > collection and ICF that can be difficult to predict from a dependency<br>
>>>> > graph. It is true that this information could be added as attributes<br>
>>>> > but again it may just be easier to write a simple analysis pass over<br>
>>>> > the output in the linker.<br>
>>>> ><br>
>>>> > >>>> - Finding bad or circular dependencies between sub-components.<br>
>>>> > >>>><br>
>>>> > >>>> There would be many more analyses you want to run at the linker input<br>
>>>> > level. Currently, lld doesn't actively support such analyses. There are a few<br>
>>>> > options to make the linker emit dependency information (e.g. --cref or -Map),<br>
>>>> > but the output of the options is not comprehensive; you cannot reconstruct a<br>
>>>> > dependency graph from the output of the options.<br>
>>>> ><br>
>>>> ><br>
>>>> ><br>
>>>> > >>>><br>
>>>> > >>>> Dumping dependency graph<br>
>>>> > >>>> So, I'm thinking if it would be desirable to add a new feature to the<br>
>>>> > linker to dump an entire dependency graph in such a way that a graph can be<br>
>>>> > reconstructed by reading it back. Once we have such feature, we can link a<br>
>>>> > program with the feature enabled and run any kind of dependency analysis<br>
>>>> > on the output. You can save dumps to compare to previous builds. You can<br>
>>>> > run any number of analyses on a dump, instead of invoking the linker for<br>
>>>> > each analysis.<br>
>>>> > >>>><br>
>>>> > >>>> I don't have a concrete idea about the file output format, but I believe<br>
>>>> > it is essentially enough to emit triplets of (<from input section>, <symbol>,<br>
>>>> > <to input section>), which represents an edge, to reconstruct a graph.<br>
>>>> > >>>><br>
>>>> > >>>> Thoughts?<br>
>>>> > >>><br>
>>>> > >>><br>
>>>> > >>> Back when I worked on the linker I pretty much always had a way to<br>
>>>> > dump a graphviz dot file to look at things. Pretty much every graph<br>
>>>> > library/tool can read dot files, and they are easy to hack up a parser for. You<br>
>>>> > can also add attributes to nodes and edges to store arbitrary data.<br>
>>>> > >><br>
>>>> > >><br>
>>>> > >> That's an interesting idea.<br>
>>>> > >><br>
>>>> > >>> As for what to put it in, it really depends on how detailed it needs to be.<br>
>>>> > Should symbols and sections be collapsed together? Should it include<br>
>>>> > relocation types? Symbol types/binding/size/etc?<br>
>>>> > >><br>
>>>> > >><br>
>>>> > >> Maybe everything? We can for example emit all symbols and input<br>
>>>> > sections first, and then emit a graph as the second half of the output. E.g.<br>
>>>> > >><br>
>>>> > >> Symbols:<br>
>>>> > >> <list of symbols><br>
>>>> > >> Sections:<br>
>>>> > >> <list of sections><br>
>>>> > >> Graph:<br>
>>>> > >> 1 2 3 // 1st section depends on 3rd section via 2nd symbol<br>
>>>> > >> 5 1 4 // likewise<br>
>>>> > ><br>
>>>> > ><br>
>>>> > > I suppose it's a question of if we want users to need to also read the inputs<br>
>>>> > if they want things like section size and other section/symbol attributes. It<br>
>>>> > would be pretty trivial to include that data as long as we have a<br>
>>>> > format/syntax for it.<br>
>>>> > ><br>
>>>> > > dot supports listing nodes first with attributes and then referring to them by<br>
>>>> > name later when listing edges.<br>
>>>> > ><br>
>>>> > > - Michael Spencer<br>
>>>> > ><br>
>>>> ><br>
>>>> > I've experimented with dot files for this type of thing in the past.<br>
>>>> > The difficulty is that they get too large to be realistically viewed<br>
>>>> > very quickly. At that point you need to write scripts to process the<br>
>>>> > output and in that case you may as well use JSON or XML, which I guess<br>
>>>> > could easily be processed into dot files. To summarise, I think we may<br>
>>>> > be able to do quite well with some very simple extra analysis in LLD,<br>
>>>> > a machine readable dependency graph would also be very useful for the<br>
>>>> > more complex cases.<br>
>>>> ><br>
>>>> > Peter<br>
>>>> ><br>
>>>> > _______________________________________________<br>
>>>> > > LLVM Developers mailing list<br>
>>>> > > <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
>>>> > > <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
>>>> > _______________________________________________<br>
>>>> > LLVM Developers mailing list<br>
>>>> > <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
>>>> > <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
>>>> _______________________________________________<br>
>>>> LLVM Developers mailing list<br>
>>>> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
>>>> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
>><br>
>> _______________________________________________<br>
>> LLVM Developers mailing list<br>
>> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
>> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
><br>
><br>
><br>
> --<br>
> --<br>
> Peter<br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br>
<br>
<br>
-- <br>
宋方睿<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>