[lld] [lld] Merge GOT entries for symbols that have been ICFed (PR #131630)

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 26 15:13:16 PDT 2025


================
@@ -262,15 +262,10 @@ bool ICF<ELFT>::constantEq(const InputSection *secA, Relocs<RelTy> ra,
     auto *db = dyn_cast<Defined>(&sb);
 
     // Placeholder symbols generated by linker scripts look the same now but
-    // may have different values later.
-    if (!da || !db || da->scriptDefined || db->scriptDefined)
-      return false;
-
-    // When comparing a pair of relocations, if they refer to different symbols,
-    // and either symbol is preemptible, the containing sections should be
-    // considered different. This is because even if the sections are identical
-    // in this DSO, they may not be after preemption.
-    if (da->isPreemptible || db->isPreemptible)
+    // may have different values later. Similarly, preemptible symbols may be
+    // different after preemption. When comparing a pair of relocation, if they
+    // refer to different symbols, containing sections should be treated different.
----------------
rnk wrote:

```suggestion
    // different after preemption. When comparing a pair of relocations, if they
    // refer to different symbols, the containing sections should be considered different.
```

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


More information about the llvm-commits mailing list