Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lld/COFF
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2015-06-28 04:35:59 +0300
committerRui Ueyama <ruiu@google.com>2015-06-28 04:35:59 +0300
commit50be6edfa60bdc6cdf1fcb8009600e2cc11785c0 (patch)
tree36ad495fef9660e925bd285310842970c41d367b /lld/COFF
parent871847e32d7e8faddcdc4e0e8c40ab0a6511f3d1 (diff)
COFF: Make doICF non-recursive. NFC.
llvm-svn: 240898
Diffstat (limited to 'lld/COFF')
-rw-r--r--lld/COFF/ICF.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/lld/COFF/ICF.cpp b/lld/COFF/ICF.cpp
index 0545d4c929ac..67ce67a4bcbe 100644
--- a/lld/COFF/ICF.cpp
+++ b/lld/COFF/ICF.cpp
@@ -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