[PATCH] D43250: [WebAssembly] Unify concepts of disgarded and non-live input chunks. NFC.

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 13 11:31:25 PST 2018


sbc100 updated this revision to Diff 134090.
sbc100 added a comment.

- update comment


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D43250

Files:
  wasm/InputChunks.h
  wasm/InputFiles.cpp
  wasm/Writer.cpp


Index: wasm/Writer.cpp
===================================================================
--- wasm/Writer.cpp
+++ wasm/Writer.cpp
@@ -662,14 +662,11 @@
         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 @@
   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 @@
   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 @@
 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];
Index: wasm/InputFiles.cpp
===================================================================
--- wasm/InputFiles.cpp
+++ wasm/InputFiles.cpp
@@ -252,7 +252,7 @@
         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 @@
                           getGlobalValue(WasmSym));
         break;
       } else {
-        Segment->Discarded = true;
+        Segment->Live = false;
         LLVM_FALLTHROUGH; // Exclude global, and add the symbol as undefined
       }
     }
Index: wasm/InputChunks.h
===================================================================
--- wasm/InputChunks.h
+++ wasm/InputChunks.h
@@ -57,12 +57,12 @@
   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:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43250.134090.patch
Type: text/x-patch
Size: 3122 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180213/f9dd6ab4/attachment.bin>


More information about the llvm-commits mailing list