diff options
Diffstat (limited to 'COFF/MarkLive.cpp')
-rw-r--r-- | COFF/MarkLive.cpp | 65 |
1 files changed, 32 insertions, 33 deletions
diff --git a/COFF/MarkLive.cpp b/COFF/MarkLive.cpp index 18b1c9c2529f..6d34cb864e3c 100644 --- a/COFF/MarkLive.cpp +++ b/COFF/MarkLive.cpp @@ -1,9 +1,8 @@ //===- MarkLive.cpp -------------------------------------------------------===// // -// The LLVM Linker -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -16,57 +15,57 @@ namespace lld { namespace coff { -static Timer GCTimer("GC", Timer::root()); +static Timer gctimer("GC", Timer::root()); // Set live bit on for each reachable chunk. Unmarked (unreachable) // COMDAT chunks will be ignored by Writer, so they will be excluded // from the final output. -void markLive(ArrayRef<Chunk *> Chunks) { - ScopedTimer T(GCTimer); +void markLive(ArrayRef<Chunk *> chunks) { + ScopedTimer t(gctimer); // We build up a worklist of sections which have been marked as live. We only // push into the worklist when we discover an unmarked section, and we mark // as we push, so sections never appear twice in the list. - SmallVector<SectionChunk *, 256> Worklist; + SmallVector<SectionChunk *, 256> worklist; // COMDAT section chunks are dead by default. Add non-COMDAT chunks. - for (Chunk *C : Chunks) - if (auto *SC = dyn_cast<SectionChunk>(C)) - if (SC->Live) - Worklist.push_back(SC); + for (Chunk *c : chunks) + if (auto *sc = dyn_cast<SectionChunk>(c)) + if (sc->live) + worklist.push_back(sc); - auto Enqueue = [&](SectionChunk *C) { - if (C->Live) + auto enqueue = [&](SectionChunk *c) { + if (c->live) return; - C->Live = true; - Worklist.push_back(C); + c->live = true; + worklist.push_back(c); }; - auto AddSym = [&](Symbol *B) { - if (auto *Sym = dyn_cast<DefinedRegular>(B)) - Enqueue(Sym->getChunk()); - else if (auto *Sym = dyn_cast<DefinedImportData>(B)) - Sym->File->Live = true; - else if (auto *Sym = dyn_cast<DefinedImportThunk>(B)) - Sym->WrappedSym->File->Live = Sym->WrappedSym->File->ThunkLive = true; + auto addSym = [&](Symbol *b) { + if (auto *sym = dyn_cast<DefinedRegular>(b)) + enqueue(sym->getChunk()); + else if (auto *sym = dyn_cast<DefinedImportData>(b)) + sym->file->live = true; + else if (auto *sym = dyn_cast<DefinedImportThunk>(b)) + sym->wrappedSym->file->live = sym->wrappedSym->file->thunkLive = true; }; // Add GC root chunks. - for (Symbol *B : Config->GCRoot) - AddSym(B); + for (Symbol *b : config->gcroot) + addSym(b); - while (!Worklist.empty()) { - SectionChunk *SC = Worklist.pop_back_val(); - assert(SC->Live && "We mark as live when pushing onto the worklist!"); + while (!worklist.empty()) { + SectionChunk *sc = worklist.pop_back_val(); + assert(sc->live && "We mark as live when pushing onto the worklist!"); // Mark all symbols listed in the relocation table for this section. - for (Symbol *B : SC->symbols()) - if (B) - AddSym(B); + for (Symbol *b : sc->symbols()) + if (b) + addSym(b); // Mark associative sections if any. - for (SectionChunk *C : SC->children()) - Enqueue(C); + for (SectionChunk &c : sc->children()) + enqueue(&c); } } |