[lld] r240898 - COFF: Make doICF non-recursive. NFC.
Rui Ueyama
ruiu at google.com
Sat Jun 27 18:35:59 PDT 2015
Author: ruiu
Date: Sat Jun 27 20:35:59 2015
New Revision: 240898
URL: http://llvm.org/viewvc/llvm-project?rev=240898&view=rev
Log:
COFF: Make doICF non-recursive. NFC.
Modified:
lld/trunk/COFF/ICF.cpp
Modified: lld/trunk/COFF/ICF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/ICF.cpp?rev=240898&r1=240897&r2=240898&view=diff
==============================================================================
--- lld/trunk/COFF/ICF.cpp (original)
+++ lld/trunk/COFF/ICF.cpp Sat Jun 27 20:35:59 2015
@@ -37,24 +37,26 @@ struct Equals {
// contents and relocations are all the same.
void doICF(const std::vector<Chunk *> &Chunks) {
std::unordered_set<SectionChunk *, Hasher, Equals> Set;
- bool removed = false;
- for (Chunk *C : Chunks) {
- auto *SC = dyn_cast<SectionChunk>(C);
- if (!SC || !SC->isCOMDAT() || !SC->isLive())
- continue;
- auto P = Set.insert(SC);
- bool Inserted = P.second;
- if (Inserted)
- continue;
- SectionChunk *Existing = *P.first;
- SC->replaceWith(Existing);
- removed = true;
- }
- // By merging sections, two relocations that originally pointed to
- // different locations can now point to the same location.
- // So, repeat the process until a convegence is obtained.
- if (removed)
- doICF(Chunks);
+ bool Redo;
+ do {
+ Set.clear();
+ Redo = false;
+ for (Chunk *C : Chunks) {
+ auto *SC = dyn_cast<SectionChunk>(C);
+ if (!SC || !SC->isCOMDAT() || !SC->isLive())
+ continue;
+ auto P = Set.insert(SC);
+ bool Inserted = P.second;
+ if (Inserted)
+ continue;
+ SectionChunk *Existing = *P.first;
+ SC->replaceWith(Existing);
+ // By merging sections, two relocations that originally pointed to
+ // different locations can now point to the same location.
+ // So, repeat the process until a convegence is obtained.
+ Redo = true;
+ }
+ } while (Redo);
}
} // namespace coff
More information about the llvm-commits
mailing list