[PATCH] [opt] Replace the recursive walk for GC with a worklist algorithm.

Rui Ueyama ruiu at google.com
Sat Jun 27 12:06:01 PDT 2015


================
Comment at: COFF/Chunks.h:13
@@ -12,2 +12,3 @@
 
+#include "InputFiles.h"
 #include "lld/Core/LLVM.h"
----------------
This makes this header and InputFiles.h mutually dependent. Please update InputFiles.h to remove inclusion of this file and add a forward declaration for the class Chunk.

================
Comment at: COFF/Chunks.h:141
@@ +140,3 @@
+
+  class symbol_iterator : public llvm::iterator_adaptor_base<
+                              symbol_iterator, const coff_relocation *,
----------------
symbol_iterator -> SymbolIterator?

================
Comment at: COFF/Chunks.h:151-156
@@ +150,8 @@
+
+  public:
+    symbol_iterator() = default;
+
+    SymbolBody *operator*() const {
+      return File->getSymbolBody(I->SymbolTableIndex);
+    }
+  };
----------------
Move this at beginning of the class definition. Also write operator*() in one line if it fits 80 cols.

================
Comment at: COFF/Writer.cpp:118
@@ +117,3 @@
+  // as we push, so sections never appear twice in the list.
+  SmallVector<SectionChunk *, 16> Worklist;
+
----------------
majnemer wrote:
> Realistically, won't we always blow out this SmallVector?
Yeah, this can be much longer than 16. Is SmallVector faster than std::vector for non-small vectors? If not, can we use std::vector instead?

================
Comment at: COFF/Writer.cpp:135
@@ +134,3 @@
+    SectionChunk *SC = Worklist.pop_back_val();
+    assert(SC->isLive() && "We mark as live when pushing onto the worklist!");
+
----------------
You don't need to call markLive() when you add a new chunk to the Worklist. Instead you can call that function here.

================
Comment at: COFF/Writer.cpp:146-147
@@ +145,4 @@
+    // Mark associative sections if any.
+    for (Chunk *ChildC : SC->children())
+      if (auto *ChildSC = dyn_cast<SectionChunk>(ChildC))
+        if (!ChildSC->isLive()) {
----------------
Associative sections are always SectionChunk. You want to change the type to eliminate this dyn_cast.

http://reviews.llvm.org/D10790

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list