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
198 LLVM_ABI void emitValue(const AsmPrinter *Asm, dwarf::Form Form) const;
199 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams,
200 dwarf::Form Form) const;
201
202 LLVM_ABI void print(raw_ostream &O) const;
203};
204
205//===--------------------------------------------------------------------===//
206/// An expression DIE.
207class DIEExpr {
208 const MCExpr *Expr;
209
210public:
211 explicit DIEExpr(const MCExpr *E) : Expr(E) {}
212
213 LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const;
214 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams,
215 dwarf::Form Form) const;
216
217 LLVM_ABI void print(raw_ostream &O) const;
218};
219
220//===--------------------------------------------------------------------===//
221/// A label DIE.
222class DIELabel {
223 const MCSymbol *Label;
224
225public:
226 explicit DIELabel(const MCSymbol *L) : Label(L) {}
227
228 LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const;
229 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams,
230 dwarf::Form Form) const;
231
232 LLVM_ABI void print(raw_ostream &O) const;
233};
234
235//===--------------------------------------------------------------------===//
236/// A BaseTypeRef DIE.
238 const DwarfCompileUnit *CU;
239 const uint64_t Index;
240 static constexpr unsigned ULEB128PadSize = 4;
241
242public:
243 explicit DIEBaseTypeRef(const DwarfCompileUnit *TheCU, uint64_t Idx)
244 : CU(TheCU), Index(Idx) {}
245
246 /// EmitValue - Emit base type reference.
247 LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const;
248 /// sizeOf - Determine size of the base type reference in bytes.
249 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &, dwarf::Form) const;
250
251 LLVM_ABI void print(raw_ostream &O) const;
252 uint64_t getIndex() const { return Index; }
253};
254
255//===--------------------------------------------------------------------===//
256/// A simple label difference DIE.
257///
258class DIEDelta {
259 const MCSymbol *LabelHi;
260 const MCSymbol *LabelLo;
261
262public:
263 DIEDelta(const MCSymbol *Hi, const MCSymbol *Lo) : LabelHi(Hi), LabelLo(Lo) {}
264
265 LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const;
266 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams,
267 dwarf::Form Form) const;
268
269 LLVM_ABI void print(raw_ostream &O) const;
270};
271
272//===--------------------------------------------------------------------===//
273/// A container for string pool string values.
274///
275/// This class is used with the DW_FORM_strp and DW_FORM_GNU_str_index forms.
278
279public:
281
282 /// Grab the string out of the object.
283 StringRef getString() const { return S.getString(); }
284
285 LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const;
286 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams,
287 dwarf::Form Form) const;
288
289 LLVM_ABI void print(raw_ostream &O) const;
290};
291
292//===--------------------------------------------------------------------===//
293/// A container for inline string values.
294///
295/// This class is used with the DW_FORM_string form.
297 StringRef S;
298
299public:
300 template <typename Allocator>
301 explicit DIEInlineString(StringRef Str, Allocator &A) : S(Str.copy(A)) {}
302
303 ~DIEInlineString() = default;
304
305 /// Grab the string out of the object.
306 StringRef getString() const { return S; }
307
308 LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const;
309 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &, dwarf::Form) const;
310
311 LLVM_ABI void print(raw_ostream &O) const;
312};
313
314//===--------------------------------------------------------------------===//
315/// A pointer to another debug information entry. An instance of this class can
316/// also be used as a proxy for a debug information entry not yet defined
317/// (ie. types.)
318class DIEEntry {
319 DIE *Entry;
320
321public:
322 DIEEntry() = delete;
323 explicit DIEEntry(DIE &E) : Entry(&E) {}
324
325 DIE &getEntry() const { return *Entry; }
326
327 LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const;
328 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams,
329 dwarf::Form Form) const;
330
331 LLVM_ABI void print(raw_ostream &O) const;
332};
333
334//===--------------------------------------------------------------------===//
335/// Represents a pointer to a location list in the debug_loc
336/// section.
338 /// Index into the .debug_loc vector.
339 size_t Index;
340
341public:
342 DIELocList(size_t I) : Index(I) {}
343
344 /// Grab the current index out.
345 size_t getValue() const { return Index; }
346
347 LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const;
348 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams,
349 dwarf::Form Form) const;
350
351 LLVM_ABI void print(raw_ostream &O) const;
352};
353
354//===--------------------------------------------------------------------===//
355/// A BaseTypeRef DIE.
357 DIEInteger Addr;
358 DIEDelta Offset;
359
360public:
361 explicit DIEAddrOffset(uint64_t Idx, const MCSymbol *Hi, const MCSymbol *Lo)
362 : Addr(Idx), Offset(Hi, Lo) {}
363
364 LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const;
365 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams,
366 dwarf::Form Form) const;
367
368 LLVM_ABI void print(raw_ostream &O) const;
369};
370
371//===--------------------------------------------------------------------===//
372/// A debug information entry value. Some of these roughly correlate
373/// to DWARF attribute classes.
374class DIEBlock;
375class DIELoc;
376class DIEValue {
377public:
378 enum Type {
380#define HANDLE_DIEVALUE(T) is##T,
381#include "llvm/CodeGen/DIEValue.def"
382 };
383
384private:
385 /// Type of data stored in the value.
386 Type Ty = isNone;
387 dwarf::Attribute Attribute = (dwarf::Attribute)0;
388 dwarf::Form Form = (dwarf::Form)0;
389
390 /// Storage for the value.
391 ///
392 /// All values that aren't standard layout (or are larger than 8 bytes)
393 /// should be stored by reference instead of by value.
394 using ValTy =
395 AlignedCharArrayUnion<DIEInteger, DIEString, DIEExpr, DIELabel,
396 DIEDelta *, DIEEntry, DIEBlock *, DIELoc *,
397 DIELocList, DIEBaseTypeRef *, DIEAddrOffset *>;
398
399 static_assert(sizeof(ValTy) <= sizeof(uint64_t) ||
400 sizeof(ValTy) <= sizeof(void *),
401 "Expected all large types to be stored via pointer");
402
403 /// Underlying stored value.
404 ValTy Val;
405
406 template <class T> void construct(T V) {
407 static_assert(std::is_standard_layout<T>::value ||
408 std::is_pointer<T>::value,
409 "Expected standard layout or pointer");
410 new (reinterpret_cast<void *>(&Val)) T(V);
411 }
412
413 template <class T> T *get() { return reinterpret_cast<T *>(&Val); }
414 template <class T> const T *get() const {
415 return reinterpret_cast<const T *>(&Val);
416 }
417 template <class T> void destruct() { get<T>()->~T(); }
418
419 /// Destroy the underlying value.
420 ///
421 /// This should get optimized down to a no-op. We could skip it if we could
422 /// add a static assert on \a std::is_trivially_copyable(), but we currently
423 /// support versions of GCC that don't understand that.
424 void destroyVal() {
425 switch (Ty) {
426 case isNone:
427 return;
428#define HANDLE_DIEVALUE_SMALL(T) \
429 case is##T: \
430 destruct<DIE##T>(); \
431 return;
432#define HANDLE_DIEVALUE_LARGE(T) \
433 case is##T: \
434 destruct<const DIE##T *>(); \
435 return;
436#include "llvm/CodeGen/DIEValue.def"
437 }
438 }
439
440 /// Copy the underlying value.
441 ///
442 /// This should get optimized down to a simple copy. We need to actually
443 /// construct the value, rather than calling memcpy, to satisfy strict
444 /// aliasing rules.
445 void copyVal(const DIEValue &X) {
446 switch (Ty) {
447 case isNone:
448 return;
449#define HANDLE_DIEVALUE_SMALL(T) \
450 case is##T: \
451 construct<DIE##T>(*X.get<DIE##T>()); \
452 return;
453#define HANDLE_DIEVALUE_LARGE(T) \
454 case is##T: \
455 construct<const DIE##T *>(*X.get<const DIE##T *>()); \
456 return;
457#include "llvm/CodeGen/DIEValue.def"
458 }
459 }
460
461public:
462 DIEValue() = default;
463
464 DIEValue(const DIEValue &X) : Ty(X.Ty), Attribute(X.Attribute), Form(X.Form) {
465 copyVal(X);
466 }
467
469 if (this == &X)
470 return *this;
471 destroyVal();
472 Ty = X.Ty;
473 Attribute = X.Attribute;
474 Form = X.Form;
475 copyVal(X);
476 return *this;
477 }
478
479 ~DIEValue() { destroyVal(); }
480
481#define HANDLE_DIEVALUE_SMALL(T) \
482 DIEValue(dwarf::Attribute Attribute, dwarf::Form Form, const DIE##T &V) \
483 : Ty(is##T), Attribute(Attribute), Form(Form) { \
484 construct<DIE##T>(V); \
485 }
486#define HANDLE_DIEVALUE_LARGE(T) \
487 DIEValue(dwarf::Attribute Attribute, dwarf::Form Form, const DIE##T *V) \
488 : Ty(is##T), Attribute(Attribute), Form(Form) { \
489 assert(V && "Expected valid value"); \
490 construct<const DIE##T *>(V); \
491 }
492#include "llvm/CodeGen/DIEValue.def"
493
494 /// Accessors.
495 /// @{
496 Type getType() const { return Ty; }
497 dwarf::Attribute getAttribute() const { return Attribute; }
498 dwarf::Form getForm() const { return Form; }
499 explicit operator bool() const { return Ty; }
500 /// @}
501
502#define HANDLE_DIEVALUE_SMALL(T) \
503 const DIE##T &getDIE##T() const { \
504 assert(getType() == is##T && "Expected " #T); \
505 return *get<DIE##T>(); \
506 }
507#define HANDLE_DIEVALUE_LARGE(T) \
508 const DIE##T &getDIE##T() const { \
509 assert(getType() == is##T && "Expected " #T); \
510 return **get<const DIE##T *>(); \
511 }
512#include "llvm/CodeGen/DIEValue.def"
513
514 /// Emit value via the Dwarf writer.
515 LLVM_ABI void emitValue(const AsmPrinter *AP) const;
516
517 /// Return the size of a value in bytes.
518 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams) const;
519
520 LLVM_ABI void print(raw_ostream &O) const;
521 LLVM_ABI void dump() const;
522};
523
526
528
530 return Next.getInt() ? nullptr : Next.getPointer();
531 }
532};
533
536
537 Node *Last = nullptr;
538
539 bool empty() const { return !Last; }
540
541 void push_back(Node &N) {
542 assert(N.Next.getPointer() == &N && "Expected unlinked node");
543 assert(static_cast<bool>(N.Next.getInt()) == true &&
544 "Expected unlinked node");
545
546 if (Last) {
547 N.Next = Last->Next;
548 Last->Next.setPointerAndInt(&N, false);
549 }
550 Last = &N;
551 }
552
554 assert(N.Next.getPointer() == &N && "Expected unlinked node");
555 assert(static_cast<bool>(N.Next.getInt()) == true &&
556 "Expected unlinked node");
557
558 if (Last) {
559 N.Next.setPointerAndInt(Last->Next.getPointer(), false);
560 Last->Next.setPointerAndInt(&N, true);
561 } else {
562 Last = &N;
563 }
564 }
565
566 /// Delete node \p N by walking through the list until \p N's predecessor is
567 /// found. Remove \p N from the list by updating the predecessor's next
568 /// pointer and reset \p N's next pointer to itself.
570 if (!Last)
571 return false;
572
573 Node *Cur = Last;
574 while (Cur->Next.getPointer() != &N) {
575 Cur = Cur->Next.getPointer();
576 if (Cur->Next.getInt())
577 return false;
578 }
579
580 Node *Target = Cur->Next.getPointer();
581 if (Target == Cur) {
582 Last = nullptr;
583 } else if (Target == Last) {
584 Cur->Next.setPointerAndInt(Target->Next.getPointer(), true);
585 Last = Cur;
586 } else {
587 Cur->Next.setPointer(Target->Next.getPointer());
588 }
589
590 Target->Next.setPointerAndInt(Target, true);
591 return true;
592 }
593};
594
595template <class T> class IntrusiveBackList : IntrusiveBackListBase {
596public:
598
601
602 T &back() { return *static_cast<T *>(Last); }
603 const T &back() const { return *static_cast<T *>(Last); }
604 T &front() {
605 return *static_cast<T *>(Last ? Last->Next.getPointer() : nullptr);
606 }
607 const T &front() const {
608 return *static_cast<T *>(Last ? Last->Next.getPointer() : nullptr);
609 }
610
612 if (Other.empty())
613 return;
614
615 T *FirstNode = static_cast<T *>(Other.Last->Next.getPointer());
616 T *IterNode = FirstNode;
617 do {
618 // Keep a pointer to the node and increment the iterator.
619 T *TmpNode = IterNode;
620 IterNode = static_cast<T *>(IterNode->Next.getPointer());
621
622 // Unlink the node and push it back to this list.
623 TmpNode->Next.setPointerAndInt(TmpNode, true);
624 push_back(*TmpNode);
625 } while (IterNode != FirstNode);
626
627 Other.Last = nullptr;
628 }
629
630 /// Deletes node \p N from the list. Note this runs in O(N).
632
633 class const_iterator;
635 : public iterator_facade_base<iterator, std::forward_iterator_tag, T> {
636 friend class const_iterator;
637
638 Node *N = nullptr;
639
640 public:
641 iterator() = default;
642 explicit iterator(T *N) : N(N) {}
643
645 N = N->getNext();
646 return *this;
647 }
648
649 explicit operator bool() const { return N; }
650 T &operator*() const { return *static_cast<T *>(N); }
651
652 bool operator==(const iterator &X) const { return N == X.N; }
653 };
654
656 : public iterator_facade_base<const_iterator, std::forward_iterator_tag,
657 const T> {
658 const Node *N = nullptr;
659
660 public:
661 const_iterator() = default;
662 // Placate MSVC by explicitly scoping 'iterator'.
664 explicit const_iterator(const T *N) : N(N) {}
665
667 N = N->getNext();
668 return *this;
669 }
670
671 explicit operator bool() const { return N; }
672 const T &operator*() const { return *static_cast<const T *>(N); }
673
674 bool operator==(const const_iterator &X) const { return N == X.N; }
675 };
676
677 iterator begin() {
678 return Last ? iterator(static_cast<T *>(Last->Next.getPointer())) : end();
679 }
680 const_iterator begin() const {
681 return const_cast<IntrusiveBackList *>(this)->begin();
682 }
683 iterator end() { return iterator(); }
684 const_iterator end() const { return const_iterator(); }
685
686 static iterator toIterator(T &N) { return iterator(&N); }
687 static const_iterator toIterator(const T &N) { return const_iterator(&N); }
688};
689
690/// A list of DIE values.
691///
692/// This is a singly-linked list, but instead of reversing the order of
693/// insertion, we keep a pointer to the back of the list so we can push in
694/// order.
695///
696/// There are two main reasons to choose a linked list over a customized
697/// vector-like data structure.
698///
699/// 1. For teardown efficiency, we want DIEs to be BumpPtrAllocated. Using a
700/// linked list here makes this way easier to accomplish.
701/// 2. Carrying an extra pointer per \a DIEValue isn't expensive. 45% of DIEs
702/// have 2 or fewer values, and 90% have 5 or fewer. A vector would be
703/// over-allocated by 50% on average anyway, the same cost as the
704/// linked-list node.
706 struct Node : IntrusiveBackListNode {
707 DIEValue V;
708
709 explicit Node(DIEValue V) : V(V) {}
710 };
711
712 using ListTy = IntrusiveBackList<Node>;
713
714 ListTy List;
715
716public:
719 : public iterator_adaptor_base<value_iterator, ListTy::iterator,
720 std::forward_iterator_tag, DIEValue> {
722
723 using iterator_adaptor =
724 iterator_adaptor_base<value_iterator, ListTy::iterator,
725 std::forward_iterator_tag, DIEValue>;
726
727 public:
728 value_iterator() = default;
729 explicit value_iterator(ListTy::iterator X) : iterator_adaptor(X) {}
730
731 explicit operator bool() const { return bool(wrapped()); }
732 DIEValue &operator*() const { return wrapped()->V; }
733 };
734
736 const_value_iterator, ListTy::const_iterator,
737 std::forward_iterator_tag, const DIEValue> {
738 using iterator_adaptor =
739 iterator_adaptor_base<const_value_iterator, ListTy::const_iterator,
740 std::forward_iterator_tag, const DIEValue>;
741
742 public:
746 explicit const_value_iterator(ListTy::const_iterator X)
747 : iterator_adaptor(X) {}
748
749 explicit operator bool() const { return bool(wrapped()); }
750 const DIEValue &operator*() const { return wrapped()->V; }
751 };
752
755
757 List.push_back(*new (Alloc) Node(V));
758 return value_iterator(ListTy::toIterator(List.back()));
759 }
760 template <class T>
765
766 /* zr33: add method here */
767 template <class T>
769 dwarf::Attribute NewAttribute, dwarf::Form Form,
770 T &&NewValue) {
771 for (llvm::DIEValue &val : values()) {
772 if (val.getAttribute() == Attribute) {
773 val = *new (Alloc)
774 DIEValue(NewAttribute, Form, std::forward<T>(NewValue));
775 return true;
776 }
777 }
778
779 return false;
780 }
781
782 template <class T>
784 dwarf::Form Form, T &&NewValue) {
785 for (llvm::DIEValue &val : values()) {
786 if (val.getAttribute() == Attribute) {
787 val = *new (Alloc) DIEValue(Attribute, Form, std::forward<T>(NewValue));
788 return true;
789 }
790 }
791
792 return false;
793 }
794
796 dwarf::Form Form, DIEValue &NewValue) {
797 for (llvm::DIEValue &val : values()) {
798 if (val.getAttribute() == Attribute) {
799 val = NewValue;
800 return true;
801 }
802 }
803
804 return false;
805 }
806
808
809 for (auto &node : List) {
810 if (node.V.getAttribute() == Attribute) {
811 return List.deleteNode(node);
812 }
813 }
814
815 return false;
816 }
817 /* end */
818
819 /// Take ownership of the nodes in \p Other, and append them to the back of
820 /// the list.
821 void takeValues(DIEValueList &Other) { List.takeNodes(Other.List); }
822
824 return make_range(value_iterator(List.begin()), value_iterator(List.end()));
825 }
827 return make_range(const_value_iterator(List.begin()),
828 const_value_iterator(List.end()));
829 }
830};
831
832//===--------------------------------------------------------------------===//
833/// A structured debug information entry. Has an abbreviation which
834/// describes its organization.
836 friend class IntrusiveBackList<DIE>;
837 friend class DIEUnit;
838
839 /// Dwarf unit relative offset.
840 unsigned Offset = 0;
841 /// Size of instance + children.
842 unsigned Size = 0;
843 unsigned AbbrevNumber = ~0u;
844 /// Dwarf tag code.
845 dwarf::Tag Tag = (dwarf::Tag)0;
846 /// Set to true to force a DIE to emit an abbreviation that says it has
847 /// children even when it doesn't. This is used for unit testing purposes.
848 bool ForceChildren = false;
849 /// Children DIEs.
850 IntrusiveBackList<DIE> Children;
851
852 /// The owner is either the parent DIE for children of other DIEs, or a
853 /// DIEUnit which contains this DIE as its unit DIE.
855
856 explicit DIE(dwarf::Tag Tag) : Tag(Tag) {}
857
858public:
859 DIE() = delete;
860 DIE(const DIE &RHS) = delete;
861 DIE(DIE &&RHS) = delete;
862 DIE &operator=(const DIE &RHS) = delete;
863 DIE &operator=(const DIE &&RHS) = delete;
864
866 return new (Alloc) DIE(Tag);
867 }
868
869 // Accessors.
870 unsigned getAbbrevNumber() const { return AbbrevNumber; }
871 dwarf::Tag getTag() const { return Tag; }
872 /// Get the compile/type unit relative offset of this DIE.
873 unsigned getOffset() const {
874 // A real Offset can't be zero because the unit headers are at offset zero.
875 assert(Offset && "Offset being queried before it's been computed.");
876 return Offset;
877 }
878 unsigned getSize() const {
879 // A real Size can't be zero because it includes the non-empty abbrev code.
880 assert(Size && "Size being queried before it's been ocmputed.");
881 return Size;
882 }
883 bool hasChildren() const { return ForceChildren || !Children.empty(); }
884 void setForceChildren(bool B) { ForceChildren = B; }
885
890
892 return make_range(Children.begin(), Children.end());
893 }
895 return make_range(Children.begin(), Children.end());
896 }
897
898 LLVM_ABI DIE *getParent() const;
899
900 /// Generate the abbreviation for this DIE.
901 ///
902 /// Calculate the abbreviation for this, which should be uniqued and
903 /// eventually used to call \a setAbbrevNumber().
905
906 /// Set the abbreviation number for this DIE.
907 void setAbbrevNumber(unsigned I) { AbbrevNumber = I; }
908
909 /// Get the absolute offset within the .debug_info or .debug_types section
910 /// for this DIE.
912
913 /// Compute the offset of this DIE and all its children.
914 ///
915 /// This function gets called just before we are going to generate the debug
916 /// information and gives each DIE a chance to figure out its CU relative DIE
917 /// offset, unique its abbreviation and fill in the abbreviation code, and
918 /// return the unit offset that points to where the next DIE will be emitted
919 /// within the debug unit section. After this function has been called for all
920 /// DIE objects, the DWARF can be generated since all DIEs will be able to
921 /// properly refer to other DIE objects since all DIEs have calculated their
922 /// offsets.
923 ///
924 /// \param FormParams Used when calculating sizes.
925 /// \param AbbrevSet the abbreviation used to unique DIE abbreviations.
926 /// \param CUOffset the compile/type unit relative offset in bytes.
927 /// \returns the offset for the DIE that follows this DIE within the
928 /// current compile/type unit.
929 LLVM_ABI unsigned
931 DIEAbbrevSet &AbbrevSet, unsigned CUOffset);
932
933 /// Climb up the parent chain to get the compile unit or type unit DIE that
934 /// this DIE belongs to.
935 ///
936 /// \returns the compile or type unit DIE that owns this DIE, or NULL if
937 /// this DIE hasn't been added to a unit DIE.
938 LLVM_ABI const DIE *getUnitDie() const;
939
940 /// Climb up the parent chain to get the compile unit or type unit that this
941 /// DIE belongs to.
942 ///
943 /// \returns the DIEUnit that represents the compile or type unit that owns
944 /// this DIE, or NULL if this DIE hasn't been added to a unit DIE.
945 LLVM_ABI DIEUnit *getUnit() const;
946
947 void setOffset(unsigned O) { Offset = O; }
948 void setSize(unsigned S) { Size = S; }
949
950 /// Add a child to the DIE.
951 DIE &addChild(DIE *Child) {
952 assert(!Child->getParent() && "Child should be orphaned");
953 Child->Owner = this;
954 Children.push_back(*Child);
955 return Children.back();
956 }
957
958 DIE &addChildFront(DIE *Child) {
959 assert(!Child->getParent() && "Child should be orphaned");
960 Child->Owner = this;
961 Children.push_front(*Child);
962 return Children.front();
963 }
964
965 /// Find a value in the DIE with the attribute given.
966 ///
967 /// Returns a default-constructed DIEValue (where \a DIEValue::getType()
968 /// gives \a DIEValue::isNone) if no such attribute exists.
970
971 LLVM_ABI void print(raw_ostream &O, unsigned IndentCount = 0) const;
972 LLVM_ABI void dump() const;
973};
974
975//===--------------------------------------------------------------------===//
976/// Represents a compile or type unit.
977class DIEUnit {
978 /// The compile unit or type unit DIE. This variable must be an instance of
979 /// DIE so that we can calculate the DIEUnit from any DIE by traversing the
980 /// parent backchain and getting the Unit DIE, and then casting itself to a
981 /// DIEUnit. This allows us to be able to find the DIEUnit for any DIE without
982 /// having to store a pointer to the DIEUnit in each DIE instance.
983 DIE Die;
984 /// The section this unit will be emitted in. This may or may not be set to
985 /// a valid section depending on the client that is emitting DWARF.
986 MCSection *Section = nullptr;
987 uint64_t Offset = 0; /// .debug_info or .debug_types absolute section offset.
988protected:
989 virtual ~DIEUnit() = default;
990
991public:
992 LLVM_ABI explicit DIEUnit(dwarf::Tag UnitTag);
993 DIEUnit(const DIEUnit &RHS) = delete;
994 DIEUnit(DIEUnit &&RHS) = delete;
995 void operator=(const DIEUnit &RHS) = delete;
996 void operator=(const DIEUnit &&RHS) = delete;
997 /// Set the section that this DIEUnit will be emitted into.
998 ///
999 /// This function is used by some clients to set the section. Not all clients
1000 /// that emit DWARF use this section variable.
1001 void setSection(MCSection *Section) {
1002 assert(!this->Section);
1003 this->Section = Section;
1004 }
1005
1007 return nullptr;
1008 }
1009
1010 /// Return the section that this DIEUnit will be emitted into.
1011 ///
1012 /// \returns Section pointer which can be NULL.
1013 MCSection *getSection() const { return Section; }
1014 void setDebugSectionOffset(uint64_t O) { Offset = O; }
1015 uint64_t getDebugSectionOffset() const { return Offset; }
1016 DIE &getUnitDie() { return Die; }
1017 const DIE &getUnitDie() const { return Die; }
1018};
1019
1020struct BasicDIEUnit final : DIEUnit {
1021 explicit BasicDIEUnit(dwarf::Tag UnitTag) : DIEUnit(UnitTag) {}
1022};
1023
1024//===--------------------------------------------------------------------===//
1025/// DIELoc - Represents an expression location.
1026//
1027class DIELoc : public DIEValueList {
1028 mutable unsigned Size = 0; // Size in bytes excluding size header.
1029
1030public:
1031 DIELoc() = default;
1032
1033 /// Calculate the size of the location expression.
1034 LLVM_ABI unsigned computeSize(const dwarf::FormParams &FormParams) const;
1035
1036 // TODO: move setSize() and Size to DIEValueList.
1037 void setSize(unsigned size) { Size = size; }
1038
1039 /// BestForm - Choose the best form for data.
1040 ///
1041 dwarf::Form BestForm(unsigned DwarfVersion) const {
1042 if (DwarfVersion > 3)
1043 return dwarf::DW_FORM_exprloc;
1044 // Pre-DWARF4 location expressions were blocks and not exprloc.
1045 if ((uint8_t)Size == Size)
1046 return dwarf::DW_FORM_block1;
1047 if ((uint16_t)Size == Size)
1048 return dwarf::DW_FORM_block2;
1049 if ((uint32_t)Size == Size)
1050 return dwarf::DW_FORM_block4;
1051 return dwarf::DW_FORM_block;
1052 }
1053
1054 LLVM_ABI void emitValue(const AsmPrinter *Asm, dwarf::Form Form) const;
1055 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &, dwarf::Form Form) const;
1056
1057 LLVM_ABI void print(raw_ostream &O) const;
1058};
1059
1060//===--------------------------------------------------------------------===//
1061/// DIEBlock - Represents a block of values.
1062//
1063class DIEBlock : public DIEValueList {
1064 mutable unsigned Size = 0; // Size in bytes excluding size header.
1065
1066public:
1067 DIEBlock() = default;
1068
1069 /// Calculate the size of the location expression.
1070 LLVM_ABI unsigned computeSize(const dwarf::FormParams &FormParams) const;
1071
1072 // TODO: move setSize() and Size to DIEValueList.
1073 void setSize(unsigned size) { Size = size; }
1074
1075 /// BestForm - Choose the best form for data.
1076 ///
1078 if ((uint8_t)Size == Size)
1079 return dwarf::DW_FORM_block1;
1080 if ((uint16_t)Size == Size)
1081 return dwarf::DW_FORM_block2;
1082 if ((uint32_t)Size == Size)
1083 return dwarf::DW_FORM_block4;
1084 return dwarf::DW_FORM_block;
1085 }
1086
1087 LLVM_ABI void emitValue(const AsmPrinter *Asm, dwarf::Form Form) const;
1088 LLVM_ABI unsigned sizeOf(const dwarf::FormParams &, dwarf::Form Form) const;
1089
1090 LLVM_ABI void print(raw_ostream &O) const;
1091};
1092
1093} // end namespace llvm
1094
1095#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:106
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:159
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:866
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
Definition DIE.cpp:852
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit label value.
Definition DIE.cpp:860
DIEAddrOffset(uint64_t Idx, const MCSymbol *Hi, const MCSymbol *Lo)
Definition DIE.h:361
uint64_t getIndex() const
Definition DIE.h:252
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit base type reference.
Definition DIE.cpp:518
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:529
DIEBaseTypeRef(const DwarfCompileUnit *TheCU, uint64_t Idx)
Definition DIE.h:243
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &, dwarf::Form) const
sizeOf - Determine size of the base type reference in bytes.
Definition DIE.cpp:524
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &, dwarf::Form Form) const
sizeOf - Determine size of block data in bytes.
Definition DIE.cpp:790
void setSize(unsigned size)
Definition DIE.h:1073
dwarf::Form BestForm() const
BestForm - Choose the best form for data.
Definition DIE.h:1077
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:803
DIEBlock()=default
LLVM_ABI void emitValue(const AsmPrinter *Asm, dwarf::Form Form) const
EmitValue - Emit block data.
Definition DIE.cpp:770
LLVM_ABI unsigned computeSize(const dwarf::FormParams &FormParams) const
Calculate the size of the location expression.
Definition DIE.cpp:759
A simple label difference DIE.
Definition DIE.h:258
DIEDelta(const MCSymbol *Hi, const MCSymbol *Lo)
Definition DIE.h:263
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:559
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
SizeOf - Determine size of delta value in bytes.
Definition DIE.cpp:544
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit delta value.
Definition DIE.cpp:537
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit debug information entry offset.
Definition DIE.cpp:646
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:701
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
Definition DIE.cpp:679
DIE & getEntry() const
Definition DIE.h:325
DIEEntry()=delete
DIEEntry(DIE &E)
Definition DIE.h:323
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:474
DIEExpr(const MCExpr *E)
Definition DIE.h:211
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit expression value.
Definition DIE.cpp:453
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
SizeOf - Determine size of expression value in bytes.
Definition DIE.cpp:459
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
Definition DIE.cpp:621
~DIEInlineString()=default
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:636
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &, dwarf::Form) const
Definition DIE.cpp:630
StringRef getString() const
Grab the string out of the object.
Definition DIE.h:306
DIEInlineString(StringRef Str, Allocator &A)
Definition DIE.h:301
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:420
uint64_t getValue() const
Definition DIE.h:196
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:442
LLVM_ABI void emitValue(const AsmPrinter *Asm, dwarf::Form Form) const
EmitValue - Emit integer of appropriate size.
Definition DIE.cpp:363
static dwarf::Form BestForm(bool IsSigned, uint64_t Int)
Choose the best form for integer.
Definition DIE.h:176
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit label value.
Definition DIE.cpp:486
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:512
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
sizeOf - Determine size of label value in bytes.
Definition DIE.cpp:494
DIELabel(const MCSymbol *L)
Definition DIE.h:226
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:846
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
Definition DIE.cpp:811
DIELocList(size_t I)
Definition DIE.h:342
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit label value.
Definition DIE.cpp:835
size_t getValue() const
Grab the current index out.
Definition DIE.h:345
void setSize(unsigned size)
Definition DIE.h:1037
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:751
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &, dwarf::Form Form) const
sizeOf - Determine size of location data in bytes.
Definition DIE.cpp:738
LLVM_ABI void emitValue(const AsmPrinter *Asm, dwarf::Form Form) const
EmitValue - Emit location data.
Definition DIE.cpp:720
LLVM_ABI unsigned computeSize(const dwarf::FormParams &FormParams) const
Calculate the size of the location expression.
Definition DIE.cpp:709
dwarf::Form BestForm(unsigned DwarfVersion) const
BestForm - Choose the best form for data.
Definition DIE.h:1041
DIELoc()=default
LLVM_ABI void emitValue(const AsmPrinter *AP, dwarf::Form Form) const
EmitValue - Emit string value.
Definition DIE.cpp:569
DIEString(DwarfStringPoolEntryRef S)
Definition DIE.h:280
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:614
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const
sizeOf - Determine size of delta value in bytes.
Definition DIE.cpp:593
StringRef getString() const
Grab the string out of the object.
Definition DIE.h:283
Represents a compile or type unit.
Definition DIE.h:977
void setSection(MCSection *Section)
Set the section that this DIEUnit will be emitted into.
Definition DIE.h:1001
void operator=(const DIEUnit &&RHS)=delete
DIEUnit(DIEUnit &&RHS)=delete
void operator=(const DIEUnit &RHS)=delete
const DIE & getUnitDie() const
Definition DIE.h:1017
DIEUnit(const DIEUnit &RHS)=delete
virtual const MCSymbol * getCrossSectionRelativeBaseAddress() const
Definition DIE.h:1006
LLVM_ABI DIEUnit(dwarf::Tag UnitTag)
Definition DIE.cpp:305
void setDebugSectionOffset(uint64_t O)
Definition DIE.h:1014
MCSection * getSection() const
Return the section that this DIEUnit will be emitted into.
Definition DIE.h:1013
DIE & getUnitDie()
Definition DIE.h:1016
virtual ~DIEUnit()=default
.debug_info or .debug_types absolute section offset.
uint64_t getDebugSectionOffset() const
Definition DIE.h:1015
const DIEValue & operator*() const
Definition DIE.h:750
const_value_iterator(DIEValueList::value_iterator X)
Definition DIE.h:744
const_value_iterator(ListTy::const_iterator X)
Definition DIE.h:746
friend class const_value_iterator
Definition DIE.h:721
value_iterator(ListTy::iterator X)
Definition DIE.h:729
DIEValue & operator*() const
Definition DIE.h:732
A list of DIE values.
Definition DIE.h:705
bool deleteValue(dwarf::Attribute Attribute)
Definition DIE.h:807
void takeValues(DIEValueList &Other)
Take ownership of the nodes in Other, and append them to the back of the list.
Definition DIE.h:821
bool replaceValue(BumpPtrAllocator &Alloc, dwarf::Attribute Attribute, dwarf::Attribute NewAttribute, dwarf::Form Form, T &&NewValue)
Definition DIE.h:768
bool replaceValue(BumpPtrAllocator &Alloc, dwarf::Attribute Attribute, dwarf::Form Form, T &&NewValue)
Definition DIE.h:783
value_range values()
Definition DIE.h:823
iterator_range< value_iterator > value_range
Definition DIE.h:753
value_iterator addValue(BumpPtrAllocator &Alloc, const DIEValue &V)
Definition DIE.h:756
const_value_range values() const
Definition DIE.h:826
iterator_range< const_value_iterator > const_value_range
Definition DIE.h:754
value_iterator addValue(BumpPtrAllocator &Alloc, dwarf::Attribute Attribute, dwarf::Form Form, T &&Value)
Definition DIE.h:761
bool replaceValue(BumpPtrAllocator &Alloc, dwarf::Attribute Attribute, dwarf::Form Form, DIEValue &NewValue)
Definition DIE.h:795
LLVM_ABI void print(raw_ostream &O) const
Definition DIE.cpp:339
LLVM_ABI void emitValue(const AsmPrinter *AP) const
Emit value via the Dwarf writer.
Definition DIE.cpp:314
DIEValue()=default
LLVM_ABI unsigned sizeOf(const dwarf::FormParams &FormParams) const
Return the size of a value in bytes.
Definition DIE.cpp:326
dwarf::Form getForm() const
Definition DIE.h:498
Type getType() const
Accessors.
Definition DIE.h:496
DIEValue(const DIEValue &X)
Definition DIE.h:464
DIEValue & operator=(const DIEValue &X)
Definition DIE.h:468
dwarf::Attribute getAttribute() const
Definition DIE.h:497
LLVM_ABI void dump() const
Definition DIE.cpp:352
A structured debug information entry.
Definition DIE.h:835
LLVM_ABI DIEValue findAttribute(dwarf::Attribute Attribute) const
Find a value in the DIE with the attribute given.
Definition DIE.cpp:209
LLVM_ABI void print(raw_ostream &O, unsigned IndentCount=0) const
Definition DIE.cpp:235
IntrusiveBackList< DIE >::const_iterator const_child_iterator
Definition DIE.h:887
unsigned getAbbrevNumber() const
Definition DIE.h:870
DIE(DIE &&RHS)=delete
friend class DIEUnit
Definition DIE.h:837
unsigned getSize() const
Definition DIE.h:878
const_child_range children() const
Definition DIE.h:894
IntrusiveBackList< DIE >::iterator child_iterator
Definition DIE.h:886
DIE & addChild(DIE *Child)
Add a child to the DIE.
Definition DIE.h:951
DIE(const DIE &RHS)=delete
LLVM_ABI DIEAbbrev generateAbbrev() const
Generate the abbreviation for this DIE.
Definition DIE.cpp:173
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:265
DIE & addChildFront(DIE *Child)
Definition DIE.h:958
void setSize(unsigned S)
Definition DIE.h:948
static DIE * get(BumpPtrAllocator &Alloc, dwarf::Tag Tag)
Definition DIE.h:865
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:202
child_range children()
Definition DIE.h:891
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:190
void setAbbrevNumber(unsigned I)
Set the abbreviation number for this DIE.
Definition DIE.h:907
iterator_range< child_iterator > child_range
Definition DIE.h:888
unsigned getOffset() const
Get the compile/type unit relative offset of this DIE.
Definition DIE.h:873
void setOffset(unsigned O)
Definition DIE.h:947
void setForceChildren(bool B)
Definition DIE.h:884
bool hasChildren() const
Definition DIE.h:883
LLVM_ABI uint64_t getDebugSectionOffset() const
Get the absolute offset within the .debug_info or .debug_types section for this DIE.
Definition DIE.cpp:184
iterator_range< const_child_iterator > const_child_range
Definition DIE.h:889
dwarf::Tag getTag() const
Definition DIE.h:871
LLVM_ABI void dump() const
Definition DIE.cpp:260
DIE & operator=(const DIE &&RHS)=delete
LLVM_ABI DIE * getParent() const
Definition DIE.cpp:171
DwarfStringPoolEntryRef: Dwarf string pool entry reference.
This class is used to gather all the unique data bits of a node.
Definition FoldingSet.h:162
FoldingSetNode()=default
const_iterator(IntrusiveBackList< T >::iterator X)
Definition DIE.h:663
bool operator==(const const_iterator &X) const
Definition DIE.h:674
const_iterator & operator++()
Definition DIE.h:666
bool operator==(const iterator &X) const
Definition DIE.h:652
void takeNodes(IntrusiveBackList< T > &Other)
Definition DIE.h:611
const T & back() const
Definition DIE.h:603
iterator end()
Definition DIE.h:683
const T & front() const
Definition DIE.h:607
void push_front(T &N)
Definition DIE.h:600
iterator begin()
Definition DIE.h:677
void push_back(T &N)
Definition DIE.h:599
static const_iterator toIterator(const T &N)
Definition DIE.h:687
const_iterator begin() const
Definition DIE.h:680
const_iterator end() const
Definition DIE.h:684
static iterator toIterator(T &N)
Definition DIE.h:686
bool deleteNode(Node &N)
Deletes node N from the list. Note this runs in O(N).
Definition DIE.h:631
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:1685
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
@ Other
Any other memory.
Definition ModRef.h:68
OutputIt copy(R &&Range, OutputIt Out)
Definition STLExtras.h:1901
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:558
#define N
BasicDIEUnit(dwarf::Tag UnitTag)
Definition DIE.h:1021
bool deleteNode(Node &N)
Delete node N by walking through the list until N's predecessor is found.
Definition DIE.h:569
void push_back(Node &N)
Definition DIE.h:541
bool empty() const
Definition DIE.h:539
IntrusiveBackListNode Node
Definition DIE.h:535
void push_front(Node &N)
Definition DIE.h:553
PointerIntPair< IntrusiveBackListNode *, 1 > Next
Definition DIE.h:525
IntrusiveBackListNode * getNext() const
Definition DIE.h:529
A helper struct providing information about the byte size of DW_FORM values that vary in size dependi...
Definition Dwarf.h:1208