24enum class DWARFSectionKindV2 {
30 DW_SECT_STR_OFFSETS = 6,
39 return ID >= DW_SECT_INFO && ID <= DW_SECT_RNGLISTS &&
44 unsigned IndexVersion) {
45 if (IndexVersion == 5) {
53 return static_cast<uint32_t>(DWARFSectionKindV2::DW_SECT_##T)
59 CASE(STR_OFFSETS, STR_OFFSETS);
60 CASE(EXT_MACINFO, MACINFO);
70 unsigned IndexVersion) {
71 if (IndexVersion == 5)
76 switch (
static_cast<DWARFSectionKindV2
>(
Value)) {
78 case DWARFSectionKindV2::DW_SECT_##S: \
85 CASE(STR_OFFSETS, STR_OFFSETS);
86 CASE(MACINFO, EXT_MACINFO);
95 const uint64_t BeginOffset = *OffsetPtr;
102 Version = IndexData.
getU32(OffsetPtr);
104 *OffsetPtr = BeginOffset;
105 Version = IndexData.
getU16(OffsetPtr);
110 NumColumns = IndexData.
getU32(OffsetPtr);
111 NumUnits = IndexData.
getU32(OffsetPtr);
112 NumBuckets = IndexData.
getU32(OffsetPtr);
116void DWARFUnitIndex::Header::dump(raw_ostream &OS)
const {
117 OS <<
formatv(
"version = {0}, units = {1}, slots = {2}\n\n",
Version,
118 NumUnits, NumBuckets);
122 bool b = parseImpl(IndexData);
125 Header.NumBuckets = 0;
135 if (!Header.parse(IndexData, &
Offset))
139 if (Header.Version == 5)
140 InfoColumnKind = DW_SECT_INFO;
143 Offset, Header.NumBuckets * (8 + 4) +
144 (2 * Header.NumUnits + 1) * 4 * Header.NumColumns))
147 Rows = std::make_unique<Entry[]>(Header.NumBuckets);
149 std::make_unique<Entry::SectionContribution *[]>(Header.NumUnits);
150 ColumnKinds = std::make_unique<DWARFSectionKind[]>(Header.NumColumns);
151 RawSectionIds = std::make_unique<uint32_t[]>(Header.NumColumns);
154 for (
unsigned i = 0; i != Header.NumBuckets; ++i)
158 for (
unsigned i = 0; i != Header.NumBuckets; ++i) {
162 Rows[i].Index =
this;
163 Rows[i].Contributions =
164 std::make_unique<Entry::SectionContribution[]>(Header.NumColumns);
165 Contribs[Index - 1] = Rows[i].Contributions.get();
169 for (
unsigned i = 0; i != Header.NumColumns; ++i) {
172 if (ColumnKinds[i] == InfoColumnKind) {
173 if (InfoColumn != -1)
179 if (InfoColumn == -1)
183 for (
unsigned i = 0; i != Header.NumUnits; ++i) {
184 auto *Contrib = Contribs[i];
185 for (
unsigned i = 0; i != Header.NumColumns; ++i)
190 for (
unsigned i = 0; i != Header.NumUnits; ++i) {
191 auto *Contrib = Contribs[i];
192 for (
unsigned i = 0; i != Header.NumColumns; ++i)
201#define HANDLE_DW_SECT(ID, NAME) \
202 case DW_SECT_##NAME: \
204#include "llvm/BinaryFormat/Dwarf.def"
222 OS <<
"Index Signature ";
223 for (
unsigned i = 0; i != Header.NumColumns; ++i) {
229 Kind == DWARFSectionKind::DW_SECT_INFO ? 40 : 24);
231 OS <<
formatv(
" Unknown: {0,-15}", RawSectionIds[i]);
233 OS <<
"\n----- ------------------";
234 for (
unsigned i = 0; i != Header.NumColumns; ++i) {
236 if (Kind == DWARFSectionKind::DW_SECT_INFO ||
238 OS <<
" ----------------------------------------";
240 OS <<
" ------------------------";
243 for (
unsigned i = 0; i != Header.NumBuckets; ++i) {
245 if (
auto *Contribs = Row.Contributions.get()) {
246 OS <<
formatv(
"{0,5} {1:x16} ", i + 1, Row.Signature);
247 for (
unsigned i = 0; i != Header.NumColumns; ++i) {
248 auto &Contrib = Contribs[i];
250 if (Kind == DWARFSectionKind::DW_SECT_INFO ||
252 OS <<
formatv(
"[{0:x16}, {1:x16}) ", Contrib.getOffset(),
253 Contrib.getOffset() + Contrib.getLength());
255 OS <<
formatv(
"[{0:x8}, {1:x8}) ", Contrib.getOffset32(),
256 Contrib.getOffset32() + Contrib.getLength32());
266 for (; i != Index->Header.NumColumns; ++i)
267 if (Index->ColumnKinds[i] == Sec)
268 return &Contributions[i];
274 return Contributions[Index->InfoColumn];
279 return &Contributions[Index->InfoColumn];
284 if (OffsetLookup.empty()) {
285 for (
uint32_t i = 0; i != Header.NumBuckets; ++i)
286 if (Rows[i].Contributions)
287 OffsetLookup.push_back(&Rows[i]);
289 return E1->Contributions[InfoColumn].getOffset() <
290 E2->Contributions[InfoColumn].getOffset();
294 return E2->Contributions[InfoColumn].getOffset() <=
Offset;
296 if (
I == OffsetLookup.begin())
300 const auto &InfoContrib = E->Contributions[InfoColumn];
301 if ((InfoContrib.getOffset() + InfoContrib.getLength()) <=
Offset)
307 uint64_t Mask = Header.NumBuckets - 1;
310 auto HP = ((S >> 32) & Mask) | 1;
318 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.