[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

llvm-svn: 325046
This commit is contained in:
Sam Clegg 2018-02-13 20:29:38 +00:00
parent a189230bf5
commit 447ae4044d
3 changed files with 9 additions and 12 deletions

View File

@ -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:

View File

@ -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
}
}

View File

@ -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 getOutputDataSegmentName(StringRef Name) {
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];