[PATCH] D49683: Simplify ICF::run(). NFC.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 23 11:01:26 PDT 2018
ruiu created this revision.
ruiu added a reviewer: pcc.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.
Simplify ICF::run(). NFC.
https://reviews.llvm.org/D49683
Files:
lld/ELF/ICF.cpp
Index: lld/ELF/ICF.cpp
===================================================================
--- lld/ELF/ICF.cpp
+++ lld/ELF/ICF.cpp
@@ -462,9 +462,11 @@
forEachClassRange(0, Sections.size(), [&](size_t Begin, size_t End) {
if (End - Begin == 1)
return;
- InputSection *Target = nullptr;
- bool SeenUnique = false, Replaced = false;
- for (size_t I = Begin; I < End; ++I) {
+
+ bool SeenUnique = Sections[Begin]->KeepUnique;
+ bool Replaced = false;
+
+ for (size_t I = Begin + 1; I < End; ++I) {
// We aren't allowed to merge two KeepUnique sections as this would break
// the guarantees provided by --keep-unique and --icf=safe, but there's
// no reason why we can't merge a non-KeepUnique section with a KeepUnique
@@ -476,14 +478,11 @@
continue;
SeenUnique = true;
}
- if (!Target) {
- Target = Sections[I];
- continue;
- }
+
if (!Replaced)
- print("selected section " + toString(Target));
+ print("selected section " + toString(Sections[Begin]));
print(" removing identical section " + toString(Sections[I]));
- Target->replace(Sections[I]);
+ Sections[Begin]->replace(Sections[I]);
Replaced = true;
// At this point we know sections merged are fully identical and hence
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49683.156828.patch
Type: text/x-patch
Size: 1334 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180723/d19fc32e/attachment.bin>
More information about the llvm-commits
mailing list