[lld] [lld][ELF] Fix a corner case of elf::getLoongArchPageDelta (PR #71907)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 17 23:23:08 PST 2023


================
@@ -159,6 +159,10 @@ uint64_t elf::getLoongArchPageDelta(uint64_t dest, uint64_t pc) {
   bool negativeA = lo12(dest) > 0x7ff;
   bool negativeB = (result & 0x8000'0000) != 0;
 
+  // A corner case; directly return the expected result.
+  if (result == 0xfffffffffffff000 && negativeA)
+    return result = 0xffffffff00000000;
----------------
MaskRay wrote:

This special case should probably be added inside `if (negativeA) { ... }` so that it reads less magic.

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


More information about the llvm-commits mailing list