[lld] bf45791 - [lld-macho][nfc] Remove unnecessary dyn_cast and simplify code
Jez Ng via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 28 11:51:07 PDT 2021
Author: Jez Ng
Date: 2021-06-28T14:50:44-04:00
New Revision: bf457919f2db496b8fbca0a3f5f25b33c4e9b8f1
URL: https://github.com/llvm/llvm-project/commit/bf457919f2db496b8fbca0a3f5f25b33c4e9b8f1
DIFF: https://github.com/llvm/llvm-project/commit/bf457919f2db496b8fbca0a3f5f25b33c4e9b8f1.diff
LOG: [lld-macho][nfc] Remove unnecessary dyn_cast and simplify code
Added:
Modified:
lld/MachO/UnwindInfoSection.cpp
Removed:
################################################################################
diff --git a/lld/MachO/UnwindInfoSection.cpp b/lld/MachO/UnwindInfoSection.cpp
index 6e9f4ff92aa2..f4bd08d2f3cb 100644
--- a/lld/MachO/UnwindInfoSection.cpp
+++ b/lld/MachO/UnwindInfoSection.cpp
@@ -231,7 +231,7 @@ relocateCompactUnwind(ConcatOutputSection *compactUnwindSection,
memcpy(buf, isec->data.data(), isec->data.size());
for (const Reloc &r : isec->relocs) {
- uint64_t referentVA = 0;
+ uint64_t referentVA = UINT64_MAX; // Tombstone value
if (auto *referentSym = r.referent.dyn_cast<Symbol *>()) {
if (!isa<Undefined>(referentSym)) {
assert(referentSym->isInGot());
@@ -242,14 +242,12 @@ relocateCompactUnwind(ConcatOutputSection *compactUnwindSection,
// that we can distinguish the null pointer case.
referentVA = referentSym->gotIndex + 1;
}
- } else if (auto *referentIsec = r.referent.dyn_cast<InputSection *>()) {
+ } else {
+ auto *referentIsec = r.referent.get<InputSection *>();
ConcatInputSection *concatIsec = checkTextSegment(referentIsec);
- if (concatIsec->shouldOmitFromOutput())
- referentVA = UINT64_MAX; // Tombstone value
- else
+ if (!concatIsec->shouldOmitFromOutput())
referentVA = referentIsec->getVA(r.addend);
}
-
writeAddress(buf + r.offset, referentVA, r.length);
}
}
More information about the llvm-commits
mailing list