[PATCH] D105866: [lld-macho] Use intermediate arrays to store opcodes

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 15 18:53:57 PDT 2021


int3 added inline comments.


================
Comment at: lld/MachO/SyntheticSections.cpp:298-299
   if (lastBinding.segment != seg) {
-    os << static_cast<uint8_t>(BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB |
-                               seg->index);
-    encodeULEB128(offset, os);
+    opcodes.push_back(
+        {BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB | seg->index, offset});
     lastBinding.segment = seg;
----------------
thevinster wrote:
> int3 wrote:
> > ah I guess we need the cast
> Fwiw, the tests did pass. I'll revert to the old implementation. 
I get why we added the cast back, but the temporary seems unnecessary... we can construct it inline as part of the `push_back` statement.

Also, the cast is only needed for `BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB | seg->index` as `|` returns an `int` (regardless of the size of its operands). We don't need the cast for the other opcodes below

(I thought you meant 'revert' as in 'partial revert', didn't realize you were going to do a full one)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105866



More information about the llvm-commits mailing list