llvm.org GIT mirror llvm / 2b32f85
dwarfdump: Improve performance on large DWP files git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342099 91177308-0d34-0410-b5e6-96231b3b80d8 David Blaikie 2 years ago
3 changed file(s) with 29 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
11291129 return std::lower_bound(adl_begin(Range), adl_end(Range), I);
11301130 }
11311131
1132 /// Provide wrappers to std::upper_bound which take ranges instead of having to
1133 /// pass begin/end explicitly.
1134 template
1135 auto upper_bound(R &&Range, ForwardIt I) -> decltype(adl_begin(Range)) {
1136 return std::upper_bound(adl_begin(Range), adl_end(Range), I);
1137 }
1138
11321139 /// Wrapper function around std::equal to detect if all elements
11331140 /// in a container are same.
11341141 template
7373 int InfoColumn = -1;
7474 std::unique_ptr ColumnKinds;
7575 std::unique_ptr Rows;
76 mutable std::vector OffsetLookup;
7677
7778 static StringRef getColumnHeader(DWARFSectionKind DS);
7879
163163
164164 const DWARFUnitIndex::Entry *
165165 DWARFUnitIndex::getFromOffset(uint32_t Offset) const {
166 for (uint32_t i = 0; i != Header.NumBuckets; ++i)
167 if (const auto &Contribs = Rows[i].Contributions) {
168 const auto &InfoContrib = Contribs[InfoColumn];
169 if (InfoContrib.Offset <= Offset &&
170 Offset < (InfoContrib.Offset + InfoContrib.Length))
171 return &Rows[i];
172 }
173 return nullptr;
166 if (OffsetLookup.empty()) {
167 for (uint32_t i = 0; i != Header.NumBuckets; ++i)
168 if (const auto &Contribs = Rows[i].Contributions)
169 OffsetLookup.push_back(&Rows[i]);
170 llvm::sort(OffsetLookup, [&](Entry *E1, Entry *E2) {
171 return E1->Contributions[InfoColumn].Offset <
172 E2->Contributions[InfoColumn].Offset;
173 });
174 }
175 auto I =
176 llvm::upper_bound(OffsetLookup, Offset, [&](uint32_t Offset, Entry *E2) {
177 return Offset < E2->Contributions[InfoColumn].Offset;
178 });
179 if (I == OffsetLookup.begin())
180 return nullptr;
181 --I;
182 const auto *E = *I;
183 const auto &InfoContrib = E->Contributions[InfoColumn];
184 if ((InfoContrib.Offset + InfoContrib.Length) <= Offset)
185 return nullptr;
186 return E;
174187 }
175188
176189 const DWARFUnitIndex::Entry *DWARFUnitIndex::getFromHash(uint64_t S) const {