[lld] [lld-macho] icf objc stubs (PR #79730)

Kyungwoo Lee via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 29 23:46:27 PST 2024


================
@@ -865,12 +910,13 @@ void ObjCStubsSection::setUp() {
                                 /*align=*/target->wordSize);
   in.objcSelrefs->live = true;
 
-  for (size_t i = 0, n = offsets.size(); i < n; ++i) {
+  for (const auto &[methname, idxOffsetPair] : methnameToidxOffsetPair) {
+    const auto &[idx, offset] = idxOffsetPair;
     in.objcSelrefs->relocs.push_back(
         {/*type=*/target->unsignedRelocType,
          /*pcrel=*/false, /*length=*/3,
-         /*offset=*/static_cast<uint32_t>(i * target->wordSize),
-         /*addend=*/offsets[i] * in.objcMethnameSection->align,
+         /*offset=*/static_cast<uint32_t>(idx * target->wordSize),
+         /*addend=*/offset * in.objcMethnameSection->align,
----------------
kyulee-com wrote:

I think `in.objcMethnameSection->align` is actually 1. yeah, it's a bit odd to multiply this, so I would just drop it.

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


More information about the llvm-commits mailing list