[PATCH] D43435: Expand a lambda that is used only once.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 19 14:39:42 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rLLD325536: [WebAssembly] Expand a lambda that is used only once. (authored by ruiu, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D43435?vs=134823&id=134971#toc

Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D43435

Files:
  wasm/MarkLive.cpp


Index: wasm/MarkLive.cpp
===================================================================
--- wasm/MarkLive.cpp
+++ wasm/MarkLive.cpp
@@ -61,33 +61,33 @@
 
   // The ctor functions are all used in the synthetic __wasm_call_ctors
   // function, but since this function is created in-place it doesn't contain
-  // reloctations which mean we have to manually mark the ctors.
+  // relocations which mean we have to manually mark the ctors.
   for (const ObjFile *Obj : Symtab->ObjectFiles) {
     const WasmLinkingData &L = Obj->getWasmObj()->linkingData();
     for (const WasmInitFunc &F : L.InitFunctions)
       Enqueue(Obj->getFunctionSymbol(F.FunctionIndex));
   }
 
-  auto EnqueueSuccessors = [Enqueue](InputChunk &Chunk) {
-    for (const WasmRelocation Reloc : Chunk.getRelocations()) {
+  // Follow relocations to mark all reachable chunks.
+  while (!Q.empty()) {
+    InputChunk *C = Q.pop_back_val();
+
+    for (const WasmRelocation Reloc : C->getRelocations()) {
       switch (Reloc.Type) {
       case R_WEBASSEMBLY_FUNCTION_INDEX_LEB:
       case R_WEBASSEMBLY_TABLE_INDEX_I32:
       case R_WEBASSEMBLY_TABLE_INDEX_SLEB:
-        Enqueue(Chunk.File->getFunctionSymbol(Reloc.Index));
+        Enqueue(C->File->getFunctionSymbol(Reloc.Index));
         break;
       case R_WEBASSEMBLY_GLOBAL_INDEX_LEB:
       case R_WEBASSEMBLY_MEMORY_ADDR_LEB:
       case R_WEBASSEMBLY_MEMORY_ADDR_SLEB:
       case R_WEBASSEMBLY_MEMORY_ADDR_I32:
-        Enqueue(Chunk.File->getGlobalSymbol(Reloc.Index));
+        Enqueue(C->File->getGlobalSymbol(Reloc.Index));
         break;
       }
     }
-  };
-
-  while (!Q.empty())
-    EnqueueSuccessors(*Q.pop_back_val());
+  }
 
   // Report garbage-collected sections.
   if (Config->PrintGcSections) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43435.134971.patch
Type: text/x-patch
Size: 1758 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180219/4e016c33/attachment.bin>


More information about the llvm-commits mailing list