[llvm] r240733 - AsmPrinter: Convert DIE::Values to a linked list
David Blaikie
dblaikie at gmail.com
Thu Jun 25 17:07:59 PDT 2015
On Thu, Jun 25, 2015 at 4:46 PM, Duncan P. N. Exon Smith <
dexonsmith at apple.com> wrote:
> Author: dexonsmith
> Date: Thu Jun 25 18:46:41 2015
> New Revision: 240733
>
> URL: http://llvm.org/viewvc/llvm-project?rev=240733&view=rev
> Log:
> AsmPrinter: Convert DIE::Values to a linked list
>
> Change `DIE::Values` to a singly linked list, where each node is
> allocated on a `BumpPtrAllocator`. In order to support `push_back()`,
> the list is circular, and points at the tail element instead of the
> head. I abstracted the core list logic out to `IntrusiveBackList` so
> that it can be reused for `DIE::Children`, which also cares about
> `push_back()`.
>
> This drops llc memory usage from 799 MB down to 735 MB, about 8%.
>
Just looking at the core of this change - where exactly are the memory
savings:
- SmallVector<DIEValue, 12> Values;
+ DIEValueList Values;
Is it just that most DIEs don't have that many values? If we had a lower
small vector size I would imagine it'd be smaller than a linked list -
paying a pointer in every value compared to paying one pointer and one size
to point to all the values? (with any DIE with more than two values that
would be efficient - more than 3 and we could have buffer pointer + size +
capacity and still be winning, no?) Do most DIEs have fewer attributes?
Most I can think of have more than 3...
Presumably I've missed something about how this is a win over alternatives.
>
> (I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`;
> see r236629 for details.)
>
> Modified:
> llvm/trunk/include/llvm/ADT/iterator.h
> llvm/trunk/include/llvm/CodeGen/DIE.h
> llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp
> llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.cpp
> llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.h
> llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
> llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
> llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
> llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h
> llvm/trunk/tools/dsymutil/DwarfLinker.cpp
> llvm/trunk/unittests/CodeGen/DIEHashTest.cpp
>
> Modified: llvm/trunk/include/llvm/ADT/iterator.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/iterator.h?rev=240733&r1=240732&r2=240733&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/ADT/iterator.h (original)
> +++ llvm/trunk/include/llvm/ADT/iterator.h Thu Jun 25 18:46:41 2015
> @@ -162,6 +162,8 @@ protected:
> int>::type = 0)
> : I(std::forward<U &&>(u)) {}
>
> + const WrappedIteratorT &wrapped() const { return I; }
> +
> public:
> typedef DifferenceTypeT difference_type;
>
>
> Modified: llvm/trunk/include/llvm/CodeGen/DIE.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DIE.h?rev=240733&r1=240732&r2=240733&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/CodeGen/DIE.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/DIE.h Thu Jun 25 18:46:41 2015
> @@ -15,6 +15,8 @@
> #define LLVM_LIB_CODEGEN_ASMPRINTER_DIE_H
>
> #include "llvm/ADT/FoldingSet.h"
> +#include "llvm/ADT/PointerIntPair.h"
> +#include "llvm/ADT/STLExtras.h"
> #include "llvm/ADT/SmallVector.h"
> #include "llvm/CodeGen/DwarfStringPoolEntry.h"
> #include "llvm/Support/Dwarf.h"
> @@ -448,6 +450,162 @@ public:
> #endif
> };
>
> +struct IntrusiveBackListNode {
> + PointerIntPair<IntrusiveBackListNode *, 1> Next;
> + IntrusiveBackListNode() : Next(this, true) {}
> +
> + IntrusiveBackListNode *getNext() const {
> + return Next.getInt() ? nullptr : Next.getPointer();
> + }
> +};
> +
> +struct IntrusiveBackListBase {
> + typedef IntrusiveBackListNode Node;
> + Node *Last = nullptr;
> +
> + bool empty() const { return !Last; }
> + void push_back(Node &N) {
> + assert(N.Next.getPointer() == &N && "Expected unlinked node");
> + assert(N.Next.getInt() == true && "Expected unlinked node");
> +
> + if (Last) {
> + N.Next = Last->Next;
> + Last->Next.setPointerAndInt(&N, false);
> + }
> + Last = &N;
> + }
> +};
> +
> +template <class T> class IntrusiveBackList : IntrusiveBackListBase {
> +public:
> + using IntrusiveBackListBase::empty;
> + void push_back(T &N) { IntrusiveBackListBase::push_back(N); }
> + T &back() { return *static_cast<T *>(Last); }
> + const T &back() const { return *static_cast<T *>(Last); }
> +
> + class const_iterator;
> + class iterator
> + : public iterator_facade_base<iterator, std::forward_iterator_tag,
> T> {
> + friend class const_iterator;
> + Node *N = nullptr;
> +
> + public:
> + iterator() = default;
> + explicit iterator(T *N) : N(N) {}
> +
> + iterator &operator++() {
> + N = N->getNext();
> + return *this;
> + }
> +
> + explicit operator bool() const { return N; }
> + T &operator*() const { return *static_cast<T *>(N); }
> +
> + bool operator==(const iterator &X) const { return N == X.N; }
> + bool operator!=(const iterator &X) const { return N != X.N; }
> + };
> +
> + class const_iterator
> + : public iterator_facade_base<const_iterator,
> std::forward_iterator_tag,
> + const T> {
> + const Node *N = nullptr;
> +
> + public:
> + const_iterator() = default;
> + const_iterator(iterator X) : N(X.N) {}
> + explicit const_iterator(const T *N) : N(N) {}
> +
> + const_iterator &operator++() {
> + N = N->getNext();
> + return *this;
> + }
> +
> + explicit operator bool() const { return N; }
> + const T &operator*() const { return *static_cast<const T *>(N); }
> +
> + bool operator==(const const_iterator &X) const { return N == X.N; }
> + bool operator!=(const const_iterator &X) const { return N != X.N; }
> + };
> +
> + iterator begin() {
> + return Last ? iterator(static_cast<T *>(Last->Next.getPointer())) :
> end();
> + }
> + const_iterator begin() const {
> + return const_cast<IntrusiveBackList *>(this)->begin();
> + }
> + iterator end() { return iterator(); }
> + const_iterator end() const { return const_iterator(); }
> +
> + static iterator toIterator(T &N) { return iterator(&N); }
> + static const_iterator toIterator(const T &N) { return
> const_iterator(&N); }
> +};
> +
> +/// A list of DIE values.
> +///
> +/// This is a singly-linked list, but instead of reversing the order of
> +/// insertion, we keep a pointer to the back of the list so we can push in
> +/// order.
> +class DIEValueList {
> + struct Node : IntrusiveBackListNode {
> + DIEValue V;
> + explicit Node(DIEValue V) : V(V) {}
> + };
> +
> + typedef IntrusiveBackList<Node> ListTy;
> + ListTy List;
> +
> +public:
> + bool empty() const { return List.empty(); }
> +
> + class const_iterator;
> + class iterator
> + : public iterator_adaptor_base<iterator, ListTy::iterator,
> + std::forward_iterator_tag, DIEValue>
> {
> + friend class const_iterator;
> + typedef iterator_adaptor_base<iterator, ListTy::iterator,
> + std::forward_iterator_tag,
> + DIEValue> iterator_adaptor;
> +
> + public:
> + iterator() = default;
> + explicit iterator(ListTy::iterator X) : iterator_adaptor(X) {}
> +
> + explicit operator bool() const { return bool(wrapped()); }
> + DIEValue &operator*() const { return wrapped()->V; }
> + };
> +
> + class const_iterator
> + : public iterator_adaptor_base<const_iterator,
> ListTy::const_iterator,
> + std::forward_iterator_tag,
> + const DIEValue> {
> + typedef iterator_adaptor_base<const_iterator, ListTy::const_iterator,
> + std::forward_iterator_tag,
> + const DIEValue> iterator_adaptor;
> +
> + public:
> + const_iterator() = default;
> + const_iterator(DIEValueList::iterator X) :
> iterator_adaptor(X.wrapped()) {}
> + explicit const_iterator(ListTy::const_iterator X) :
> iterator_adaptor(X) {}
> +
> + explicit operator bool() const { return bool(wrapped()); }
> + const DIEValue &operator*() const { return wrapped()->V; }
> + };
> +
> + iterator insert(BumpPtrAllocator &Alloc, DIEValue V) {
> + List.push_back(*new (Alloc) Node(V));
> + return iterator(ListTy::toIterator(List.back()));
> + }
> + template <class... Ts>
> + iterator emplace(BumpPtrAllocator &Alloc, Ts &&... Args) {
> + return insert(Alloc, DIEValue(std::forward<Ts>(Args)...));
> + }
> +
> + iterator begin() { return iterator(List.begin()); }
> + iterator end() { return iterator(List.end()); }
> + const_iterator begin() const { return const_iterator(List.begin()); }
> + const_iterator end() const { return const_iterator(List.end()); }
> +};
> +
>
> //===--------------------------------------------------------------------===//
> /// DIE - A structured debug information entry. Has an abbreviation which
> /// describes its organization.
> @@ -481,7 +639,7 @@ protected:
>
> /// Attribute values.
> ///
> - SmallVector<DIEValue, 12> Values;
> + DIEValueList Values;
>
> protected:
> DIE() : Offset(0), Size(0), Parent(nullptr) {}
> @@ -504,19 +662,20 @@ public:
> return llvm::make_range(Children.begin(), Children.end());
> }
>
> - typedef SmallVectorImpl<DIEValue>::const_iterator value_iterator;
> + typedef DIEValueList::iterator value_iterator;
> typedef iterator_range<value_iterator> value_range;
>
> - value_iterator values_begin() const { return Values.begin(); }
> - value_iterator values_end() const { return Values.end(); }
> - value_range values() const {
> - return llvm::make_range(values_begin(), values_end());
> + value_range values() {
> + return llvm::make_range(Values.begin(), Values.end());
> }
>
> - void setValue(unsigned I, DIEValue New) {
> - assert(I < Values.size());
> - Values[I] = New;
> + typedef DIEValueList::const_iterator const_value_iterator;
> + typedef iterator_range<const_value_iterator> const_value_range;
> +
> + const_value_range values() const {
> + return llvm::make_range(Values.begin(), Values.end());
> }
> +
> DIE *getParent() const { return Parent; }
>
> /// Generate the abbreviation for this DIE.
> @@ -539,10 +698,13 @@ public:
>
> /// addValue - Add a value and attributes to a DIE.
> ///
> - void addValue(DIEValue Value) { Values.push_back(Value); }
> + value_iterator addValue(BumpPtrAllocator &Alloc, DIEValue Value) {
> + return Values.insert(Alloc, Value);
> + }
> template <class T>
> - void addValue(dwarf::Attribute Attribute, dwarf::Form Form, T &&Value) {
> - Values.emplace_back(Attribute, Form, std::forward<T>(Value));
> + value_iterator addValue(BumpPtrAllocator &Alloc, dwarf::Attribute
> Attribute,
> + dwarf::Form Form, T &&Value) {
> + return Values.emplace(Alloc, Attribute, Form, std::forward<T>(Value));
> }
>
> /// addChild - Add a child to the DIE.
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp?rev=240733&r1=240732&r2=240733&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp Thu Jun 25 18:46:41 2015
> @@ -165,18 +165,17 @@ void DIE::print(raw_ostream &O, unsigned
> }
>
> IndentCount += 2;
> - for (unsigned i = 0, N = Values.size(); i < N; ++i) {
> + unsigned I = 0;
> + for (const auto &V : Values) {
> O << Indent;
>
> if (!isBlock)
> - O << dwarf::AttributeString(Values[i].getAttribute());
> + O << dwarf::AttributeString(V.getAttribute());
> else
> - O << "Blk[" << i << "]";
> + O << "Blk[" << I++ << "]";
>
> - O << " "
> - << dwarf::FormEncodingString(Values[i].getForm())
> - << " ";
> - Values[i].print(O);
> + O << " " << dwarf::FormEncodingString(V.getForm()) << " ";
> + V.print(O);
> O << "\n";
> }
> IndentCount -= 2;
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.cpp?rev=240733&r1=240732&r2=240733&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.cpp Thu Jun 25 18:46:41 2015
> @@ -263,7 +263,7 @@ void DIEHash::hashDIEEntry(dwarf::Attrib
>
> // Hash all of the values in a block like set of values. This assumes that
> // all of the data is going to be added as integers.
> -void DIEHash::hashBlockData(const DIE::value_range &Values) {
> +void DIEHash::hashBlockData(const DIE::const_value_range &Values) {
> for (const auto &V : Values)
> Hash.update((uint64_t)V.getDIEInteger().getValue());
> }
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.h?rev=240733&r1=240732&r2=240733&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.h (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.h Thu Jun 25 18:46:41 2015
> @@ -128,7 +128,7 @@ private:
>
> /// \brief Hashes the data in a block like DIEValue, e.g. DW_FORM_block
> or
> /// DW_FORM_exprloc.
> - void hashBlockData(const DIE::value_range &Values);
> + void hashBlockData(const DIE::const_value_range &Values);
>
> /// \brief Hashes the contents pointed to in the .debug_loc section.
> void hashLocList(const DIELocList &LocList);
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=240733&r1=240732&r2=240733&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Thu Jun 25
> 18:46:41 2015
> @@ -42,7 +42,8 @@ void DwarfCompileUnit::addLabelAddress(D
> DD->addArangeLabel(SymbolCU(this, Label));
>
> unsigned idx = DD->getAddressPool().getIndex(Label);
> - Die.addValue(Attribute, dwarf::DW_FORM_GNU_addr_index, DIEInteger(idx));
> + Die.addValue(DIEValueAllocator, Attribute,
> dwarf::DW_FORM_GNU_addr_index,
> + DIEInteger(idx));
> }
>
> void DwarfCompileUnit::addLocalLabelAddress(DIE &Die,
> @@ -52,9 +53,11 @@ void DwarfCompileUnit::addLocalLabelAddr
> DD->addArangeLabel(SymbolCU(this, Label));
>
> if (Label)
> - Die.addValue(Attribute, dwarf::DW_FORM_addr, DIELabel(Label));
> + Die.addValue(DIEValueAllocator, Attribute, dwarf::DW_FORM_addr,
> + DIELabel(Label));
> else
> - Die.addValue(Attribute, dwarf::DW_FORM_addr, DIEInteger(0));
> + Die.addValue(DIEValueAllocator, Attribute, dwarf::DW_FORM_addr,
> + DIEInteger(0));
> }
>
> unsigned DwarfCompileUnit::getOrCreateSourceID(StringRef FileName,
> @@ -225,16 +228,15 @@ void DwarfCompileUnit::addRange(RangeSpa
> CURanges.back().setEnd(Range.getEnd());
> }
>
> -void DwarfCompileUnit::addSectionLabel(DIE &Die, dwarf::Attribute
> Attribute,
> - const MCSymbol *Label,
> - const MCSymbol *Sec) {
> +DIE::value_iterator
> +DwarfCompileUnit::addSectionLabel(DIE &Die, dwarf::Attribute Attribute,
> + const MCSymbol *Label, const MCSymbol
> *Sec) {
> if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())
> - addLabel(Die, Attribute,
> - DD->getDwarfVersion() >= 4 ? dwarf::DW_FORM_sec_offset
> - : dwarf::DW_FORM_data4,
> - Label);
> - else
> - addSectionDelta(Die, Attribute, Label, Sec);
> + return addLabel(Die, Attribute,
> + DD->getDwarfVersion() >= 4 ? dwarf::DW_FORM_sec_offset
> + : dwarf::DW_FORM_data4,
> + Label);
> + return addSectionDelta(Die, Attribute, Label, Sec);
> }
>
> void DwarfCompileUnit::initStmtList() {
> @@ -242,20 +244,19 @@ void DwarfCompileUnit::initStmtList() {
> MCSymbol *LineTableStartSym =
> Asm->OutStreamer->getDwarfLineTableSymbol(getUniqueID());
>
> - stmtListIndex = std::distance(UnitDie.values_begin(),
> UnitDie.values_end());
> -
> // DW_AT_stmt_list is a offset of line number information for this
> // compile unit in debug_line section. For split dwarf this is
> // left in the skeleton CU and so not included.
> // The line table entries are not always emitted in assembly, so it
> // is not okay to use line_table_start here.
> const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
> - addSectionLabel(UnitDie, dwarf::DW_AT_stmt_list, LineTableStartSym,
> - TLOF.getDwarfLineSection()->getBeginSymbol());
> + StmtListValue =
> + addSectionLabel(UnitDie, dwarf::DW_AT_stmt_list, LineTableStartSym,
> + TLOF.getDwarfLineSection()->getBeginSymbol());
> }
>
> void DwarfCompileUnit::applyStmtList(DIE &D) {
> - D.addValue(UnitDie.values_begin()[stmtListIndex]);
> + D.addValue(DIEValueAllocator, *StmtListValue);
> }
>
> void DwarfCompileUnit::attachLowHighPC(DIE &D, const MCSymbol *Begin,
> @@ -361,11 +362,13 @@ void DwarfCompileUnit::constructScopeDIE
> FinalChildren.push_back(std::move(ScopeDIE));
> }
>
> -void DwarfCompileUnit::addSectionDelta(DIE &Die, dwarf::Attribute
> Attribute,
> - const MCSymbol *Hi, const MCSymbol
> *Lo) {
> - Die.addValue(Attribute, DD->getDwarfVersion() >= 4 ?
> dwarf::DW_FORM_sec_offset
> - :
> dwarf::DW_FORM_data4,
> - new (DIEValueAllocator) DIEDelta(Hi, Lo));
> +DIE::value_iterator
> +DwarfCompileUnit::addSectionDelta(DIE &Die, dwarf::Attribute Attribute,
> + const MCSymbol *Hi, const MCSymbol *Lo)
> {
> + return Die.addValue(DIEValueAllocator, Attribute,
> + DD->getDwarfVersion() >= 4 ?
> dwarf::DW_FORM_sec_offset
> + : dwarf::DW_FORM_data4,
> + new (DIEValueAllocator) DIEDelta(Hi, Lo));
> }
>
> void DwarfCompileUnit::addScopeRangeList(DIE &ScopeDIE,
> @@ -781,7 +784,7 @@ void DwarfCompileUnit::addLocationList(D
> unsigned Index) {
> dwarf::Form Form = DD->getDwarfVersion() >= 4 ?
> dwarf::DW_FORM_sec_offset
> : dwarf::DW_FORM_data4;
> - Die.addValue(Attribute, Form, DIELocList(Index));
> + Die.addValue(DIEValueAllocator, Attribute, Form, DIELocList(Index));
> }
>
> void DwarfCompileUnit::applyVariableAttributes(const DbgVariable &Var,
> @@ -798,7 +801,7 @@ void DwarfCompileUnit::applyVariableAttr
> /// Add a Dwarf expression attribute data and value.
> void DwarfCompileUnit::addExpr(DIELoc &Die, dwarf::Form Form,
> const MCExpr *Expr) {
> - Die.addValue((dwarf::Attribute)0, Form, DIEExpr(Expr));
> + Die.addValue(DIEValueAllocator, (dwarf::Attribute)0, Form,
> DIEExpr(Expr));
> }
>
> void DwarfCompileUnit::applySubprogramAttributesToDefinition(
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h?rev=240733&r1=240732&r2=240733&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h Thu Jun 25
> 18:46:41 2015
> @@ -31,7 +31,7 @@ class LexicalScope;
> class DwarfCompileUnit : public DwarfUnit {
> /// The attribute index of DW_AT_stmt_list in the compile unit DIE,
> avoiding
> /// the need to search for it in applyStmtList.
> - unsigned stmtListIndex;
> + DIE::value_iterator StmtListValue;
>
> /// Skeleton unit associated with this unit.
> DwarfCompileUnit *Skeleton;
> @@ -92,8 +92,8 @@ public:
> const MCSymbol *Label);
>
> /// addSectionDelta - Add a label delta attribute data and value.
> - void addSectionDelta(DIE &Die, dwarf::Attribute Attribute, const
> MCSymbol *Hi,
> - const MCSymbol *Lo);
> + DIE::value_iterator addSectionDelta(DIE &Die, dwarf::Attribute
> Attribute,
> + const MCSymbol *Hi, const MCSymbol
> *Lo);
>
> DwarfCompileUnit &getCU() override { return *this; }
>
> @@ -106,8 +106,9 @@ public:
>
> /// addSectionLabel - Add a Dwarf section label attribute data and
> value.
> ///
> - void addSectionLabel(DIE &Die, dwarf::Attribute Attribute,
> - const MCSymbol *Label, const MCSymbol *Sec);
> + DIE::value_iterator addSectionLabel(DIE &Die, dwarf::Attribute
> Attribute,
> + const MCSymbol *Label,
> + const MCSymbol *Sec);
>
> /// \brief Find DIE for the given subprogram and attach appropriate
> /// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=240733&r1=240732&r2=240733&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Thu Jun 25 18:46:41
> 2015
> @@ -184,16 +184,18 @@ void DwarfUnit::insertDIE(const DINode *
>
> void DwarfUnit::addFlag(DIE &Die, dwarf::Attribute Attribute) {
> if (DD->getDwarfVersion() >= 4)
> - Die.addValue(Attribute, dwarf::DW_FORM_flag_present, DIEInteger(1));
> + Die.addValue(DIEValueAllocator, Attribute,
> dwarf::DW_FORM_flag_present,
> + DIEInteger(1));
> else
> - Die.addValue(Attribute, dwarf::DW_FORM_flag, DIEInteger(1));
> + Die.addValue(DIEValueAllocator, Attribute, dwarf::DW_FORM_flag,
> + DIEInteger(1));
> }
>
> void DwarfUnit::addUInt(DIE &Die, dwarf::Attribute Attribute,
> Optional<dwarf::Form> Form, uint64_t Integer) {
> if (!Form)
> Form = DIEInteger::BestForm(false, Integer);
> - Die.addValue(Attribute, *Form, DIEInteger(Integer));
> + Die.addValue(DIEValueAllocator, Attribute, *Form, DIEInteger(Integer));
> }
>
> void DwarfUnit::addUInt(DIE &Block, dwarf::Form Form, uint64_t Integer) {
> @@ -204,7 +206,7 @@ void DwarfUnit::addSInt(DIE &Die, dwarf:
> Optional<dwarf::Form> Form, int64_t Integer) {
> if (!Form)
> Form = DIEInteger::BestForm(true, Integer);
> - Die.addValue(Attribute, *Form, DIEInteger(Integer));
> + Die.addValue(DIEValueAllocator, Attribute, *Form, DIEInteger(Integer));
> }
>
> void DwarfUnit::addSInt(DIELoc &Die, Optional<dwarf::Form> Form,
> @@ -214,14 +216,15 @@ void DwarfUnit::addSInt(DIELoc &Die, Opt
>
> void DwarfUnit::addString(DIE &Die, dwarf::Attribute Attribute,
> StringRef String) {
> - Die.addValue(Attribute,
> + Die.addValue(DIEValueAllocator, Attribute,
> isDwoUnit() ? dwarf::DW_FORM_GNU_str_index :
> dwarf::DW_FORM_strp,
> DIEString(DU->getStringPool().getEntry(*Asm, String)));
> }
>
> -void DwarfUnit::addLabel(DIE &Die, dwarf::Attribute Attribute,
> dwarf::Form Form,
> - const MCSymbol *Label) {
> - Die.addValue(Attribute, Form, DIELabel(Label));
> +DIE::value_iterator DwarfUnit::addLabel(DIE &Die, dwarf::Attribute
> Attribute,
> + dwarf::Form Form,
> + const MCSymbol *Label) {
> + return Die.addValue(DIEValueAllocator, Attribute, Form,
> DIELabel(Label));
> }
>
> void DwarfUnit::addLabel(DIELoc &Die, dwarf::Form Form, const MCSymbol
> *Label) {
> @@ -254,7 +257,7 @@ void DwarfUnit::addOpAddress(DIELoc &Die
>
> void DwarfUnit::addLabelDelta(DIE &Die, dwarf::Attribute Attribute,
> const MCSymbol *Hi, const MCSymbol *Lo) {
> - Die.addValue(Attribute, dwarf::DW_FORM_data4,
> + Die.addValue(DIEValueAllocator, Attribute, dwarf::DW_FORM_data4,
> new (DIEValueAllocator) DIEDelta(Hi, Lo));
> }
>
> @@ -269,8 +272,8 @@ void DwarfUnit::addDIETypeSignature(DIE
> // and think this is a full definition.
> addFlag(Die, dwarf::DW_AT_declaration);
>
> - Die.addValue(dwarf::DW_AT_signature, dwarf::DW_FORM_ref_sig8,
> - DIETypeSignature(Type));
> + Die.addValue(DIEValueAllocator, dwarf::DW_AT_signature,
> + dwarf::DW_FORM_ref_sig8, DIETypeSignature(Type));
> }
>
> void DwarfUnit::addDIEEntry(DIE &Die, dwarf::Attribute Attribute,
> @@ -282,7 +285,7 @@ void DwarfUnit::addDIEEntry(DIE &Die, dw
> DieCU = &getUnitDie();
> if (!EntryCU)
> EntryCU = &getUnitDie();
> - Die.addValue(Attribute,
> + Die.addValue(DIEValueAllocator, Attribute,
> EntryCU == DieCU ? dwarf::DW_FORM_ref4 :
> dwarf::DW_FORM_ref_addr,
> Entry);
> }
> @@ -299,14 +302,15 @@ DIE &DwarfUnit::createAndAddDIE(unsigned
> void DwarfUnit::addBlock(DIE &Die, dwarf::Attribute Attribute, DIELoc
> *Loc) {
> Loc->ComputeSize(Asm);
> DIELocs.push_back(Loc); // Memoize so we can call the destructor later
> on.
> - Die.addValue(Attribute, Loc->BestForm(DD->getDwarfVersion()), Loc);
> + Die.addValue(DIEValueAllocator, Attribute,
> + Loc->BestForm(DD->getDwarfVersion()), Loc);
> }
>
> void DwarfUnit::addBlock(DIE &Die, dwarf::Attribute Attribute,
> DIEBlock *Block) {
> Block->ComputeSize(Asm);
> DIEBlocks.push_back(Block); // Memoize so we can call the destructor
> later on.
> - Die.addValue(Attribute, Block->BestForm(), Block);
> + Die.addValue(DIEValueAllocator, Attribute, Block->BestForm(), Block);
> }
>
> void DwarfUnit::addSourceLine(DIE &Die, unsigned Line, StringRef File,
> @@ -1386,8 +1390,8 @@ void DwarfUnit::constructMemberDIE(DIE &
> // Objective-C properties.
> if (DINode *PNode = DT->getObjCProperty())
> if (DIE *PDie = getDIE(PNode))
> - MemberDie.addValue(dwarf::DW_AT_APPLE_property, dwarf::DW_FORM_ref4,
> - DIEEntry(*PDie));
> + MemberDie.addValue(DIEValueAllocator, dwarf::DW_AT_APPLE_property,
> + dwarf::DW_FORM_ref4, DIEEntry(*PDie));
>
> if (DT->isArtificial())
> addFlag(MemberDie, dwarf::DW_AT_artificial);
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h?rev=240733&r1=240732&r2=240733&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h Thu Jun 25 18:46:41 2015
> @@ -73,6 +73,9 @@ protected:
> /// MDNode for the compile unit.
> const DICompileUnit *CUNode;
>
> + // All DIEValues are allocated through this allocator.
> + BumpPtrAllocator DIEValueAllocator;
> +
> /// Unit debug information entry.
> DIE UnitDie;
>
> @@ -104,9 +107,6 @@ protected:
> /// corresponds to the MDNode mapped with the subprogram DIE.
> DenseMap<DIE *, const DINode *> ContainingTypeMap;
>
> - // All DIEValues are allocated through this allocator.
> - BumpPtrAllocator DIEValueAllocator;
> -
> /// The section this unit will be emitted in.
> MCSection *Section;
>
> @@ -206,8 +206,8 @@ public:
> void addString(DIE &Die, dwarf::Attribute Attribute, StringRef Str);
>
> /// \brief Add a Dwarf label attribute data and value.
> - void addLabel(DIE &Die, dwarf::Attribute Attribute, dwarf::Form Form,
> - const MCSymbol *Label);
> + DIE::value_iterator addLabel(DIE &Die, dwarf::Attribute Attribute,
> + dwarf::Form Form, const MCSymbol *Label);
>
> void addLabel(DIELoc &Die, dwarf::Form Form, const MCSymbol *Label);
>
>
> Modified: llvm/trunk/tools/dsymutil/DwarfLinker.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfLinker.cpp?rev=240733&r1=240732&r2=240733&view=diff
>
> ==============================================================================
> --- llvm/trunk/tools/dsymutil/DwarfLinker.cpp (original)
> +++ llvm/trunk/tools/dsymutil/DwarfLinker.cpp Thu Jun 25 18:46:41 2015
> @@ -60,33 +60,23 @@ using HalfOpenIntervalMap =
>
> typedef HalfOpenIntervalMap<uint64_t, int64_t> FunctionIntervals;
>
> -// FIXME: Delete this structure once DIE::Values has a stable iterator we
> can
> -// use instead.
> +// FIXME: Delete this structure.
> struct PatchLocation {
> - DIE *Die;
> - unsigned Index;
> + DIE::value_iterator I;
>
> - PatchLocation() : Die(nullptr), Index(0) {}
> - PatchLocation(DIE &Die, unsigned Index) : Die(&Die), Index(Index) {}
> - PatchLocation(DIE &Die)
> - : Die(&Die), Index(std::distance(Die.values_begin(),
> Die.values_end())) {}
> + PatchLocation() = default;
> + PatchLocation(DIE::value_iterator I) : I(I) {}
>
> void set(uint64_t New) const {
> - assert(Die);
> - assert((signed)Index <
> - std::distance(Die->values_begin(), Die->values_end()));
> - const auto &Old = Die->values_begin()[Index];
> + assert(I);
> + const auto &Old = *I;
> assert(Old.getType() == DIEValue::isInteger);
> - Die->setValue(Index,
> - DIEValue(Old.getAttribute(), Old.getForm(),
> DIEInteger(New)));
> + *I = DIEValue(Old.getAttribute(), Old.getForm(), DIEInteger(New));
> }
>
> uint64_t get() const {
> - assert(Die);
> - assert((signed)Index <
> - std::distance(Die->values_begin(), Die->values_end()));
> - assert(Die->values_begin()[Index].getType() == DIEValue::isInteger);
> - return Die->values_begin()[Index].getDIEInteger().getValue();
> + assert(I);
> + return I->getDIEInteger().getValue();
> }
> };
>
> @@ -1837,7 +1827,7 @@ unsigned DwarfLinker::cloneStringAttribu
> // Switch everything to out of line strings.
> const char *String = *Val.getAsCString(&U);
> unsigned Offset = StringPool.getStringOffset(String);
> - Die.addValue(dwarf::Attribute(AttrSpec.Attr), dwarf::DW_FORM_strp,
> + Die.addValue(DIEAlloc, dwarf::Attribute(AttrSpec.Attr),
> dwarf::DW_FORM_strp,
> DIEInteger(Offset));
> return 4;
> }
> @@ -1887,18 +1877,21 @@ unsigned DwarfLinker::cloneDieReferenceA
> uint32_t NewRefOffset =
> RefUnit->getStartOffset() + NewRefDie->getOffset();
> Attr = NewRefOffset;
> + Die.addValue(DIEAlloc, dwarf::Attribute(AttrSpec.Attr),
> + dwarf::DW_FORM_ref_addr, DIEInteger(Attr));
> } else {
> // A forward reference. Note and fixup later.
> Attr = 0xBADDEF;
> - Unit.noteForwardReference(NewRefDie, RefUnit, PatchLocation(Die));
> + Unit.noteForwardReference(
> + NewRefDie, RefUnit,
> + Die.addValue(DIEAlloc, dwarf::Attribute(AttrSpec.Attr),
> + dwarf::DW_FORM_ref_addr, DIEInteger(Attr)));
> }
> - Die.addValue(dwarf::Attribute(AttrSpec.Attr), dwarf::DW_FORM_ref_addr,
> - DIEInteger(Attr));
> return AttrSize;
> }
>
> - Die.addValue(dwarf::Attribute(AttrSpec.Attr),
> dwarf::Form(AttrSpec.Form),
> - DIEEntry(*NewRefDie));
> + Die.addValue(DIEAlloc, dwarf::Attribute(AttrSpec.Attr),
> + dwarf::Form(AttrSpec.Form), DIEEntry(*NewRefDie));
> return AttrSize;
> }
>
> @@ -1930,8 +1923,8 @@ unsigned DwarfLinker::cloneBlockAttribut
> dwarf::Form(AttrSpec.Form), Block);
> ArrayRef<uint8_t> Bytes = *Val.getAsBlock();
> for (auto Byte : Bytes)
> - Attr->addValue(static_cast<dwarf::Attribute>(0), dwarf::DW_FORM_data1,
> - DIEInteger(Byte));
> + Attr->addValue(DIEAlloc, static_cast<dwarf::Attribute>(0),
> + dwarf::DW_FORM_data1, DIEInteger(Byte));
> // FIXME: If DIEBlock and DIELoc just reuses the Size field of
> // the DIE class, this if could be replaced by
> // Attr->setSize(Bytes.size()).
> @@ -1941,7 +1934,7 @@ unsigned DwarfLinker::cloneBlockAttribut
> else
> Block->ComputeSize(&Streamer->getAsmPrinter());
> }
> - Die.addValue(Value);
> + Die.addValue(DIEAlloc, Value);
> return AttrSize;
> }
>
> @@ -1975,7 +1968,7 @@ unsigned DwarfLinker::cloneAddressAttrib
> Addr = (Info.OrigHighPc ? Info.OrigHighPc : Addr) + Info.PCOffset;
> }
>
> - Die.addValue(static_cast<dwarf::Attribute>(AttrSpec.Attr),
> + Die.addValue(DIEAlloc, static_cast<dwarf::Attribute>(AttrSpec.Attr),
> static_cast<dwarf::Form>(AttrSpec.Form), DIEInteger(Addr));
> return Unit.getOrigUnit().getAddressByteSize();
> }
> @@ -2004,20 +1997,20 @@ unsigned DwarfLinker::cloneScalarAttribu
> &Unit.getOrigUnit(), &InputDIE);
> return 0;
> }
> - DIEInteger Attr(Value);
> + PatchLocation Patch =
> + Die.addValue(DIEAlloc, dwarf::Attribute(AttrSpec.Attr),
> + dwarf::Form(AttrSpec.Form), DIEInteger(Value));
> if (AttrSpec.Attr == dwarf::DW_AT_ranges)
> - Unit.noteRangeAttribute(Die, PatchLocation(Die));
> + Unit.noteRangeAttribute(Die, Patch);
> // A more generic way to check for location attributes would be
> // nice, but it's very unlikely that any other attribute needs a
> // location list.
> else if (AttrSpec.Attr == dwarf::DW_AT_location ||
> AttrSpec.Attr == dwarf::DW_AT_frame_base)
> - Unit.noteLocationAttribute(PatchLocation(Die), Info.PCOffset);
> + Unit.noteLocationAttribute(Patch, Info.PCOffset);
> else if (AttrSpec.Attr == dwarf::DW_AT_declaration && Value)
> Info.IsDeclaration = true;
>
> - Die.addValue(dwarf::Attribute(AttrSpec.Attr),
> dwarf::Form(AttrSpec.Form),
> - Attr);
> return AttrSize;
> }
>
> @@ -2367,8 +2360,7 @@ static void insertLineSequence(std::vect
> static void patchStmtList(DIE &Die, DIEInteger Offset) {
> for (auto &V : Die.values())
> if (V.getAttribute() == dwarf::DW_AT_stmt_list) {
> - Die.setValue(&V - Die.values_begin(),
> - DIEValue(V.getAttribute(), V.getForm(), Offset));
> + V = DIEValue(V.getAttribute(), V.getForm(), Offset);
> return;
> }
>
>
> Modified: llvm/trunk/unittests/CodeGen/DIEHashTest.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/CodeGen/DIEHashTest.cpp?rev=240733&r1=240732&r2=240733&view=diff
>
> ==============================================================================
> --- llvm/trunk/unittests/CodeGen/DIEHashTest.cpp (original)
> +++ llvm/trunk/unittests/CodeGen/DIEHashTest.cpp Thu Jun 25 18:46:41 2015
> @@ -22,6 +22,10 @@ namespace {
>
> // Test fixture
> class DIEHashTest : public testing::Test {
> +public:
> + BumpPtrAllocator Alloc;
> +
> +private:
> StringMap<DwarfStringPoolEntry> Pool;
>
> public:
> @@ -36,7 +40,7 @@ TEST_F(DIEHashTest, Data1) {
> DIEHash Hash;
> DIE Die(dwarf::DW_TAG_base_type);
> DIEInteger Size(4);
> - Die.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Size);
> + Die.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Size);
> uint64_t MD5Res = Hash.computeTypeSignature(Die);
> ASSERT_EQ(0x1AFE116E83701108ULL, MD5Res);
> }
> @@ -45,11 +49,11 @@ TEST_F(DIEHashTest, Data1) {
> TEST_F(DIEHashTest, TrivialType) {
> DIE Unnamed(dwarf::DW_TAG_structure_type);
> DIEInteger One(1);
> - Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
> + Unnamed.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
> One);
>
> // Line and file number are ignored.
> - Unnamed.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
> - Unnamed.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, One);
> + Unnamed.addValue(Alloc, dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1,
> One);
> + Unnamed.addValue(Alloc, dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1,
> One);
> uint64_t MD5Res = DIEHash().computeTypeSignature(Unnamed);
>
> // The exact same hash GCC produces for this DIE.
> @@ -61,8 +65,8 @@ TEST_F(DIEHashTest, NamedType) {
> DIE Foo(dwarf::DW_TAG_structure_type);
> DIEInteger One(1);
> DIEString FooStr = getString("foo");
> - Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
> - Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
> + Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
> + Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
>
> uint64_t MD5Res = DIEHash().computeTypeSignature(Foo);
>
> @@ -77,15 +81,16 @@ TEST_F(DIEHashTest, NamespacedType) {
> auto Space = make_unique<DIE>(dwarf::DW_TAG_namespace);
> DIEInteger One(1);
> DIEString SpaceStr = getString("space");
> - Space->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, SpaceStr);
> + Space->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp,
> SpaceStr);
> // DW_AT_declaration is ignored.
> - Space->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present,
> One);
> + Space->addValue(Alloc, dwarf::DW_AT_declaration,
> dwarf::DW_FORM_flag_present,
> + One);
> // sibling?
>
> auto Foo = make_unique<DIE>(dwarf::DW_TAG_structure_type);
> DIEString FooStr = getString("foo");
> - Foo->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
> - Foo->addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
> + Foo->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
> + Foo->addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
>
> DIE &N = *Foo;
> Space->addChild(std::move(Foo));
> @@ -101,24 +106,24 @@ TEST_F(DIEHashTest, NamespacedType) {
> TEST_F(DIEHashTest, TypeWithMember) {
> DIE Unnamed(dwarf::DW_TAG_structure_type);
> DIEInteger Four(4);
> - Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
> + Unnamed.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
> Four);
>
> DIE Int(dwarf::DW_TAG_base_type);
> DIEString IntStr = getString("int");
> - Int.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, IntStr);
> - Int.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
> + Int.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, IntStr);
> + Int.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
> DIEInteger Five(5);
> - Int.addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Five);
> + Int.addValue(Alloc, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Five);
>
> DIEEntry IntRef(Int);
>
> auto Member = make_unique<DIE>(dwarf::DW_TAG_member);
> DIEString MemberStr = getString("member");
> - Member->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemberStr);
> + Member->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp,
> MemberStr);
> DIEInteger Zero(0);
> - Member->addValue(dwarf::DW_AT_data_member_location,
> dwarf::DW_FORM_data1,
> - Zero);
> - Member->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntRef);
> + Member->addValue(Alloc, dwarf::DW_AT_data_member_location,
> + dwarf::DW_FORM_data1, Zero);
> + Member->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntRef);
>
> Unnamed.addChild(std::move(Member));
>
> @@ -131,34 +136,34 @@ TEST_F(DIEHashTest, TypeWithMember) {
> TEST_F(DIEHashTest, ReusedType) {
> DIE Unnamed(dwarf::DW_TAG_structure_type);
> DIEInteger Eight(8);
> - Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
> + Unnamed.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
> Eight);
>
> DIEInteger Four(4);
> DIE Int(dwarf::DW_TAG_base_type);
> DIEString IntStr = getString("int");
> - Int.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, IntStr);
> - Int.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
> + Int.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, IntStr);
> + Int.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
> DIEInteger Five(5);
> - Int.addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Five);
> + Int.addValue(Alloc, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Five);
>
> DIEEntry IntRef(Int);
>
> auto Mem1 = make_unique<DIE>(dwarf::DW_TAG_member);
> DIEString Mem1Str = getString("mem1");
> - Mem1->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, Mem1Str);
> + Mem1->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, Mem1Str);
> DIEInteger Zero(0);
> - Mem1->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
> + Mem1->addValue(Alloc, dwarf::DW_AT_data_member_location,
> dwarf::DW_FORM_data1,
> Zero);
> - Mem1->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntRef);
> + Mem1->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntRef);
>
> Unnamed.addChild(std::move(Mem1));
>
> auto Mem2 = make_unique<DIE>(dwarf::DW_TAG_member);
> DIEString Mem2Str = getString("mem2");
> - Mem2->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, Mem2Str);
> - Mem2->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
> + Mem2->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, Mem2Str);
> + Mem2->addValue(Alloc, dwarf::DW_AT_data_member_location,
> dwarf::DW_FORM_data1,
> Four);
> - Mem2->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntRef);
> + Mem2->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntRef);
>
> Unnamed.addChild(std::move(Mem2));
>
> @@ -171,15 +176,15 @@ TEST_F(DIEHashTest, ReusedType) {
> TEST_F(DIEHashTest, RecursiveType) {
> DIE Foo(dwarf::DW_TAG_structure_type);
> DIEInteger One(1);
> - Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
> + Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
> DIEString FooStr = getString("foo");
> - Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
> + Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
>
> auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
> DIEString MemStr = getString("mem");
> - Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
> + Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
> DIEEntry FooRef(Foo);
> - Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRef);
> + Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRef);
> // DW_AT_external and DW_AT_declaration are ignored anyway, so skip
> them.
>
> Foo.addChild(std::move(Mem));
> @@ -193,23 +198,24 @@ TEST_F(DIEHashTest, RecursiveType) {
> TEST_F(DIEHashTest, Pointer) {
> DIE Foo(dwarf::DW_TAG_structure_type);
> DIEInteger Eight(8);
> - Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
> + Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
> Eight);
> DIEString FooStr = getString("foo");
> - Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
> + Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
>
> auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
> DIEString MemStr = getString("mem");
> - Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
> + Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
> DIEInteger Zero(0);
> - Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
> Zero);
> + Mem->addValue(Alloc, dwarf::DW_AT_data_member_location,
> dwarf::DW_FORM_data1,
> + Zero);
>
> DIE FooPtr(dwarf::DW_TAG_pointer_type);
> - FooPtr.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
> + FooPtr.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
> Eight);
> DIEEntry FooRef(Foo);
> - FooPtr.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRef);
> + FooPtr.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRef);
>
> DIEEntry FooPtrRef(FooPtr);
> - Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooPtrRef);
> + Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooPtrRef);
>
> Foo.addChild(std::move(Mem));
>
> @@ -222,27 +228,29 @@ TEST_F(DIEHashTest, Pointer) {
> TEST_F(DIEHashTest, Reference) {
> DIE Foo(dwarf::DW_TAG_structure_type);
> DIEInteger Eight(8);
> - Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
> + Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
> Eight);
> DIEString FooStr = getString("foo");
> - Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
> + Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
>
> auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
> DIEString MemStr = getString("mem");
> - Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
> + Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
> DIEInteger Zero(0);
> - Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
> Zero);
> + Mem->addValue(Alloc, dwarf::DW_AT_data_member_location,
> dwarf::DW_FORM_data1,
> + Zero);
>
> DIE FooRef(dwarf::DW_TAG_reference_type);
> - FooRef.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
> + FooRef.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
> Eight);
> DIEEntry FooEntry(Foo);
> - FooRef.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooEntry);
> + FooRef.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
> FooEntry);
>
> DIE FooRefConst(dwarf::DW_TAG_const_type);
> DIEEntry FooRefRef(FooRef);
> - FooRefConst.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRefRef);
> + FooRefConst.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
> + FooRefRef);
>
> DIEEntry FooRefConstRef(FooRefConst);
> - Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRefConstRef);
> + Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
> FooRefConstRef);
>
> Foo.addChild(std::move(Mem));
>
> @@ -255,27 +263,29 @@ TEST_F(DIEHashTest, Reference) {
> TEST_F(DIEHashTest, RValueReference) {
> DIE Foo(dwarf::DW_TAG_structure_type);
> DIEInteger Eight(8);
> - Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
> + Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
> Eight);
> DIEString FooStr = getString("foo");
> - Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
> + Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
>
> auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
> DIEString MemStr = getString("mem");
> - Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
> + Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
> DIEInteger Zero(0);
> - Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
> Zero);
> + Mem->addValue(Alloc, dwarf::DW_AT_data_member_location,
> dwarf::DW_FORM_data1,
> + Zero);
>
> DIE FooRef(dwarf::DW_TAG_rvalue_reference_type);
> - FooRef.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
> + FooRef.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
> Eight);
> DIEEntry FooEntry(Foo);
> - FooRef.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooEntry);
> + FooRef.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
> FooEntry);
>
> DIE FooRefConst(dwarf::DW_TAG_const_type);
> DIEEntry FooRefRef(FooRef);
> - FooRefConst.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRefRef);
> + FooRefConst.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
> + FooRefRef);
>
> DIEEntry FooRefConstRef(FooRefConst);
> - Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRefConstRef);
> + Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
> FooRefConstRef);
>
> Foo.addChild(std::move(Mem));
>
> @@ -288,24 +298,25 @@ TEST_F(DIEHashTest, RValueReference) {
> TEST_F(DIEHashTest, PtrToMember) {
> DIE Foo(dwarf::DW_TAG_structure_type);
> DIEInteger Eight(8);
> - Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
> + Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
> Eight);
> DIEString FooStr = getString("foo");
> - Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
> + Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
>
> auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
> DIEString MemStr = getString("mem");
> - Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
> + Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
> DIEInteger Zero(0);
> - Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
> Zero);
> + Mem->addValue(Alloc, dwarf::DW_AT_data_member_location,
> dwarf::DW_FORM_data1,
> + Zero);
>
> DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
> DIEEntry FooEntry(Foo);
> - PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooEntry);
> - PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
> + PtrToFooMem.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
> FooEntry);
> + PtrToFooMem.addValue(Alloc, dwarf::DW_AT_containing_type,
> dwarf::DW_FORM_ref4,
> FooEntry);
>
> DIEEntry PtrToFooMemRef(PtrToFooMem);
> - Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PtrToFooMemRef);
> + Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
> PtrToFooMemRef);
>
> Foo.addChild(std::move(Mem));
>
> @@ -329,27 +340,30 @@ TEST_F(DIEHashTest, PtrToMemberDeclDefMa
> uint64_t MD5ResDecl;
> {
> DIE Bar(dwarf::DW_TAG_structure_type);
> - Bar.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
> - Bar.addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present,
> One);
> + Bar.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
> + Bar.addValue(Alloc, dwarf::DW_AT_declaration,
> dwarf::DW_FORM_flag_present,
> + One);
>
> DIE Foo(dwarf::DW_TAG_structure_type);
> - Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
> - Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
> + Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
> Eight);
> + Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
>
> auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
> - Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
> - Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
> - Zero);
> + Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
> + Mem->addValue(Alloc, dwarf::DW_AT_data_member_location,
> + dwarf::DW_FORM_data1, Zero);
>
> DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
> DIEEntry BarEntry(Bar);
> - PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
> BarEntry);
> + PtrToFooMem.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
> + BarEntry);
> DIEEntry FooEntry(Foo);
> - PtrToFooMem.addValue(dwarf::DW_AT_containing_type,
> dwarf::DW_FORM_ref4,
> - FooEntry);
> + PtrToFooMem.addValue(Alloc, dwarf::DW_AT_containing_type,
> + dwarf::DW_FORM_ref4, FooEntry);
>
> DIEEntry PtrToFooMemRef(PtrToFooMem);
> - Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PtrToFooMemRef);
> + Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
> + PtrToFooMemRef);
>
> Foo.addChild(std::move(Mem));
>
> @@ -358,27 +372,29 @@ TEST_F(DIEHashTest, PtrToMemberDeclDefMa
> uint64_t MD5ResDef;
> {
> DIE Bar(dwarf::DW_TAG_structure_type);
> - Bar.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
> - Bar.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
> + Bar.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
> + Bar.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
> One);
>
> DIE Foo(dwarf::DW_TAG_structure_type);
> - Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
> - Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
> + Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
> Eight);
> + Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
>
> auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
> - Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
> - Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
> - Zero);
> + Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
> + Mem->addValue(Alloc, dwarf::DW_AT_data_member_location,
> + dwarf::DW_FORM_data1, Zero);
>
> DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
> DIEEntry BarEntry(Bar);
> - PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
> BarEntry);
> + PtrToFooMem.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
> + BarEntry);
> DIEEntry FooEntry(Foo);
> - PtrToFooMem.addValue(dwarf::DW_AT_containing_type,
> dwarf::DW_FORM_ref4,
> - FooEntry);
> + PtrToFooMem.addValue(Alloc, dwarf::DW_AT_containing_type,
> + dwarf::DW_FORM_ref4, FooEntry);
>
> DIEEntry PtrToFooMemRef(PtrToFooMem);
> - Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PtrToFooMemRef);
> + Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
> + PtrToFooMemRef);
>
> Foo.addChild(std::move(Mem));
>
> @@ -402,26 +418,29 @@ TEST_F(DIEHashTest, PtrToMemberDeclDefMi
> uint64_t MD5ResDecl;
> {
> DIE Bar(dwarf::DW_TAG_structure_type);
> - Bar.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
> - Bar.addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present,
> One);
> + Bar.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
> + Bar.addValue(Alloc, dwarf::DW_AT_declaration,
> dwarf::DW_FORM_flag_present,
> + One);
>
> DIE Foo(dwarf::DW_TAG_structure_type);
> - Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
> - Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
> + Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
> Eight);
> + Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
>
> auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
> - Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
> - Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
> - Zero);
> + Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
> + Mem->addValue(Alloc, dwarf::DW_AT_data_member_location,
> + dwarf::DW_FORM_data1, Zero);
>
> DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
> DIEEntry BarEntry(Bar);
> - PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
> BarEntry);
> - PtrToFooMem.addValue(dwarf::DW_AT_containing_type,
> dwarf::DW_FORM_ref4,
> + PtrToFooMem.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
> BarEntry);
> + PtrToFooMem.addValue(Alloc, dwarf::DW_AT_containing_type,
> + dwarf::DW_FORM_ref4, BarEntry);
>
> DIEEntry PtrToFooMemRef(PtrToFooMem);
> - Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PtrToFooMemRef);
> + Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
> + PtrToFooMemRef);
>
> Foo.addChild(std::move(Mem));
>
> @@ -430,26 +449,28 @@ TEST_F(DIEHashTest, PtrToMemberDeclDefMi
> uint64_t MD5ResDef;
> {
> DIE Bar(dwarf::DW_TAG_structure_type);
> - Bar.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
> - Bar.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
> + Bar.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
> + Bar.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
> One);
>
> DIE Foo(dwarf::DW_TAG_structure_type);
> - Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
> - Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
> + Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
> Eight);
> + Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
>
> auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
> - Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
> - Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
> - Zero);
> + Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
> + Mem->addValue(Alloc, dwarf::DW_AT_data_member_location,
> + dwarf::DW_FORM_data1, Zero);
>
> DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
> DIEEntry BarEntry(Bar);
> - PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
> BarEntry);
> - PtrToFooMem.addValue(dwarf::DW_AT_containing_type,
> dwarf::DW_FORM_ref4,
> + PtrToFooMem.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
> BarEntry);
> + PtrToFooMem.addValue(Alloc, dwarf::DW_AT_containing_type,
> + dwarf::DW_FORM_ref4, BarEntry);
>
> DIEEntry PtrToFooMemRef(PtrToFooMem);
> - Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PtrToFooMemRef);
> + Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
> + PtrToFooMemRef);
>
> Foo.addChild(std::move(Mem));
>
> @@ -473,23 +494,26 @@ TEST_F(DIEHashTest, RefUnnamedType) {
> DIEString MemStr = getString("mem");
>
> DIE Unnamed(dwarf::DW_TAG_structure_type);
> - Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
> + Unnamed.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
> One);
>
> DIE Foo(dwarf::DW_TAG_structure_type);
> - Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
> - Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
> + Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
> Eight);
> + Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
>
> auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
> - Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
> - Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
> Zero);
> + Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
> + Mem->addValue(Alloc, dwarf::DW_AT_data_member_location,
> dwarf::DW_FORM_data1,
> + Zero);
>
> DIE UnnamedPtr(dwarf::DW_TAG_pointer_type);
> - UnnamedPtr.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
> Eight);
> + UnnamedPtr.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
> + Eight);
> DIEEntry UnnamedRef(Unnamed);
> - UnnamedPtr.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, UnnamedRef);
> + UnnamedPtr.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
> + UnnamedRef);
>
> DIEEntry UnnamedPtrRef(UnnamedPtr);
> - Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, UnnamedPtrRef);
> + Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
> UnnamedPtrRef);
>
> Foo.addChild(std::move(Mem));
>
> @@ -502,12 +526,12 @@ TEST_F(DIEHashTest, RefUnnamedType) {
> TEST_F(DIEHashTest, NestedType) {
> DIE Unnamed(dwarf::DW_TAG_structure_type);
> DIEInteger One(1);
> - Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
> + Unnamed.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
> One);
>
> auto Foo = make_unique<DIE>(dwarf::DW_TAG_structure_type);
> DIEString FooStr = getString("foo");
> - Foo->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
> - Foo->addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
> + Foo->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
> + Foo->addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
>
> Unnamed.addChild(std::move(Foo));
>
> @@ -521,11 +545,11 @@ TEST_F(DIEHashTest, NestedType) {
> TEST_F(DIEHashTest, MemberFunc) {
> DIE Unnamed(dwarf::DW_TAG_structure_type);
> DIEInteger One(1);
> - Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
> + Unnamed.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
> One);
>
> auto Func = make_unique<DIE>(dwarf::DW_TAG_subprogram);
> DIEString FuncStr = getString("func");
> - Func->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FuncStr);
> + Func->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FuncStr);
>
> Unnamed.addChild(std::move(Func));
>
> @@ -542,21 +566,24 @@ TEST_F(DIEHashTest, MemberFuncFlag) {
> DIE A(dwarf::DW_TAG_structure_type);
> DIEInteger One(1);
> DIEString AStr = getString("A");
> - A.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, AStr);
> - A.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
> - A.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
> - A.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, One);
> + A.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, AStr);
> + A.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
> + A.addValue(Alloc, dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
> + A.addValue(Alloc, dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, One);
>
> auto Func = make_unique<DIE>(dwarf::DW_TAG_subprogram);
> DIEString FuncStr = getString("func");
> DIEString FuncLinkage = getString("_ZN1A4funcEv");
> DIEInteger Two(2);
> - Func->addValue(dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, One);
> - Func->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FuncStr);
> - Func->addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
> - Func->addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, Two);
> - Func->addValue(dwarf::DW_AT_linkage_name, dwarf::DW_FORM_strp,
> FuncLinkage);
> - Func->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present,
> One);
> + Func->addValue(Alloc, dwarf::DW_AT_external,
> dwarf::DW_FORM_flag_present,
> + One);
> + Func->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FuncStr);
> + Func->addValue(Alloc, dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1,
> One);
> + Func->addValue(Alloc, dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1,
> Two);
> + Func->addValue(Alloc, dwarf::DW_AT_linkage_name, dwarf::DW_FORM_strp,
> + FuncLinkage);
> + Func->addValue(Alloc, dwarf::DW_AT_declaration,
> dwarf::DW_FORM_flag_present,
> + One);
>
> A.addChild(std::move(Func));
>
> @@ -575,35 +602,36 @@ TEST_F(DIEHashTest, MemberSdata) {
> DIE A(dwarf::DW_TAG_structure_type);
> DIEInteger One(1);
> DIEString AStr = getString("A");
> - A.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, AStr);
> - A.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
> - A.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
> - A.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, One);
> + A.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, AStr);
> + A.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
> + A.addValue(Alloc, dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
> + A.addValue(Alloc, dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, One);
>
> DIEInteger Four(4);
> DIEInteger Five(5);
> DIEString FStr = getString("int");
> DIE IntTyDIE(dwarf::DW_TAG_base_type);
> - IntTyDIE.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
> - IntTyDIE.addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Five);
> - IntTyDIE.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FStr);
> + IntTyDIE.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
> Four);
> + IntTyDIE.addValue(Alloc, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
> Five);
> + IntTyDIE.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FStr);
>
> DIEEntry IntTy(IntTyDIE);
> auto PITyDIE = make_unique<DIE>(dwarf::DW_TAG_const_type);
> - PITyDIE->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntTy);
> + PITyDIE->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntTy);
>
> DIEEntry PITy(*PITyDIE);
> auto PI = make_unique<DIE>(dwarf::DW_TAG_member);
> DIEString PIStr = getString("PI");
> DIEInteger Two(2);
> DIEInteger NegThree(-3);
> - PI->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, PIStr);
> - PI->addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
> - PI->addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, Two);
> - PI->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PITy);
> - PI->addValue(dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, One);
> - PI->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present,
> One);
> - PI->addValue(dwarf::DW_AT_const_value, dwarf::DW_FORM_sdata, NegThree);
> + PI->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, PIStr);
> + PI->addValue(Alloc, dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
> + PI->addValue(Alloc, dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, Two);
> + PI->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PITy);
> + PI->addValue(Alloc, dwarf::DW_AT_external, dwarf::DW_FORM_flag_present,
> One);
> + PI->addValue(Alloc, dwarf::DW_AT_declaration,
> dwarf::DW_FORM_flag_present,
> + One);
> + PI->addValue(Alloc, dwarf::DW_AT_const_value, dwarf::DW_FORM_sdata,
> NegThree);
>
> A.addChild(std::move(PI));
>
> @@ -620,32 +648,35 @@ TEST_F(DIEHashTest, MemberBlock) {
> DIE A(dwarf::DW_TAG_structure_type);
> DIEInteger One(1);
> DIEString AStr = getString("A");
> - A.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, AStr);
> - A.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
> - A.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
> - A.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, One);
> + A.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, AStr);
> + A.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
> + A.addValue(Alloc, dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
> + A.addValue(Alloc, dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, One);
>
> DIEInteger Four(4);
> DIEString FStr = getString("float");
> auto FloatTyDIE = make_unique<DIE>(dwarf::DW_TAG_base_type);
> - FloatTyDIE->addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
> Four);
> - FloatTyDIE->addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Four);
> - FloatTyDIE->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FStr);
> + FloatTyDIE->addValue(Alloc, dwarf::DW_AT_byte_size,
> dwarf::DW_FORM_data1,
> + Four);
> + FloatTyDIE->addValue(Alloc, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
> + Four);
> + FloatTyDIE->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp,
> FStr);
>
> DIEEntry FloatTy(*FloatTyDIE);
> auto PITyDIE = make_unique<DIE>(dwarf::DW_TAG_const_type);
> - PITyDIE->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FloatTy);
> + PITyDIE->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
> FloatTy);
>
> DIEEntry PITy(*PITyDIE);
> auto PI = make_unique<DIE>(dwarf::DW_TAG_member);
> DIEString PIStr = getString("PI");
> DIEInteger Two(2);
> - PI->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, PIStr);
> - PI->addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
> - PI->addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, Two);
> - PI->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PITy);
> - PI->addValue(dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, One);
> - PI->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present,
> One);
> + PI->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, PIStr);
> + PI->addValue(Alloc, dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
> + PI->addValue(Alloc, dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, Two);
> + PI->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PITy);
> + PI->addValue(Alloc, dwarf::DW_AT_external, dwarf::DW_FORM_flag_present,
> One);
> + PI->addValue(Alloc, dwarf::DW_AT_declaration,
> dwarf::DW_FORM_flag_present,
> + One);
>
> DIEBlock PIBlock;
> DIEInteger Blk1(0xc3);
> @@ -653,12 +684,13 @@ TEST_F(DIEHashTest, MemberBlock) {
> DIEInteger Blk3(0x48);
> DIEInteger Blk4(0x40);
>
> - PIBlock.addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, Blk1);
> - PIBlock.addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, Blk2);
> - PIBlock.addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, Blk3);
> - PIBlock.addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, Blk4);
> + PIBlock.addValue(Alloc, (dwarf::Attribute)0, dwarf::DW_FORM_data1,
> Blk1);
> + PIBlock.addValue(Alloc, (dwarf::Attribute)0, dwarf::DW_FORM_data1,
> Blk2);
> + PIBlock.addValue(Alloc, (dwarf::Attribute)0, dwarf::DW_FORM_data1,
> Blk3);
> + PIBlock.addValue(Alloc, (dwarf::Attribute)0, dwarf::DW_FORM_data1,
> Blk4);
>
> - PI->addValue(dwarf::DW_AT_const_value, dwarf::DW_FORM_block1, &PIBlock);
> + PI->addValue(Alloc, dwarf::DW_AT_const_value, dwarf::DW_FORM_block1,
> + &PIBlock);
>
> A.addChild(std::move(PI));
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150625/20c4dcac/attachment.html>
More information about the llvm-commits
mailing list