[lld] r324756 - Make a lambda a static function to make the ICF main function shorter.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 9 10:00:46 PST 2018
Author: ruiu
Date: Fri Feb 9 10:00:46 2018
New Revision: 324756
URL: http://llvm.org/viewvc/llvm-project?rev=324756&view=rev
Log:
Make a lambda a static function to make the ICF main function shorter.
Modified:
lld/trunk/ELF/ICF.cpp
Modified: lld/trunk/ELF/ICF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ICF.cpp?rev=324756&r1=324755&r2=324756&view=diff
==============================================================================
--- lld/trunk/ELF/ICF.cpp (original)
+++ lld/trunk/ELF/ICF.cpp Fri Feb 9 10:00:46 2018
@@ -391,6 +391,13 @@ void ICF<ELFT>::forEachClass(std::functi
++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>::ru
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]);
}
});
More information about the llvm-commits
mailing list