[lld] r247869 - COFF: Remove DefinedSymbol::isLive() and markLive(). NFC.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 16 16:55:52 PDT 2015
Author: ruiu
Date: Wed Sep 16 18:55:52 2015
New Revision: 247869
URL: http://llvm.org/viewvc/llvm-project?rev=247869&view=rev
Log:
COFF: Remove DefinedSymbol::isLive() and markLive(). NFC.
Basically the concept of "liveness" is for sections (or chunks in LLD
terminology) and not for symbols. Symbols are always available or live,
or otherwise it indicates a link failure.
Previously, we had isLive() and markLive() methods for DefinedSymbol.
They are confusing methods. What they actually did is to act as a proxy
to backing section chunks. We can simplify eliminate these methods
and call section chunk's methods directly.
Modified:
lld/trunk/COFF/SymbolTable.cpp
lld/trunk/COFF/Symbols.h
lld/trunk/COFF/Writer.cpp
Modified: lld/trunk/COFF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/SymbolTable.cpp?rev=247869&r1=247868&r2=247869&view=diff
==============================================================================
--- lld/trunk/COFF/SymbolTable.cpp (original)
+++ lld/trunk/COFF/SymbolTable.cpp Wed Sep 16 18:55:52 2015
@@ -325,7 +325,7 @@ void SymbolTable::printMap(llvm::raw_ost
OS << File->getShortName() << ":\n";
for (SymbolBody *Body : File->getSymbols())
if (auto *R = dyn_cast<DefinedRegular>(Body))
- if (!R->isCOMDAT() || R->isLive())
+ if (R->getChunk()->isLive())
OS << Twine::utohexstr(Config->ImageBase + R->getRVA())
<< " " << R->getName() << "\n";
}
Modified: lld/trunk/COFF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Symbols.h?rev=247869&r1=247868&r2=247869&view=diff
==============================================================================
--- lld/trunk/COFF/Symbols.h (original)
+++ lld/trunk/COFF/Symbols.h Wed Sep 16 18:55:52 2015
@@ -181,8 +181,6 @@ public:
uint64_t getRVA() { return (*Data)->getRVA() + Sym->Value; }
bool isCOMDAT() { return IsCOMDAT; }
- bool isLive() const { return (*Data)->isLive(); }
- void markLive() { (*Data)->markLive(); }
SectionChunk *getChunk() { return *Data; }
uint32_t getValue() { return Sym->Value; }
Modified: lld/trunk/COFF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.cpp?rev=247869&r1=247868&r2=247869&view=diff
==============================================================================
--- lld/trunk/COFF/Writer.cpp (original)
+++ lld/trunk/COFF/Writer.cpp Wed Sep 16 18:55:52 2015
@@ -257,14 +257,17 @@ void Writer::markLive() {
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) {
- auto *D = dyn_cast<DefinedRegular>(U->repl());
- if (!D || D->isLive())
- continue;
- D->markLive();
- Worklist.push_back(D->getChunk());
- }
+ 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();
@@ -273,17 +276,11 @@ void Writer::markLive() {
// Mark all symbols listed in the relocation table for this section.
for (SymbolBody *S : SC->symbols())
if (auto *D = dyn_cast<DefinedRegular>(S->repl()))
- if (!D->isLive()) {
- D->markLive();
- Worklist.push_back(D->getChunk());
- }
+ Enqueue(D->getChunk());
// Mark associative sections if any.
- for (SectionChunk *ChildSC : SC->children())
- if (!ChildSC->isLive()) {
- ChildSC->markLive();
- Worklist.push_back(ChildSC);
- }
+ for (SectionChunk *C : SC->children())
+ Enqueue(C);
}
}
@@ -434,7 +431,7 @@ size_t Writer::addEntryToStringTable(Str
Optional<coff_symbol16> Writer::createSymbol(Defined *Def) {
if (auto *D = dyn_cast<DefinedRegular>(Def))
- if (!D->isLive())
+ if (!D->getChunk()->isLive())
return None;
coff_symbol16 Sym;
More information about the llvm-commits
mailing list