summaryrefslogtreecommitdiffstats
path: root/lld/COFF/Writer.cpp
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2015-09-19 21:36:28 +0000
committerRui Ueyama <ruiu@google.com>2015-09-19 21:36:28 +0000
commita5f0f758d343baa277c15d04b578b574189fb078 (patch)
tree495934825d067e5b54d140d4ea642a2b0e5a011b /lld/COFF/Writer.cpp
parent0652c595061d1ec5accdec3f7be8d30d72180ce5 (diff)
downloadbcm5719-llvm-a5f0f758d343baa277c15d04b578b574189fb078.tar.gz
bcm5719-llvm-a5f0f758d343baa277c15d04b578b574189fb078.zip
COFF: Move markLive() from Writer.cpp to its own file.
Conceptually, garbage collection is not part of Writer, so move the function out of the file. llvm-svn: 248099
Diffstat (limited to 'lld/COFF/Writer.cpp')
-rw-r--r--lld/COFF/Writer.cpp55
1 files changed, 0 insertions, 55 deletions
diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index 7a4fbc2bdd3..8e1a652980f 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -49,8 +49,6 @@ public:
void run();
private:
- void markLive();
- void dedupCOMDATs();
void createSections();
void createMiscChunks();
void createImportTables();
@@ -216,8 +214,6 @@ bool Defined::isExecutable() {
// The main function of the writer.
void Writer::run() {
- markLive();
- dedupCOMDATs();
createSections();
createMiscChunks();
createImportTables();
@@ -239,57 +235,6 @@ void Writer::run() {
error(Buffer->commit(), "Failed to write the output file");
}
-// Set live bit on for each reachable chunk. Unmarked (unreachable)
-// COMDAT chunks will be ignored in the next step, so that they don't
-// come to the final output file.
-void Writer::markLive() {
- if (!Config->DoGC)
- return;
-
- // 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;
-
- // COMDAT section chunks are dead by default. Add non-COMDAT chunks.
- for (Chunk *C : Symtab->getChunks())
- if (auto *SC = dyn_cast<SectionChunk>(C))
- if (SC->isLive())
- Worklist.push_back(SC);
-
- auto Enqueue = [&](SectionChunk *C) {
- if (C->isLive())
- return;
- C->markLive();
- Worklist.push_back(C);
- };
-
- // Add GC root chunks.
- for (Undefined *U : Config->GCRoot)
- if (auto *D = dyn_cast<DefinedRegular>(U->repl()))
- Enqueue(D->getChunk());
-
- while (!Worklist.empty()) {
- SectionChunk *SC = Worklist.pop_back_val();
- assert(SC->isLive() && "We mark as live when pushing onto the worklist!");
-
- // Mark all symbols listed in the relocation table for this section.
- for (SymbolBody *S : SC->symbols())
- if (auto *D = dyn_cast<DefinedRegular>(S->repl()))
- Enqueue(D->getChunk());
-
- // Mark associative sections if any.
- for (SectionChunk *C : SC->children())
- Enqueue(C);
- }
-}
-
-// Merge identical COMDAT sections.
-void Writer::dedupCOMDATs() {
- if (Config->DoICF)
- doICF(Symtab->getChunks());
-}
-
static StringRef getOutputSection(StringRef Name) {
StringRef S = Name.split('$').first;
auto It = Config->Merge.find(S);
OpenPOWER on IntegriCloud