[PATCH] D42511: [WebAssembly] Add support for --gc-sections

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 30 17:30:09 PST 2018


ruiu accepted this revision.
ruiu added a comment.

LGTM with these changes.



================
Comment at: wasm/Driver.cpp:285
   Symbol *EntrySym = nullptr;
-  if (!Config->Relocatable) {
+  if (Config->Relocatable) {
+    if (!Config->Entry.empty())
----------------
I'd avoid writing a large nested if's if possible. Could you write two if's like this?

  if (Config->Relocatable) {
     // error check
  }

  Symbol *EntrySym = nullptr;
  if (!Config->Relocatalbe) {
    ....
  }


================
Comment at: wasm/MarkLive.cpp:94-98
+    auto CheckChunk = [](const InputChunk *C) {
+      if (!C->Live)
+        message("removing unused section '" + C->getName() + "' in file '" +
+                C->getFileName() + "'");
+    };
----------------
I'd make this a file-scope function now. But on second thought, I'd just repeat it twice. It's not very beautiful but that's probably simpler than defining a function.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D42511





More information about the llvm-commits mailing list