[lld] [lld-macho] Choose ICF root function deterministically based on symbol names (PR #158157)

Ellis Hoag via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 3 15:42:43 PST 2025


================
@@ -408,11 +408,35 @@ void ICF::run() {
         // When using safe_thunks, ensure that we first sort by icfEqClass and
         // then by keepUnique (descending). This guarantees that within an
         // equivalence class, the keepUnique inputs are always first.
-        if (config->icfLevel == ICFLevel::safe_thunks)
-          if (a->icfEqClass[0] == b->icfEqClass[0])
-            return a->keepUnique > b->keepUnique;
+        if (a->icfEqClass[0] == b->icfEqClass[0]) {
----------------
ellishg wrote:

Early return and I think we can unindent this code block one level.

```suggestion
        if (a->icfEqClass[0] != b->icfEqClass[0])
          return a->icfEqClass[0] < b->icfEqClass[0];
```

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


More information about the llvm-commits mailing list