From 34133b23e4ac36d686f4db582e63f8ce7946c31f Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Mon, 19 Feb 2018 22:34:47 +0000 Subject: [WebAssembly] Expand a lambda that is used only once. Differential Revision: https://reviews.llvm.org/D43435 llvm-svn: 325536 --- lld/wasm/MarkLive.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'lld/wasm/MarkLive.cpp') diff --git a/lld/wasm/MarkLive.cpp b/lld/wasm/MarkLive.cpp index bba1b9d8b35..1e00ca04ea2 100644 --- a/lld/wasm/MarkLive.cpp +++ b/lld/wasm/MarkLive.cpp @@ -61,33 +61,33 @@ void lld::wasm::markLive() { // 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) { -- cgit v1.2.3