[lld] r325046 - [WebAssembly] Unify concepts of discarded and non-live input chunks. NFC.
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 13 12:29:38 PST 2018
Author: sbc
Date: Tue Feb 13 12:29:38 2018
New Revision: 325046
URL: http://llvm.org/viewvc/llvm-project?rev=325046&view=rev
Log:
[WebAssembly] Unify concepts of discarded and non-live input chunks. NFC.
It seems redundant to store this information twice. None of the
locations where this bit is checked care about the distinction.
Differential Revision: https://reviews.llvm.org/D43250
Modified:
lld/trunk/wasm/InputChunks.h
lld/trunk/wasm/InputFiles.cpp
lld/trunk/wasm/Writer.cpp
Modified: lld/trunk/wasm/InputChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/InputChunks.h?rev=325046&r1=325045&r2=325046&view=diff
==============================================================================
--- lld/trunk/wasm/InputChunks.h (original)
+++ lld/trunk/wasm/InputChunks.h Tue Feb 13 12:29:38 2018
@@ -57,12 +57,12 @@ public:
virtual StringRef getComdat() const = 0;
virtual StringRef getName() const = 0;
- bool Discarded = false;
std::vector<OutputRelocation> OutRelocations;
ObjFile *File;
- // The garbage collector sets sections' Live bits.
- // If GC is disabled, all sections are considered live by default.
+ // Signals that the section is part of the output. The garbage collector,
+ // and COMDAT handling can set a sections' Live bit.
+ // If GC is disabled, all sections start out as live by default.
unsigned Live : 1;
protected:
Modified: lld/trunk/wasm/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/InputFiles.cpp?rev=325046&r1=325045&r2=325046&view=diff
==============================================================================
--- lld/trunk/wasm/InputFiles.cpp (original)
+++ lld/trunk/wasm/InputFiles.cpp Tue Feb 13 12:29:38 2018
@@ -252,7 +252,7 @@ void ObjFile::initializeSymbols() {
S = createDefined(WasmSym, Symbol::Kind::DefinedFunctionKind, Function);
break;
} else {
- Function->Discarded = true;
+ Function->Live = false;
LLVM_FALLTHROUGH; // Exclude function, and add the symbol as undefined
}
}
@@ -267,7 +267,7 @@ void ObjFile::initializeSymbols() {
getGlobalValue(WasmSym));
break;
} else {
- Segment->Discarded = true;
+ Segment->Live = false;
LLVM_FALLTHROUGH; // Exclude global, and add the symbol as undefined
}
}
Modified: lld/trunk/wasm/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Writer.cpp?rev=325046&r1=325045&r2=325046&view=diff
==============================================================================
--- lld/trunk/wasm/Writer.cpp (original)
+++ lld/trunk/wasm/Writer.cpp Tue Feb 13 12:29:38 2018
@@ -662,14 +662,11 @@ void Writer::calculateExports() {
continue;
if (Sym->isGlobal())
continue;
- if (Sym->getChunk()->Discarded)
+ if (!Sym->getChunk()->Live)
continue;
if ((Sym->isHidden() || Sym->isLocal()) && !ExportHidden)
continue;
-
- // We should never be exporting a non-live symbol
- assert(Sym->getChunk()->Live);
ExportedSymbols.emplace_back(WasmExportEntry{Sym, BudgeLocalName(Sym)});
}
}
@@ -759,7 +756,7 @@ void Writer::assignIndexes() {
for (ObjFile *File : Symtab->ObjectFiles) {
DEBUG(dbgs() << "Functions: " << File->getName() << "\n");
for (InputFunction *Func : File->Functions) {
- if (Func->Discarded || !Func->Live)
+ if (!Func->Live)
continue;
DefinedFunctions.emplace_back(Func);
Func->setOutputIndex(FunctionIndex++);
@@ -769,7 +766,7 @@ void Writer::assignIndexes() {
for (ObjFile *File : Symtab->ObjectFiles) {
DEBUG(dbgs() << "Handle relocs: " << File->getName() << "\n");
auto HandleRelocs = [&](InputChunk *Chunk) {
- if (Chunk->Discarded)
+ if (!Chunk->Live)
return;
ArrayRef<WasmSignature> Types = File->getWasmObj()->types();
for (const WasmRelocation& Reloc : Chunk->getRelocations()) {
@@ -813,7 +810,7 @@ static StringRef getOutputDataSegmentNam
void Writer::createOutputSegments() {
for (ObjFile *File : Symtab->ObjectFiles) {
for (InputSegment *Segment : File->Segments) {
- if (Segment->Discarded || !Segment->Live)
+ if (!Segment->Live)
continue;
StringRef Name = getOutputDataSegmentName(Segment->getName());
OutputSegment *&S = SegmentMap[Name];
More information about the llvm-commits
mailing list