[lld] [LLD][COFF] Fix ARM64 EC chunks comparator (PR #75407)

via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 13 16:00:03 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-platform-windows

Author: Alexandre Ganea (aganea)

<details>
<summary>Changes</summary>

Fix string weak ordering relationship. Since we were only testing `!aType` before, `comp(a, b)` and `comp(b, a)` would both return `true`.

---
Full diff: https://github.com/llvm/llvm-project/pull/75407.diff


1 Files Affected:

- (modified) lld/COFF/Writer.cpp (+2-1) 


``````````diff
diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index 89e0f5b2df7441..0d28091efef2b1 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -1480,7 +1480,8 @@ void Writer::sortECChunks() {
       llvm::stable_sort(sec->chunks, [=](const Chunk *a, const Chunk *b) {
         std::optional<chpe_range_type> aType = a->getArm64ECRangeType(),
                                        bType = b->getArm64ECRangeType();
-        return !aType || (bType && *aType < *bType);
+        return (!aType ? 0 : (unsigned)*aType + 1) <
+               (!bType ? 0 : (unsigned)*bType + 1);
       });
   }
 }

``````````

</details>


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


More information about the llvm-commits mailing list