[lld] r325538 - Merge two small functions and add comments.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 19 14:44:18 PST 2018


Author: ruiu
Date: Mon Feb 19 14:44:18 2018
New Revision: 325538

URL: http://llvm.org/viewvc/llvm-project?rev=325538&view=rev
Log:
Merge two small functions and add comments.

Differential Revision: https://reviews.llvm.org/D43406

Modified:
    lld/trunk/wasm/InputChunks.cpp

Modified: lld/trunk/wasm/InputChunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/InputChunks.cpp?rev=325538&r1=325537&r2=325538&view=diff
==============================================================================
--- lld/trunk/wasm/InputChunks.cpp (original)
+++ lld/trunk/wasm/InputChunks.cpp Mon Feb 19 14:44:18 2018
@@ -78,19 +78,19 @@ static void applyRelocation(uint8_t *Buf
   }
 }
 
-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.




More information about the llvm-commits mailing list