[lld] [lld-macho] icf objc stubs (PR #79730)
    Jez Ng via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Mon Jan 29 16:51:19 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,
----------------
int3 wrote:
Multiplying by `align` seems kind of weird. It just happens to equal `target->wordSize`, but we should just reference wordSize directly
(I know this is existing code)
https://github.com/llvm/llvm-project/pull/79730
    
    
More information about the llvm-commits
mailing list