[PATCH] D36351: [lld][ELF] Add profile guided section layout

Rafael Avila de Espindola via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 12 10:17:01 PDT 2018


espindola added inline comments.


================
Comment at: ELF/CallGraphSort.cpp:71
+
+struct Section {
+  Section(const InputSectionBase *IS) : ISB(IS) { Size = ISB->getSize(); }
----------------
This structure is almost a perfect duplicate of Cluster. That is not too surprising since each cluster starts as a single section.

In the traditional description of union-find, there is only one type of element which gets combined as union operations are performed.

I was able to remove this struct and I think it makes the code quite a bite closer to a description of the union-find structure and easier to read. The patch on top of this is at https://reviews.llvm.org/D45577.



================
Comment at: ELF/CallGraphSort.cpp:289
+    // NOTE: Consider using a disjoint-set to track section -> cluster mapping
+    // if this is ever slow.
+    for (int SI : C.Sections)
----------------
BTW, this is a very interesting problem.

The traditional disjoint-set/union-find uses unordered sets which are easy to represent with trees with only parent pointers.

Changing it to represent order in the sets and still be efficient is an interesting challenge (not for this patch).



https://reviews.llvm.org/D36351





More information about the llvm-commits mailing list