LLVM 24.0.0git
DIE.h
Go to the documentation of this file.
1//===- lib/CodeGen/DIE.h - DWARF Info Entries -------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Data structures for DWARF info entries.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CODEGEN_DIE_H
14#define LLVM_CODEGEN_DIE_H
15
16#include "llvm/ADT/FoldingSet.h"
20#include "llvm/ADT/StringRef.h"
21#include "llvm/ADT/iterator.h"
28#include <cassert>
29#include <cstddef>
30#include <cstdint>
31#include <iterator>
32#include <new>
33#include <type_traits>
34#include <utility>
35#include <vector>
36
37namespace llvm {
38
39class AsmPrinter;
40class DIE;
41class DIEUnit;
43class MCExpr;
44class MCSection;
45class MCSymbol;
46class raw_ostream;
47
48//===--------------------------------------------------------------------===//
49/// Dwarf abbreviation data, describes one attribute of a Dwarf abbreviation.
51 /// Dwarf attribute code.
52 dwarf::Attribute Attribute;
53
54 /// Dwarf form code.
55 dwarf::Form Form;
56
57 /// Dwarf attribute value for DW_FORM_implicit_const
58 int64_t Value = 0;
59
60public:
62 : Attribute(A), Form(F) {}
64 : Attribute(A), Form(dwarf::DW_FORM_implicit_const), Value(V) {}
65
66 /// Accessors.
67 /// @{
68 dwarf::Attribute getAttribute() const { return Attribute; }
69 dwarf::Form getForm() const { return Form; }
70 int64_t getValue() const { return Value; }
71 /// @}
72
73 /// Used to gather unique data for the abbreviation folding set.
74 LLVM_ABI void Profile(FoldingSetNodeID &ID) const;
75};
76
77//===--------------------------------------------------------------------===//
78/// Dwarf abbreviation, describes the organization of a debug information
79/// object.
80class DIEAbbrev : public FoldingSetNode {
81 /// Unique number for node.
82 unsigned Number = 0;
83
84 /// Dwarf tag code.
85 dwarf::Tag Tag;
86
87 /// Whether or not this node has children.
88 ///
89 /// This cheats a bit in all of the uses since the values in the standard
90 /// are 0 and 1 for no children and children respectively.
91 bool Children;
92
93 /// Raw data bytes for abbreviation.
95
96public:
97 DIEAbbrev(dwarf::Tag T, bool C) : Tag(T), Children(C) {}
98
99 /// Accessors.
100 /// @{
101 dwarf::Tag getTag() const { return Tag; }
102 unsigned getNumber() const { return Number; }
103 bool hasChildren() const { return Children; }
104 const SmallVectorImpl<DIEAbbrevData> &getData() const { return Data; }
105 void setChildrenFlag(bool hasChild) { Children = hasChild; }
106 void setNumber(unsigned N) { Number = N; }
107 /// @}
108
109 /// Adds another set of attribute information to the abbreviation.
111 Data.push_back(DIEAbbrevData(Attribute, Form));
112 }
113
114 /// Adds attribute with DW_FORM_implicit_const value
118
119 /// Adds another set of attribute information to the abbreviation.
120 void AddAttribute(const DIEAbbrevData &AbbrevData) {
121 Data.push_back(AbbrevData);
122 }
123
124 /// Used to gather unique data for the abbreviation folding set.
125 LLVM_ABI void Profile(FoldingSetNodeID &ID) const;
126
127 /// Print the abbreviation using the specified asm printer.
128 LLVM_ABI void Emit(const AsmPrinter *AP) const;
129
130 LLVM_ABI void print(raw_ostream &O) const;
131 LLVM_ABI void dump() const;
132};
133
134//===--------------------------------------------------------------------===//
135/// Helps unique DIEAbbrev objects and assigns abbreviation numbers.
136///
137/// This class will unique the DIE abbreviations for a llvm::DIE object and
138/// assign a unique abbreviation number to each unique DIEAbbrev object it
139/// finds. The resulting collection of DIEAbbrev objects can then be emitted
140/// into the .debug_abbrev section.
142 /// The bump allocator to use when creating DIEAbbrev objects in the uniqued
143 /// storage container.
144 BumpPtrAllocator &Alloc;
145 /// FoldingSet that uniques the abbreviations.
146 FoldingSet<DIEAbbrev> AbbreviationsSet;
147 /// A list of all the unique abbreviations in use.
148 std::vector<DIEAbbrev *> Abbreviations;
149
150public:
153
154 /// Generate the abbreviation declaration for a DIE and return a pointer to
155 /// the generated abbreviation.
156 ///
157 /// \param Die the debug info entry to generate the abbreviation for.
158 /// \returns A reference to the uniqued abbreviation declaration that is
159 /// owned by this class.
161
162 /// Print all abbreviations using the specified asm printer.
163 LLVM_ABI void Emit(const AsmPrinter *AP, MCSection *Section) const;
164};
165
166//===--------------------------------------------------------------------===//
167/// An integer value DIE.
168///
170 uint64_t Integer;
171
172public:
173 explicit DIEInteger(uint64_t I) : Integer(I) {}
174
175 /// Choose the best form for integer.
176 static dwarf::Form BestForm(bool IsSigned, uint64_t Int) {
177 if (IsSigned) {
178 const int64_t SignedInt = Int;
179 if ((int8_t)Int == SignedInt)
180 return dwarf::DW_FORM_data1;
181 if ((int16_t)Int == SignedInt)
182 return dwarf::DW_FORM_data2;
183 if ((int32_t)Int == SignedInt)
184 return dwarf::DW_FORM_data4;
185 } else {
186 if ((uint8_t)Int == Int)
187 return dwarf::DW_FORM_data1;
188 if ((uint16_t)Int == Int)
189 return dwarf::DW_FORM_data2;
190 if ((uint32_t)Int == Int)
191 return dwarf::DW_FORM_data4;
192 }
193 return dwarf::DW_FORM_data8;
194 }
195
196 uint64_t getValue() const { return Integer; }
197 void setValue(uint64_t Val) { Integer = Val; }
198
199 LLVM_ABI void emitValue(const AsmPrinter *Asm, dwarf::Form Form) const;
200 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams,
201 dwarf::Form Form) const;
202
203 LLVM_ABI void print(raw_ostream &O) const;
204};
205
206//===--------------------------------------------------------------------===//
207/// An expression DIE.
208class DIEExpr {
209 const MCExpr *Expr;
210
211public:
212 explicit DIEExpr(const MCExpr *E) : Expr(E) {}
213
214 /// Get MCExpr.
215 const MCExpr *getValue() const { return Expr; }
216
217 LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const;
218 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams,
219 dwarf::Form Form) const;
220
221 LLVM_ABI void print(raw_ostream &O) const;
222};
223
224//===--------------------------------------------------------------------===//
225/// A label DIE.
226class DIELabel {
227 const MCSymbol *Label;
228
229public:
230 explicit DIELabel(const MCSymbol *L) : Label(L) {}
231
232 /// Get MCSymbol.
233 const MCSymbol *getValue() const { return Label; }
234
235 LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const;
236 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams,
237 dwarf::Form Form) const;
238
239 LLVM_ABI void print(raw_ostream &O) const;
240};
241
242//===--------------------------------------------------------------------===//
243/// A BaseTypeRef DIE.
245 const DwarfCompileUnit *CU;
246 const uint64_t Index;
247 static constexpr unsigned ULEB128PadSize = 4;
248
249public:
250 explicit DIEBaseTypeRef(const DwarfCompileUnit *TheCU, uint64_t Idx)
251 : CU(TheCU), Index(Idx) {}
252
253 /// EmitValue - Emit base type reference.
254 LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const;
255 /// sizeOf - Determine size of the base type reference in bytes.
256 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &, dwarf::Form) const;
257
258 LLVM_ABI void print(raw_ostream &O) const;
259 uint64_t getIndex() const { return Index; }
260};
261
262//===--------------------------------------------------------------------===//
263/// A simple label difference DIE.
264///
265class DIEDelta {
266 const MCSymbol *LabelHi;
267 const MCSymbol *LabelLo;
268
269public:
270 DIEDelta(const MCSymbol *Hi, const MCSymbol *Lo) : LabelHi(Hi), LabelLo(Lo) {}
271
272 LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const;
273 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams,
274 dwarf::Form Form) const;
275
276 LLVM_ABI void print(raw_ostream &O) const;
277};
278
279//===--------------------------------------------------------------------===//
280/// A container for string pool string values.
281///
282/// This class is used with the DW_FORM_strp and DW_FORM_GNU_str_index forms.
285
286public:
288
289 /// Grab the string out of the object.
290 StringRef getString() const { return S.getString(); }
291
292 LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const;
293 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams,
294 dwarf::Form Form) const;
295
296 LLVM_ABI void print(raw_ostream &O) const;
297};
298
299//===--------------------------------------------------------------------===//
300/// A container for inline string values.
301///
302/// This class is used with the DW_FORM_string form.
304 StringRef S;
305
306public:
307 template <typename Allocator>
308 explicit DIEInlineString(StringRef Str, Allocator &A) : S(Str.copy(A)) {}
309
310 ~DIEInlineString() = default;
311
312 /// Grab the string out of the object.
313 StringRef getString() const { return S; }
314
315 LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const;
316 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &, dwarf::Form) const;
317
318 LLVM_ABI void print(raw_ostream &O) const;
319};
320
321//===--------------------------------------------------------------------===//
322/// A pointer to another debug information entry. An instance of this class can
323/// also be used as a proxy for a debug information entry not yet defined
324/// (ie. types.)
325class DIEEntry {
326 DIE *Entry;
327
328public:
329 DIEEntry() = delete;
330 explicit DIEEntry(DIE &E) : Entry(&E) {}
331
332 DIE &getEntry() const { return *Entry; }
333
334 LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const;
335 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams,
336 dwarf::Form Form) const;
337
338 LLVM_ABI void print(raw_ostream &O) const;
339};
340
341//===--------------------------------------------------------------------===//
342/// Represents a pointer to a location list in the debug_loc
343/// section.
345 /// Index into the .debug_loc vector.
346 size_t Index;
347
348public:
349 DIELocList(size_t I) : Index(I) {}
350
351 /// Grab the current index out.
352 size_t getValue() const { return Index; }
353
354 LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const;
355 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams,
356 dwarf::Form Form) const;
357
358 LLVM_ABI void print(raw_ostream &O) const;
359};
360
361//===--------------------------------------------------------------------===//
362/// A BaseTypeRef DIE.
364 DIEInteger Addr;
365 DIEDelta Offset;
366
367public:
368 explicit DIEAddrOffset(uint64_t Idx, const MCSymbol *Hi, const MCSymbol *Lo)
369 : Addr(Idx), Offset(Hi, Lo) {}
370
371 LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const;
372 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams,
373 dwarf::Form Form) const;
374
375 LLVM_ABI void print(raw_ostream &O) const;
376};
377
378//===--------------------------------------------------------------------===//
379/// A debug information entry value. Some of these roughly correlate
380/// to DWARF attribute classes.
381class DIEBlock;
382class DIELoc;
383class DIEValue {
384public:
385 enum Type {
387#define HANDLE_DIEVALUE(T) is##T,
388#include "llvm/CodeGen/DIEValue.def"
389 };
390
391private:
392 /// Type of data stored in the value.
393 Type Ty = isNone;
394 dwarf::Attribute Attribute = (dwarf::Attribute)0;
395 dwarf::Form Form = (dwarf::Form)0;
396
397 /// Storage for the value.
398 ///
399 /// All values that aren't standard layout (or are larger than 8 bytes)
400 /// should be stored by reference instead of by value.
401 using ValTy =
402 AlignedCharArrayUnion<DIEInteger, DIEString, DIEExpr, DIELabel,
403 DIEDelta *, DIEEntry, DIEBlock *, DIELoc *,
404 DIELocList, DIEBaseTypeRef *, DIEAddrOffset *>;
405
406 static_assert(sizeof(ValTy) <= sizeof(uint64_t) ||
407 sizeof(ValTy) <= sizeof(void *),
408 "Expected all large types to be stored via pointer");
409
410 /// Underlying stored value.
411 ValTy Val;
412
413 template <class T> void construct(T V) {
414 static_assert(std::is_standard_layout<T>::value ||
415 std::is_pointer<T>::value,
416 "Expected standard layout or pointer");
417 new (reinterpret_cast<void *>(&Val)) T(V);
418 }
419
420 template <class T> T *get() { return reinterpret_cast<T *>(&Val); }
421 template <class T> const T *get() const {
422 return reinterpret_cast<const T *>(&Val);
423 }
424 template <class T> void destruct() { get<T>()->~T(); }
425
426 /// Destroy the underlying value.
427 ///
428 /// This should get optimized down to a no-op. We could skip it if we could
429 /// add a static assert on \a std::is_trivially_copyable(), but we currently
430 /// support versions of GCC that don't understand that.
431 void destroyVal() {
432 switch (Ty) {
433 case isNone:
434 return;
435#define HANDLE_DIEVALUE_SMALL(T) \
436 case is##T: \
437 destruct<DIE##T>(); \
438 return;
439#define HANDLE_DIEVALUE_LARGE(T) \
440 case is##T: \
441 destruct<const DIE##T *>(); \
442 return;
443#include "llvm/CodeGen/DIEValue.def"
444 }
445 }
446
447 /// Copy the underlying value.
448 ///
449 /// This should get optimized down to a simple copy. We need to actually
450 /// construct the value, rather than calling memcpy, to satisfy strict
451 /// aliasing rules.
452 void copyVal(const DIEValue &X) {
453 switch (Ty) {
454 case isNone:
455 return;
456#define HANDLE_DIEVALUE_SMALL(T) \
457 case is##T: \
458 construct<DIE##T>(*X.get<DIE##T>()); \
459 return;
460#define HANDLE_DIEVALUE_LARGE(T) \
461 case is##T: \
462 construct<const DIE##T *>(*X.get<const DIE##T *>()); \
463 return;
464#include "llvm/CodeGen/DIEValue.def"
465 }
466 }
467
468public:
469 DIEValue() = default;
470
471 DIEValue(const DIEValue &X) : Ty(X.Ty), Attribute(X.Attribute), Form(X.Form) {
472 copyVal(X);
473 }
474
476 if (this == &X)
477 return *this;
478 destroyVal();
479 Ty = X.Ty;
480 Attribute = X.Attribute;
481 Form = X.Form;
482 copyVal(X);
483 return *this;
484 }
485
486 ~DIEValue() { destroyVal(); }
487
488#define HANDLE_DIEVALUE_SMALL(T) \
489 DIEValue(dwarf::Attribute Attribute, dwarf::Form Form, const DIE##T &V) \
490 : Ty(is##T), Attribute(Attribute), Form(Form) { \
491 construct<DIE##T>(V); \
492 }
493#define HANDLE_DIEVALUE_LARGE(T) \
494 DIEValue(dwarf::Attribute Attribute, dwarf::Form Form, const DIE##T *V) \
495 : Ty(is##T), Attribute(Attribute), Form(Form) { \
496 assert(V && "Expected valid value"); \
497 construct<const DIE##T *>(V); \
498 }
499#include "llvm/CodeGen/DIEValue.def"
500
501 /// Accessors.
502 /// @{
503 Type getType() const { return Ty; }
504 dwarf::Attribute getAttribute() const { return Attribute; }
505 dwarf::Form getForm() const { return Form; }
506 explicit operator bool() const { return Ty; }
507 /// @}
508
509#define HANDLE_DIEVALUE_SMALL(T) \
510 const DIE##T &getDIE##T() const { \
511 assert(getType() == is##T && "Expected " #T); \
512 return *get<DIE##T>(); \
513 }
514#define HANDLE_DIEVALUE_LARGE(T) \
515 const DIE##T &getDIE##T() const { \
516 assert(getType() == is##T && "Expected " #T); \
517 return **get<const DIE##T *>(); \
518 }
519#include "llvm/CodeGen/DIEValue.def"
520
521 /// Emit value via the Dwarf writer.
522 LLVM_ABI void emitValue(const AsmPrinter *AP) const;
523
524 /// Return the size of a value in bytes.
525 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams) const;
526
527 LLVM_ABI void print(raw_ostream &O) const;
528 LLVM_ABI void dump() const;
529};
530
533
535
537 return Next.getInt() ? nullptr : Next.getPointer();
538 }
539};
540
543
544 Node *Last = nullptr;
545
546 bool empty() const { return !Last; }
547
548 void push_back(Node &N) {
549 assert(N.Next.getPointer() == &N && "Expected unlinked node");
550 assert(static_cast<bool>(N.Next.getInt()) == true &&
551 "Expected unlinked node");
552
553 if (Last) {
554 N.Next = Last->Next;
555 Last->Next.setPointerAndInt(&N, false);
556 }
557 Last = &N;
558 }
559
561 assert(N.Next.getPointer() == &N && "Expected unlinked node");
562 assert(static_cast<bool>(N.Next.getInt()) == true &&
563 "Expected unlinked node");
564
565 if (Last) {
566 N.Next.setPointerAndInt(Last->Next.getPointer(), false);
567 Last->Next.setPointerAndInt(&N, true);
568 } else {
569 Last = &N;
570 }
571 }
572
573 /// Delete node \p N by walking through the list until \p N's predecessor is
574 /// found. Remove \p N from the list by updating the predecessor's next
575 /// pointer and reset \p N's next pointer to itself.
577 if (!Last)
578 return false;
579
580 Node *Cur = Last;
581 while (Cur->Next.getPointer() != &N) {
582 Cur = Cur->Next.getPointer();
583 if (Cur->Next.getInt())
584 return false;
585 }
586
587 Node *Target = Cur->Next.getPointer();
588 if (Target == Cur) {
589 Last = nullptr;
590 } else if (Target == Last) {
591 Cur->Next.setPointerAndInt(Target->Next.getPointer(), true);
592 Last = Cur;
593 } else {
594 Cur->Next.setPointer(Target->Next.getPointer());
595 }
596
597 Target->Next.setPointerAndInt(Target, true);
598 return true;
599 }
600};
601
602template <class T> class IntrusiveBackList : IntrusiveBackListBase {
603public:
605
608
609 T &back() { return *static_cast<T *>(Last); }
610 const T &back() const { return *static_cast<T *>(Last); }
611 T &front() {
612 return *static_cast<T *>(Last ? Last->Next.getPointer() : nullptr);
613 }
614 const T &front() const {
615 return *static_cast<T *>(Last ? Last->Next.getPointer() : nullptr);
616 }
617
619 if (Other.empty())
620 return;
621
622 T *FirstNode = static_cast<T *>(Other.Last->Next.getPointer());
623 T *IterNode = FirstNode;
624 do {
625 // Keep a pointer to the node and increment the iterator.
626 T *TmpNode = IterNode;
627 IterNode = static_cast<T *>(IterNode->Next.getPointer());
628
629 // Unlink the node and push it back to this list.
630 TmpNode->Next.setPointerAndInt(TmpNode, true);
631 push_back(*TmpNode);
632 } while (IterNode != FirstNode);
633
634 Other.Last = nullptr;
635 }
636
637 /// Deletes node \p N from the list. Note this runs in O(N).
639
640 class const_iterator;
642 : public iterator_facade_base<iterator, std::forward_iterator_tag, T> {
643 friend class const_iterator;
644
645 Node *N = nullptr;
646
647 public:
648 iterator() = default;
649 explicit iterator(T *N) : N(N) {}
650
652 N = N->getNext();
653 return *this;
654 }
655
656 explicit operator bool() const { return N; }
657 T &operator*() const { return *static_cast<T *>(N); }
658
659 bool operator==(const iterator &X) const { return N == X.N; }
660 };
661
663 : public iterator_facade_base<const_iterator, std::forward_iterator_tag,
664 const T> {
665 const Node *N = nullptr;
666
667 public:
668 const_iterator() = default;
669 // Placate MSVC by explicitly scoping 'iterator'.
671 explicit const_iterator(const T *N) : N(N) {}
672
674 N = N->getNext();
675 return *this;
676 }
677
678 explicit operator bool() const { return N; }
679 const T &operator*() const { return *static_cast<const T *>(N); }
680
681 bool operator==(const const_iterator &X) const { return N == X.N; }
682 };
683
684 iterator begin() {
685 return Last ? iterator(static_cast<T *>(Last->Next.getPointer())) : end();
686 }
687 const_iterator begin() const {
688 return const_cast<IntrusiveBackList *>(this)->begin();
689 }
690 iterator end() { return iterator(); }
691 const_iterator end() const { return const_iterator(); }
692
693 static iterator toIterator(T &N) { return iterator(&N); }
694 static const_iterator toIterator(const T &N) { return const_iterator(&N); }
695};
696
697/// A list of DIE values.
698///
699/// This is a singly-linked list, but instead of reversing the order of
700/// insertion, we keep a pointer to the back of the list so we can push in
701/// order.
702///
703/// There are two main reasons to choose a linked list over a customized
704/// vector-like data structure.
705///
706/// 1. For teardown efficiency, we want DIEs to be BumpPtrAllocated. Using a
707/// linked list here makes this way easier to accomplish.
708/// 2. Carrying an extra pointer per \a DIEValue isn't expensive. 45% of DIEs
709/// have 2 or fewer values, and 90% have 5 or fewer. A vector would be
710/// over-allocated by 50% on average anyway, the same cost as the
711/// linked-list node.
713 struct Node : IntrusiveBackListNode {
714 DIEValue V;
715
716 explicit Node(DIEValue V) : V(V) {}
717 };
718
719 using ListTy = IntrusiveBackList<Node>;
720
721 ListTy List;
722
723public:
726 : public iterator_adaptor_base<value_iterator, ListTy::iterator,
727 std::forward_iterator_tag, DIEValue> {
729
730 using iterator_adaptor =
731 iterator_adaptor_base<value_iterator, ListTy::iterator,
732 std::forward_iterator_tag, DIEValue>;
733
734 public:
735 value_iterator() = default;
736 explicit value_iterator(ListTy::iterator X) : iterator_adaptor(X) {}
737
738 explicit operator bool() const { return bool(wrapped()); }
739 DIEValue &operator*() const { return wrapped()->V; }
740 };
741
743 const_value_iterator, ListTy::const_iterator,
744 std::forward_iterator_tag, const DIEValue> {
745 using iterator_adaptor =
746 iterator_adaptor_base<const_value_iterator, ListTy::const_iterator,
747 std::forward_iterator_tag, const DIEValue>;
748
749 public:
753 explicit const_value_iterator(ListTy::const_iterator X)
754 : iterator_adaptor(X) {}
755
756 explicit operator bool() const { return bool(wrapped()); }
757 const DIEValue &operator*() const { return wrapped()->V; }
758 };
759
762
764 List.push_back(*new (Alloc) Node(V));
765 return value_iterator(ListTy::toIterator(List.back()));
766 }
767 template <class T>
772
773 /* zr33: add method here */
774 template <class T>
776 dwarf::Attribute NewAttribute, dwarf::Form Form,
777 T &&NewValue) {
778 for (llvm::DIEValue &val : values()) {
779 if (val.getAttribute() == Attribute) {
780 val = *new (Alloc)
781 DIEValue(NewAttribute, Form, std::forward<T>(NewValue));
782 return true;
783 }
784 }
785
786 return false;
787 }
788
789 template <class T>
791 dwarf::Form Form, T &&NewValue) {
792 for (llvm::DIEValue &val : values()) {
793 if (val.getAttribute() == Attribute) {
794 val = *new (Alloc) DIEValue(Attribute, Form, std::forward<T>(NewValue));
795 return true;
796 }
797 }
798
799 return false;
800 }
801
803 dwarf::Form Form, DIEValue &NewValue) {
804 for (llvm::DIEValue &val : values()) {
805 if (val.getAttribute() == Attribute) {
806 val = NewValue;
807 return true;
808 }
809 }
810
811 return false;
812 }
813
815
816 for (auto &node : List) {
817 if (node.V.getAttribute() == Attribute) {
818 return List.deleteNode(node);
819 }
820 }
821
822 return false;
823 }
824 /* end */
825
826 /// Take ownership of the nodes in \p Other, and append them to the back of
827 /// the list.
828 void takeValues(DIEValueList &Other) { List.takeNodes(Other.List); }
829
831 return make_range(value_iterator(List.begin()), value_iterator(List.end()));
832 }
834 return make_range(const_value_iterator(List.begin()),
835 const_value_iterator(List.end()));
836 }
837};
838
839//===--------------------------------------------------------------------===//
840/// A structured debug information entry. Has an abbreviation which
841/// describes its organization.
843 friend class IntrusiveBackList<DIE>;
844 friend class DIEUnit;
845
846 /// Dwarf unit relative offset.
847 unsigned Offset = 0;
848 /// Size of instance + children.
849 unsigned Size = 0;
850 unsigned AbbrevNumber = ~0u;
851 /// Dwarf tag code.
852 dwarf::Tag Tag = (dwarf::Tag)0;
853 /// Set to true to force a DIE to emit an abbreviation that says it has
854 /// children even when it doesn't. This is used for unit testing purposes.
855 bool ForceChildren = false;
856 /// Children DIEs.
857 IntrusiveBackList<DIE> Children;
858
859 /// The owner is either the parent DIE for children of other DIEs, or a
860 /// DIEUnit which contains this DIE as its unit DIE.
862
863 explicit DIE(dwarf::Tag Tag) : Tag(Tag) {}
864
865public:
866 DIE() = delete;
867 DIE(const DIE &RHS) = delete;
868 DIE(DIE &&RHS) = delete;
869 DIE &operator=(const DIE &RHS) = delete;
870 DIE &operator=(const DIE &&RHS) = delete;
871
873 return new (Alloc) DIE(Tag);
874 }
875
876 // Accessors.
877 unsigned getAbbrevNumber() const { return AbbrevNumber; }
878 dwarf::Tag getTag() const { return Tag; }
879 /// Get the compile/type unit relative offset of this DIE.
880 unsigned getOffset() const {
881 // A real Offset can't be zero because the unit headers are at offset zero.
882 assert(Offset && "Offset being queried before it's been computed.");
883 return Offset;
884 }
885 unsigned getSize() const {
886 // A real Size can't be zero because it includes the non-empty abbrev code.
887 assert(Size && "Size being queried before it's been ocmputed.");
888 return Size;
889 }
890 bool hasChildren() const { return ForceChildren || !Children.empty(); }
891 void setForceChildren(bool B) { ForceChildren = B; }
892
897
899 return make_range(Children.begin(), Children.end());
900 }
902 return make_range(Children.begin(), Children.end());
903 }
904
905 LLVM_ABI DIE *getParent() const;
906
907 /// Generate the abbreviation for this DIE.
908 ///
909 /// Calculate the abbreviation for this, which should be uniqued and
910 /// eventually used to call \a setAbbrevNumber().
912
913 /// Set the abbreviation number for this DIE.
914 void setAbbrevNumber(unsigned I) { AbbrevNumber = I; }
915
916 /// Get the absolute offset within the .debug_info or .debug_types section
917 /// for this DIE.
919
920 /// Compute the offset of this DIE and all its children.
921 ///
922 /// This function gets called just before we are going to generate the debug
923 /// information and gives each DIE a chance to figure out its CU relative DIE
924 /// offset, unique its abbreviation and fill in the abbreviation code, and
925 /// return the unit offset that points to where the next DIE will be emitted
926 /// within the debug unit section. After this function has been called for all
927 /// DIE objects, the DWARF can be generated since all DIEs will be able to
928 /// properly refer to other DIE objects since all DIEs have calculated their
929 /// offsets.
930 ///
931 /// \param FormParams Used when calculating sizes.
932 /// \param AbbrevSet the abbreviation used to unique DIE abbreviations.
933 /// \param CUOffset the compile/type unit relative offset in bytes.
934 /// \returns the offset for the DIE that follows this DIE within the
935 /// current compile/type unit.
936 LLVM_ABI unsigned
938 DIEAbbrevSet &AbbrevSet, unsigned CUOffset);
939
940 /// Climb up the parent chain to get the compile unit or type unit DIE that
941 /// this DIE belongs to.
942 ///
943 /// \returns the compile or type unit DIE that owns this DIE, or NULL if
944 /// this DIE hasn't been added to a unit DIE.
945 LLVM_ABI const DIE *getUnitDie() const;
946
947 /// Climb up the parent chain to get the compile unit or type unit that this
948 /// DIE belongs to.
949 ///
950 /// \returns the DIEUnit that represents the compile or type unit that owns
951 /// this DIE, or NULL if this DIE hasn't been added to a unit DIE.
952 LLVM_ABI DIEUnit *getUnit() const;
953
954 void setOffset(unsigned O) { Offset = O; }
955 void setSize(unsigned S) { Size = S; }
956
957 /// Add a child to the DIE.
958 DIE &addChild(DIE *Child) {
959 assert(!Child->getParent() && "Child should be orphaned");
960 Child->Owner = this;
961 Children.push_back(*Child);
962 return Children.back();
963 }
964
965 DIE &addChildFront(DIE *Child) {
966 assert(!Child->getParent() && "Child should be orphaned");
967 Child->Owner = this;
968 Children.push_front(*Child);
969 return Children.front();
970 }
971
972 /// Find a value in the DIE with the attribute given.
973 ///
974 /// Returns a default-constructed DIEValue (where \a DIEValue::getType()
975 /// gives \a DIEValue::isNone) if no such attribute exists.
977
978 LLVM_ABI void print(raw_ostream &O, unsigned IndentCount = 0) const;
979 LLVM_ABI void dump() const;
980};
981
982//===--------------------------------------------------------------------===//
983/// Represents a compile or type unit.
984class DIEUnit {
985 /// The compile unit or type unit DIE. This variable must be an instance of
986 /// DIE so that we can calculate the DIEUnit from any DIE by traversing the
987 /// parent backchain and getting the Unit DIE, and then casting itself to a
988 /// DIEUnit. This allows us to be able to find the DIEUnit for any DIE without
989 /// having to store a pointer to the DIEUnit in each DIE instance.
990 DIE Die;
991 /// The section this unit will be emitted in. This may or may not be set to
992 /// a valid section depending on the client that is emitting DWARF.
993 MCSection *Section = nullptr;
994 uint64_t Offset = 0; /// .debug_info or .debug_types absolute section offset.
995protected:
996 virtual ~DIEUnit() = default;
997
998public:
999 LLVM_ABI explicit DIEUnit(dwarf::Tag UnitTag);
1000 DIEUnit(const DIEUnit &RHS) = delete;
1001 DIEUnit(DIEUnit &&RHS) = delete;
1002 void operator=(const DIEUnit &RHS) = delete;
1003 void operator=(const DIEUnit &&RHS) = delete;
1004 /// Set the section that this DIEUnit will be emitted into.
1005 ///
1006 /// This function is used by some clients to set the section. Not all clients
1007 /// that emit DWARF use this section variable.
1008 void setSection(MCSection *Section) {
1009 assert(!this->Section);
1010 this->Section = Section;
1011 }
1012
1014 return nullptr;
1015 }
1016
1017 /// Return the section that this DIEUnit will be emitted into.
1018 ///
1019 /// \returns Section pointer which can be NULL.
1020 MCSection *getSection() const { return Section; }
1021 void setDebugSectionOffset(uint64_t O) { Offset = O; }
1022 uint64_t getDebugSectionOffset() const { return Offset; }
1023 DIE &getUnitDie() { return Die; }
1024 const DIE &getUnitDie() const { return Die; }
1025};
1026
1027struct BasicDIEUnit final : DIEUnit {
1028 explicit BasicDIEUnit(dwarf::Tag UnitTag) : DIEUnit(UnitTag) {}
1029};
1030
1031//===--------------------------------------------------------------------===//
1032/// DIELoc - Represents an expression location.
1033//
1034class DIELoc : public DIEValueList {
1035 mutable unsigned Size = 0; // Size in bytes excluding size header.
1036
1037public:
1038 DIELoc() = default;
1039
1040 /// Calculate the size of the location expression.
1041 LLVM_ABI unsigned computeSize(const dwarf::FormParams &FormParams) const;
1042
1043 // TODO: move setSize() and Size to DIEValueList.
1044 void setSize(unsigned size) { Size = size; }
1045
1046 /// BestForm - Choose the best form for data.
1047 ///
1048 dwarf::Form BestForm(unsigned DwarfVersion) const {
1049 if (DwarfVersion > 3)
1050 return dwarf::DW_FORM_exprloc;
1051 // Pre-DWARF4 location expressions were blocks and not exprloc.
1052 if ((uint8_t)Size == Size)
1053 return dwarf::DW_FORM_block1;
1054 if ((uint16_t)Size == Size)
1055 return dwarf::DW_FORM_block2;
1056 if ((uint32_t)Size == Size)
1057 return dwarf::DW_FORM_block4;
1058 return dwarf::DW_FORM_block;
1059 }
1060
1061 LLVM_ABI void emitValue(const AsmPrinter *Asm, dwarf::Form Form) const;
1062 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &, dwarf::Form Form) const;
1063
1064 LLVM_ABI void print(raw_ostream &O) const;
1065};
1066
1067//===--------------------------------------------------------------------===//
1068/// DIEBlock - Represents a block of values.
1069//
1070class DIEBlock : public DIEValueList {
1071 mutable unsigned Size = 0; // Size in bytes excluding size header.
1072
1073public:
1074 DIEBlock() = default;
1075
1076 /// Calculate the size of the location expression.
1077 LLVM_ABI unsigned computeSize(const dwarf::FormParams &FormParams) const;
1078
1079 // TODO: move setSize() and Size to DIEValueList.
1080 void setSize(unsigned size) { Size = size; }
1081
1082 /// BestForm - Choose the best form for data.
1083 ///
1085 if ((uint8_t)Size == Size)
1086 return dwarf::DW_FORM_block1;
1087 if ((uint16_t)Size == Size)
1088 return dwarf::DW_FORM_block2;
1089 if ((uint32_t)Size == Size)
1090 return dwarf::DW_FORM_block4;
1091 return dwarf::DW_FORM_block;
1092 }
1093
1094 LLVM_ABI void emitValue(const AsmPrinter *Asm, dwarf::Form Form) const;
1095 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &, dwarf::Form Form) const;
1096
1097 LLVM_ABI void print(raw_ostream &O) const;
1098};
1099
1100} // end namespace llvm
1101
1102#endif // LLVM_CODEGEN_DIE_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
unsigned uint64_t
This file defines the BumpPtrAllocator interface.
#define X(NUM, ENUM, NAME)
Definition ELF.h:857
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_ABI
Definition Compiler.h:215
This file contains constants used for implementing Dwarf debug support.
This file defines a hash set that can be used to remove duplication of nodes in a graph.
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
Load MIR Sample Profile
#define T
This file defines the PointerIntPair class.
This file defines the PointerUnion class, which is a discriminated union of pointer types.
Basic Register Allocator
This file defines the SmallVector class.
Value * RHS
This class is intended to be used as a driving class for all asm writers.
Definition AsmPrinter.h:91
Functions, function parameters, and return types can have attributes to indicate how they should be t...
Definition Attributes.h:105
Dwarf abbreviation data, describes one attribute of a Dwarf abbreviation.
Definition DIE.h:50
dwarf::Form getForm() const
Definition DIE.h:69
dwarf::Attribute getAttribute() const
Accessors.
Definition DIE.h:68
DIEAbbrevData(dwarf::Attribute A, int64_t V)
Definition DIE.h:63
int64_t getValue() const
Definition DIE.h:70
DIEAbbrevData(dwarf::Attribute A, dwarf::Form F)
Definition DIE.h:61
Helps unique DIEAbbrev objects and assigns abbreviation numbers.
Definition DIE.h:141
LLVM_ABI ~DIEAbbrevSet()
Definition DIE.cpp:131
LLVM_ABI void Emit(const AsmPrinter *AP, MCSection *Section) const
Print all abbreviations using the specified asm printer.
Definition DIE.cpp:160
DIEAbbrevSet(BumpPtrAllocator &A)
Definition DIE.h:151
LLVM_ABI DIEAbbrev & uniqueAbbreviation(DIE &Die)
Generate the abbreviation declaration for a DIE and return a pointer to the generated abbreviation.
Definition DIE.cpp:136
Dwarf abbreviation, describes the organization of a debug information object.
Definition DIE.h:80
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:101
void AddImplicitConstAttribute(dwarf::Attribute Attribute, int64_t Value)
Adds attribute with DW_FORM_implicit_const value.
Definition DIE.h:115
unsigned getNumber() const
Definition DIE.h:102
LLVM_ABI void Emit(const AsmPrinter *AP) const
Print the abbreviation using the specified asm printer.
Definition DIE.cpp:62
void AddAttribute(dwarf::Attribute Attribute, dwarf::Form Form)
Adds another set of attribute information to the abbreviation.
Definition DIE.h:110
void AddAttribute(const DIEAbbrevData &AbbrevData)
Adds another set of attribute information to the abbreviation.
Definition DIE.h:120
const SmallVectorImpl< DIEAbbrevData > & getData() const
Definition DIE.h:104
DIEAbbrev(dwarf::Tag T, bool C)
Definition DIE.h:97
void setChildrenFlag(bool hasChild)
Definition DIE.h:105
dwarf::Tag getTag() const
Accessors.
Definition DIE.h:101
void setNumber(unsigned N)
Definition DIE.h:106
LLVM_ABI void dump() const
Definition DIE.cpp:122
bool hasChildren() const
Definition DIE.h:103
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:867
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
Definition DIE.cpp:853
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit label value.
Definition DIE.cpp:861
DIEAddrOffset(uint64_t Idx, const MCSymbol *Hi, const MCSymbol *Lo)
Definition DIE.h:368
uint64_t getIndex() const
Definition DIE.h:259
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit base type reference.
Definition DIE.cpp:519
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:530
DIEBaseTypeRef(const DwarfCompileUnit *TheCU, uint64_t Idx)
Definition DIE.h:250
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &, dwarf::Form) const
sizeOf - Determine size of the base type reference in bytes.
Definition DIE.cpp:525
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &, dwarf::Form Form) const
sizeOf - Determine size of block data in bytes.
Definition DIE.cpp:791
void setSize(unsigned size)
Definition DIE.h:1080
dwarf::Form BestForm() const
BestForm - Choose the best form for data.
Definition DIE.h:1084
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:804
DIEBlock()=default
LLVM_ABI void emitValue(const AsmPrinter *Asm, dwarf::Form Form) const
EmitValue - Emit block data.
Definition DIE.cpp:771
LLVM_ABI unsigned computeSize(const dwarf::FormParams &FormParams) const
Calculate the size of the location expression.
Definition DIE.cpp:760
A simple label difference DIE.
Definition DIE.h:265
DIEDelta(const MCSymbol *Hi, const MCSymbol *Lo)
Definition DIE.h:270
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:560
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
SizeOf - Determine size of delta value in bytes.
Definition DIE.cpp:545
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit delta value.
Definition DIE.cpp:538
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit debug information entry offset.
Definition DIE.cpp:647
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:702
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
Definition DIE.cpp:680
DIE & getEntry() const
Definition DIE.h:332
DIEEntry()=delete
DIEEntry(DIE &E)
Definition DIE.h:330
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:475
const MCExpr * getValue() const
Get MCExpr.
Definition DIE.h:215
DIEExpr(const MCExpr *E)
Definition DIE.h:212
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit expression value.
Definition DIE.cpp:454
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
SizeOf - Determine size of expression value in bytes.
Definition DIE.cpp:460
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
Definition DIE.cpp:622
~DIEInlineString()=default
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:637
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &, dwarf::Form) const
Definition DIE.cpp:631
StringRef getString() const
Grab the string out of the object.
Definition DIE.h:313
DIEInlineString(StringRef Str, Allocator &A)
Definition DIE.h:308
An integer value DIE.
Definition DIE.h:169
DIEInteger(uint64_t I)
Definition DIE.h:173
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
sizeOf - Determine size of integer value in bytes.
Definition DIE.cpp:421
uint64_t getValue() const
Definition DIE.h:196
void setValue(uint64_t Val)
Definition DIE.h:197
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:443
LLVM_ABI void emitValue(const AsmPrinter *Asm, dwarf::Form Form) const
EmitValue - Emit integer of appropriate size.
Definition DIE.cpp:364
static dwarf::Form BestForm(bool IsSigned, uint64_t Int)
Choose the best form for integer.
Definition DIE.h:176
const MCSymbol * getValue() const
Get MCSymbol.
Definition DIE.h:233
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit label value.
Definition DIE.cpp:487
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:513
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
sizeOf - Determine size of label value in bytes.
Definition DIE.cpp:495
DIELabel(const MCSymbol *L)
Definition DIE.h:230
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:847
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
Definition DIE.cpp:812
DIELocList(size_t I)
Definition DIE.h:349
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit label value.
Definition DIE.cpp:836
size_t getValue() const
Grab the current index out.
Definition DIE.h:352
void setSize(unsigned size)
Definition DIE.h:1044
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:752
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &, dwarf::Form Form) const
sizeOf - Determine size of location data in bytes.
Definition DIE.cpp:739
LLVM_ABI void emitValue(const AsmPrinter *Asm, dwarf::Form Form) const
EmitValue - Emit location data.
Definition DIE.cpp:721
LLVM_ABI unsigned computeSize(const dwarf::FormParams &FormParams) const
Calculate the size of the location expression.
Definition DIE.cpp:710
dwarf::Form BestForm(unsigned DwarfVersion) const
BestForm - Choose the best form for data.
Definition DIE.h:1048
DIELoc()=default
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit string value.
Definition DIE.cpp:570
DIEString(DwarfStringPoolEntryRef S)
Definition DIE.h:287
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:615
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
sizeOf - Determine size of delta value in bytes.
Definition DIE.cpp:594
StringRef getString() const
Grab the string out of the object.
Definition DIE.h:290
Represents a compile or type unit.
Definition DIE.h:984
void setSection(MCSection *Section)
Set the section that this DIEUnit will be emitted into.
Definition DIE.h:1008
void operator=(const DIEUnit &&RHS)=delete
DIEUnit(DIEUnit &&RHS)=delete
void operator=(const DIEUnit &RHS)=delete
const DIE & getUnitDie() const
Definition DIE.h:1024
DIEUnit(const DIEUnit &RHS)=delete
virtual const MCSymbol * getCrossSectionRelativeBaseAddress() const
Definition DIE.h:1013
LLVM_ABI DIEUnit(dwarf::Tag UnitTag)
Definition DIE.cpp:306
void setDebugSectionOffset(uint64_t O)
Definition DIE.h:1021
MCSection * getSection() const
Return the section that this DIEUnit will be emitted into.
Definition DIE.h:1020
DIE & getUnitDie()
Definition DIE.h:1023
virtual ~DIEUnit()=default
.debug_info or .debug_types absolute section offset.
uint64_t getDebugSectionOffset() const
Definition DIE.h:1022
const DIEValue & operator*() const
Definition DIE.h:757
const_value_iterator(DIEValueList::value_iterator X)
Definition DIE.h:751
const_value_iterator(ListTy::const_iterator X)
Definition DIE.h:753
friend class const_value_iterator
Definition DIE.h:728
value_iterator(ListTy::iterator X)
Definition DIE.h:736
DIEValue & operator*() const
Definition DIE.h:739
A list of DIE values.
Definition DIE.h:712
bool deleteValue(dwarf::Attribute Attribute)
Definition DIE.h:814
void takeValues(DIEValueList &Other)
Take ownership of the nodes in Other, and append them to the back of the list.
Definition DIE.h:828
bool replaceValue(BumpPtrAllocator &Alloc, dwarf::Attribute Attribute, dwarf::Attribute NewAttribute, dwarf::Form Form, T &&NewValue)
Definition DIE.h:775
bool replaceValue(BumpPtrAllocator &Alloc, dwarf::Attribute Attribute, dwarf::Form Form, T &&NewValue)
Definition DIE.h:790
value_range values()
Definition DIE.h:830
iterator_range< value_iterator > value_range
Definition DIE.h:760
value_iterator addValue(BumpPtrAllocator &Alloc, const DIEValue &V)
Definition DIE.h:763
const_value_range values() const
Definition DIE.h:833
iterator_range< const_value_iterator > const_value_range
Definition DIE.h:761
value_iterator addValue(BumpPtrAllocator &Alloc, dwarf::Attribute Attribute, dwarf::Form Form, T &&Value)
Definition DIE.h:768
bool replaceValue(BumpPtrAllocator &Alloc, dwarf::Attribute Attribute, dwarf::Form Form, DIEValue &NewValue)
Definition DIE.h:802
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:340
LLVM_ABI void emitValue(const AsmPrinter *AP) const
Emit value via the Dwarf writer.
Definition DIE.cpp:315
DIEValue()=default
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams) const
Return the size of a value in bytes.
Definition DIE.cpp:327
dwarf::Form getForm() const
Definition DIE.h:505
Type getType() const
Accessors.
Definition DIE.h:503
DIEValue(const DIEValue &X)
Definition DIE.h:471
DIEValue & operator=(const DIEValue &X)
Definition DIE.h:475
dwarf::Attribute getAttribute() const
Definition DIE.h:504
LLVM_ABI void dump() const
Definition DIE.cpp:353
A structured debug information entry.
Definition DIE.h:842
LLVM_ABI DIEValue findAttribute(dwarf::Attribute Attribute) const
Find a value in the DIE with the attribute given.
Definition DIE.cpp:210
LLVM_ABI void print(raw_ostream &O, unsigned IndentCount=0) const
Definition DIE.cpp:236
IntrusiveBackList< DIE >::const_iterator const_child_iterator
Definition DIE.h:894
unsigned getAbbrevNumber() const
Definition DIE.h:877
DIE(DIE &&RHS)=delete
friend class DIEUnit
Definition DIE.h:844
unsigned getSize() const
Definition DIE.h:885
const_child_range children() const
Definition DIE.h:901
IntrusiveBackList< DIE >::iterator child_iterator
Definition DIE.h:893
DIE & addChild(DIE *Child)
Add a child to the DIE.
Definition DIE.h:958
DIE(const DIE &RHS)=delete
LLVM_ABI DIEAbbrev generateAbbrev() const
Generate the abbreviation for this DIE.
Definition DIE.cpp:174
LLVM_ABI unsigned computeOffsetsAndAbbrevs(const dwarf::FormParams &FormParams, DIEAbbrevSet &AbbrevSet, unsigned CUOffset)
Compute the offset of this DIE and all its children.
Definition DIE.cpp:266
DIE & addChildFront(DIE *Child)
Definition DIE.h:965
void setSize(unsigned S)
Definition DIE.h:955
static DIE * get(BumpPtrAllocator &Alloc, dwarf::Tag Tag)
Definition DIE.h:872
LLVM_ABI DIEUnit * getUnit() const
Climb up the parent chain to get the compile unit or type unit that this DIE belongs to.
Definition DIE.cpp:203
child_range children()
Definition DIE.h:898
DIE & operator=(const DIE &RHS)=delete
DIE()=delete
LLVM_ABI const DIE * getUnitDie() const
Climb up the parent chain to get the compile unit or type unit DIE that this DIE belongs to.
Definition DIE.cpp:191
void setAbbrevNumber(unsigned I)
Set the abbreviation number for this DIE.
Definition DIE.h:914
iterator_range< child_iterator > child_range
Definition DIE.h:895
unsigned getOffset() const
Get the compile/type unit relative offset of this DIE.
Definition DIE.h:880
void setOffset(unsigned O)
Definition DIE.h:954
void setForceChildren(bool B)
Definition DIE.h:891
bool hasChildren() const
Definition DIE.h:890
LLVM_ABI uint64_t getDebugSectionOffset() const
Get the absolute offset within the .debug_info or .debug_types section for this DIE.
Definition DIE.cpp:185
iterator_range< const_child_iterator > const_child_range
Definition DIE.h:896
dwarf::Tag getTag() const
Definition DIE.h:878
LLVM_ABI void dump() const
Definition DIE.cpp:261
DIE & operator=(const DIE &&RHS)=delete
LLVM_ABI DIE * getParent() const
Definition DIE.cpp:172
DwarfStringPoolEntryRef: Dwarf string pool entry reference.
This class is used to gather all the unique data bits of a node.
Definition FoldingSet.h:220
const_iterator(IntrusiveBackList< T >::iterator X)
Definition DIE.h:670
bool operator==(const const_iterator &X) const
Definition DIE.h:681
const_iterator & operator++()
Definition DIE.h:673
bool operator==(const iterator &X) const
Definition DIE.h:659
void takeNodes(IntrusiveBackList< T > &Other)
Definition DIE.h:618
const T & back() const
Definition DIE.h:610
iterator end()
Definition DIE.h:690
const T & front() const
Definition DIE.h:614
void push_front(T &N)
Definition DIE.h:607
iterator begin()
Definition DIE.h:684
void push_back(T &N)
Definition DIE.h:606
static const_iterator toIterator(const T &N)
Definition DIE.h:694
const_iterator begin() const
Definition DIE.h:687
const_iterator end() const
Definition DIE.h:691
static iterator toIterator(T &N)
Definition DIE.h:693
bool deleteNode(Node &N)
Deletes node N from the list. Note this runs in O(N).
Definition DIE.h:638
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:34
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition MCSection.h:580
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
PointerIntPair - This class implements a pair of a pointer and small integer.
A discriminated union of two or more pointer types, with the discriminator in the low bits of the poi...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Target - Wrapper for Target specific information.
LLVM Value Representation.
Definition Value.h:75
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition iterator.h:80
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
Calculates the starting offsets for various sections within the .debug_names section.
Definition Dwarf.h:35
Attribute
Attributes.
Definition Dwarf.h:125
This is an optimization pass for GlobalISel generic memory operations.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
Definition STLExtras.h:1669
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
FoldingSetBase::Node FoldingSetNode
Definition FoldingSet.h:410
@ Other
Any other memory.
Definition ModRef.h:68
OutputIt copy(R &&Range, OutputIt Out)
Definition STLExtras.h:1885
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:390
FoldingSetImpl< T, Trait > FoldingSet
This template class is used to instantiate a specialized implementation of the folding set to the nod...
Definition FoldingSet.h:561
#define N
BasicDIEUnit(dwarf::Tag UnitTag)
Definition DIE.h:1028
bool deleteNode(Node &N)
Delete node N by walking through the list until N's predecessor is found.
Definition DIE.h:576
void push_back(Node &N)
Definition DIE.h:548
bool empty() const
Definition DIE.h:546
IntrusiveBackListNode Node
Definition DIE.h:542
void push_front(Node &N)
Definition DIE.h:560
PointerIntPair< IntrusiveBackListNode *, 1 > Next
Definition DIE.h:532
IntrusiveBackListNode * getNext() const
Definition DIE.h:536
A helper struct providing information about the byte size of DW_FORM values that vary in size dependi...
Definition Dwarf.h:1199