[lld] [lld][WebAssembly]: Defer __wasm_apply_data_relocs decision to writer… (PR #109249)

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 19 06:24:41 PDT 2024


================
@@ -1467,15 +1469,29 @@ void Writer::createApplyDataRelocationsFunction() {
   {
     raw_string_ostream os(bodyContent);
     writeUleb128(os, 0, "num locals");
+    uint64_t off = os.tell();
     for (const OutputSegment *seg : segments)
       if (!config->sharedMemory || !seg->isTLS())
         for (const InputChunk *inSeg : seg->inputSegments)
           inSeg->generateRelocationCode(os);
----------------
sbc100 wrote:

Would it be cleaner to return a boolean from `generateRelocationCode`? 

i.e.

```
wroteRelocations |= inSeg->generateRelocationCode(os);
...
if (!wroteRelocations) {
  return;
}
```

Not a big deal but it seems more explictly/obvious.

https://github.com/llvm/llvm-project/pull/109249


More information about the llvm-commits mailing list