[PATCH] D104169: [lld-macho] Put back shouldOmitFromOutput() asserts
Jez Ng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 11 19:01:21 PDT 2021
int3 created this revision.
int3 added reviewers: lld-macho, thakis.
Herald added a reviewer: gkm.
Herald added a project: lld-macho.
int3 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
I removed them in rG5de7467e982 <https://reviews.llvm.org/rG5de7467e9821485f492eb97fafd796e1db4c6bb5> but @thakis pointed out that
they were useful to keep, so here they are again. I've also converted
the `!isCoalescedWeak()` asserts into `!shouldOmitFromOutput()` asserts,
since the latter check subsumes the former.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D104169
Files:
lld/MachO/InputSection.cpp
lld/MachO/InputSection.h
lld/MachO/MapFile.cpp
lld/MachO/UnwindInfoSection.cpp
Index: lld/MachO/UnwindInfoSection.cpp
===================================================================
--- lld/MachO/UnwindInfoSection.cpp
+++ lld/MachO/UnwindInfoSection.cpp
@@ -174,6 +174,7 @@
}
if (auto *referentIsec = r.referent.dyn_cast<InputSection *>()) {
+ assert(!shouldOmitFromOutput(referentIsec));
// Personality functions can be referenced via section relocations
// if they live in the same object file. Create placeholder synthetic
// symbols for them in the GOT.
Index: lld/MachO/MapFile.cpp
===================================================================
--- lld/MachO/MapFile.cpp
+++ lld/MachO/MapFile.cpp
@@ -65,8 +65,10 @@
if (isa<ObjFile>(file))
for (Symbol *sym : file->symbols)
if (auto *d = dyn_cast_or_null<Defined>(sym))
- if (d->isLive() && d->isec && d->getFile() == file)
+ if (d->isLive() && d->isec && d->getFile() == file) {
+ assert(!shouldOmitFromOutput(d->isec));
v.push_back(d);
+ }
return v;
}
@@ -142,6 +144,7 @@
os << "# Address\t File Name\n";
for (InputSection *isec : inputSections) {
auto symsIt = sectionSyms.find(isec);
+ assert(!shouldOmitFromOutput(isec) || (symsIt == sectionSyms.end()));
if (symsIt == sectionSyms.end())
continue;
for (Symbol *sym : symsIt->second) {
Index: lld/MachO/InputSection.h
===================================================================
--- lld/MachO/InputSection.h
+++ lld/MachO/InputSection.h
@@ -113,6 +113,12 @@
uint64_t outSecFileOff = 0;
};
+// Helper function to make it easy to sprinkle asserts.
+inline bool shouldOmitFromOutput(InputSection *isec) {
+ return isa<ConcatInputSection>(isec) &&
+ cast<ConcatInputSection>(isec)->shouldOmitFromOutput();
+}
+
// We allocate a lot of these and binary search on them, so they should be as
// compact as possible. Hence the use of 31 rather than 64 bits for the hash.
struct StringPiece {
Index: lld/MachO/InputSection.cpp
===================================================================
--- lld/MachO/InputSection.cpp
+++ lld/MachO/InputSection.cpp
@@ -68,6 +68,7 @@
minuendVA = toSym->getVA() + minuend.addend;
else {
auto *referentIsec = minuend.referent.get<InputSection *>();
+ assert(!::shouldOmitFromOutput(referentIsec));
minuendVA = referentIsec->getVA(minuend.addend);
}
referentVA = minuendVA - fromSym->getVA();
@@ -86,6 +87,7 @@
referentVA -= firstTLVDataSection->addr;
}
} else if (auto *referentIsec = r.referent.dyn_cast<InputSection *>()) {
+ assert(!::shouldOmitFromOutput(referentIsec));
referentVA = referentIsec->getVA(r.addend);
}
target->relocateOne(loc, r, referentVA, getVA() + r.offset);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104169.351618.patch
Type: text/x-patch
Size: 2827 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210612/c608eb91/attachment.bin>
More information about the llvm-commits
mailing list