[lld] 1412719 - [lld/mac] Remove else-after-return in ICF code

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 20 11:24:23 PDT 2021


Author: Nico Weber
Date: 2021-10-20T14:24:13-04:00
New Revision: 1412719066a6efdfdb35a400d589d84a0ef83f28

URL: https://github.com/llvm/llvm-project/commit/1412719066a6efdfdb35a400d589d84a0ef83f28
DIFF: https://github.com/llvm/llvm-project/commit/1412719066a6efdfdb35a400d589d84a0ef83f28.diff

LOG: [lld/mac] Remove else-after-return in ICF code

No behavior change.

Added: 
    

Modified: 
    lld/MachO/ICF.cpp

Removed: 
    


################################################################################
diff  --git a/lld/MachO/ICF.cpp b/lld/MachO/ICF.cpp
index 370a325125ca1..8552918cd08a0 100644
--- a/lld/MachO/ICF.cpp
+++ b/lld/MachO/ICF.cpp
@@ -110,20 +110,18 @@ static bool equalsConstant(const ConcatInputSection *ia,
       const auto *sb = rb.referent.get<Symbol *>();
       if (sa->kind() != sb->kind())
         return false;
-      if (isa<Defined>(sa)) {
-        const auto *da = cast<Defined>(sa);
-        const auto *db = cast<Defined>(sb);
-        if (da->isec && db->isec) {
-          isecA = da->isec;
-          isecB = db->isec;
-        } else {
-          assert(da->isAbsolute() && db->isAbsolute());
-          return da->value == db->value;
-        }
-      } else {
+      if (!isa<Defined>(sa)) {
         assert(isa<DylibSymbol>(sa));
         return sa == sb;
       }
+      const auto *da = cast<Defined>(sa);
+      const auto *db = cast<Defined>(sb);
+      if (!da->isec || !db->isec) {
+        assert(da->isAbsolute() && db->isAbsolute());
+        return da->value == db->value;
+      }
+      isecA = da->isec;
+      isecB = db->isec;
     } else {
       isecA = ra.referent.get<InputSection *>();
       isecB = rb.referent.get<InputSection *>();


        


More information about the llvm-commits mailing list