summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/ICF.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp
index 61b6dd42915..310364a89e0 100644
--- a/lld/ELF/ICF.cpp
+++ b/lld/ELF/ICF.cpp
@@ -391,6 +391,13 @@ void ICF<ELFT>::forEachClass(std::function<void(size_t, size_t)> Fn) {
++Cnt;
}
+static void Print(const Twine &Prefix, InputSection *S) {
+ if (!Config->PrintIcfSections)
+ return;
+ std::string File = S->File ? S->File->getName() : "<internal>";
+ message(Prefix + " section '" + S->Name + "' from file '" + File + "'");
+};
+
// The main function of ICF.
template <class ELFT> void ICF<ELFT>::run() {
// Collect sections to merge.
@@ -424,22 +431,13 @@ template <class ELFT> void ICF<ELFT>::run() {
log("ICF needed " + Twine(Cnt) + " iterations");
- auto Print = [&](const Twine &Prefix, size_t I) {
- if (!Config->PrintIcfSections)
- return;
- InputSection *S = Sections[I];
- std::string File = S->File ? S->File->getName() : "<internal>";
- message(Prefix + " section '" + S->Name + "' from file '" + File + "'");
- };
-
// Merge sections by the equivalence class.
forEachClassRange(0, Sections.size(), [&](size_t Begin, size_t End) {
if (End - Begin == 1)
return;
-
- Print("selected", Begin);
+ Print("selected", Sections[Begin]);
for (size_t I = Begin + 1; I < End; ++I) {
- Print(" removing identical", I);
+ Print(" removing identical", Sections[I]);
Sections[Begin]->replace(Sections[I]);
}
});
OpenPOWER on IntegriCloud