[PATCH] D33183: [ELF] - Simplify readAddressArea() implementation.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 15 03:11:48 PDT 2017
grimar created this revision.
Herald added a subscriber: aprantl.
This patch depends on a change for LLVM DWARF parsers, I'll post it in a few minutes as
a separate patch.
Approach significantly simplifies LLD .gdb_index code and makes it much faster.
Also it should resolve issues, like https://reviews.llvm.org/D33176 tries to address once and forever in a clean way.
LLC binary linking without patch and without --gdb-index: 1,599241063
LLC binary linking without patch and with --gdb-index: 6,064316262
LLC binary linking with patch and with --gdb-index: 4,116792104
Time spent for building gdbindex changes from (6,064316262 - 1,599241063 == 4,465075199)
to (4,116792104- 1,599241063 == 2,517551041).
That is 2,517551041/4,465075199 = 0,564 or about 44% speedup.
https://reviews.llvm.org/D33183
Files:
ELF/SyntheticSections.cpp
Index: ELF/SyntheticSections.cpp
===================================================================
--- ELF/SyntheticSections.cpp
+++ ELF/SyntheticSections.cpp
@@ -1701,16 +1701,6 @@
return Ret;
}
-static InputSectionBase *findSection(ArrayRef<InputSectionBase *> Arr,
- uint64_t Offset) {
- for (InputSectionBase *S : Arr)
- if (S && S != &InputSection::Discarded)
- if (Offset >= S->getOffsetInFile() &&
- Offset < S->getOffsetInFile() + S->getSize())
- return S;
- return nullptr;
-}
-
static std::vector<AddressEntry>
readAddressArea(DWARFContext &Dwarf, InputSection *Sec, size_t CurrentCU) {
std::vector<AddressEntry> Ret;
@@ -1720,10 +1710,12 @@
CU->collectAddressRanges(Ranges);
ArrayRef<InputSectionBase *> Sections = Sec->File->getSections();
- for (std::pair<uint64_t, uint64_t> &R : Ranges)
- if (InputSectionBase *S = findSection(Sections, R.first))
- Ret.push_back({S, R.first - S->getOffsetInFile(),
- R.second - S->getOffsetInFile(), CurrentCU});
+ for (DWARFAddress &R : Ranges) {
+ InputSectionBase *S = Sections[R.SecNdx];
+ if (!S || S == &InputSection::Discarded)
+ continue;
+ Ret.push_back({S, R.LowPC, R.HighPC, CurrentCU});
+ }
++CurrentCU;
}
return Ret;
@@ -1744,27 +1736,15 @@
return Ret;
}
-class ObjInfoTy : public llvm::LoadedObjectInfo {
- uint64_t getSectionLoadAddress(const object::SectionRef &Sec) const override {
- auto &S = static_cast<const object::ELFSectionRef &>(Sec);
- if (S.getFlags() & ELF::SHF_ALLOC)
- return S.getOffset();
- return 0;
- }
-
- std::unique_ptr<llvm::LoadedObjectInfo> clone() const override { return {}; }
-};
-
void GdbIndexSection::readDwarf(InputSection *Sec) {
Expected<std::unique_ptr<object::ObjectFile>> Obj =
object::ObjectFile::createObjectFile(Sec->File->MB);
if (!Obj) {
error(toString(Sec->File) + ": error creating DWARF context");
return;
}
- ObjInfoTy ObjInfo;
- DWARFContextInMemory Dwarf(*Obj.get(), &ObjInfo);
+ DWARFContextInMemory Dwarf(*Obj.get());
size_t CuId = CompilationUnits.size();
for (std::pair<uint64_t, uint64_t> &P : readCuList(Dwarf, Sec))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33183.98964.patch
Type: text/x-patch
Size: 2262 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170515/24572cb7/attachment.bin>
More information about the llvm-commits
mailing list