mirror of
https://github.com/intel/llvm.git
synced 2026-01-25 19:44:38 +08:00
COFF: Make doICF non-recursive. NFC.
llvm-svn: 240898
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user