From 7bed9eec368c743e5bb755dc5058f0a8fb4d087b Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Sun, 20 Nov 2016 23:15:54 +0000 Subject: [PATCH] Update comments. llvm-svn: 287509 --- lld/ELF/ICF.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp index 229c07a..03c88d6 100644 --- a/lld/ELF/ICF.cpp +++ b/lld/ELF/ICF.cpp @@ -113,16 +113,16 @@ template static std::vector *> getSections() { return V; } -// All sections between Begin and End must have the same group ID before -// you call this function. This function compare sections between Begin -// and End using Eq and assign new group IDs for new groups. +// Before calling this function, all sections in Arr must have the +// same group ID. This function compare sections in Arr using Eq and +// assign new group IDs for new groups. template void ICF::segregate(MutableArrayRef *> Arr, Comparator Eq) { - // This loop rearranges [Begin, End) so that all sections that are - // equal in terms of Eq are contiguous. The algorithm is quadratic in - // the worst case, but that is not an issue in practice because the - // number of distinct sections in [Begin, End) is usually very small. + // This loop rearranges Arr so that all sections that are equal in + // terms of Eq are contiguous. The algorithm is quadratic in the + // worst case, but that is not an issue in practice because the + // number of distinct sections in Arr is usually very small. InputSection **I = Arr.begin(); for (;;) { InputSection *Head = *I; @@ -136,6 +136,7 @@ void ICF::segregate(MutableArrayRef *> Arr, } } +// Call Fn for each section group having the same group ID. template void ICF::forEachGroup( std::vector *> &V, @@ -177,6 +178,8 @@ static bool equalsConstant(const InputSection *A, return relocationEq(A->rels(), B->rels()); } +// Compare two lists of relocations. Returns true if all pairs of +// relocations point to the same section in terms of ICF. template static bool variableEq(const InputSection *A, ArrayRef RelsA, const InputSection *B, ArrayRef RelsB) { @@ -221,7 +224,7 @@ template void ICF::run() { // Set MSB on to avoid collisions with serial group IDs S->GroupId = getHash(S) | (uint64_t(1) << 63); - // From now on, sections in V are ordered so that sections in + // From now on, sections in Sections are ordered so that sections in // the same group are consecutive in the vector. std::stable_sort(Sections.begin(), Sections.end(), [](InputSection *A, InputSection *B) { -- 2.7.4