[PATCH] D43406: Merge two small functions and add comments.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 16 15:09:01 PST 2018


ruiu updated this revision to Diff 134740.
ruiu added a comment.

- removed a comment from the .h file


https://reviews.llvm.org/D43406

Files:
  lld/wasm/InputChunks.cpp


Index: lld/wasm/InputChunks.cpp
===================================================================
--- lld/wasm/InputChunks.cpp
+++ lld/wasm/InputChunks.cpp
@@ -44,8 +44,10 @@
   DEBUG(dbgs() << "write reloc: type=" << Reloc.Reloc.Type
                << " index=" << Reloc.Reloc.Index << " value=" << Reloc.Value
                << " offset=" << Reloc.Reloc.Offset << "\n");
+
   Buf += Reloc.Reloc.Offset;
   int64_t ExistingValue;
+
   switch (Reloc.Reloc.Type) {
   case R_WEBASSEMBLY_TYPE_INDEX_LEB:
   case R_WEBASSEMBLY_FUNCTION_INDEX_LEB:
@@ -74,19 +76,19 @@
   }
 }
 
-static void applyRelocations(uint8_t *Buf, ArrayRef<OutputRelocation> Relocs) {
-  if (!Relocs.size())
+// Copy this input chunk to an mmap'ed output file.
+void InputChunk::writeTo(uint8_t *Buf) const {
+  // Copy contents
+  memcpy(Buf + getOutputOffset(), data().data(), data().size());
+
+  // Apply relocations
+  if (OutRelocations.empty())
     return;
-  DEBUG(dbgs() << "applyRelocations: count=" << Relocs.size() << "\n");
-  for (const OutputRelocation &Reloc : Relocs)
+  DEBUG(dbgs() << "applyRelocations: count=" << OutRelocations.size() << "\n");
+  for (const OutputRelocation &Reloc : OutRelocations)
     applyRelocation(Buf, Reloc);
 }
 
-void InputChunk::writeTo(uint8_t *SectionStart) const {
-  memcpy(SectionStart + getOutputOffset(), data().data(), data().size());
-  applyRelocations(SectionStart, OutRelocations);
-}
-
 // Populate OutRelocations based on the input relocations and offset within the
 // output section.  Calculates the updated index and offset for each relocation
 // as well as the value to write out in the final binary.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43406.134740.patch
Type: text/x-patch
Size: 1645 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180216/571a835a/attachment.bin>


More information about the llvm-commits mailing list