[lld] [lld][InstrProf] Do not use cstring offset hashes in function order for compression (PR #113606)

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 24 11:32:41 PDT 2024


https://github.com/SharonXSharon created https://github.com/llvm/llvm-project/pull/113606


Using the hashes of cstring offset turned to have very minimal impact on the compressed size of large iOS apps. The patch removes that code, thus the cstring symbols will be treated the same way as other defined symbols in terms of hashes calculation.

>From 71cc70577515e18896bff52f4cf8fc1f59020501 Mon Sep 17 00:00:00 2001
From: SharonXSharon <xiaoranxu.nju at gmail.com>
Date: Thu, 24 Oct 2024 11:30:16 -0700
Subject: [PATCH] [lld][InstrProf] Do not use cstring offset hashes in function
 order for compression

Using the hashes of cstring offset turned to have very minimal impact on the compressed size of large iOS apps. The patch removes that code, thus the cstring symbols will be treated the same way as other defined symbols in terms of hashes calculation.
---
 lld/MachO/BPSectionOrderer.cpp | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/lld/MachO/BPSectionOrderer.cpp b/lld/MachO/BPSectionOrderer.cpp
index 07b44d48d65932..5db2242a35ef28 100644
--- a/lld/MachO/BPSectionOrderer.cpp
+++ b/lld/MachO/BPSectionOrderer.cpp
@@ -53,11 +53,8 @@ getRelocHash(const Reloc &reloc,
     kind = ("Section " + Twine(static_cast<uint8_t>(isec->kind()))).str();
   if (auto *sym = reloc.referent.dyn_cast<Symbol *>()) {
     kind += (" Symbol " + Twine(static_cast<uint8_t>(sym->kind()))).str();
-    if (auto *d = dyn_cast<Defined>(sym)) {
-      if (isa_and_nonnull<CStringInputSection>(isec))
-        return getRelocHash(kind, 0, isec->getOffset(d->value), reloc.addend);
+    if (auto *d = dyn_cast<Defined>(sym))
       return getRelocHash(kind, sectionIdx.value_or(0), d->value, reloc.addend);
-    }
   }
   return getRelocHash(kind, sectionIdx.value_or(0), 0, reloc.addend);
 }



More information about the llvm-commits mailing list