23enum class DWARFSectionKindV2 {
29 DW_SECT_STR_OFFSETS = 6,
38 return ID >= DW_SECT_INFO && ID <= DW_SECT_RNGLISTS &&
43 unsigned IndexVersion) {
44 if (IndexVersion == 5) {
52 return static_cast<uint32_t>(DWARFSectionKindV2::DW_SECT_##T)
58 CASE(STR_OFFSETS, STR_OFFSETS);
59 CASE(EXT_MACINFO, MACINFO);
69 unsigned IndexVersion) {
70 if (IndexVersion == 5)
75 switch (
static_cast<DWARFSectionKindV2
>(
Value)) {
77 case DWARFSectionKindV2::DW_SECT_##S: \
84 CASE(STR_OFFSETS, STR_OFFSETS);
85 CASE(MACINFO, EXT_MACINFO);
94 const uint64_t BeginOffset = *OffsetPtr;
101 Version = IndexData.
getU32(OffsetPtr);
103 *OffsetPtr = BeginOffset;
104 Version = IndexData.
getU16(OffsetPtr);
109 NumColumns = IndexData.
getU32(OffsetPtr);
110 NumUnits = IndexData.
getU32(OffsetPtr);
111 NumBuckets = IndexData.
getU32(OffsetPtr);
115void DWARFUnitIndex::Header::dump(raw_ostream &OS)
const {
116 OS <<
formatv(
"version = {0}, units = {1}, slots = {2}\n\n",
Version,
117 NumUnits, NumBuckets);
121 bool b = parseImpl(IndexData);
124 Header.NumBuckets = 0;
134 if (!Header.parse(IndexData, &
Offset))
138 if (Header.Version == 5)
139 InfoColumnKind = DW_SECT_INFO;
142 Offset, Header.NumBuckets * (8 + 4) +
143 (2 * Header.NumUnits + 1) * 4 * Header.NumColumns))
146 Rows = std::make_unique<Entry[]>(Header.NumBuckets);
148 std::make_unique<Entry::SectionContribution *[]>(Header.NumUnits);
149 ColumnKinds = std::make_unique<DWARFSectionKind[]>(Header.NumColumns);
150 RawSectionIds = std::make_unique<uint32_t[]>(Header.NumColumns);
153 for (
unsigned i = 0; i != Header.NumBuckets; ++i)
157 for (
unsigned i = 0; i != Header.NumBuckets; ++i) {
161 Rows[i].Index =
this;
162 Rows[i].Contributions =
163 std::make_unique<Entry::SectionContribution[]>(Header.NumColumns);
164 Contribs[Index - 1] = Rows[i].Contributions.get();
168 for (
unsigned i = 0; i != Header.NumColumns; ++i) {
171 if (ColumnKinds[i] == InfoColumnKind) {
172 if (InfoColumn != -1)
178 if (InfoColumn == -1)
182 for (
unsigned i = 0; i != Header.NumUnits; ++i) {
183 auto *Contrib = Contribs[i];
184 for (
unsigned i = 0; i != Header.NumColumns; ++i)
189 for (
unsigned i = 0; i != Header.NumUnits; ++i) {
190 auto *Contrib = Contribs[i];
191 for (
unsigned i = 0; i != Header.NumColumns; ++i)
200#define HANDLE_DW_SECT(ID, NAME) \
201 case DW_SECT_##NAME: \
203#include "llvm/BinaryFormat/Dwarf.def"
221 OS <<
"Index Signature ";
222 for (
unsigned i = 0; i != Header.NumColumns; ++i) {
228 Kind == DWARFSectionKind::DW_SECT_INFO ? 40 : 24);
230 OS <<
formatv(
" Unknown: {0,-15}", RawSectionIds[i]);
232 OS <<
"\n----- ------------------";
233 for (
unsigned i = 0; i != Header.NumColumns; ++i) {
235 if (Kind == DWARFSectionKind::DW_SECT_INFO ||
237 OS <<
" ----------------------------------------";
239 OS <<
" ------------------------";
242 for (
unsigned i = 0; i != Header.NumBuckets; ++i) {
244 if (
auto *Contribs = Row.Contributions.get()) {
245 OS <<
formatv(
"{0,5} {1:x16} ", i + 1, Row.Signature);
246 for (
unsigned i = 0; i != Header.NumColumns; ++i) {
247 auto &Contrib = Contribs[i];
249 if (Kind == DWARFSectionKind::DW_SECT_INFO ||
251 OS <<
formatv(
"[{0:x16}, {1:x16}) ", Contrib.getOffset(),
252 Contrib.getOffset() + Contrib.getLength());
254 OS <<
formatv(
"[{0:x8}, {1:x8}) ", Contrib.getOffset32(),
255 Contrib.getOffset32() + Contrib.getLength32());
265 for (; i != Index->Header.NumColumns; ++i)
266 if (Index->ColumnKinds[i] == Sec)
267 return &Contributions[i];
273 return Contributions[Index->InfoColumn];
278 return &Contributions[Index->InfoColumn];
283 if (OffsetLookup.empty()) {
284 for (
uint32_t i = 0; i != Header.NumBuckets; ++i)
285 if (Rows[i].Contributions)
286 OffsetLookup.push_back(&Rows[i]);
288 return E1->Contributions[InfoColumn].getOffset() <
289 E2->Contributions[InfoColumn].getOffset();
293 return E2->Contributions[InfoColumn].getOffset() <=
Offset;
295 if (
I == OffsetLookup.begin())
299 const auto &InfoContrib = E->Contributions[InfoColumn];
300 if ((InfoContrib.getOffset() + InfoContrib.getLength()) <=
Offset)
306 uint64_t Mask = Header.NumBuckets - 1;
309 auto HP = ((S >> 32) & Mask) | 1;
317 if (Rows[
H].Index ==
nullptr)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
constexpr bool isKnownV5SectionID(uint32_t ID)
static std::string getSignature(FunctionType *FTy)
LLVM_ABI const SectionContribution * getContribution() const
LLVM_ABI void dump(raw_ostream &OS) const
LLVM_ABI bool parse(DataExtractor IndexData)
LLVM_ABI const Entry * getFromHash(uint64_t Offset) const
LLVM_ABI const Entry * getFromOffset(uint64_t Offset) const
Represent a constant reference to a string, i.e.
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
auto partition_point(R &&Range, Predicate P)
Binary search for the first iterator in a range where a predicate is false.
LLVM_ABI DWARFSectionKind deserializeSectionKind(uint32_t Value, unsigned IndexVersion)
Convert a value read from an index section to the internal representation.
DWARFSectionKind
The enum of section identifiers to be used in internal interfaces.
@ DW_SECT_EXT_unknown
Denotes a value read from an index section that does not correspond to any of the supported standards...
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
LLVM_ABI uint32_t serializeSectionKind(DWARFSectionKind Kind, unsigned IndexVersion)
Convert the internal value for a section kind to an on-disk value.
void sort(IteratorTy Start, IteratorTy End)
FormattedString left_justify(StringRef Str, unsigned Width)
left_justify - append spaces after string so total output is Width characters.