[PATCH] D102546: [lld][WebAssembly] Refactor input chunk class hierarchy. NFC

Derek Schuff via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 17 17:07:38 PDT 2021


dschuff added inline comments.


================
Comment at: lld/wasm/InputChunks.h:68-69
+  uint64_t getOffset(uint64_t offset) const;
+  // For data segments translate and offset into the input segment into
+  // and offset into the output segment
+  uint64_t getSegmentOffset(uint64_t offset) const;
----------------



================
Comment at: lld/wasm/InputChunks.h:122
   ArrayRef<WasmRelocation> relocations;
-  Kind sectionKind;
+  mutable ArrayRef<uint8_t> rawData;
 };
----------------
Ick. I guess this is the trick you borrowed from ELF to avoid virtual functions? I guess the idea is that the subclass can mutate this directly, but the superclass can return it as const?


================
Comment at: lld/wasm/InputChunks.h:155
 
 // Merge segment handling copied from lld/ELF/InputSection.h.  Keep in sync
 // where possible.
----------------
Is this still true?


================
Comment at: lld/wasm/InputChunks.h:229
   static bool classof(const InputChunk *c) {
     return c->kind() == InputChunk::MergedSegment;
   }
----------------
should we rename this kind to `MergedChunk`?


================
Comment at: lld/wasm/InputChunks.h:321
 
-  StringRef getName() const override { return name; }
-  StringRef getDebugName() const override { return debugName; }
-  uint32_t getComdat() const override { return UINT32_MAX; }
-
-  void setBody(ArrayRef<uint8_t> body_) { body = body_; }
-
-protected:
-  ArrayRef<uint8_t> data() const override { return body; }
-
-  StringRef name;
-  StringRef debugName;
-  ArrayRef<uint8_t> body;
+  void setBody(ArrayRef<uint8_t> body_) { rawData = body_; }
 };
----------------
why this naming scheme for `body_`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102546/new/

https://reviews.llvm.org/D102546



More information about the llvm-commits mailing list