Index: llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h =================================================================== --- llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h +++ llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h @@ -43,6 +43,7 @@ namespace llvm { class DataExtractor; +class MCRegisterInfo; class MemoryBuffer; class raw_ostream; @@ -85,6 +86,8 @@ bool CheckedForDWP = false; std::string DWPName; + std::unique_ptr RegInfo; + /// Read compile units from the debug_info section (if necessary) /// and store them in CUs. void parseCompileUnits(); @@ -106,9 +109,9 @@ public: DWARFContext(std::unique_ptr DObj, - std::string DWPName = "") - : DIContext(CK_DWARF), DWPName(std::move(DWPName)), - DObj(std::move(DObj)) {} + std::string DWPName = ""); + ~DWARFContext(); + DWARFContext(DWARFContext &) = delete; DWARFContext &operator=(DWARFContext &) = delete; @@ -243,6 +246,8 @@ std::shared_ptr getDWOContext(StringRef AbsolutePath); + const MCRegisterInfo *getRegisterInfo() const { return RegInfo.get(); } + /// Function used to handle default error reporting policy. Prints a error /// message and returns Continue, so DWARF context ignores the error. static ErrorPolicy defaultErrorHandler(Error E); @@ -255,6 +260,11 @@ create(const StringMap> &Sections, uint8_t AddrSize, bool isLittleEndian = sys::IsLittleEndianHost); + /// Loads register info for the architecture of the provided object file. + /// Improves readability of dumped DWARF expressions. Requires the caller to + /// have initialized the relevant target descriptions. + Error loadRegisterInfo(const object::ObjectFile &Obj); + private: /// Return the compile unit that includes an offset (relative to .debug_info). DWARFCompileUnit *getCompileUnitForOffset(uint32_t Offset); Index: llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h =================================================================== --- llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h +++ llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h @@ -10,6 +10,7 @@ #ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGLOC_H #define LLVM_DEBUGINFO_DWARF_DWARFDEBUGLOC_H +#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" #include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h" @@ -18,8 +19,10 @@ namespace llvm { class raw_ostream; +class DWARFUnit; class DWARFDebugLoc { +public: /// A single location within a location list. struct Entry { /// The beginning address of the instruction range. @@ -27,7 +30,7 @@ /// The ending address of the instruction range. uint64_t End; /// The location of the variable within the specified range. - SmallVector Loc; + SmallVector Loc; }; /// A list of locations that contain one variable. @@ -37,8 +40,11 @@ unsigned Offset; /// All the locations in which the variable is stored. SmallVector Entries; + /// Dump this list on OS. + void dump(raw_ostream &OS, const DWARFUnit* Unit, unsigned Indent) const; }; +private: using LocationLists = SmallVector; /// A list of all the variables in the debug_loc section, each one describing @@ -47,32 +53,43 @@ public: /// Print the location lists found within the debug_loc section. - void dump(raw_ostream &OS) const; + void dump(raw_ostream &OS, const DWARFUnit *Unit) const; /// Parse the debug_loc section accessible via the 'data' parameter using the /// address size also given in 'data' to interpret the address ranges. void parse(const DWARFDataExtractor &data); + + Optional parseOneLocationList(DWARFDataExtractor Data, + unsigned AddressSize, + uint32_t *Offset); }; class DWARFDebugLocDWO { +public: struct Entry { uint64_t Start; uint32_t Length; - SmallVector Loc; + SmallVector Loc; }; struct LocationList { unsigned Offset; SmallVector Entries; + void dump(raw_ostream &OS, const DWARFUnit *Unit, + unsigned Indent = 12) const; }; +private: using LocationLists = SmallVector; LocationLists Locations; public: void parse(DataExtractor data); - void dump(raw_ostream &OS) const; + void dump(raw_ostream &OS, const DWARFUnit *Unit) const; + + static Optional parseOneLocationList(DataExtractor Data, + uint32_t *Offset); }; } // end namespace llvm Index: llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h =================================================================== --- /dev/null +++ llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h @@ -0,0 +1,144 @@ +//===--- DWARFExpression.h - DWARF Expression handling ----------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARFEXPRESSION_H +#define LLVM_DEBUGINFO_DWARFEXPRESSION_H + +#include "llvm/ADT/iterator.h" +#include "llvm/ADT/iterator_range.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/Support/DataExtractor.h" + +namespace llvm { +class DWARFUnit; +class raw_ostream; + +class DWARFExpression { +public: + class iterator; + + /// This class represents an Operation in the Expression. Each operation can + /// have up to 2 oprerands. + /// + /// An Operation can be in Error state (check with isError()). This + /// means that it couldn't be decoded successfully and if it is the + /// case, all others fields contain undefined values. + class Op { + public: + /// Size and signedness of expression operations' operands. + enum Encoding : uint8_t { + Size1 = 0, + Size2 = 1, + Size4 = 2, + Size8 = 3, + SizeLEB = 4, + SizeAddr = 5, + SizeRefAddr = 6, + SizeBlock = 7, ///< Preceding operand contains block size + SignBit = 0x8, + SignedSize1 = SignBit | Size1, + SignedSize2 = SignBit | Size2, + SignedSize4 = SignBit | Size4, + SignedSize8 = SignBit | Size8, + SignedSizeLEB = SignBit | SizeLEB, + SizeNA = 0xFF ///< Unused operands get this encoding. + }; + + enum DwarfVersion : uint8_t { + DwarfNA, ///< Serves as a marker for unused entries + Dwarf2 = 2, + Dwarf3, + Dwarf4 + }; + + /// Description of the encoding of one expression Op. + struct Description { + DwarfVersion Version; ///< Dwarf version where the Op was introduced. + Encoding Op[2]; ///< Encoding for Op operands, or SizeNA. + + Description(DwarfVersion Version = DwarfNA, Encoding Op1 = SizeNA, + Encoding Op2 = SizeNA) + : Version(Version) { + Op[0] = Op1; + Op[1] = Op2; + } + }; + + private: + friend class DWARFExpression::iterator; + uint8_t Opcode; ///< The Op Opcode, DW_OP_. + Description Desc; + bool Error; + uint32_t EndOffset; + uint64_t Operands[2]; + + public: + Description &getDescription() { return Desc; } + uint8_t getCode() { return Opcode; } + uint64_t getRawOperand(unsigned Idx) { return Operands[Idx]; } + uint32_t getEndOffset() { return EndOffset; } + bool extract(DataExtractor Data, const DWARFUnit *U, uint32_t Offset); + bool isError() { return Error; } + bool print(raw_ostream &OS, const DWARFExpression *U, bool isEH); + }; + + /// An iterator to go through the expression operations. + class iterator + : public iterator_facade_base { + friend class DWARFExpression; + DWARFExpression *Expression; + uint32_t Offset; + Op Op; + iterator(DWARFExpression *Expression, uint32_t Offset) + : Expression(Expression), Offset(Offset) { + Op.Error = Offset >= Expression->Data.getData().size() || + !Op.extract(Expression->Data, Expression->Unit, Offset); + } + + public: + class Op& operator++() { + Offset = Op.isError() ? Expression->Data.getData().size() : Op.EndOffset; + Op.Error = Offset >= Expression->Data.getData().size() || + !Op.extract(Expression->Data, Expression->Unit, Offset); + return Op; + } + + class Op &operator*() { + return Op; + } + + // Comparison operators are provided out of line. + friend bool operator==(const iterator&, const iterator&); + }; + + DWARFExpression(DataExtractor Data, const DWARFUnit *Unit) + : Data(Data), Unit(Unit) {} + + iterator begin() { return iterator(this, 0); } + iterator end() { return iterator(this, Data.getData().size()); } + + void print(raw_ostream &OS); + +private: + DataExtractor Data; + const DWARFUnit *Unit; +}; + +inline bool operator==(const DWARFExpression::iterator &LHS, + const DWARFExpression::iterator &RHS) { + return LHS.Expression == RHS.Expression && LHS.Offset == RHS.Offset; +} + +inline bool operator!=(const DWARFExpression::iterator &LHS, + const DWARFExpression::iterator &RHS) { + return !(LHS == RHS); +} + +} +#endif Index: llvm/lib/DebugInfo/DWARF/CMakeLists.txt =================================================================== --- llvm/lib/DebugInfo/DWARF/CMakeLists.txt +++ llvm/lib/DebugInfo/DWARF/CMakeLists.txt @@ -15,6 +15,7 @@ DWARFDebugPubTable.cpp DWARFDebugRangeList.cpp DWARFDie.cpp + DWARFExpression.cpp DWARFFormValue.cpp DWARFGdbIndex.cpp DWARFTypeUnit.cpp Index: llvm/lib/DebugInfo/DWARF/DWARFContext.cpp =================================================================== --- llvm/lib/DebugInfo/DWARF/DWARFContext.cpp +++ llvm/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -31,10 +31,12 @@ #include "llvm/DebugInfo/DWARF/DWARFSection.h" #include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h" #include "llvm/DebugInfo/DWARF/DWARFVerifier.h" +#include "llvm/MC/MCRegisterInfo.h" #include "llvm/Object/Decompressor.h" #include "llvm/Object/MachO.h" #include "llvm/Object/ObjectFile.h" #include "llvm/Object/RelocVisitor.h" +#include "llvm/Support/TargetRegistry.h" #include "llvm/Support/Casting.h" #include "llvm/Support/DataExtractor.h" #include "llvm/Support/Error.h" @@ -59,6 +61,12 @@ using FileLineInfoKind = DILineInfoSpecifier::FileLineInfoKind; using FunctionNameKind = DILineInfoSpecifier::FunctionNameKind; +DWARFContext::DWARFContext(std::unique_ptr DObj, + std::string DWPName) + : DIContext(CK_DWARF), DWPName(std::move(DWPName)), DObj(std::move(DObj)) {} + +DWARFContext::~DWARFContext() = default; + static void dumpAccelSection(raw_ostream &OS, StringRef Name, const DWARFObject &Obj, const DWARFSection &Section, @@ -237,12 +245,18 @@ if (DumpType == DIDT_All || DumpType == DIDT_Loc) { OS << "\n.debug_loc contents:\n"; - getDebugLoc()->dump(OS); + // The compile unit is wrong, but the same dirty trick is used in + // getDebugLoc(). + if (getNumCompileUnits()) + getDebugLoc()->dump(OS, getCompileUnitAtIndex(0)); } if (DumpType == DIDT_All || DumpType == DIDT_LocDwo) { OS << "\n.debug_loc.dwo contents:\n"; - getDebugLocDWO()->dump(OS); + // The compile unit is wrong, but the same dirty trick is used in + // getDebugLoc(). + if (getNumCompileUnits()) + getDebugLocDWO()->dump(OS, getCompileUnitAtIndex(0)); } if (DumpType == DIDT_All || DumpType == DIDT_Frames) { @@ -838,6 +852,7 @@ return std::shared_ptr(std::move(S), Ctxt); } + static Error createError(const Twine &Reason, llvm::Error E) { return make_error(Reason + toString(std::move(E)), inconvertibleErrorCode()); @@ -1295,3 +1310,19 @@ llvm::make_unique(Sections, AddrSize, isLittleEndian); return llvm::make_unique(std::move(DObj), ""); } + +Error DWARFContext::loadRegisterInfo(const object::ObjectFile &Obj) { + // Detect the architecture from the object file. We usually don't need OS + // info to lookup a target and create register info. + Triple TT; + TT.setArch(Triple::ArchType(Obj.getArch())); + TT.setVendor(Triple::UnknownVendor); + TT.setOS(Triple::UnknownOS); + std::string TargetLookupError; + const Target *TheTarget = + TargetRegistry::lookupTarget(TT.str(), TargetLookupError); + if (!TargetLookupError.empty()) + return make_error(TargetLookupError, inconvertibleErrorCode()); + RegInfo.reset(TheTarget->createMCRegInfo(TT.str())); + return Error::success(); +} Index: llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp =================================================================== --- llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp +++ llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp @@ -11,7 +11,10 @@ #include "llvm/ADT/StringRef.h" #include "llvm/BinaryFormat/Dwarf.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" +#include "llvm/DebugInfo/DWARF/DWARFExpression.h" #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h" +#include "llvm/DebugInfo/DWARF/DWARFUnit.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" #include @@ -20,104 +23,144 @@ using namespace llvm; -void DWARFDebugLoc::dump(raw_ostream &OS) const { +void DWARFDebugLoc::LocationList::dump(raw_ostream& OS, const DWARFUnit *Unit, + unsigned Indent) const +{ + for (const Entry &E : Entries) { + OS << '\n'; + OS.indent(Indent); + OS << format("0x%016" PRIx64, E.Begin + Unit->getBaseAddress()) << " - " + << format("0x%016" PRIx64, E.End + Unit->getBaseAddress()) << ": "; + + DWARFDataExtractor Data(StringRef((const char*)E.Loc.data(), E.Loc.size()), + Unit->getDebugInfoExtractor().isLittleEndian(), + Unit->getAddressByteSize()); + DWARFExpression(Data, Unit).print(OS); + } +} + +void DWARFDebugLoc::dump(raw_ostream &OS, const DWARFUnit *Unit) const { for (const LocationList &L : Locations) { OS << format("0x%8.8x: ", L.Offset); - const unsigned Indent = 12; - for (const Entry &E : L.Entries) { - if (&E != L.Entries.begin()) - OS.indent(Indent); - OS << "Beginning address offset: " << format("0x%016" PRIx64, E.Begin) - << '\n'; - OS.indent(Indent) << " Ending address offset: " - << format("0x%016" PRIx64, E.End) << '\n'; - OS.indent(Indent) << " Location description: "; - for (unsigned char Loc : E.Loc) { - OS << format("%2.2x ", Loc); - } - OS << "\n\n"; + L.dump(OS, Unit, sizeof("0x00000000: ")); + OS << "\n\n"; + } +} + +Optional +DWARFDebugLoc::parseOneLocationList(DWARFDataExtractor Data, unsigned AddressSize, + unsigned *Offset) { + LocationList LL; + LL.Offset = *Offset; + + // 2.6.2 Location Lists + // A location list entry consists of: + while (true) { + Entry E; + if (!Data.isValidOffsetForDataOfSize(*Offset, 2 * AddressSize)) { + llvm::errs() << "Location list overflows the debug_loc section.\n"; + return None; + } + + // 1. A beginning address offset. ... + E.Begin = Data.getRelocatedAddress(Offset); + + // 2. An ending address offset. ... + E.End = Data.getRelocatedAddress(Offset); + + // The end of any given location list is marked by an end of list entry, + // which consists of a 0 for the beginning address offset and a 0 for the + // ending address offset. + if (E.Begin == 0 && E.End == 0) + return LL; + + if (!Data.isValidOffsetForDataOfSize(*Offset, 2)) { + llvm::errs() << "Location list overflows the debug_loc section.\n"; + return None; + } + + unsigned Bytes = Data.getU16(Offset); + if (!Data.isValidOffsetForDataOfSize(*Offset, Bytes)) { + llvm::errs() << "Location list overflows the debug_loc section.\n"; + return None; } + // A single location description describing the location of the object... + StringRef str = Data.getData().substr(*Offset, Bytes); + *Offset += Bytes; + E.Loc.reserve(str.size()); + std::copy(str.begin(), str.end(), std::back_inserter(E.Loc)); + LL.Entries.push_back(std::move(E)); } } void DWARFDebugLoc::parse(const DWARFDataExtractor &data) { uint32_t Offset = 0; - while (data.isValidOffset(Offset+data.getAddressSize()-1)) { - Locations.resize(Locations.size() + 1); - LocationList &Loc = Locations.back(); - Loc.Offset = Offset; - // 2.6.2 Location Lists - // A location list entry consists of: - while (true) { - // A beginning and ending address offsets. - Entry E; - E.Begin = data.getRelocatedAddress(&Offset); - E.End = data.getRelocatedAddress(&Offset); - - // The end of any given location list is marked by an end of list entry, - // which consists of a 0 for the beginning address offset and a 0 for the - // ending address offset. - if (E.Begin == 0 && E.End == 0) - break; - - unsigned Bytes = data.getU16(&Offset); - // A single location description describing the location of the object... - StringRef str = data.getData().substr(Offset, Bytes); - Offset += Bytes; - E.Loc.append(str.begin(), str.end()); - Loc.Entries.push_back(std::move(E)); - } + while (data.isValidOffset(Offset + data.getAddressSize() - 1)) { + if (auto LL = parseOneLocationList(data, data.getAddressSize(), &Offset)) + Locations.push_back(std::move(*LL)); + else + break; } if (data.isValidOffset(Offset)) errs() << "error: failed to consume entire .debug_loc section\n"; } +Optional +DWARFDebugLocDWO::parseOneLocationList(DataExtractor Data, unsigned *Offset) { + LocationList LL; + LL.Offset = *Offset; + + // dwarf::DW_LLE_end_of_list_entry is 0 and indicates the end of the list. + while (auto Kind = static_cast(Data.getU8(Offset))) { + if (Kind != dwarf::DW_LLE_startx_length) { + llvm::errs() << "error: dumping support for LLE of kind " << (int)Kind + << " not implemented\n"; + return None; + } + + Entry E; + E.Start = Data.getULEB128(Offset); + E.Length = Data.getU32(Offset); + + unsigned Bytes = Data.getU16(Offset); + // A single location description describing the location of the object... + StringRef str = Data.getData().substr(*Offset, Bytes); + *Offset += Bytes; + E.Loc.resize(str.size()); + std::copy(str.begin(), str.end(), E.Loc.begin()); + + LL.Entries.push_back(std::move(E)); + } + return LL; +} + void DWARFDebugLocDWO::parse(DataExtractor data) { uint32_t Offset = 0; while (data.isValidOffset(Offset)) { - Locations.resize(Locations.size() + 1); - LocationList &Loc = Locations.back(); - Loc.Offset = Offset; - dwarf::LocationListEntry Kind; - while ((Kind = static_cast( - data.getU8(&Offset))) != dwarf::DW_LLE_end_of_list) { - - if (Kind != dwarf::DW_LLE_startx_length) { - errs() << "error: dumping support for LLE of kind " << (int)Kind - << " not implemented\n"; - return; - } - - Entry E; - - E.Start = data.getULEB128(&Offset); - E.Length = data.getU32(&Offset); - - unsigned Bytes = data.getU16(&Offset); - // A single location description describing the location of the object... - StringRef str = data.getData().substr(Offset, Bytes); - Offset += Bytes; - E.Loc.resize(str.size()); - std::copy(str.begin(), str.end(), E.Loc.begin()); - - Loc.Entries.push_back(std::move(E)); - } + if (auto LL = parseOneLocationList(data, &Offset)) + Locations.push_back(std::move(*LL)); + else + return; } } -void DWARFDebugLocDWO::dump(raw_ostream &OS) const { +void DWARFDebugLocDWO::LocationList::dump(raw_ostream &OS, const DWARFUnit *Unit, + unsigned Indent) const { + for (const Entry &E : Entries) { + OS << '\n'; + OS.indent(Indent); + OS << "Addr idx " << E.Start << " (w/ length " << E.Length << "): "; + DWARFDataExtractor Data(StringRef(E.Loc.data(), E.Loc.size()), + Unit->getDebugInfoExtractor().isLittleEndian(), + Unit->getAddressByteSize()); + DWARFExpression(Data, Unit).print(OS); + } +} + +void DWARFDebugLocDWO::dump(raw_ostream &OS, const DWARFUnit *Unit) const { for (const LocationList &L : Locations) { OS << format("0x%8.8x: ", L.Offset); - const unsigned Indent = 12; - for (const Entry &E : L.Entries) { - if (&E != L.Entries.begin()) - OS.indent(Indent); - OS << "Beginning address index: " << E.Start << '\n'; - OS.indent(Indent) << " Length: " << E.Length << '\n'; - OS.indent(Indent) << " Location description: "; - for (unsigned char Loc : E.Loc) - OS << format("%2.2x ", Loc); - OS << "\n\n"; - } + L.dump(OS, Unit); + OS << "\n\n"; } } Index: llvm/lib/DebugInfo/DWARF/DWARFDie.cpp =================================================================== --- llvm/lib/DebugInfo/DWARF/DWARFDie.cpp +++ llvm/lib/DebugInfo/DWARF/DWARFDie.cpp @@ -16,6 +16,7 @@ #include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" #include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h" +#include "llvm/DebugInfo/DWARF/DWARFExpression.h" #include "llvm/DebugInfo/DWARF/DWARFFormValue.h" #include "llvm/DebugInfo/DWARF/DWARFUnit.h" #include "llvm/Object/ObjectFile.h" @@ -81,6 +82,46 @@ } } +static void dumpLocation(raw_ostream &OS, DWARFFormValue &FormValue, + DWARFUnit *U, unsigned Indent) { + DWARFContext &Ctx = U->getContext(); + const DWARFObject &Obj = Ctx.getDWARFObj(); + if (FormValue.isFormClass(DWARFFormValue::FC_Block) || + FormValue.isFormClass(DWARFFormValue::FC_Exprloc)) { + ArrayRef Expr = *FormValue.getAsBlock(); + DataExtractor Data(StringRef((const char *)Expr.data(), Expr.size()), + Ctx.isLittleEndian(), 0); + DWARFExpression(Data, U).print(OS); + return; + } + + FormValue.dump(OS); + if (FormValue.isFormClass(DWARFFormValue::FC_SectionOffset)) { + const DWARFSection &LocSection = Obj.getLocSection(); + const DWARFSection &LocDWOSection = Obj.getLocDWOSection(); + uint32_t Offset = *FormValue.getAsSectionOffset(); + + if (!LocSection.Data.empty()) { + DWARFDebugLoc DebugLoc; + DWARFDataExtractor Data(Obj, LocSection, Ctx.isLittleEndian(), + Obj.getAddressSize()); + auto LL = + DebugLoc.parseOneLocationList(Data, U->getAddressByteSize(), &Offset); + if (LL) + LL->dump(OS, U, Indent); + else + OS << "error extracting location list."; + } else if (!LocDWOSection.Data.empty()) { + DataExtractor Data(LocDWOSection.Data, Ctx.isLittleEndian(), 0); + auto LL = DWARFDebugLocDWO::parseOneLocationList(Data, &Offset); + if (LL) + LL->dump(OS, U, Indent); + else + OS << "error extracting location list."; + } + } +} + static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die, uint32_t *OffsetPtr, dwarf::Attribute Attr, dwarf::Form Form, unsigned Indent, @@ -129,6 +170,9 @@ WithColor(OS, Color) << Name; else if (Attr == DW_AT_decl_line || Attr == DW_AT_call_line) OS << *formValue.getAsUnsignedConstant(); + else if (Attr == DW_AT_location || Attr == DW_AT_frame_base || + Attr == DW_AT_data_member_location) + dumpLocation(OS, formValue, U, sizeof(BaseIndent) + Indent + 4); else formValue.dump(OS, DumpOpts); Index: llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp =================================================================== --- /dev/null +++ llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp @@ -0,0 +1,267 @@ +//===-- DWARFExpression.cpp -----------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "llvm/DebugInfo/DWARF/DWARFExpression.h" +#include "llvm/BinaryFormat/Dwarf.h" +#include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h" +#include "llvm/DebugInfo/DWARF/DWARFContext.h" +#include "llvm/MC/MCRegisterInfo.h" +#include "llvm/Support/Format.h" +#include +#include +#include + +using namespace llvm; +using namespace dwarf; + +namespace llvm { + +typedef std::vector DescVector; + +static DescVector getDescriptions() { + DescVector Descriptions; + typedef DWARFExpression::Op Op; + typedef Op::Description Desc; + + Descriptions.resize(0xff); + Descriptions[DW_OP_addr] = Desc(Op::Dwarf2, Op::SizeAddr); + Descriptions[DW_OP_deref] = Desc(Op::Dwarf2); + Descriptions[DW_OP_const1u] = Desc(Op::Dwarf2, Op::Size1); + Descriptions[DW_OP_const1s] = Desc(Op::Dwarf2, Op::SignedSize1); + Descriptions[DW_OP_const2u] = Desc(Op::Dwarf2, Op::Size2); + Descriptions[DW_OP_const2s] = Desc(Op::Dwarf2, Op::SignedSize2); + Descriptions[DW_OP_const4u] = Desc(Op::Dwarf2, Op::Size4); + Descriptions[DW_OP_const4s] = Desc(Op::Dwarf2, Op::SignedSize4); + Descriptions[DW_OP_const8u] = Desc(Op::Dwarf2, Op::Size8); + Descriptions[DW_OP_const8s] = Desc(Op::Dwarf2, Op::SignedSize8); + Descriptions[DW_OP_constu] = Desc(Op::Dwarf2, Op::SizeLEB); + Descriptions[DW_OP_consts] = Desc(Op::Dwarf2, Op::SignedSizeLEB); + Descriptions[DW_OP_dup] = Desc(Op::Dwarf2); + Descriptions[DW_OP_drop] = Desc(Op::Dwarf2); + Descriptions[DW_OP_over] = Desc(Op::Dwarf2); + Descriptions[DW_OP_pick] = Desc(Op::Dwarf2, Op::Size1); + Descriptions[DW_OP_swap] = Desc(Op::Dwarf2); + Descriptions[DW_OP_rot] = Desc(Op::Dwarf2); + Descriptions[DW_OP_xderef] = Desc(Op::Dwarf2); + Descriptions[DW_OP_abs] = Desc(Op::Dwarf2); + Descriptions[DW_OP_and] = Desc(Op::Dwarf2); + Descriptions[DW_OP_div] = Desc(Op::Dwarf2); + Descriptions[DW_OP_minus] = Desc(Op::Dwarf2); + Descriptions[DW_OP_mod] = Desc(Op::Dwarf2); + Descriptions[DW_OP_mul] = Desc(Op::Dwarf2); + Descriptions[DW_OP_neg] = Desc(Op::Dwarf2); + Descriptions[DW_OP_not] = Desc(Op::Dwarf2); + Descriptions[DW_OP_or] = Desc(Op::Dwarf2); + Descriptions[DW_OP_plus] = Desc(Op::Dwarf2); + Descriptions[DW_OP_plus_uconst] = Desc(Op::Dwarf2, Op::SizeLEB); + Descriptions[DW_OP_shl] = Desc(Op::Dwarf2); + Descriptions[DW_OP_shr] = Desc(Op::Dwarf2); + Descriptions[DW_OP_shra] = Desc(Op::Dwarf2); + Descriptions[DW_OP_xor] = Desc(Op::Dwarf2); + Descriptions[DW_OP_skip] = Desc(Op::Dwarf2, Op::SignedSize2); + Descriptions[DW_OP_bra] = Desc(Op::Dwarf2, Op::SignedSize2); + Descriptions[DW_OP_eq] = Desc(Op::Dwarf2); + Descriptions[DW_OP_ge] = Desc(Op::Dwarf2); + Descriptions[DW_OP_gt] = Desc(Op::Dwarf2); + Descriptions[DW_OP_le] = Desc(Op::Dwarf2); + Descriptions[DW_OP_lt] = Desc(Op::Dwarf2); + Descriptions[DW_OP_ne] = Desc(Op::Dwarf2); + for (uint16_t LA = DW_OP_lit0; LA <= DW_OP_lit31; ++LA) + Descriptions[LA] = Desc(Op::Dwarf2); + for (uint16_t LA = DW_OP_reg0; LA <= DW_OP_reg31; ++LA) + Descriptions[LA] = Desc(Op::Dwarf2); + for (uint16_t LA = DW_OP_breg0; LA <= DW_OP_breg31; ++LA) + Descriptions[LA] = Desc(Op::Dwarf2, Op::SignedSizeLEB); + Descriptions[DW_OP_regx] = Desc(Op::Dwarf2, Op::SizeLEB); + Descriptions[DW_OP_fbreg] = Desc(Op::Dwarf2, Op::SignedSizeLEB); + Descriptions[DW_OP_bregx] = Desc(Op::Dwarf2, Op::SizeLEB, Op::SignedSizeLEB); + Descriptions[DW_OP_piece] = Desc(Op::Dwarf2, Op::SizeLEB); + Descriptions[DW_OP_deref_size] = Desc(Op::Dwarf2, Op::Size1); + Descriptions[DW_OP_xderef_size] = Desc(Op::Dwarf2, Op::Size1); + Descriptions[DW_OP_nop] = Desc(Op::Dwarf2); + Descriptions[DW_OP_push_object_address] = Desc(Op::Dwarf3); + Descriptions[DW_OP_call2] = Desc(Op::Dwarf3, Op::Size2); + Descriptions[DW_OP_call4] = Desc(Op::Dwarf3, Op::Size4); + Descriptions[DW_OP_call_ref] = Desc(Op::Dwarf3, Op::SizeRefAddr); + Descriptions[DW_OP_form_tls_address] = Desc(Op::Dwarf3); + Descriptions[DW_OP_call_frame_cfa] = Desc(Op::Dwarf3); + Descriptions[DW_OP_bit_piece] = Desc(Op::Dwarf3, Op::SizeLEB, Op::SizeLEB); + Descriptions[DW_OP_implicit_value] = + Desc(Op::Dwarf3, Op::SizeLEB, Op::SizeBlock); + Descriptions[DW_OP_stack_value] = Desc(Op::Dwarf3); + Descriptions[DW_OP_GNU_push_tls_address] = Desc(Op::Dwarf3); + Descriptions[DW_OP_GNU_addr_index] = Desc(Op::Dwarf4, Op::SizeLEB); + Descriptions[DW_OP_GNU_const_index] = Desc(Op::Dwarf4, Op::SizeLEB); + return Descriptions; +} + +static DWARFExpression::Op::Description getOpDesc(unsigned OpCode) { + // FIXME: Make this constexpr once all compilers are smart enough to do it. + static DescVector Descriptions = getDescriptions(); + assert(OpCode < Descriptions.size()); + return Descriptions[OpCode]; +} + +static uint8_t getRefAddrSize(uint8_t AddrSize, uint16_t Version) { + return (Version == 2) ? AddrSize : 4; +} + +bool DWARFExpression::Op::extract(DataExtractor Data, const DWARFUnit *U, + uint32_t Offset) { + Opcode = Data.getU8(&Offset); + + Desc = getOpDesc(Opcode); + if (Desc.Version == Op::DwarfNA) + return false; + + for (unsigned Operand = 0; Operand < 2; ++Operand) { + unsigned Size = Desc.Op[Operand]; + unsigned Signed = Size & Op::SignBit; + + if (Size == Op::SizeNA) + break; + + switch (Size & ~Op::SignBit) { + case Op::Size1: + Operands[Operand] = Data.getU8(&Offset); + if (Signed) + Operands[Operand] = (int8_t)Operands[Operand]; + break; + case Op::Size2: + Operands[Operand] = Data.getU16(&Offset); + if (Signed) + Operands[Operand] = (int16_t)Operands[Operand]; + break; + case Op::Size4: + Operands[Operand] = Data.getU32(&Offset); + if (Signed) + Operands[Operand] = (int32_t)Operands[Operand]; + break; + case Op::Size8: + Operands[Operand] = Data.getU64(&Offset); + break; + case Op::SizeAddr: + if (U->getAddressByteSize() == 8) { + Operands[Operand] = Data.getU64(&Offset); + } else { + assert(U->getAddressByteSize() == 4); + Operands[Operand] = Data.getU32(&Offset); + } + break; + case Op::SizeRefAddr: + if (getRefAddrSize(U->getAddressByteSize(), U->getVersion()) == 8) { + Operands[Operand] = Data.getU64(&Offset); + } else { + assert(getRefAddrSize(U->getAddressByteSize(), U->getVersion()) == 4); + Operands[Operand] = Data.getU32(&Offset); + } + break; + case Op::SizeLEB: + if (Signed) + Operands[Operand] = Data.getSLEB128(&Offset); + else + Operands[Operand] = Data.getULEB128(&Offset); + break; + case Op::SizeBlock: + // We need a size, so this cannot be the first operand + if (Operand == 0) + return false; + // Store the offset of the block as the value. + Operands[Operand] = Offset; + Offset += Operands[Operand - 1]; + break; + default: + llvm_unreachable("Unknown DWARFExpression Op size"); + } + } + + EndOffset = Offset; + return true; +} + +static bool prettyPrintRegisterOp(raw_ostream &OS, uint8_t Opcode, + uint64_t Operands[2], + const MCRegisterInfo *MRI, bool isEH) { + uint64_t DwarfRegNum; + unsigned OpNum = 0; + + if (Opcode == DW_OP_bregx || Opcode == DW_OP_regx) + DwarfRegNum = Operands[OpNum++]; + else if (Opcode >= DW_OP_breg0 && Opcode < DW_OP_bregx) + DwarfRegNum = Opcode - DW_OP_breg0; + else + DwarfRegNum = Opcode - DW_OP_reg0; + + int LLVMRegNum = MRI->getLLVMRegNum(DwarfRegNum, isEH); + if (LLVMRegNum >= 0) + if (const char *RegName = MRI->getName(LLVMRegNum)) { + if ((Opcode >= DW_OP_breg0 && Opcode <= DW_OP_breg31) || + Opcode == DW_OP_bregx) + OS << format(" %s%+" PRId64, RegName, Operands[OpNum]); + else + OS << ' ' << RegName; + return true; + } + + return false; +} + +bool DWARFExpression::Op::print(raw_ostream &OS, const DWARFExpression *Expr, + bool isEH) { + if (Error) { + OS << "decoding error."; + return false; + } + + StringRef Name = OperationEncodingString(Opcode); + assert(!Name.empty() && "DW_OP has no name!"); + OS << Name.drop_front(3); + + if ((Opcode >= DW_OP_breg0 && Opcode <= DW_OP_breg31) || + (Opcode >= DW_OP_reg0 && Opcode <= DW_OP_reg31) || + Opcode == DW_OP_bregx || Opcode == DW_OP_regx) + if (const MCRegisterInfo *MRI = Expr->Unit->getContext().getRegisterInfo()) + if (prettyPrintRegisterOp(OS, Opcode, Operands, MRI, isEH)) + return true; + + for (unsigned Operand = 0; Operand < 2; ++Operand) { + unsigned Size = Desc.Op[Operand]; + unsigned Signed = Size & Op::SignBit; + + if (Size == Op::SizeNA) + break; + + if (Size == Op::SizeBlock) { + uint32_t Offset = Operands[Operand]; + for (unsigned i = 0; i < Operands[Operand - 1]; ++i) + OS << format(" 0x%02x", Expr->Data.getU8(&Offset)); + } else { + if (Signed) + OS << format(" %+" PRId64, (int64_t)Operands[Operand]); + else + OS << format(" 0x%" PRIx64, Operands[Operand]); + } + } + return true; +} + +void DWARFExpression::print(raw_ostream &OS) { + for (auto &Op : *this) { + if (!Op.print(OS, this, /* isEH */ false)) { + uint32_t FailOffset = Op.getEndOffset(); + while (FailOffset < Data.getData().size()) + OS << format(" %02x", Data.getU8(&FailOffset)); + return; + } + if (Op.getEndOffset() < Data.getData().size()) + OS << ", "; + } +} + +} // namespace llvm Index: llvm/test/CodeGen/ARM/2011-01-19-MergedGlobalDbg.ll =================================================================== --- llvm/test/CodeGen/ARM/2011-01-19-MergedGlobalDbg.ll +++ llvm/test/CodeGen/ARM/2011-01-19-MergedGlobalDbg.ll @@ -9,24 +9,17 @@ @x3 = internal global i8 1, align 1, !dbg !6 @x4 = internal global i8 1, align 1, !dbg !8 @x5 = global i8 1, align 1, !dbg !10 -; Check debug info output for merged global. -; DW_AT_location -; 0x03 DW_OP_addr -; 0x.. .long __MergedGlobals -; 0x10 DW_OP_constu -; 0x.. offset -; 0x22 DW_OP_plus ; CHECK: DW_TAG_variable ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name {{.*}} "x1" ; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_location [DW_FORM_exprloc] (<0x5> 03 [[ADDR:.. .. .. ..]] ) +; CHECK: DW_AT_location [DW_FORM_exprloc] (OP_addr [[ADDR:0x[0-9a-fA-F]+]]) ; CHECK: DW_TAG_variable ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name {{.*}} "x2" ; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_location [DW_FORM_exprloc] (<0x7> 03 [[ADDR]] 23 01 ) +; CHECK: DW_AT_location [DW_FORM_exprloc] (OP_addr [[ADDR]], OP_plus_uconst 0x1) ; Function Attrs: nounwind optsize define zeroext i8 @get1(i8 zeroext %a) #0 !dbg !16 { Index: llvm/test/CodeGen/ARM/2011-08-02-MergedGlobalDbg.ll =================================================================== --- llvm/test/CodeGen/ARM/2011-08-02-MergedGlobalDbg.ll +++ llvm/test/CodeGen/ARM/2011-08-02-MergedGlobalDbg.ll @@ -1,23 +1,15 @@ ; RUN: llc -arm-global-merge -global-merge-group-by-use=false -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s -; Check debug info output for merged global. -; DW_AT_location -; 0x03 DW_OP_addr -; 0x.. .long __MergedGlobals -; 0x10 DW_OP_constu -; 0x.. offset -; 0x22 DW_OP_plus - ; CHECK: DW_TAG_variable ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name {{.*}} "x1" ; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_location [DW_FORM_exprloc] (<0x5> 03 [[ADDR:.. .. .. ..]] ) +; CHECK: DW_AT_location [DW_FORM_exprloc] (OP_addr [[ADDR:0x[0-9a-fA-F]+]]) ; CHECK: DW_TAG_variable ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name {{.*}} "x2" ; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_location [DW_FORM_exprloc] (<0x7> 03 [[ADDR]] 23 04 ) +; CHECK: DW_AT_location [DW_FORM_exprloc] (OP_addr [[ADDR]], OP_plus_uconst 0x4) source_filename = "test/CodeGen/ARM/2011-08-02-MergedGlobalDbg.ll" target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n32" Index: llvm/test/CodeGen/ARM/debug-info-blocks.ll =================================================================== --- llvm/test/CodeGen/ARM/debug-info-blocks.ll +++ llvm/test/CodeGen/ARM/debug-info-blocks.ll @@ -5,17 +5,11 @@ ; CHECK-NOT: DW_TAG_subprogram ; CHECK: DW_TAG_variable ; CHECK-NOT: DW_TAG -; CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] ([[MYDATA_LOC:0x[0-9a-f]*]]) +; CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] +; CHECK-NEXT: 0x{{.*}} - 0x{{.*}}: {{.*}} OP_plus_uconst 0x4, OP_deref, OP_plus_uconst 0x18 +; CHECK-NEXT: 0x{{.*}} - 0x{{.*}}: {{.*}} OP_plus_uconst 0x4, OP_deref, OP_plus_uconst 0x18 ; CHECK-NEXT: DW_AT_name {{.*}} "mydata" -; debug_loc content -; CHECK: .debug_loc contents: -; CHECK: [[MYDATA_LOC]]: Beginning address offset: {{.*}} -; CHECK-NOT: {{0x[0-9a-f]*}}: Beginning address offset -; CHECK: Location description: {{.*}} 23 04 06 23 18 -; CHECK-NOT: {{0x[0-9a-f]*}}: Beginning address offset -; CHECK: Location description: {{.*}} 23 04 06 23 18 - ; Radar 9331779 target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:32:64-v128:32:128-a0:0:32-n32" target triple = "thumbv7-apple-ios" Index: llvm/test/CodeGen/ARM/debug-info-sreg2.ll =================================================================== --- llvm/test/CodeGen/ARM/debug-info-sreg2.ll +++ llvm/test/CodeGen/ARM/debug-info-sreg2.ll @@ -5,12 +5,9 @@ ; Just making sure the first part of the location isn't a repetition ; of the size of the location description. -; -; 0x90 DW_OP_regx of super-register -; CHECK: 0x00000000: Beginning address offset: -; CHECK-NEXT: Ending address offset: -; CHECK-NEXT: Location description: 90 {{.. .. $}} +; CHECK: 0x00000000: +; CHECK-NEXT: 0x{{[0-9]*[a-f]*}} - 0x{{[0-9]*[a-f]*}}: OP_regx D8 define void @_Z3foov() optsize ssp !dbg !1 { entry: Index: llvm/test/CodeGen/X86/2010-01-18-DbgValue.ll =================================================================== --- llvm/test/CodeGen/X86/2010-01-18-DbgValue.ll +++ llvm/test/CodeGen/X86/2010-01-18-DbgValue.ll @@ -5,8 +5,7 @@ ; CHECK-LABEL: DW_TAG_subprogram ; CHECK: DW_AT_name [DW_FORM_strp] ( {{.*}}"foo") ; CHECK: DW_TAG_formal_parameter -; CHECK-NEXT: DW_AT_location [DW_FORM_exprloc] (<0x2> 91 {{..}} ) -; DW_OP_fbreg ?? +; CHECK-NEXT: DW_AT_location [DW_FORM_exprloc] (OP_fbreg {{[^ ]*}}) ; CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( {{.*}}"my_r0") %struct.Pt = type { double, double } Index: llvm/test/CodeGen/X86/2011-01-24-DbgValue-Before-Use.ll =================================================================== --- llvm/test/CodeGen/X86/2011-01-24-DbgValue-Before-Use.ll +++ llvm/test/CodeGen/X86/2011-01-24-DbgValue-Before-Use.ll @@ -9,7 +9,8 @@ ; CHECK: DW_TAG_variable ; CHECK: DW_TAG_variable ; CHECK-NEXT: DW_AT_location -; CHECK-NEXT: DW_AT_name {{.*}} "z_s" +; CHECK-NOT: DW_{{TAG|AT}} +; CHECK: DW_AT_name {{.*}} "z_s" ; CHECK-NEXT: DW_AT_decl_file ; CHECK-NEXT: DW_AT_decl_line ; CHECK-NEXT: DW_AT_type{{.*}}{[[TYPE:.*]]} Index: llvm/test/CodeGen/X86/dbg-baseptr.ll =================================================================== --- llvm/test/CodeGen/X86/dbg-baseptr.ll +++ llvm/test/CodeGen/X86/dbg-baseptr.ll @@ -22,12 +22,10 @@ ; DWARF-LABEL: .debug_info contents: ; DWARF-LABEL: DW_TAG_subprogram -; DWARF: DW_AT_frame_base [DW_FORM_exprloc] (<0x1> 57 ) -; 0x57 -> RSP +; DWARF: DW_AT_frame_base [DW_FORM_exprloc] (OP_reg7 RSP) ; DWARF: DW_AT_name [DW_FORM_strp] ( {{.*}}"f0") ; DWARF: DW_TAG_formal_parameter -; DWARF-NEXT: DW_AT_location [DW_FORM_exprloc] (<0x2> 91 08 ) -; DW_OP_fbreg (0x91) 0x08 +; DWARF-NEXT: DW_AT_location [DW_FORM_exprloc] (OP_fbreg +8) ; DWARF-NEXT: DW_AT_name [DW_FORM_strp] ( {{.*}}"input") @@ -48,12 +46,10 @@ } ; DWARF-LABEL: DW_TAG_subprogram -; DWARF: DW_AT_frame_base [DW_FORM_exprloc] (<0x1> 56 ) -; 0x56 -> RBP +; DWARF: DW_AT_frame_base [DW_FORM_exprloc] (OP_reg6 RBP) ; DWARF: DW_AT_name [DW_FORM_strp] ( {{.*}}"f1") ; DWARF: DW_TAG_formal_parameter -; DWARF-NEXT: DW_AT_location [DW_FORM_exprloc] (<0x2> 91 10 ) -; DW_OP_fbreg (0x91) 0x10 +; DWARF-NEXT: DW_AT_location [DW_FORM_exprloc] (OP_fbreg +16) ; DWARF-NEXT: DW_AT_name [DW_FORM_strp] ( {{.*}}"input") ; CHECK-LABEL: f2: @@ -75,12 +71,10 @@ ; "input" should still be referred to through RBP. ; DWARF-LABEL: DW_TAG_subprogram -; DWARF: DW_AT_frame_base [DW_FORM_exprloc] (<0x1> 56 ) -; 0x56 -> RBP +; DWARF: DW_AT_frame_base [DW_FORM_exprloc] (OP_reg6 RBP) ; DWARF: DW_AT_name [DW_FORM_strp] ( {{.*}}"f2") ; DWARF: DW_TAG_formal_parameter -; DWARF-NEXT: DW_AT_location [DW_FORM_exprloc] (<0x2> 91 10 ) -; DW_OP_fbreg (0x91) 0x10 +; DWARF-NEXT: DW_AT_location [DW_FORM_exprloc] (OP_fbreg +16) ; DWARF-NEXT: DW_AT_name [DW_FORM_strp] ( {{.*}}"input") declare void @llvm.dbg.declare(metadata, metadata, metadata) Index: llvm/test/DebugInfo/AArch64/asan-stack-vars.ll =================================================================== --- llvm/test/DebugInfo/AArch64/asan-stack-vars.ll +++ llvm/test/DebugInfo/AArch64/asan-stack-vars.ll @@ -27,13 +27,11 @@ ; CHECK-NEXT: DW_AT_high_pc [DW_FORM_addr] ([[FN_END:.*]]) ; CHECK: "_cmd" ; CHECK: DW_TAG_formal_parameter -; CHECK-NEXT: DW_AT_location {{.*}} ([[OFS:.*]]) +; CHECK-NEXT: DW_AT_location +; CHECK-NEXT: 0x{{0*}} - 0x{{.*}}: +; CHECK-NOT: DW_AT_ +; CHECK: 0x{{.*}} - [[FN_END]]: ; CHECK-NEXT: DW_AT_name {{.*}}"imageSize" -; -; CHECK: .debug_loc contents: -; CHECK: [[OFS]]: Beginning address offset: 0x0000000000000000 -; CHECK_NOT: 0x{{.*}}: Beginning -; CHECK: Ending address offset: [[FN_END]] ; ModuleID = 'm.m' source_filename = "m.m" Index: llvm/test/DebugInfo/AArch64/bitfields.ll =================================================================== --- llvm/test/DebugInfo/AArch64/bitfields.ll +++ llvm/test/DebugInfo/AArch64/bitfields.ll @@ -19,12 +19,12 @@ ; CHECK: DW_AT_byte_size {{.*}} (0x04) ; CHECK-NEXT: DW_AT_bit_size {{.*}} (0x02) ; CHECK-NEXT: DW_AT_bit_offset {{.*}} (0x00) -; CHECK-NEXT: DW_AT_data_member_location {{.*}} 00 +; CHECK-NEXT: DW_AT_data_member_location {{.*}} (OP_plus_uconst 0x0) ; CHECK: DW_TAG_member ; CHECK-NEXT: DW_AT_name{{.*}}"b" ; CHECK-NOT: DW_TAG_member -; CHECK: DW_AT_data_member_location {{.*}} 04 +; CHECK: DW_AT_data_member_location {{.*}} (OP_plus_uconst 0x4) ; CHECK: DW_TAG_member ; CHECK-NEXT: DW_AT_name{{.*}}"c" @@ -32,7 +32,7 @@ ; CHECK: DW_AT_byte_size {{.*}} (0x04) ; CHECK-NEXT: DW_AT_bit_size {{.*}} (0x01) ; CHECK-NEXT: DW_AT_bit_offset {{.*}} (0x00) -; CHECK-NEXT: DW_AT_data_member_location {{.*}} 08 +; CHECK: DW_AT_data_member_location {{.*}} (OP_plus_uconst 0x8) ; CHECK: DW_TAG_member ; CHECK-NEXT: DW_AT_name{{.*}}"d" @@ -40,7 +40,7 @@ ; CHECK: DW_AT_byte_size {{.*}} (0x04) ; CHECK-NEXT: DW_AT_bit_size {{.*}} (0x1c) ; CHECK-NEXT: DW_AT_bit_offset {{.*}} (0x01) -; CHECK-NEXT: DW_AT_data_member_location {{.*}} 08 +; CHECK-NEXT: DW_AT_data_member_location {{.*}} (OP_plus_uconst 0x8) ; ModuleID = 'bitfields.c' source_filename = "test/DebugInfo/AArch64/bitfields.ll" Index: llvm/test/DebugInfo/AArch64/coalescing.ll =================================================================== --- llvm/test/DebugInfo/AArch64/coalescing.ll +++ llvm/test/DebugInfo/AArch64/coalescing.ll @@ -23,10 +23,8 @@ ; CHECK: .debug_info contents: ; CHECK: DW_TAG_variable ; CHECK-NEXT: DW_AT_location + ; CHECK-NEXT: OP_breg31 WSP+12, OP_deref ; CHECK-NEXT: DW_AT_name {{.*}}"size" - ; CHECK: .debug_loc contents: - ; Expecting the encoding for sp+12: DW_OP_breg31 0c - ; CHECK: Location description: 8f 0c ret void, !dbg !18 } Index: llvm/test/DebugInfo/AArch64/frameindices.ll =================================================================== --- llvm/test/DebugInfo/AArch64/frameindices.ll +++ llvm/test/DebugInfo/AArch64/frameindices.ll @@ -5,8 +5,7 @@ ; CHECK: DW_TAG_inlined_subroutine ; CHECK: "_Z3f111A" ; CHECK: DW_TAG_formal_parameter -; CHECK: DW_AT_location [DW_FORM_block1] (<0x0c> 93 01 91 51 93 0f 93 01 91 4a 93 07 ) -; -- piece 0x00000001, fbreg -47, piece 0x0000000f, piece 0x00000001, fbreg -54, piece 0x00000007 ------^ +; CHECK: DW_AT_location [DW_FORM_block1] (OP_piece 0x1, OP_fbreg -47, OP_piece 0xf, OP_piece 0x1, OP_fbreg -54, OP_piece 0x7) ; CHECK: DW_AT_abstract_origin {{.*}} "p1" ; ; long a; Index: llvm/test/DebugInfo/AMDGPU/variable-locations.ll =================================================================== --- llvm/test/DebugInfo/AMDGPU/variable-locations.ll +++ llvm/test/DebugInfo/AMDGPU/variable-locations.ll @@ -19,7 +19,7 @@ ; CHECK-NEXT: DW_AT_external ; CHECK-NEXT: DW_AT_decl_file ; CHECK-NEXT: DW_AT_decl_line -; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (<0x09> 03 00 00 00 00 00 00 00 00 ) +; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (OP_addr 0x0) @GlobA = common addrspace(1) global i32 0, align 4, !dbg !0 ; CHECK: {{.*}}DW_TAG_variable @@ -28,20 +28,20 @@ ; CHECK-NEXT: DW_AT_external ; CHECK-NEXT: DW_AT_decl_file ; CHECK-NEXT: DW_AT_decl_line -; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (<0x09> 03 00 00 00 00 00 00 00 00 ) +; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (OP_addr 0x0) @GlobB = common addrspace(1) global i32 0, align 4, !dbg !6 define amdgpu_kernel void @kernel1( ; CHECK: {{.*}}DW_TAG_formal_parameter -; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (<0x06> 91 04 10 01 16 18 ) +; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (OP_fbreg +4, OP_constu 0x1, OP_swap, OP_xderef) ; CHECK-NEXT: DW_AT_name {{.*}}"ArgN" i32 %ArgN, ; CHECK: {{.*}}DW_TAG_formal_parameter -; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (<0x06> 91 08 10 01 16 18 ) +; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (OP_fbreg +8, OP_constu 0x1, OP_swap, OP_xderef) ; CHECK-NEXT: DW_AT_name {{.*}}"ArgA" i32 addrspace(1)* %ArgA, ; CHECK: {{.*}}DW_TAG_formal_parameter -; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (<0x06> 91 10 10 01 16 18 ) +; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (OP_fbreg +16, OP_constu 0x1, OP_swap, OP_xderef) ; CHECK-NEXT: DW_AT_name {{.*}}"ArgB" i32 addrspace(1)* %ArgB) !dbg !13 { entry: Index: llvm/test/DebugInfo/ARM/PR16736.ll =================================================================== --- llvm/test/DebugInfo/ARM/PR16736.ll +++ llvm/test/DebugInfo/ARM/PR16736.ll @@ -1,10 +1,23 @@ ; RUN: llc -filetype=asm < %s | FileCheck %s ; RUN: llc -filetype=obj < %s \ -; RUN: | llvm-dwarfdump - | FileCheck %s --check-prefix=DWARF +; RUN: | llvm-dwarfdump -debug-dump=info - | FileCheck %s --check-prefix=DWARF ; ; CHECK: @DEBUG_VALUE: h:x <- [DW_OP_plus_uconst {{.*}}] [%R{{.*}}+0] -; DWARF: Location description: {{7[0-9] [0-9]+ $}} -; DW_OP_breg. +.. +; DWARF: DW_TAG_formal_parameter +; DWARF: DW_AT_location +; DWARF-NEXT: OP_reg0 R0 +; DWARF: DW_TAG_formal_parameter +; DWARF: DW_AT_location +; DWARF-NEXT: OP_reg1 R1 +; DWARF: DW_TAG_formal_parameter +; DWARF: DW_AT_location +; DWARF-NEXT: OP_reg2 R2 +; DWARF: DW_TAG_formal_parameter +; DWARF: DW_AT_location +; DWARF-NEXT: OP_reg3 R3 +; DWARF: DW_TAG_formal_parameter +; DWARF: DW_AT_location +; DWARF-NEXT: OP_breg7 R7+8 ; generated from: ; clang -cc1 -triple thumbv7 -S -O1 arm.cpp -g ; Index: llvm/test/DebugInfo/ARM/PR26163.ll =================================================================== --- llvm/test/DebugInfo/ARM/PR26163.ll +++ llvm/test/DebugInfo/ARM/PR26163.ll @@ -1,4 +1,4 @@ -; RUN: llc -filetype=obj -o - < %s | llvm-dwarfdump - | FileCheck %s +; RUN: llc -filetype=obj -o - < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s ; ; Checks that we're creating two ranges, one that terminates immediately ; and one that spans the rest of the function. This isn't necessarily the @@ -6,13 +6,11 @@ ; one has a bit_piece), but it is what is currently being emitted, any ; change here needs to be intentional, so the test is very specific. ; -; CHECK: .debug_loc contents: -; CHECK: 0x00000000: Beginning address offset: 0x0000000000000004 -; CHECK: Ending address offset: 0x0000000000000004 -; CHECK: Location description: 10 00 9f -; CHECK: Beginning address offset: 0x0000000000000004 -; CHECK: Ending address offset: 0x0000000000000014 -; CHECK: Location description: 10 00 9f +; CHECK: DW_TAG_inlined_subroutine +; CHECK: DW_TAG_variable +; CHECK: DW_AT_location [DW_FORM_sec_offset] ({{.*}} +; CHECK: 0x0000000000000004 - 0x0000000000000004: OP_constu 0x0, OP_stack_value, OP_piece 0x8 +; CHECK: 0x0000000000000004 - 0x0000000000000014: OP_constu 0x0, OP_stack_value, OP_piece 0x4) ; Created form the following test case (PR26163) with ; clang -cc1 -triple armv4t--freebsd11.0-gnueabi -emit-obj -debug-info-kind=standalone -O2 -x c test.c Index: llvm/test/DebugInfo/ARM/bitfield.ll =================================================================== --- llvm/test/DebugInfo/ARM/bitfield.ll +++ llvm/test/DebugInfo/ARM/bitfield.ll @@ -14,7 +14,7 @@ ; CHECK: DW_AT_byte_size {{.*}} (0x04) ; CHECK: DW_AT_bit_size {{.*}} (0x1c) ; CHECK: DW_AT_bit_offset {{.*}} (0xfffffffffffffff8) -; CHECK: DW_AT_data_member_location {{.*}}00 +; CHECK: DW_AT_data_member_location {{.*}} (OP_plus_uconst 0x0) source_filename = "test/DebugInfo/ARM/bitfield.ll" target datalayout = "e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32" target triple = "thumbv7-apple-ios" Index: llvm/test/DebugInfo/ARM/partial-subreg.ll =================================================================== --- llvm/test/DebugInfo/ARM/partial-subreg.ll +++ llvm/test/DebugInfo/ARM/partial-subreg.ll @@ -8,12 +8,9 @@ ; CHECK: DW_TAG_subprogram ; CHECK: DW_AT_name {{.*}}"subscript.get" ; CHECK: DW_TAG_formal_parameter -; CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] (0x00000000) -; CHECK: .debug_loc -; CHECK: 0x00000000: Beginning address offset -; CHECK-NEXT: Ending address offset -; CHECK-NEXT: Location description: 90 90 02 93 08 90 91 02 93 04 -; d16, piece 0x00000008, d17, piece 0x00000004 +; CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] ({{.*}} +; CHECK-NEXT: 0x{{.*}} - 0x{{.*}}: OP_regx D16, OP_piece 0x8, OP_regx D17, OP_piece 0x4, OP_regx D16, OP_piece 0x8, OP_regx D17, OP_piece 0x4 + source_filename = "simd.ll" target datalayout = "e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32" target triple = "armv7-apple-ios7.0" Index: llvm/test/DebugInfo/ARM/s-super-register.ll =================================================================== --- llvm/test/DebugInfo/ARM/s-super-register.ll +++ llvm/test/DebugInfo/ARM/s-super-register.ll @@ -4,8 +4,7 @@ ; The S registers on ARM are expressed as pieces of their super-registers in DWARF. ; -; 0x90 DW_OP_regx of super-register -; CHECK: Location description: 90 +; CHECK: OP_regx define void @_Z3foov() optsize ssp !dbg !1 { entry: Index: llvm/test/DebugInfo/ARM/split-complex.ll =================================================================== --- llvm/test/DebugInfo/ARM/split-complex.ll +++ llvm/test/DebugInfo/ARM/split-complex.ll @@ -14,8 +14,7 @@ ; The target has no native double type. ; SROA split the complex value into two i64 values. ; CHECK: DW_TAG_formal_parameter - ; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (<0x04> 10 00 93 08 ) - ; DW_AT_location ( constu 0x00000000, piece 0x00000008 ) + ; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (OP_constu 0x0, OP_piece 0x8) ; CHECK-NEXT: DW_AT_name {{.*}} "c" tail call void @llvm.dbg.value(metadata i64 0, metadata !14, metadata !17), !dbg !16 ; Manually removed to disable location list emission: Index: llvm/test/DebugInfo/Generic/incorrect-variable-debugloc1.ll =================================================================== --- llvm/test/DebugInfo/Generic/incorrect-variable-debugloc1.ll +++ llvm/test/DebugInfo/Generic/incorrect-variable-debugloc1.ll @@ -23,8 +23,11 @@ ; return c; ; } -; DWARF23: Location description: 10 0d {{$}} -; DWARF4: Location description: 10 0d 9f +; CHECK: DW_TAG_variable +; CHECK: DW_AT_location +; CHECK-NOT: DW_AT +; DWARF23: OP_constu 0xd{{$}} +; DWARF4: OP_constu 0xd, OP_stack_value{{$}} ; Function Attrs: uwtable define i32 @main() #0 !dbg !4 { Index: llvm/test/DebugInfo/MIR/AArch64/clobber-sp.mir =================================================================== --- llvm/test/DebugInfo/MIR/AArch64/clobber-sp.mir +++ llvm/test/DebugInfo/MIR/AArch64/clobber-sp.mir @@ -3,20 +3,11 @@ # CHECK: .debug_info contents: # CHECK: DW_TAG_formal_parameter # CHECK: DW_TAG_formal_parameter -# CHECK-NEXT: DW_AT_location [DW_FORM_data4] ([[LOC:.*]]) +# CHECK-NEXT: DW_AT_location +# CHECK-NEXT: 0x0000000000000000 - 0x0000000000000014: OP_reg1 W1 +# CHECK-NEXT: 0x0000000000000014 - 0x0000000000000038: OP_breg31 WSP+8 # CHECK-NEXT: DW_AT_name {{.*}}"y" -# CHECK: .debug_loc contents: -# CHECK: [[LOC]]: -# CHECK-SAME: Beginning address offset: 0x0000000000000000 -# CHECK-NEXT: Ending address offset: 0x0000000000000014 -# CHECK-NEXT: Location description: 51 -# reg1 -# -# The range of y's [SP+8] location must not be interrupted by the call to h. -# CHECK: Beginning address offset: 0x0000000000000014 -# CHECK-NEXT: Ending address offset: 0x0000000000000038 -# CHECK-NEXT: Location description: 8f 08 -# breg31 +8 + --- | ; Generated at -Os from: ; struct Rect { Index: llvm/test/DebugInfo/MIR/ARM/split-superreg-piece.mir =================================================================== --- llvm/test/DebugInfo/MIR/ARM/split-superreg-piece.mir +++ llvm/test/DebugInfo/MIR/ARM/split-superreg-piece.mir @@ -1,14 +1,11 @@ # RUN: llc -start-before=livedebugvalues -filetype=obj -o - %s | \ -# RUN: llvm-dwarfdump - | FileCheck %s +# RUN: llvm-dwarfdump -debug-dump=info - | FileCheck %s # CHECK: .debug_info contents: # CHECK: DW_TAG_variable -# CHECK-NEXT: DW_AT_location [DW_FORM_data4] ([[OFS:.*]]) +# CHECK-NEXT: DW_AT_location +# CHECK-NEXT: 0x0000000000000010 - 0x0000000000000018: OP_piece 0x10, OP_regx D0, OP_piece 0x8, OP_regx D1, OP_piece 0x8) # CHECK-NEXT: DW_AT_name {{.*}}"vec" -# CHECK: .debug_loc contents: -# CHECK: [[OFS]]: Beginning address offset: 0x0000000000000010 -# CHECK: Ending address offset: 0x0000000000000018 -# CHECK: Location description: 93 10 90 80 02 93 08 90 81 02 93 08 -# piece 0x00000010, d0, piece 0x00000008, d1, piece 0x00000008 + --- | ; Generate from (and then manually modified to incorporate a DW_OP_LLVM_fragment): ; typedef float vec2 __attribute__((vector_size(16))); Index: llvm/test/DebugInfo/MIR/ARM/split-superreg.mir =================================================================== --- llvm/test/DebugInfo/MIR/ARM/split-superreg.mir +++ llvm/test/DebugInfo/MIR/ARM/split-superreg.mir @@ -2,13 +2,10 @@ # RUN: llvm-dwarfdump - | FileCheck %s # CHECK: .debug_info contents: # CHECK: DW_TAG_variable -# CHECK-NEXT: DW_AT_location [DW_FORM_data4] ([[OFS:.*]]) +# CHECK-NEXT: DW_AT_location +# CHECK-NEXT: 0x0000000000000010 - 0x0000000000000018: OP_regx D0, OP_piece 0x8, OP_regx D1, OP_piece 0x8) # CHECK-NEXT: DW_AT_name {{.*}}"vec" -# CHECK: .debug_loc contents: -# CHECK: [[OFS]]: Beginning address offset: 0x0000000000000010 -# CHECK: Ending address offset: 0x0000000000000018 -# CHECK: Location description: 90 80 02 93 08 90 81 02 93 08 -# d0, piece 0x00000008, d1, piece 0x00000008 + --- | ; Generated from: ; typedef float vec2 __attribute__((vector_size(16))); Index: llvm/test/DebugInfo/MIR/X86/bit-piece-dh.mir =================================================================== --- llvm/test/DebugInfo/MIR/X86/bit-piece-dh.mir +++ llvm/test/DebugInfo/MIR/X86/bit-piece-dh.mir @@ -1,8 +1,7 @@ # RUN: llc -filetype=obj -o - %s | llvm-dwarfdump --debug-dump=info - | FileCheck %s # CHECK: .debug_info contents: # CHECK: DW_TAG_variable -# rdx, bit-piece 8 8 -# CHECK-NEXT: DW_AT_location {{.*}} 51 9d 08 08 +# CHECK-NEXT: DW_AT_location {{.*}} (OP_reg1 RDX, OP_bit_piece 0x8 0x8) # CHECK-NEXT: DW_AT_name {{.*}}"dh" --- | ; Manually created after: Index: llvm/test/DebugInfo/Mips/dsr-fixed-objects.ll =================================================================== --- llvm/test/DebugInfo/Mips/dsr-fixed-objects.ll +++ llvm/test/DebugInfo/Mips/dsr-fixed-objects.ll @@ -1,7 +1,5 @@ ; RUN: llc -march=mips -mcpu=mips32r2 -O1 -filetype=obj -relocation-model=pic <%s | \ -; RUN: llvm-dwarfdump -debug-dump=all - | FileCheck %s -check-prefix=F0 -; RUN: llc -march=mips -mcpu=mips32r2 -O1 -filetype=obj -relocation-model=pic <%s | \ -; RUN: llvm-dwarfdump -debug-dump=all - | FileCheck %s -check-prefix=F1 +; RUN: llvm-dwarfdump -debug-dump=all - | FileCheck %s ; void foo(int *); ; @@ -22,15 +20,12 @@ declare void @foo(i32*) -; F0: DW_AT_name {{.*}}"e" -; F0: DW_TAG_variable -; F0-NEXT: DW_AT_location [DW_FORM_sec_offset] ([[LOC:.*]]) -; F0-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000006b] = "x") -; -; x -> DW_OP_reg1(51) -; F0: [[LOC]]: Beginning address offset: 0x0000000000000028 -; F0: Ending address offset: 0x000000000000002c -; F0: Location description: 51 +; CHECK: DW_AT_name {{.*}}"e" +; CHECK: DW_TAG_variable +; CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] ( +; CHECK-NEXT: 0x0000000000000028 - 0x000000000000002c: OP_reg1 AT_64 +; CHECK-NEXT: 0x000000000000002c - 0x0000000000000048: OP_breg29 SP_64+16, OP_deref) +; CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000006b] = "x") define i32 @f0(i32 signext %a, i32 signext %b, i32 signext %c, i32 signext %d, i32 signext %e) !dbg !4 { entry: @@ -57,16 +52,11 @@ } -; F1: DW_AT_name {{.*}}"x" -; F1: DW_AT_name {{.*}}"e" -; F1: DW_TAG_variable -; F1-NEXT: DW_AT_location [DW_FORM_sec_offset] ([[LOC:.*]]) -; F1-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000006b] = "x") - -; x -> DW_OP_reg1(51) -; F1: [[LOC]]: Beginning address offset: 0x0000000000000080 -; F1: Ending address offset: 0x0000000000000084 -; F1: Location description: 51 +; CHECK: DW_TAG_variable +; CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] ( +; CHECK-NEXT: 0x0000000000000080 - 0x0000000000000084: OP_reg1 AT_64 +; CHECK-NEXT: 0x0000000000000084 - 0x0000000000000098: OP_breg29 SP_64+16, OP_deref) +; CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000006b] = "x") define i32 @f1(i32 signext %a, i32 signext %b, i32 signext %c, i32 signext %d, i32 signext %e) !dbg !15 { entry: Index: llvm/test/DebugInfo/Mips/dsr-non-fixed-objects.ll =================================================================== --- llvm/test/DebugInfo/Mips/dsr-non-fixed-objects.ll +++ llvm/test/DebugInfo/Mips/dsr-non-fixed-objects.ll @@ -1,7 +1,5 @@ ; RUN: llc -march=mips -mcpu=mips32r2 -O0 -filetype=obj -fast-isel=0 <%s | \ -; RUN: llvm-dwarfdump -debug-dump=all - | FileCheck %s -check-prefix=F2 -; RUN: llc -march=mips -mcpu=mips32r2 -O0 -filetype=obj -fast-isel=0 <%s | \ -; RUN: llvm-dwarfdump -debug-dump=all - | FileCheck %s -check-prefix=F3 +; RUN: llvm-dwarfdump -debug-dump=all - | FileCheck %s declare void @llvm.dbg.declare(metadata, metadata, metadata) @@ -22,9 +20,9 @@ ; return w; ; } -; c -> DW_OP_breg29(r29): 16 -; F2: DW_AT_location [DW_FORM_exprloc] (<0x2> 8d 10 ) -; F2: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000065] = "c") +; CHECK: DW_TAG_subprogram +; CHECK: DW_AT_location [DW_FORM_exprloc] (OP_breg29 SP_64+36) +; CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000065] = "c") ; Function Attrs: nounwind define i32 @f2(i32 signext %a, i32 signext %b) !dbg !4 { @@ -46,9 +44,9 @@ ret i32 %2, !dbg !27 } -; c -> DW_OP_breg23(r23): 16 -; F3: DW_AT_location [DW_FORM_exprloc] (<0x2> 87 10 ) -; F3: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000065] = "c") +; CHECK: DW_TAG_subprogram +; CHECK: DW_AT_location [DW_FORM_exprloc] (OP_breg23 S7_64+32) +; CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000065] = "c") define i32* @f3(i32 signext %a, i32 signext %b) !dbg !8 { entry: Index: llvm/test/DebugInfo/SystemZ/variable-loc.ll =================================================================== --- llvm/test/DebugInfo/SystemZ/variable-loc.ll +++ llvm/test/DebugInfo/SystemZ/variable-loc.ll @@ -14,9 +14,8 @@ ; CHECK: brasl %r14, populate_array@PLT ; DEBUG: DW_TAG_variable -; Rather hard-coded, but 0x91 => DW_OP_fbreg and 0xa401 is SLEB128 encoded 164. ; DEBUG-NOT: DW_TAG -; DEBUG: DW_AT_location {{.*}}(<0x3> 91 a4 01 ) +; DEBUG: DW_AT_location {{.*}}(OP_fbreg +164) ; DEBUG-NOT: DW_TAG ; DEBUG: DW_AT_name {{.*}} "main_arr" Index: llvm/test/DebugInfo/X86/DW_AT_location-reference.ll =================================================================== --- llvm/test/DebugInfo/X86/DW_AT_location-reference.ll +++ llvm/test/DebugInfo/X86/DW_AT_location-reference.ll @@ -31,22 +31,18 @@ ; // The 'x' variable and its symbol reference location ; CHECK: .debug_info contents: ; CHECK: DW_TAG_variable -; CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] (0x00000000) +; CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] (0x00000000 +; Check that the location contains only 4 ranges - this verifies that the 4th +; and 5th ranges were successfully merged into a single range. +; CHECK-NEXT: 0x{{[0-9a-f]*}} - 0x{{[0-9a-f]*}}: +; CHECK-NEXT: 0x{{[0-9a-f]*}} - 0x{{[0-9a-f]*}}: +; CHECK-NEXT: 0x{{[0-9a-f]*}} - 0x{{[0-9a-f]*}}: +; CHECK-NEXT: 0x{{[0-9a-f]*}} - 0x{{[0-9a-f]*}}: {{.*}}) ; CHECK-NEXT: DW_AT_name {{.*}} "x" ; CHECK-NEXT: DW_AT_decl_file ; CHECK-NEXT: DW_AT_decl_line ; CHECK-NEXT: DW_AT_type -; Check that the location contains only 4 ranges - this verifies that the 4th -; and 5th ranges were successfully merged into a single range. -; CHECK: .debug_loc contents: -; CHECK: 0x00000000: -; CHECK: Beginning address offset: -; CHECK: Beginning address offset: -; CHECK: Beginning address offset: -; CHECK: Beginning address offset: -; CHECK-NOT: Beginning address offset: - ; Check that we have no relocations in Darwin's output. ; DARWIN-NOT: X86_64_RELOC{{.*}} __debug_loc Index: llvm/test/DebugInfo/X86/FrameIndexExprs.ll =================================================================== --- llvm/test/DebugInfo/X86/FrameIndexExprs.ll +++ llvm/test/DebugInfo/X86/FrameIndexExprs.ll @@ -3,8 +3,7 @@ ; RUN: llc -mtriple=x86_64-apple-darwin -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s ; CHECK: DW_TAG_formal_parameter ; CHECK: DW_TAG_formal_parameter -; CHECK-NEXT: DW_AT_location [DW_FORM_exprloc] (<0xa> 91 78 93 03 93 06 91 7d 93 03 ) -; fbreg -8, piece 0x00000003, piece 0x00000006, fbreg -3, piece 0x00000003 +; CHECK-NEXT: DW_AT_location [DW_FORM_exprloc] (OP_fbreg -8, OP_piece 0x3, OP_piece 0x6, OP_fbreg -3, OP_piece 0x3) ; CHECK-NEXT: DW_AT_abstract_origin {{.*}}"p" source_filename = "bugpoint-reduced-simplified.ll" target triple = "x86_64-apple-darwin" Index: llvm/test/DebugInfo/X86/PR26148.ll =================================================================== --- llvm/test/DebugInfo/X86/PR26148.ll +++ llvm/test/DebugInfo/X86/PR26148.ll @@ -1,4 +1,4 @@ -; RUN: llc -filetype=obj -o - < %s | llvm-dwarfdump - | FileCheck %s +; RUN: llc -filetype=obj -o - < %s | llvm-dwarfdump - -debug-dump=loc | FileCheck %s ; ; Created using clang -g -O3 from: ; struct S0 { @@ -19,14 +19,8 @@ ; AS in 26163, we expect two ranges (as opposed to one), the first one being zero sized ; ; -; CHECK: Beginning address offset: 0x0000000000000004 -; CHECK: Ending address offset: 0x0000000000000004 -; CHECK: Location description: 10 03 93 04 55 93 02 -; constu 0x00000003, piece 0x00000004, rdi, piece 0x00000002 -; CHECK: Beginning address offset: 0x0000000000000004 -; CHECK: Ending address offset: 0x0000000000000014 -; CHECK: Location description: 10 03 93 04 10 00 -; constu 0x00000003, piece 0x00000004, constu 0x00000000, piece 0x00000004 +; CHECK: 0x0000000000000004 - 0x0000000000000004: OP_constu 0x3, OP_piece 0x4, OP_reg5 RDI, OP_piece 0x2 +; CHECK: 0x0000000000000004 - 0x0000000000000014: OP_constu 0x3, OP_piece 0x4, OP_constu 0x0, OP_piece 0x4 source_filename = "test/DebugInfo/X86/PR26148.ll" target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" Index: llvm/test/DebugInfo/X86/array.ll =================================================================== --- llvm/test/DebugInfo/X86/array.ll +++ llvm/test/DebugInfo/X86/array.ll @@ -21,8 +21,7 @@ ; CHECK: callq _f ; DWARF: DW_TAG_variable -; "<0x2> 91 00" means fbreg 0, i.e. offset RSP+0. -; DWARF-NEXT: DW_AT_location [DW_FORM_exprloc] (<0x2> 91 00 ) +; DWARF-NEXT: DW_AT_location [DW_FORM_exprloc] (OP_fbreg +0) ; DWARF-NEXT: DW_AT_name [DW_FORM_strp] ( {{.*}} = "array") ; ModuleID = '/tmp/array.c' Index: llvm/test/DebugInfo/X86/bitfields.ll =================================================================== --- llvm/test/DebugInfo/X86/bitfields.ll +++ llvm/test/DebugInfo/X86/bitfields.ll @@ -19,12 +19,12 @@ ; CHECK: DW_AT_byte_size {{.*}} (0x04) ; CHECK-NEXT: DW_AT_bit_size {{.*}} (0x02) ; CHECK-NEXT: DW_AT_bit_offset {{.*}} (0x1e) -; CHECK-NEXT: DW_AT_data_member_location {{.*}} 00 +; CHECK-NEXT: DW_AT_data_member_location {{.*}} (OP_plus_uconst 0x0) ; CHECK: DW_TAG_member ; CHECK-NEXT: DW_AT_name{{.*}}"b" ; CHECK-NOT: DW_TAG_member -; CHECK: DW_AT_data_member_location {{.*}} 04 +; CHECK: DW_AT_data_member_location {{.*}} (OP_plus_uconst 0x4) ; CHECK: DW_TAG_member ; CHECK-NEXT: DW_AT_name{{.*}}"c" @@ -32,7 +32,7 @@ ; CHECK: DW_AT_byte_size {{.*}} (0x04) ; CHECK-NEXT: DW_AT_bit_size {{.*}} (0x01) ; CHECK-NEXT: DW_AT_bit_offset {{.*}} (0x1f) -; CHECK-NEXT: DW_AT_data_member_location {{.*}} 08 +; CHECK: DW_AT_data_member_location {{.*}} (OP_plus_uconst 0x8) ; CHECK: DW_TAG_member ; CHECK-NEXT: DW_AT_name{{.*}}"d" @@ -40,7 +40,7 @@ ; CHECK: DW_AT_byte_size {{.*}} (0x04) ; CHECK-NEXT: DW_AT_bit_size {{.*}} (0x1c) ; CHECK-NEXT: DW_AT_bit_offset {{.*}} (0x03) -; CHECK-NEXT: DW_AT_data_member_location {{.*}} 08 +; CHECK-NEXT: DW_AT_data_member_location {{.*}} (OP_plus_uconst 0x8) ; ModuleID = 'bitfields.c' source_filename = "test/DebugInfo/X86/bitfields.ll" Index: llvm/test/DebugInfo/X86/block-capture.ll =================================================================== --- llvm/test/DebugInfo/X86/block-capture.ll +++ llvm/test/DebugInfo/X86/block-capture.ll @@ -4,8 +4,7 @@ ; Checks that we emit debug info for the block variable declare. ; CHECK: DW_TAG_subprogram ; CHECK: DW_TAG_variable -; fbreg +8, deref, +32 -; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (<0x05> 91 08 06 23 20 ) +; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (OP_fbreg +8, OP_deref, OP_plus_uconst 0x20) ; CHECK-NEXT: DW_AT_name {{.*}} "block" ; Extracted from the clang output for: Index: llvm/test/DebugInfo/X86/constant-loclist.ll =================================================================== --- llvm/test/DebugInfo/X86/constant-loclist.ll +++ llvm/test/DebugInfo/X86/constant-loclist.ll @@ -1,24 +1,22 @@ -; RUN: %llc_dwarf -filetype=obj %s -o - | llvm-dwarfdump - | FileCheck %s +; RUN: %llc_dwarf -filetype=obj %s -o - | llvm-dwarfdump -debug-dump=info - | FileCheck %s ; A hand-written testcase to check 64-bit constant handling in location lists. ; CHECK: .debug_info contents: ; CHECK: DW_TAG_variable -; CHECK-NEXT: DW_AT_location [DW_FORM_data4] (0x[[D:.*]]) +; CHECK-NEXT: DW_AT_location [DW_FORM_data4] ( +; CHECK-NEXT: 0x{{.*}} - 0x{{.*}}: OP_constu 0x4000000000000000) ; CHECK-NEXT: DW_AT_name {{.*}}"d" ; CHECK: DW_TAG_variable -; CHECK-NEXT: DW_AT_location [DW_FORM_data4] (0x[[I:.*]]) +; CHECK-NEXT: DW_AT_location [DW_FORM_data4] ( +; CHECK-NEXT: 0x{{.*}} - 0x{{.*}}: OP_consts +0 +; CHECK-NEXT: 0x{{.*}} - 0x{{.*}}: OP_consts +4611686018427387904) ; CHECK-NEXT: DW_AT_name {{.*}}"i" ; CHECK: DW_TAG_variable -; CHECK-NEXT: DW_AT_location [DW_FORM_data4] (0x[[U:.*]]) +; CHECK-NEXT: DW_AT_location [DW_FORM_data4] ( +; CHECK-NEXT: 0x{{.*}} - 0x{{.*}}: OP_constu 0x0 +; CHECK-NEXT: 0x{{.*}} - 0x{{.*}}: OP_constu 0x4000000000000000) ; CHECK-NEXT: DW_AT_name {{.*}}"u" -; CHECK: .debug_loc contents: -; CHECK: [[D]]: -; CHECK: Location description: 10 80 80 80 80 80 80 80 80 40 -; CHECK: [[I]]: -; CHECK: Location description: 11 80 80 80 80 80 80 80 80 c0 00 -; CHECK: [[U]]: -; CHECK: Location description: 10 80 80 80 80 80 80 80 80 40 source_filename = "test.c" target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" Index: llvm/test/DebugInfo/X86/data_member_location.ll =================================================================== --- llvm/test/DebugInfo/X86/data_member_location.ll +++ llvm/test/DebugInfo/X86/data_member_location.ll @@ -20,11 +20,11 @@ ; DWARF2: DW_AT_name {{.*}} "c" ; DWARF2-NOT: DW_TAG -; DWARF2: DW_AT_data_member_location {{.*}} (<0x02> 23 00 ) +; DWARF2: DW_AT_data_member_location {{.*}} (OP_plus_uconst 0x0) ; DWARF2: DW_AT_name {{.*}} "i" ; DWARF2-NOT: DW_TAG -; DWARF2: DW_AT_data_member_location {{.*}} (<0x02> 23 04 ) +; DWARF2: DW_AT_data_member_location {{.*}} (OP_plus_uconst 0x4) source_filename = "test/DebugInfo/X86/data_member_location.ll" Index: llvm/test/DebugInfo/X86/dbg-declare-alloca.ll =================================================================== --- llvm/test/DebugInfo/X86/dbg-declare-alloca.ll +++ llvm/test/DebugInfo/X86/dbg-declare-alloca.ll @@ -8,9 +8,8 @@ ; CHECK-LABEL: use_dbg_declare: ; CHECK-NOT: #DEBUG_VALUE -; "<0x2> 91 00" means "fbreg uleb(0)", i.e. RSP+0. ; DWARF: DW_TAG_variable -; DWARF-NEXT: DW_AT_location [DW_FORM_exprloc] (<0x2> 91 00 ) +; DWARF-NEXT: DW_AT_location [DW_FORM_exprloc] (OP_fbreg +0) ; DWARF-NEXT: DW_AT_name [DW_FORM_strp] ( {{.*}} = "o") Index: llvm/test/DebugInfo/X86/dbg-declare-arg.ll =================================================================== --- llvm/test/DebugInfo/X86/dbg-declare-arg.ll +++ llvm/test/DebugInfo/X86/dbg-declare-arg.ll @@ -5,13 +5,9 @@ ; ; CHECK: DW_AT_name {{.*}}"j" ; CHECK: DW_TAG_variable -; CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] (0x00000000) +; CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] ( +; CHECK-NEXT: 0x{{.*}} - 0x{{.*}}: OP_breg7 RSP+8) ; CHECK-NEXT: DW_AT_name {{.*}}"my_a" -; CHECK: .debug_loc contents: -; CHECK: 0x00000000: Beginning address offset: -; CHECK-NEXT: Ending address offset: -; CHECK-NEXT: Location description: 77 08 -; rsp+8 %class.A = type { i32, i32, i32, i32 } Index: llvm/test/DebugInfo/X86/dbg-declare.ll =================================================================== --- llvm/test/DebugInfo/X86/dbg-declare.ll +++ llvm/test/DebugInfo/X86/dbg-declare.ll @@ -8,7 +8,7 @@ ; "[DW_FORM_exprloc] <0x2> 91 XX" means fbreg uleb(XX) ; DWARF-LABEL: DW_TAG_formal_parameter -; DWARF-NEXT: DW_AT_location [DW_FORM_exprloc] (<0x2> 91 70 ) +; DWARF-NEXT: DW_AT_location [DW_FORM_exprloc] (OP_fbreg -16) ; DWARF-NEXT: DW_AT_name [DW_FORM_strp] ( {{.*}} = "x") ; FIXME: There is no debug info to describe "a". Index: llvm/test/DebugInfo/X86/dbg-merge-loc-entry.ll =================================================================== --- llvm/test/DebugInfo/X86/dbg-merge-loc-entry.ll +++ llvm/test/DebugInfo/X86/dbg-merge-loc-entry.ll @@ -7,7 +7,7 @@ target triple = "x86_64-apple-darwin8" ; Test that consecutive, identical DBG_VALUEs are merged. -;CHECK: DW_AT_location{{.*}}(<0x1> 55 ) +; CHECK: DW_AT_location{{.*}}(OP_reg5 RDI) %0 = type { i64, i1 } Index: llvm/test/DebugInfo/X86/dbg-value-const-byref.ll =================================================================== --- llvm/test/DebugInfo/X86/dbg-value-const-byref.ll +++ llvm/test/DebugInfo/X86/dbg-value-const-byref.ll @@ -21,29 +21,14 @@ ; CHECK: .debug_info contents: ; CHECK: DW_TAG_variable ; CHECK-NOT: DW_TAG -; CHECK: DW_AT_location [DW_FORM_data4] ([[LOC:.*]]) +; CHECK: DW_AT_location {{.*}}({{.*}} +; CHECK-NEXT: 0x{{0*.*}} - [[C1:0x.*]]: OP_consts +3 +; CHECK-NEXT: [[C1]] - [[C2:0x.*]]: OP_consts +7 +; CHECK-NEXT: [[C2]] - [[R1:0x.*]]: OP_reg0 RAX +; CHECK-NEXT: [[R1]] - [[R2:0x.*]]: OP_breg7 RSP+4, OP_deref) ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name{{.*}}"i" -; CHECK: .debug_loc contents: -; CHECK: [[LOC]]: -; consts 0x00000003 -; CHECK: Beginning address offset: 0x0000000000000{{.*}} -; CHECK: Ending address offset: [[C1:.*]] -; CHECK: Location description: 11 03 -; consts 0x00000007 -; CHECK: Beginning address offset: [[C1]] -; CHECK: Ending address offset: [[C2:.*]] -; CHECK: Location description: 11 07 -; rax -; CHECK: Beginning address offset: [[C2]] -; CHECK: Ending address offset: [[R1:.*]] -; CHECK: Location description: 50 -; rdi+0 -; CHECK: Beginning address offset: [[R1]] -; CHECK: Ending address offset: [[R2:.*]] -; CHECK: Location description: 77 04 -; rsp+4 -; + target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-apple-macosx10.9.0" Index: llvm/test/DebugInfo/X86/dbg-value-frame-index.ll =================================================================== --- llvm/test/DebugInfo/X86/dbg-value-frame-index.ll +++ llvm/test/DebugInfo/X86/dbg-value-frame-index.ll @@ -21,8 +21,8 @@ ; CHECK-LABEL: test ; CHECK: #DEBUG_VALUE: test:w <- [DW_OP_plus_uconst 8] [%RSP+0] -; DWARF: Location description: 77 08 -; DW_OP_breg7 +8 +; DWARF: DW_AT_location [DW_FORM_sec_offset] ( +; DWARF-NEXT: {{.*}} - {{.*}}: OP_breg7 RSP+8) declare i1 @fn(i64*, i64*, i64*, i8*, i64, i64*, i32*, i8*) declare void @llvm.dbg.value(metadata, metadata, metadata) Index: llvm/test/DebugInfo/X86/dbg-value-regmask-clobber.ll =================================================================== --- llvm/test/DebugInfo/X86/dbg-value-regmask-clobber.ll +++ llvm/test/DebugInfo/X86/dbg-value-regmask-clobber.ll @@ -22,14 +22,10 @@ ; argc is the first formal parameter. ; DWARF: .debug_info contents: ; DWARF: DW_TAG_formal_parameter -; DWARF-NEXT: DW_AT_location [DW_FORM_sec_offset] ([[argc_loc_offset:0x.*]]) +; DWARF-NEXT: DW_AT_location [DW_FORM_sec_offset] ({{0x.*}} +; DWARF-NEXT: 0x0000000000000000 - 0x0000000000000013: OP_reg2 RCX) ; DWARF-NEXT: DW_AT_name [DW_FORM_strp] {{.*}} "argc" -; DWARF: .debug_loc contents: -; DWARF: [[argc_loc_offset]]: Beginning address offset: 0x0000000000000000 -; DWARF-NEXT: Ending address offset: 0x0000000000000013 -; DWARF-NEXT: Location description: 52 - ; ModuleID = 't.cpp' source_filename = "test/DebugInfo/X86/dbg-value-regmask-clobber.ll" target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" Index: llvm/test/DebugInfo/X86/debug-info-blocks.ll =================================================================== --- llvm/test/DebugInfo/X86/debug-info-blocks.ll +++ llvm/test/DebugInfo/X86/debug-info-blocks.ll @@ -27,10 +27,7 @@ ; CHECK-NOT: {{DW_TAG|NULL}} ; CHECK: DW_TAG_variable ; CHECK-NOT: DW_TAG -; 0x06 = DW_OP_deref -; 0x23 = DW_OP_uconst -; 0x91 = DW_OP_fbreg -; CHECK: DW_AT_location{{.*}}91 {{[0-9]+}} 06 23 {{[0-9]+}} ) +; CHECK: DW_AT_location{{.*}}(OP_fbreg -24, OP_deref, OP_plus_uconst 0x20) ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name{{.*}}"self" ; CHECK-NOT: DW_TAG Index: llvm/test/DebugInfo/X86/debug-info-packed-struct.ll =================================================================== --- llvm/test/DebugInfo/X86/debug-info-packed-struct.ll +++ llvm/test/DebugInfo/X86/debug-info-packed-struct.ll @@ -29,15 +29,15 @@ ; CHECK: DW_AT_byte_size {{.*}} (0x18) ; CHECK: DW_TAG_member ; CHECK: DW_AT_name {{.*}} "l0_ofs0" -; CHECK: DW_AT_data_member_location {{.*}}00 +; CHECK: DW_AT_data_member_location {{.*}} (OP_plus_uconst 0x0) ; CHECK: DW_TAG_member ; CHECK: DW_AT_name {{.*}} "l0_ofs8" -; CHECK: DW_AT_data_member_location {{.*}}08 +; CHECK: DW_AT_data_member_location {{.*}} (OP_plus_uconst 0x8) ; CHECK: DW_TAG_member ; CHECK: DW_AT_name {{.*}} "l0_ofs16" ; CHECK: DW_AT_bit_size {{.*}} (0x01) ; CHECK: DW_AT_bit_offset {{.*}} (0x1f) -; CHECK: DW_AT_data_member_location {{.*}}10 +; CHECK: DW_AT_data_member_location {{.*}} (OP_plus_uconst 0x10) ; // --------------------------------------------------------------------- ; // Implicitly packed. @@ -62,16 +62,16 @@ ; CHECK: DW_AT_byte_size {{.*}} (0x0c) ; CHECK: DW_TAG_member ; CHECK: DW_AT_name {{.*}} "l1_ofs0" -; CHECK: DW_AT_data_member_location {{.*}}00 +; CHECK: DW_AT_data_member_location {{.*}} (OP_plus_uconst 0x0) ; CHECK: DW_TAG_member ; CHECK: DW_AT_name {{.*}} "l1_ofs1" -; CHECK: DW_AT_data_member_location {{.*}}01 +; CHECK: DW_AT_data_member_location {{.*}} (OP_plus_uconst 0x1) ; CHECK: DW_TAG_member ; CHECK: DW_AT_name {{.*}} "l1_ofs9" ; CHECK: DW_AT_byte_size {{.*}} (0x04) ; CHECK: DW_AT_bit_size {{.*}} (0x01) ; CHECK: DW_AT_bit_offset {{.*}} (0x17) -; CHECK: DW_AT_data_member_location {{.*}}08 +; CHECK: DW_AT_data_member_location {{.*}} (OP_plus_uconst 0x8) ; // --------------------------------------------------------------------- ; // Explicitly packed. @@ -95,16 +95,16 @@ ; CHECK: DW_AT_byte_size {{.*}} (0x0a) ; CHECK: DW_TAG_member ; CHECK: DW_AT_name {{.*}} "l2_ofs0" -; CHECK: DW_AT_data_member_location {{.*}}00 +; CHECK: DW_AT_data_member_location {{.*}} (OP_plus_uconst 0x0) ; CHECK: DW_TAG_member ; CHECK: DW_AT_name {{.*}} "l2_ofs1" -; CHECK: DW_AT_data_member_location {{.*}}01 +; CHECK: DW_AT_data_member_location {{.*}} (OP_plus_uconst 0x1) ; CHECK: DW_TAG_member ; CHECK: DW_AT_name {{.*}} "l2_ofs9" ; CHECK: DW_AT_byte_size {{.*}} (0x04) ; CHECK: DW_AT_bit_size {{.*}} (0x01) ; CHECK: DW_AT_bit_offset {{.*}} (0x17) -; CHECK: DW_AT_data_member_location {{.*}}08 +; CHECK: DW_AT_data_member_location {{.*}} (OP_plus_uconst 0x8) ; // --------------------------------------------------------------------- ; // Explicitly packed with different alignment. @@ -128,16 +128,16 @@ ; CHECK: DW_AT_byte_size {{.*}} (0x10) ; CHECK: DW_TAG_member ; CHECK: DW_AT_name {{.*}} "l3_ofs0" -; CHECK: DW_AT_data_member_location {{.*}}00 +; CHECK: DW_AT_data_member_location {{.*}} (OP_plus_uconst 0x0) ; CHECK: DW_TAG_member ; CHECK: DW_AT_name {{.*}} "l3_ofs4" -; CHECK: DW_AT_data_member_location {{.*}}04 +; CHECK: DW_AT_data_member_location {{.*}} (OP_plus_uconst 0x4) ; CHECK: DW_TAG_member ; CHECK: DW_AT_name {{.*}} "l3_ofs12" ; CHECK: DW_AT_byte_size {{.*}} (0x04) ; CHECK: DW_AT_bit_size {{.*}} (0x01) ; CHECK: DW_AT_bit_offset {{.*}} (0x1f) -; CHECK: DW_AT_data_member_location {{.*}}0c +; CHECK: DW_AT_data_member_location {{.*}} (OP_plus_uconst 0xc) !llvm.dbg.cu = !{!2} !llvm.module.flags = !{!49, !50} Index: llvm/test/DebugInfo/X86/debug-loc-asan.ll =================================================================== --- llvm/test/DebugInfo/X86/debug-loc-asan.ll +++ llvm/test/DebugInfo/X86/debug-loc-asan.ll @@ -1,6 +1,6 @@ ; RUN: llc -O0 -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s ; RUN: llc -O0 -mtriple=x86_64-unknown-linux-gnu -filetype=obj < %s \ -; RUN: | llvm-dwarfdump - | FileCheck %s --check-prefix=DWARF +; RUN: | llvm-dwarfdump -debug-dump=info - | FileCheck %s --check-prefix=DWARF ; Verify that we have correct debug info for local variables in code ; instrumented with AddressSanitizer. @@ -30,8 +30,9 @@ ; CHECK: .quad .Lfunc_begin0-.Lfunc_begin0 ; CHECK-NEXT: .quad [[START_LABEL]]-.Lfunc_begin0 ; CHECK: DW_OP_breg5 -; DWARF: Location description: 75 00 06 -; DW_OP_breg5+0 DW_OP_deref +; DWARF: DW_TAG_formal_parameter +; DWARF: DW_AT_location +; DWARF-NEXT: {{.*}} - {{.*}}: OP_breg5 RDI+0, OP_deref ; Then it's addressed via %rsp: ; CHECK: .quad [[START_LABEL]]-.Lfunc_begin0 @@ -39,8 +40,7 @@ ; CHECK: DW_OP_breg7 ; CHECK-NEXT: [[OFFSET]] ; CHECK: DW_OP_deref -; DWARF: Location description: {{77 .. 06 06}} -; DW_OP_breg7+OFFSET DW_OP_deref DW_OP_deref +; DWARF-NEXT: {{.*}} - {{.*}}: OP_breg7 RSP+{{[0-9]+}}, OP_deref, OP_deref) ; ModuleID = 'test.cc' target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" Index: llvm/test/DebugInfo/X86/debug-loc-frame.ll =================================================================== --- llvm/test/DebugInfo/X86/debug-loc-frame.ll +++ llvm/test/DebugInfo/X86/debug-loc-frame.ll @@ -26,18 +26,10 @@ ; CHECK: DW_TAG_subprogram ; CHECK-NOT: NULL ; CHECK: DW_TAG_variable -; CHECK: DW_AT_location [DW_FORM_sec_offset] ([[DEBUGLOCOFFSET:0x[0-9a-f]+]]){{[[:space:]].*}}"val" - -; See that 'val' has at least one location entry with a DW_op_breg? operand. -; The DWARF DW_op_breg* ops are encoded from 0x70 to 0x8f, but checking for an -; op in the range from 0x70 to 0x7f should suffice because that range covers -; all integer GPRs. -; -; CHECK: .debug_loc contents: -; CHECK-NOT: .debug{{.*}} contents -; CHECK: [[DEBUGLOCOFFSET]]: Beginning -; CHECK-NOT: {{0x[0-9a-f]+}}: Beginning -; CHECK: Location description: 7{{[0-9a-f] .*}} +; CHECK: DW_AT_location [DW_FORM_sec_offset] ({{.*}} +; CHECK-NEXT: {{0x.*}} - {{0x.*}}: OP_reg0 RAX +; CHECK-NEXT: {{0x.*}} - {{0x.*}}: OP_breg7 RSP+4, OP_deref) +; CHECK-NEXT: DW_AT_name {{.*}}"val" ; ModuleID = 'frame.c' source_filename = "frame.c" Index: llvm/test/DebugInfo/X86/debug-loc-offset.ll =================================================================== --- llvm/test/DebugInfo/X86/debug-loc-offset.ll +++ llvm/test/DebugInfo/X86/debug-loc-offset.ll @@ -27,12 +27,13 @@ ; debug_loc entries are relative to the low_pc of the CU. The loc entry for ; the byval argument in foo.cpp is in the second CU and so should have ; an offset relative to that CU rather than from the beginning of the text -; section. +; section. Today, llvm-dwarfdump adds the low low_pc of the CU when dumping +; locations, so they should match. ; Checking that we have two compile units with two sets of high/lo_pc. ; CHECK: .debug_info contents ; CHECK: DW_TAG_compile_unit -; CHECK: DW_AT_low_pc +; CHECK: DW_AT_low_pc {{.*}} (0x0000000000000020) ; CHECK: DW_AT_high_pc ; CHECK: DW_TAG_subprogram @@ -41,21 +42,23 @@ ; CHECK-NOT: {{DW_TAG|NULL}} ; CHECK: DW_TAG_formal_parameter ; CHECK-NOT: DW_TAG -; CHECK: DW_AT_location [DW_FORM_sec_offset] (0x00000000) -; CHECK-NOT: DW_TAG -; CHECK: DW_AT_name [DW_FORM_strp]{{.*}}"a" +; CHECK: DW_AT_location [DW_FORM_sec_offset] ({{.*}} +; CHECK-NEXT: 0x0000000000000020 - 0x0000000000000037: {{.*}} +; CHECK-NEXT: 0x0000000000000037 - 0x0000000000000063: {{.*}} +; CHECK-NEXT: DW_AT_name [DW_FORM_strp]{{.*}}"a" ; CHECK: DW_TAG_variable ; CHECK: DW_AT_location [DW_FORM_exprloc] ; CHECK-NOT: DW_AT_location ; CHECK: DW_TAG_compile_unit -; CHECK: DW_AT_low_pc +; CHECK: DW_AT_low_pc {{.*}} (0x0000000000000000) ; CHECK: DW_AT_high_pc ; CHECK: .debug_loc contents: -; CHECK: 0x00000000: Beginning address offset: 0x0000000000000000 -; CHECK: Ending address offset: 0x0000000000000017 +; CHECK: 0x00000000: +; CHECK-NEXT: 0x0000000000000020 - 0x0000000000000037: {{.*}} +; CHECK-NEXT: 0x0000000000000037 - 0x0000000000000063: {{.*}} %struct.A = type { i32 (...)**, i32 } Index: llvm/test/DebugInfo/X86/dw_op_minus_direct.ll =================================================================== --- llvm/test/DebugInfo/X86/dw_op_minus_direct.ll +++ llvm/test/DebugInfo/X86/dw_op_minus_direct.ll @@ -13,12 +13,13 @@ ; DWARF2: .debug_info ; DWARF2: DW_TAG_formal_parameter ; DWARF2-NEXT: DW_AT_name {{.*}}"i" -; DWARF2-NOT: DW_AT_location +; DWARF2-NOT: DW_AT_location -; CHECK: Beginning address offset: 0x0000000000000000 -; CHECK: Ending address offset: 0x0000000000000004 -; CHECK: Location description: 70 00 10 ff ff ff ff 0f 1a 10 01 1c 9f +; CHECK: .debug_loc contents: +; CHECK: 0x00000000: +; CHECK-NEXT: 0x0000000000000000 - 0x0000000000000004: OP_breg0 RAX+0, OP_constu 0xffffffff, OP_and, OP_constu 0x1, OP_minus, OP_stack_value ; rax+0, constu 0xffffffff, and, constu 0x00000001, minus, stack-value + source_filename = "minus.c" target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-apple-macosx10.12.0" Index: llvm/test/DebugInfo/X86/fi-expr.ll =================================================================== --- llvm/test/DebugInfo/X86/fi-expr.ll +++ llvm/test/DebugInfo/X86/fi-expr.ll @@ -3,8 +3,9 @@ ; A hand-crafted FrameIndex location with a DW_OP_deref. ; CHECK: DW_TAG_formal_parameter ; fbreg -8, deref -; CHECK-NEXT: DW_AT_location {{.*}} (<0x3> 91 78 06 ) +; CHECK-NEXT: DW_AT_location {{.*}} (OP_fbreg -8, OP_deref) ; CHECK-NEXT: DW_AT_name {{.*}} "foo" + define void @f(i8* %bar) !dbg !6 { entry: %foo.addr = alloca i8* Index: llvm/test/DebugInfo/X86/fi-piece.ll =================================================================== --- llvm/test/DebugInfo/X86/fi-piece.ll +++ llvm/test/DebugInfo/X86/fi-piece.ll @@ -5,8 +5,7 @@ ; CHECK: DW_TAG_subprogram ; CHECK: DW_AT_abstract_origin ; CHECK: DW_TAG_variable -; CHECK-NEXT: DW_AT_location [DW_FORM_exprloc] (<0x8> 91 7c 93 02 91 78 93 02 ) -; fbreg -8, piece 0x00000002, fbreg -4, piece 0x00000002 +; CHECK-NEXT: DW_AT_location [DW_FORM_exprloc] (OP_fbreg -4, OP_piece 0x2, OP_fbreg -8, OP_piece 0x2) ; CHECK-NEXT: DW_AT_abstract_origin {{.*}}"a" ; Inlined variable, not to be merged. ; CHECK-NOT: DW_TAG Index: llvm/test/DebugInfo/X86/fission-cu.ll =================================================================== --- llvm/test/DebugInfo/X86/fission-cu.ll +++ llvm/test/DebugInfo/X86/fission-cu.ll @@ -79,7 +79,7 @@ ; CHECK: DW_AT_external [DW_FORM_flag_present] (true) ; CHECK: DW_AT_decl_file [DW_FORM_data1] (0x01) ; CHECK: DW_AT_decl_line [DW_FORM_data1] (1) -; CHECK: DW_AT_location [DW_FORM_exprloc] (<0x2> fb 00 ) +; CHECK: DW_AT_location [DW_FORM_exprloc] (OP_GNU_addr_index 0x0) ; CHECK: [[TYPE]]: DW_TAG_base_type ; CHECK: DW_AT_name [DW_FORM_GNU_str_index] ( indexed (00000004) string = "int") Index: llvm/test/DebugInfo/X86/fission-ranges.ll =================================================================== --- llvm/test/DebugInfo/X86/fission-ranges.ll +++ llvm/test/DebugInfo/X86/fission-ranges.ll @@ -12,10 +12,10 @@ ; CHECK: .debug_info.dwo contents: -; CHECK: DW_AT_location [DW_FORM_sec_offset] ([[A:0x[0-9a-z]*]]) -; CHECK: DW_AT_location [DW_FORM_sec_offset] ([[E:0x[0-9a-z]*]]) -; CHECK: DW_AT_location [DW_FORM_sec_offset] ([[B:0x[0-9a-z]*]]) -; CHECK: DW_AT_location [DW_FORM_sec_offset] ([[D:0x[0-9a-z]*]]) +; CHECK: DW_AT_location [DW_FORM_sec_offset] ([[A:0x[0-9a-z]*]] +; CHECK: DW_AT_location [DW_FORM_sec_offset] ([[E:0x[0-9a-z]*]] +; CHECK: DW_AT_location [DW_FORM_sec_offset] ([[B:0x[0-9a-z]*]] +; CHECK: DW_AT_location [DW_FORM_sec_offset] ([[D:0x[0-9a-z]*]] ; CHECK: DW_AT_ranges [DW_FORM_sec_offset] (0x00000000 ; CHECK: .debug_loc contents: ; CHECK-NOT: Beginning address offset @@ -24,22 +24,16 @@ ; Don't assume these locations are entirely correct - feel free to update them ; if they've changed due to a bugfix, change in register allocation, etc. -; CHECK: [[A]]: Beginning address index: 2 -; CHECK-NEXT: Length: 169 -; CHECK-NEXT: Location description: 11 00 -; CHECK-NEXT: {{^$}} -; CHECK-NEXT: Beginning address index: 3 -; CHECK-NEXT: Length: 25 -; CHECK-NEXT: Location description: 50 -; CHECK: [[E]]: Beginning address index: 4 -; CHECK-NEXT: Length: 19 -; CHECK-NEXT: Location description: 50 -; CHECK: [[B]]: Beginning address index: 5 -; CHECK-NEXT: Length: 17 -; CHECK-NEXT: Location description: 50 -; CHECK: [[D]]: Beginning address index: 6 -; CHECK-NEXT: Length: 17 -; CHECK-NEXT: Location description: 50 +; CHECK: [[A]]: +; CHECK-NEXT: Addr idx 2 (w/ length 169): OP_consts +0, OP_stack_value +; CHECK-NEXT: Addr idx 3 (w/ length 25): OP_reg0 RAX +; CHECK: [[E]]: +; CHECK-NEXT: Addr idx 4 (w/ length 19): OP_reg0 RAX +; CHECK: [[B]]: +; CHECK-NEXT: Addr idx 5 (w/ length 17): OP_reg0 RAX +; CHECK: [[D]]: +; CHECK-NEXT: Addr idx 6 (w/ length 17): OP_reg0 RAX + ; Make sure we don't produce any relocations in any .dwo section (though in particular, debug_info.dwo) ; HDR-NOT: .rela.{{.*}}.dwo Index: llvm/test/DebugInfo/X86/float_const_loclist.ll =================================================================== --- llvm/test/DebugInfo/X86/float_const_loclist.ll +++ llvm/test/DebugInfo/X86/float_const_loclist.ll @@ -20,21 +20,14 @@ ; ; CHECK: .debug_info contents: ; CHECK: DW_TAG_variable -; CHECK-NEXT: DW_AT_location {{.*}} (0x[[LD:.*]]) +; CHECK-NEXT: DW_AT_location {{.*}} ( +; CHECK-NEXT: [[START:0x.*]] - [[END:0x.*]]: OP_constu 0xc8f5c28f5c28f800, OP_piece 0x8, OP_constu 0x4000, OP_bit_piece 0x10 0x40) ; CHECK-NEXT: DW_AT_name {{.*}}"ld" ; CHECK: DW_TAG_variable -; CHECK-NEXT: DW_AT_location {{.*}} (0x[[F:.*]]) +; CHECK-NEXT: DW_AT_location {{.*}} ( +; CHECK-NEXT: [[START]] - [[END]]: OP_constu 0x4048f5c3) ; CHECK-NEXT: DW_AT_name {{.*}}"f" -; -; CHECK: .debug_loc contents: -; CHECK: [[LD]]: Beginning address offset: [[START:.*]] -; CHECK: Ending address offset: [[END:.*]] -; CHECK: Location description: 10 80 f0 a3 e1 f5 d1 f0 fa c8 01 93 08 10 80 80 01 9d 10 40 -; constu 0xc8f5c28f5c28f800, piece 8, constu 0x00004000, bit-piece 16 64 -; CHECK: [[F]]: Beginning address offset: [[START]] -; CHECK: Ending address offset: [[END]] -; CHECK: Location description: 10 c3 eb a3 82 04 -; constu ... + source_filename = "test.c" target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-apple-macosx10.11.0" Index: llvm/test/DebugInfo/X86/frame-register.ll =================================================================== --- llvm/test/DebugInfo/X86/frame-register.ll +++ llvm/test/DebugInfo/X86/frame-register.ll @@ -1,7 +1,6 @@ ; RUN: llc %s -filetype=obj -o - | llvm-dwarfdump --debug-dump=info - | FileCheck %s ; CHECK: DW_TAG_variable -; DW_OP_fbreg -; CHECK-NEXT: DW_AT_location [DW_FORM_exprloc] (<0x2> 91 00 ) +; CHECK-NEXT: DW_AT_location [DW_FORM_exprloc] (OP_fbreg +0) ; CHECK-NEXT: DW_AT_name {{.*}}"i" target datalayout = "e-m:e-p:32:32-i64:64-f80:128-n8:16:32:64-S128" Index: llvm/test/DebugInfo/X86/inlined-formal-parameter.ll =================================================================== --- llvm/test/DebugInfo/X86/inlined-formal-parameter.ll +++ llvm/test/DebugInfo/X86/inlined-formal-parameter.ll @@ -19,11 +19,10 @@ ; CHECK: DW_TAG_inlined_subroutine ; CHECK-NEXT: DW_AT_abstract_origin {{.*}} "bar" ; CHECK: DW_TAG_formal_parameter -; CHECK-NEXT: DW_AT_location [DW_FORM_data4] (0x00000000) +; CHECK-NEXT: DW_AT_location [DW_FORM_data4] ( +; CHECK-NEXT: {{.*}} - {{.*}}: OP_consts +0) ; CHECK-NEXT: DW_AT_abstract_origin {{.*}} "a" -; -; CHECK: .debug_loc -; CHECK: Location description: 11 00 + target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-apple-darwin" Index: llvm/test/DebugInfo/X86/live-debug-variables.ll =================================================================== --- llvm/test/DebugInfo/X86/live-debug-variables.ll +++ llvm/test/DebugInfo/X86/live-debug-variables.ll @@ -22,8 +22,11 @@ ; F(a,b,c,d,e); ; } -; CHECK: Beginning address offset -; CHECK-NOT: Beginning address offset +; CHECK: .debug_loc contents: +; CHECK-NEXT: 0x00000000: +; CHECK-NEXT: 0x000000000000001f - 0x000000000000003c: OP_reg3 RBX +; We should only have one entry +; CHECK-NOT: : declare i32 @foobar(i32, i32, i32, i32, i32) Index: llvm/test/DebugInfo/X86/op_deref.ll =================================================================== --- llvm/test/DebugInfo/X86/op_deref.ll +++ llvm/test/DebugInfo/X86/op_deref.ll @@ -5,19 +5,16 @@ ; RUN: | llvm-dwarfdump -debug-dump=info - \ ; RUN: | FileCheck %s -check-prefix=CHECK -check-prefix=DWARF3 -; FIXME: The location here needs to be fixed, but llvm-dwarfdump doesn't handle -; DW_AT_location lists yet. -; DWARF4: DW_AT_location [DW_FORM_sec_offset] (0x00000000) +; DWARF4: DW_AT_location [DW_FORM_sec_offset] (0x00000000 +; DWARF4-NEXT: {{.*}}: OP_breg2 RCX+0, OP_deref -; FIXME: The location here needs to be fixed, but llvm-dwarfdump doesn't handle -; DW_AT_location lists yet. -; DWARF3: DW_AT_location [DW_FORM_data4] (0x00000000) +; DWARF3: DW_AT_location [DW_FORM_data4] (0x00000000 +; DWARF3-NEXT: {{.*}}: OP_breg2 RCX+0, OP_deref ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000067] = "vla") -; Unfortunately llvm-dwarfdump can't unparse a list of DW_AT_locations -; right now, so we check the asm output: +; Check the DEBUG_VALUE comments for good measure. ; RUN: llc -O0 -mtriple=x86_64-apple-darwin %s -o - -filetype=asm | FileCheck %s -check-prefix=ASM-CHECK ; vla should have a register-indirect address at one point. ; ASM-CHECK: DEBUG_VALUE: vla <- [DW_OP_deref] [%RCX+0] Index: llvm/test/DebugInfo/X86/parameters.ll =================================================================== --- llvm/test/DebugInfo/X86/parameters.ll +++ llvm/test/DebugInfo/X86/parameters.ll @@ -1,7 +1,7 @@ ; REQUIRES: object-emission ; ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -O0 -filetype=obj < %s > %t -; RUN: llvm-dwarfdump %t | FileCheck %s +; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s ; Test case derived from compiling the following source with clang -g: ; @@ -23,21 +23,25 @@ ; } ; CHECK: debug_info contents -; 0x74 is DW_OP_breg4, showing that the parameter is accessed indirectly -; (with a zero offset) from the register parameter. -; CHECK: DW_AT_location {{.*}} 74 00 06 - +; The parameter is accessed indirectly (with a zero offset) from the second +; register parameter. RDI is consumed by 'sret'. +; CHECK: DW_TAG_subprogram +; CHECK: DW_AT_name{{.*}} = "func" +; CHECK: DW_TAG_formal_parameter +; CHECK: DW_AT_location {{.*}} (OP_breg4 RSI+0, OP_deref) ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name{{.*}} = "f" -; -; CHECK: DW_AT_location{{.*}}([[G_LOC:0x[0-9]*]]) + +; CHECK: DW_TAG_subprogram +; CHECK: DW_AT_name{{.*}} = "func2" +; CHECK: DW_TAG_formal_parameter +; CHECK: DW_AT_location{{.*}}(OP_fbreg +23) +; CHECK: DW_TAG_formal_parameter +; CHECK: DW_AT_location{{.*}}( +; CHECK-NEXT: {{.*}}: OP_breg4 RSI+0, OP_deref +; CHECK-NEXT: {{.*}}: OP_breg7 RSP+8, OP_deref, OP_deref) ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name{{.*}} = "g" -; -; CHECK: debug_loc contents -; CHECK: [[G_LOC]]: Beginning -; CHECK-NEXT: Ending -; CHECK-NEXT: Location description: 74 00 %"struct.pr14763::foo" = type { i8 } Index: llvm/test/DebugInfo/X86/partial-constant.ll =================================================================== --- llvm/test/DebugInfo/X86/partial-constant.ll +++ llvm/test/DebugInfo/X86/partial-constant.ll @@ -16,9 +16,10 @@ ; ; The constant should NOT be available for the entire function. ; CHECK-NOT: DW_AT_const_value -; CHECK: .debug_loc -; CHECK: Location description: 10 01 9f -; constu 0x00000001, stack-value +; CHECK: .debug_loc contents: +; CHECK-NEXT: 0x00000000: +; CHECK-NEXT: {{.*}}: OP_constu 0x1, OP_stack_value + source_filename = "test.ii" target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-apple-macosx10.12.0" Index: llvm/test/DebugInfo/X86/pieces-1.ll =================================================================== --- llvm/test/DebugInfo/X86/pieces-1.ll +++ llvm/test/DebugInfo/X86/pieces-1.ll @@ -17,14 +17,9 @@ ; CHECK: .debug_loc contents: ; -; 0x0000000000000000 - 0x0000000000000006: rdi, piece 0x00000008, rsi, piece 0x00000004 -; CHECK: Beginning address offset: 0x0000000000000000 -; CHECK: Ending address offset: [[LTMP3:.*]] -; CHECK: Location description: 55 93 08 54 93 04 -; 0x0000000000000006 - 0x0000000000000008: rbp-8, piece 0x00000008, rax, piece 0x00000004 ) -; CHECK: Beginning address offset: [[LTMP3]] -; CHECK: Ending address offset: [[END:.*]] -; CHECK: Location description: 76 78 93 08 54 93 04 +; CHECK: 0x0000000000000000 - [[LTMP3:.*]]: OP_reg5 RDI, OP_piece 0x8, OP_reg4 RSI, OP_piece 0x4 +; 0x0000000000000006 - 0x0000000000000008: rbp-8, piece 0x8, rax, piece 0x4 ) +; CHECK: [[LTMP3]] - {{.*}}: OP_breg6 RBP-8, OP_piece 0x8, OP_reg4 RSI, OP_piece 0x4 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-apple-macosx10.9.0" Index: llvm/test/DebugInfo/X86/pieces-2.ll =================================================================== --- llvm/test/DebugInfo/X86/pieces-2.ll +++ llvm/test/DebugInfo/X86/pieces-2.ll @@ -17,15 +17,10 @@ ; ; ; CHECK: DW_TAG_variable [4] -; CHECK-NEXT: DW_AT_location [DW_FORM_data4] ([[LOC:.*]]) +; CHECK-NEXT: DW_AT_location [DW_FORM_data4] ( +; CHECK-NEXT: 0x0000000000000004 - 0x0000000000000005: OP_reg0 RAX, OP_piece 0x4) ; CHECK-NEXT: DW_AT_name {{.*}}"i1" -; -; CHECK: .debug_loc -; CHECK: [[LOC]]: Beginning address offset: 0x0000000000000004 -; CHECK-NEXT: Ending address offset: 0x0000000000000005 -; rax, piece 0x00000004 -; CHECK-NEXT: Location description: 50 93 04 -; + ; ModuleID = '/Volumes/Data/llvm/test/DebugInfo/X86/sroasplit-1.ll' target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-apple-macosx10.9.0" Index: llvm/test/DebugInfo/X86/pieces-3.ll =================================================================== --- llvm/test/DebugInfo/X86/pieces-3.ll +++ llvm/test/DebugInfo/X86/pieces-3.ll @@ -16,26 +16,14 @@ ; } ; ; CHECK: DW_TAG_formal_parameter [3] -; CHECK-NEXT: DW_AT_location [DW_FORM_data4] ([[LOC1:.*]]) +; CHECK-NEXT: DW_AT_location [DW_FORM_data4] ( +; CHECK-NEXT: 0x0000000000000000 - 0x0000000000000004: OP_reg5 RDI, OP_piece 0x8, OP_piece 0x4, OP_reg4 RSI, OP_piece 0x4 +; CHECK-NEXT: 0x0000000000000004 - 0x0000000000000008: OP_reg5 RDI, OP_piece 0x8, OP_piece 0x4, OP_reg4 RSI, OP_piece 0x4) ; CHECK-NEXT: DW_AT_name {{.*}}"outer" ; CHECK: DW_TAG_variable -; CHECK-NEXT: DW_AT_location -; rsi, piece 0x00000004 -; CHECK-SAME: 54 93 04 +; CHECK-NEXT: DW_AT_location {{.*}}(OP_reg4 RSI, OP_piece 0x4) ; CHECK-NEXT: "i1" -; -; CHECK: .debug_loc -; CHECK: [[LOC1]]: Beginning address offset: 0x0000000000000000 -; CHECK-NEXT: Ending address offset: 0x0000000000000004 -; rdi, piece 0x00000008, piece 0x00000004, rsi, piece 0x00000004 -; CHECK-NEXT: Location description: 55 93 08 93 04 54 93 04 -; This location is split into two ranges with identical locations -; because it comes from a DBG_VALUE %RSI followed by a DBG_VALUE %ESI. -; CHECK: Beginning address offset: 0x0000000000000004 -; CHECK-NEXT: Ending address offset: 0x0000000000000008 -; CHECK-NEXT: Location description: 55 93 08 93 04 54 93 04 -; ; ModuleID = '/Volumes/Data/llvm/test/DebugInfo/X86/sroasplit-2.ll' target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-apple-macosx10.9.0" Index: llvm/test/DebugInfo/X86/pieces-4.ll =================================================================== --- llvm/test/DebugInfo/X86/pieces-4.ll +++ llvm/test/DebugInfo/X86/pieces-4.ll @@ -1,5 +1,5 @@ ; RUN: llc < %s | FileCheck %s -; RUN: llc -filetype=obj < %s | llvm-dwarfdump - | FileCheck %s --check-prefix=DWARF +; RUN: llc -filetype=obj < %s | llvm-dwarfdump -debug-dump=loc - | FileCheck %s --check-prefix=DWARF ; Compile the following with -O1: @@ -22,8 +22,10 @@ ; CHECK: #NO_APP ; CHECK: movl [[offs]](%rsp), %eax # 4-byte Reload ; CHECK: retq -; DWARF: Location description: {{77 .. 93 04 10 00 9f 93 04}} -; DW_OP_breg7+offs DW_OP_piece 4 DW_OP_constu 0 DW_OP_stack_value DW_OP_piece 4 + +; DWARF: .debug_loc contents: +; DWARF-NEXT: 0x00000000: +; DWARF-NEXT: {{.*}}: OP_breg7 RSP+{{[0-9]+}}, OP_piece 0x4, OP_constu 0x0, OP_stack_value, OP_piece 0x4 ; ModuleID = 't.c' source_filename = "t.c" Index: llvm/test/DebugInfo/X86/reference-argument.ll =================================================================== --- llvm/test/DebugInfo/X86/reference-argument.ll +++ llvm/test/DebugInfo/X86/reference-argument.ll @@ -12,9 +12,7 @@ ; CHECK: DW_AT_name {{.*}} "this" ; CHECK-NOT: DW_TAG_subprogram ; CHECK: DW_TAG_formal_parameter -; CHECK-NEXT: DW_AT_location -; rsi+0 -; CHECK-SAME: 74 00 +; CHECK-NEXT: DW_AT_location {{.*}}(OP_breg4 RSI+0) ; CHECK-NEXT: DW_AT_name {{.*}} "v" target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" Index: llvm/test/DebugInfo/X86/single-dbg_value.ll =================================================================== --- llvm/test/DebugInfo/X86/single-dbg_value.ll +++ llvm/test/DebugInfo/X86/single-dbg_value.ll @@ -5,14 +5,13 @@ ; ; CHECK: .debug_info contents: ; CHECK: DW_TAG_variable -; CHECK-NEXT: DW_AT_location [DW_FORM_data4] +; CHECK-NEXT: DW_AT_location [DW_FORM_data4] ( +; CHECK-NEXT: {{.*}}: OP_reg0 RAX) ; CHECK-NEXT: DW_AT_name{{.*}}"a" -; CHECK: .debug_loc contents: -; rax -; CHECK: Location description: 50 + ; SANITY: DBG_VALUE ; SANITY-NOT: DBG_VALUE -; ModuleID = 'test.ll' + ; Compiled with -O: ; void h(int); ; int g(); @@ -21,6 +20,8 @@ ; int a = g(); ; h(a); ; } + +; ModuleID = 'test.ll' target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-apple-macosx" Index: llvm/test/DebugInfo/X86/single-fi.ll =================================================================== --- llvm/test/DebugInfo/X86/single-fi.ll +++ llvm/test/DebugInfo/X86/single-fi.ll @@ -3,7 +3,7 @@ ; A single FI location. This used to trigger an assertion in debug libstdc++. ; CHECK: DW_TAG_formal_parameter ; fbreg -8 -; CHECK-NEXT: DW_AT_location {{.*}} (<0x2> 91 78 ) +; CHECK-NEXT: DW_AT_location {{.*}} (OP_fbreg -8) ; CHECK-NEXT: DW_AT_name {{.*}} "dipsy" define void @tinkywinky(i8* %dipsy) !dbg !6 { entry: Index: llvm/test/DebugInfo/X86/split-global.ll =================================================================== --- llvm/test/DebugInfo/X86/split-global.ll +++ llvm/test/DebugInfo/X86/split-global.ll @@ -11,21 +11,19 @@ ; CHECK: DW_TAG_variable ; CHECK-NEXT: DW_AT_name {{.*}}"point" ; CHECK-NOT: DW_TAG -; CHECK: DW_AT_location [DW_FORM_exprloc] (<0x16> 03 04 00 00 00 00 00 00 00 93 04 03 00 00 00 00 00 00 00 00 93 04 ) -; [0x0000000000000004], piece 0x00000004, [0x0000000000000000], piece 0x00000004 +; CHECK: DW_AT_location [DW_FORM_exprloc] (OP_addr 0x4, OP_piece 0x4, OP_addr 0x0, OP_piece 0x4) ; CHECK-NOT: DW_TAG ; CHECK: DW_TAG ; CHECK: DW_TAG_variable ; CHECK-NEXT: DW_AT_name {{.*}}"part_const" ; CHECK-NOT: DW_TAG -; CHECK: DW_AT_location [DW_FORM_exprloc] (<0x10> 03 08 00 00 00 00 00 00 00 93 04 10 02 9f 93 04 ) +; CHECK: DW_AT_location [DW_FORM_exprloc] (OP_addr 0x8, OP_piece 0x4, OP_constu 0x2, OP_stack_value, OP_piece 0x4) ; [0x0000000000000008], piece 0x00000004, constu 0x00000002, stack-value, piece 0x00000004 ; CHECK-NOT: DW_TAG ; CHECK: DW_TAG_variable ; CHECK-NEXT: DW_AT_name {{.*}}"full_const" ; CHECK-NOT: DW_TAG -; CHECK: DW_AT_location [DW_FORM_exprloc] (<0xa> 10 01 9f 93 04 10 02 9f 93 04 ) -; constu 0x00000001, stack-value, piece 0x00000004, constu 0x00000002, stack-value, piece 0x00000004 +; CHECK: DW_AT_location [DW_FORM_exprloc] (OP_constu 0x1, OP_stack_value, OP_piece 0x4, OP_constu 0x2, OP_stack_value, OP_piece 0x4) ; CHECK-NOT: DW_TAG @point.y = global i32 2, align 4, !dbg !13 @point.x = global i32 1, align 4, !dbg !12 Index: llvm/test/DebugInfo/X86/sret.ll =================================================================== --- llvm/test/DebugInfo/X86/sret.ll +++ llvm/test/DebugInfo/X86/sret.ll @@ -10,13 +10,10 @@ ; RUN: llc -O0 -fast-isel=false -mtriple=x86_64-apple-darwin -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s ; CHECK: _ZN1B9AInstanceEv ; CHECK: DW_TAG_variable -; CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] (0x00000000) +; CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] (0x00000000 +; CHECK-NEXT: {{.*}} - {{.*}}: OP_breg5 RDI+0 +; CHECK-NEXT: {{.*}} - {{.*}}: OP_breg6 RBP-24, OP_deref) ; CHECK-NEXT: DW_AT_name {{.*}}"a" -; CHECK: .debug_loc contents: -; CHECK: 0x00000000: Beginning address offset: -; CHECK-NEXT: Ending address offset: -; CHECK-NEXT: Location description: 75 00 -; rdi+0 %class.A = type { i32 (...)**, i32 } %class.B = type { i8 } Index: llvm/test/DebugInfo/X86/stack-value-dwarf2.ll =================================================================== --- llvm/test/DebugInfo/X86/stack-value-dwarf2.ll +++ llvm/test/DebugInfo/X86/stack-value-dwarf2.ll @@ -1,7 +1,8 @@ -; RUN: llc -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s +; RUN: llc -filetype=obj -o - %s | llvm-dwarfdump -debug-dump=loc - | FileCheck %s + ; Note that it would be even better to avoid emitting the empty piece. -; CHECK: Location description: 93 08 -; piece 0x00000008 +; CHECK: {{.*}}: OP_piece 0x8{{$}} + source_filename = "bugpoint-reduced-simplified.ll" target triple = "i386-apple-ios7.0.0" Index: llvm/test/DebugInfo/X86/stack-value-piece.ll =================================================================== --- llvm/test/DebugInfo/X86/stack-value-piece.ll +++ llvm/test/DebugInfo/X86/stack-value-piece.ll @@ -18,25 +18,22 @@ ; CHECK: DW_TAG_subprogram ; CHECK: DW_AT_name {{.*}} "i" ; CHECK: DW_TAG_variable -; CHECK-NEXT: DW_AT_location {{.*}} ([[I:.*]]) +; CHECK-NEXT: DW_AT_location {{.*}} ([[I:.*]] +; CHECK-NEXT: {{.*}} - {{.*}}: OP_reg5 RDI, OP_piece 0x4, OP_constu 0x0, OP_stack_value, OP_piece 0x4) ; CHECK-NEXT: DW_AT_name {{.*}} "r" ; ; CHECK: DW_TAG_subprogram ; CHECK: DW_AT_name {{.*}} "f" ; CHECK: DW_TAG_variable -; CHECK-NEXT: DW_AT_location {{.*}} ([[F:.*]]) +; CHECK-NEXT: DW_AT_location {{.*}} ([[F:.*]] +; CHECK-NEXT: {{.*}} - {{.*}}: OP_reg17 XMM0, OP_piece 0x4, OP_constu 0x0, OP_stack_value, OP_piece 0x4) ; CHECK-NEXT: DW_AT_name {{.*}} "r" ; ; CHECK: .debug_loc contents: -; CHECK: [[I]]: Beginning address offset: -; CHECK-NEXT: Ending address offset: -; CHECK-NEXT: Location description: 55 93 04 10 00 9f 93 04 -; rdi, piece 0x00000004, constu 0x00000000, stack-value, piece 0x00000004 -; -; CHECK: [[F]]: Beginning address offset: -; CHECK-NEXT: Ending address offset: -; CHECK-NEXT: Location description: 61 93 04 10 00 9f 93 04 -; reg17, piece 0x00000004, constu 0x00000000, stack-value, piece 0x00000004 +; CHECK: [[I]]: +; CHECK-NEXT: {{.*}} - {{.*}}: OP_reg5 RDI, OP_piece 0x4, OP_constu 0x0, OP_stack_value, OP_piece 0x4 +; CHECK: [[F]]: +; CHECK-NEXT: {{.*}} - {{.*}}: OP_reg17 XMM0, OP_piece 0x4, OP_constu 0x0, OP_stack_value, OP_piece 0x4 source_filename = "stack-value-piece.c" target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" Index: llvm/test/DebugInfo/X86/subregisters.ll =================================================================== --- llvm/test/DebugInfo/X86/subregisters.ll +++ llvm/test/DebugInfo/X86/subregisters.ll @@ -8,11 +8,9 @@ ; ; CHECK: .debug_info contents: ; CHECK: DW_TAG_variable -; CHECK-NEXT: DW_AT_location [DW_FORM_data4] (0x00000000) +; CHECK-NEXT: DW_AT_location [DW_FORM_data4] ( +; CHECK-NEXT: {{.*}} - {{.*}}: OP_reg4 RSI) ; CHECK-NEXT: DW_AT_name [DW_FORM_strp]{{.*}} "a" -; CHECK: .debug_loc contents: -; rsi -; CHECK: Location description: 54 ; ; struct bar { ; int a; Index: llvm/test/DebugInfo/X86/template.ll =================================================================== --- llvm/test/DebugInfo/X86/template.ll +++ llvm/test/DebugInfo/X86/template.ll @@ -29,7 +29,7 @@ ; The address of the global 'glbl', followed by DW_OP_stack_value (9f), to use ; the value immediately, rather than indirecting through the address. -; CHECK-NEXT: DW_AT_location [DW_FORM_exprloc]{{ *}}(<0xa> 03 00 00 00 00 00 00 00 00 9f ) +; CHECK-NEXT: DW_AT_location [DW_FORM_exprloc]{{ *}}(OP_addr 0x0, OP_stack_value) ; CHECK-NOT: NULL ; CHECK: DW_TAG_GNU_template_template_param Index: llvm/test/DebugInfo/X86/this-stack_value.ll =================================================================== --- llvm/test/DebugInfo/X86/this-stack_value.ll +++ llvm/test/DebugInfo/X86/this-stack_value.ll @@ -18,8 +18,8 @@ ; modified by the debugger. ; ; ASM: [DW_OP_stack_value] -; CHECK: DW_AT_location {{.*}} 70 00 9f -; rax+0, stack-value +; CHECK: DW_AT_location {{.*}} (OP_breg0 RAX+0, OP_stack_value) + source_filename = "ab.cpp" target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-apple-macosx10.12.0" Index: llvm/test/DebugInfo/dwarfdump-debug-loc-simple.test =================================================================== --- llvm/test/DebugInfo/dwarfdump-debug-loc-simple.test +++ llvm/test/DebugInfo/dwarfdump-debug-loc-simple.test @@ -3,24 +3,20 @@ CHECK: .debug_info CHECK: DW_AT_name{{.*}}"f" -CHECK: DW_AT_location{{.*}}([[F_LOC:0x[0-9a-f]*]]) +CHECK: DW_AT_location{{.*}}([[F_LOC:0x[0-9a-f]*]] +CHECK-NEXT: 0x0000000000000000 - 0x0000000000000023: OP_reg1 ECX +CHECK-NEXT: 0x0000000000000023 - 0x000000000000005d: OP_breg5 EBP-16) CHECK: DW_AT_name{{.*}}"g" -CHECK: DW_AT_location{{.*}}([[G_LOC:0x[0-9a-f]*]]) +CHECK: DW_AT_location{{.*}}([[G_LOC:0x[0-9a-f]*]] +CHECK-NEXT: 0x0000000000000000 - 0x0000000000000020: OP_reg0 EAX +CHECK-NEXT: 0x0000000000000020 - 0x000000000000005d: OP_breg5 EBP-12) + CHECK: .debug_loc contents: -CHECK-NEXT: [[F_LOC]]: Beginning address offset: 0x0000000000000000 -CHECK-NEXT: Ending address offset: 0x0000000000000023 +CHECK-NEXT: [[F_LOC]]: this is actually the wrong location due to PR14763, but that doesn't matter for the purposes of testing dwarfdump -CHECK-NEXT: Location description: 51 -CHECK-NEXT: {{^$}} -CHECK-NEXT: Beginning address offset: 0x0000000000000023 -CHECK-NEXT: Ending address offset: 0x000000000000005d -CHECK-NEXT: Location description: 75 70 -CHECK-NEXT: {{^$}} -CHECK-NEXT: [[G_LOC]]: Beginning address offset: 0x0000000000000000 -CHECK-NEXT: Ending address offset: 0x0000000000000020 -CHECK-NEXT: Location description: 50 -CHECK-NEXT: {{^$}} -CHECK-NEXT: Beginning address offset: 0x0000000000000020 -CHECK-NEXT: Ending address offset: 0x000000000000005d -CHECK-NEXT: Location description: 75 74 +CHECK-NEXT: 0x0000000000000000 - 0x0000000000000023: OP_reg1 ECX +CHECK-NEXT: 0x0000000000000023 - 0x000000000000005d: OP_breg5 EBP-16 +CHECK: [[G_LOC]]: +CHECK-NEXT: 0x0000000000000000 - 0x0000000000000020: OP_reg0 EAX +CHECK-NEXT: 0x0000000000000020 - 0x000000000000005d: OP_breg5 EBP-12 Index: llvm/test/tools/dsymutil/ARM/scattered.c =================================================================== --- llvm/test/tools/dsymutil/ARM/scattered.c +++ llvm/test/tools/dsymutil/ARM/scattered.c @@ -8,5 +8,5 @@ CHECK-NOT: DW_TAG CHECK: DW_AT_name{{.*}}"bar" CHECK-NOT: DW_TAG -CHECK: DW_AT_location{{.*}}<0x05> 03 10 00 01 00 +CHECK: DW_AT_location{{.*}}(OP_addr 0x10010) Index: llvm/test/tools/dsymutil/X86/basic-linking-x86.test =================================================================== --- llvm/test/tools/dsymutil/X86/basic-linking-x86.test +++ llvm/test/tools/dsymutil/X86/basic-linking-x86.test @@ -31,19 +31,19 @@ CHECK: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public) CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000ea0) CHECK: DW_AT_high_pc [DW_FORM_addr] (0x0000000100000ec4) -CHECK: DW_AT_frame_base [DW_FORM_block1] (<0x01> 56 ) +CHECK: DW_AT_frame_base [DW_FORM_block1] (OP_reg6 RBP) CHECK: DW_TAG_formal_parameter [3] CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000056] = "argc") CHECK: DW_AT_decl_file [DW_FORM_data1] ("/Inputs{{[/\\]}}basic1.c") CHECK: DW_AT_decl_line [DW_FORM_data1] (23) CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x0063 => {0x00000063}) -CHECK: DW_AT_location [DW_FORM_block1] (<0x02> 91 78 ) +CHECK: DW_AT_location [DW_FORM_block1] (OP_fbreg -8) CHECK: DW_TAG_formal_parameter [3] CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000005b] = "argv") CHECK: DW_AT_decl_file [DW_FORM_data1] ("/Inputs{{[/\\]}}basic1.c") CHECK: DW_AT_decl_line [DW_FORM_data1] (23) CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x006a => {0x0000006a}) -CHECK: DW_AT_location [DW_FORM_block1] (<0x02> 91 70 ) +CHECK: DW_AT_location [DW_FORM_block1] (OP_fbreg -16) CHECK: NULL CHECK: DW_TAG_base_type [4] CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000060] = "int") @@ -75,31 +75,31 @@ CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000072] = "private_int") CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x0026 => {0x000000a7}) CHECK: DW_AT_decl_file [DW_FORM_data1] ("/Inputs{{[/\\]}}basic2.c") -BASIC: DW_AT_location [DW_FORM_block1] (<0x09> 03 08 10 00 00 01 00 00 00 ) -ARCHIVE: DW_AT_location [DW_FORM_block1] (<0x09> 03 04 10 00 00 01 00 00 00 ) +BASIC: DW_AT_location [DW_FORM_block1] (OP_addr 0x100001008) +ARCHIVE: DW_AT_location [DW_FORM_block1] (OP_addr 0x100001004) CHECK: DW_TAG_variable [7] CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000007e] = "baz") CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x0026 => {0x000000a7}) CHECK: DW_AT_decl_file [DW_FORM_data1] ("/Inputs{{[/\\]}}basic2.c") -CHECK: DW_AT_location [DW_FORM_block1] (<0x09> 03 00 10 00 00 01 00 00 00 ) +CHECK: DW_AT_location [DW_FORM_block1] (OP_addr 0x100001000) CHECK: DW_TAG_subprogram [2] * CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000082] = "foo") CHECK: DW_AT_decl_file [DW_FORM_data1] ("/Inputs{{[/\\]}}basic2.c") CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x0026 => {0x000000a7}) CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000ed0) CHECK: DW_AT_high_pc [DW_FORM_addr] (0x0000000100000f19) -CHECK: DW_AT_frame_base [DW_FORM_block1] (<0x01> 56 ) +CHECK: DW_AT_frame_base [DW_FORM_block1] (OP_reg6 RBP) CHECK: DW_TAG_formal_parameter [3] CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000086] = "arg") CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x0026 => {0x000000a7}) -CHECK: DW_AT_location [DW_FORM_block1] (<0x02> 91 7c ) +CHECK: DW_AT_location [DW_FORM_block1] (OP_fbreg -4) CHECK: NULL CHECK: DW_TAG_subprogram [8] CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000008a] = "inc") CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x0026 => {0x000000a7}) CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000f20) CHECK: DW_AT_high_pc [DW_FORM_addr] (0x0000000100000f37) -CHECK: DW_AT_frame_base [DW_FORM_block1] (<0x01> 56 ) +CHECK: DW_AT_frame_base [DW_FORM_block1] (OP_reg6 RBP) CHECK: NULL CHECK: Compile Unit: @@ -114,8 +114,8 @@ CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000097] = "val") CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x003c => {0x00000162}) CHECK: DW_AT_decl_file [DW_FORM_data1] ("/Inputs{{[/\\]}}basic3.c") -BASIC: DW_AT_location [DW_FORM_block1] (<0x09> 03 04 10 00 00 01 00 00 00 ) -ARCHIVE: DW_AT_location [DW_FORM_block1] (<0x09> 03 08 10 00 00 01 00 00 00 ) +BASIC: DW_AT_location [DW_FORM_block1] (OP_addr 0x100001004) +ARCHIVE: DW_AT_location [DW_FORM_block1] (OP_addr 0x100001008) CHECK: DW_TAG_volatile_type [10] CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x0041 => {0x00000167}) CHECK: DW_TAG_base_type [4] @@ -125,18 +125,18 @@ CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x0041 => {0x00000167}) CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000f40) CHECK: DW_AT_high_pc [DW_FORM_addr] (0x0000000100000f84) -CHECK: DW_AT_frame_base [DW_FORM_block1] (<0x01> 56 ) +CHECK: DW_AT_frame_base [DW_FORM_block1] (OP_reg6 RBP) CHECK: DW_TAG_formal_parameter [3] CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000086] = "arg") CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x0041 => {0x00000167}) -CHECK: DW_AT_location [DW_FORM_block1] (<0x02> 91 78 ) +CHECK: DW_AT_location [DW_FORM_block1] (OP_fbreg -8) CHECK: NULL CHECK: DW_TAG_subprogram [8] CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000008a] = "inc") CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x0041 => {0x00000167}) CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000f90) CHECK: DW_AT_high_pc [DW_FORM_addr] (0x0000000100000fa9) -CHECK: DW_AT_frame_base [DW_FORM_block1] (<0x01> 56 ) +CHECK: DW_AT_frame_base [DW_FORM_block1] (OP_reg6 RBP) CHECK: NULL Index: llvm/test/tools/dsymutil/X86/basic-lto-dw4-linking-x86.test =================================================================== --- llvm/test/tools/dsymutil/X86/basic-lto-dw4-linking-x86.test +++ llvm/test/tools/dsymutil/X86/basic-lto-dw4-linking-x86.test @@ -16,19 +16,19 @@ CHECK: DW_TAG_subprogram [2] * CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000f40) CHECK: DW_AT_high_pc [DW_FORM_data4] (0x0000000b) -CHECK: DW_AT_frame_base [DW_FORM_exprloc] (<0x1> 56 ) +CHECK: DW_AT_frame_base [DW_FORM_exprloc] (OP_reg6 RBP) CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000027] = "main") CHECK: DW_AT_decl_file [DW_FORM_data1] ("/Inputs{{[/\\]}}basic1.c") CHECK: DW_AT_prototyped [DW_FORM_flag_present] (true) CHECK: DW_AT_type [DW_FORM_ref_addr] (0x00000000000000a1) CHECK: DW_AT_external [DW_FORM_flag_present] (true) CHECK: DW_TAG_formal_parameter [3] -CHECK: DW_AT_location [DW_FORM_exprloc] (<0x3> 55 93 04 ) +CHECK: DW_AT_location [DW_FORM_exprloc] (OP_reg5 RDI, OP_piece 0x4) CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000002c] = "argc") CHECK: DW_AT_decl_file [DW_FORM_data1] ("/Inputs{{[/\\]}}basic1.c") CHECK: DW_AT_type [DW_FORM_ref_addr] (0x00000000000000a1) CHECK: DW_TAG_formal_parameter [4] -CHECK: DW_AT_location [DW_FORM_exprloc] (<0x1> 54 ) +CHECK: DW_AT_location [DW_FORM_exprloc] (OP_reg4 RSI) CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000031] = "argv") CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x0060 => {0x00000060}) CHECK: NULL @@ -55,11 +55,11 @@ CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000044] = "int") CHECK: DW_TAG_variable [8] CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000048] = "baz") -CHECK: DW_AT_location [DW_FORM_exprloc] (<0x9> 03 00 10 00 00 01 00 00 00 ) +CHECK: DW_AT_location [DW_FORM_exprloc] (OP_addr 0x100001000) CHECK: DW_TAG_variable [8] CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000004c] = "private_int") CHECK: DW_AT_decl_file [DW_FORM_data1] ("/Inputs{{[/\\]}}basic2.c") -CHECK: DW_AT_location [DW_FORM_exprloc] (<0x9> 03 08 10 00 00 01 00 00 00 ) +CHECK: DW_AT_location [DW_FORM_exprloc] (OP_addr 0x100001008) CHECK: DW_TAG_subprogram [9] CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000058] = "inc") CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x002a => {0x000000a1}) @@ -67,13 +67,14 @@ CHECK: DW_TAG_subprogram [10] * CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000f50) CHECK: DW_AT_high_pc [DW_FORM_data4] (0x00000037) -CHECK: DW_AT_frame_base [DW_FORM_exprloc] (<0x1> 56 ) +CHECK: DW_AT_frame_base [DW_FORM_exprloc] (OP_reg6 RBP) CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000005c] = "foo") CHECK: DW_AT_decl_file [DW_FORM_data1] ("/Inputs{{[/\\]}}basic2.c") CHECK: DW_AT_prototyped [DW_FORM_flag_present] (true) CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x002a => {0x000000a1}) CHECK: DW_TAG_formal_parameter [11] -CHECK: DW_AT_location [DW_FORM_sec_offset] (0x00000000) +CHECK: DW_AT_location [DW_FORM_sec_offset] (0x00000000 +CHECK: 0x0000000100000f50 - 0x0000000100000f5c: OP_reg5 RDI, OP_piece 0x4) CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000060] = "arg") CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x002a => {0x000000a1}) CHECK: DW_TAG_inlined_subroutine [12] @@ -94,7 +95,7 @@ CHECK: DW_TAG_variable [13] CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000006d] = "val") CHECK: DW_AT_decl_file [DW_FORM_data1] ("/Inputs{{[/\\]}}basic3.c") -CHECK: DW_AT_location [DW_FORM_exprloc] (<0x9> 03 04 10 00 00 01 00 00 00 ) +CHECK: DW_AT_location [DW_FORM_exprloc] (OP_addr 0x100001004) CHECK: DW_TAG_volatile_type [14] CHECK: DW_TAG_subprogram [15] CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000058] = "inc") @@ -102,10 +103,12 @@ CHECK: DW_TAG_subprogram [2] * CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000f90) CHECK: DW_AT_high_pc [DW_FORM_data4] (0x00000024) -CHECK: DW_AT_frame_base [DW_FORM_exprloc] (<0x1> 56 ) +CHECK: DW_AT_frame_base [DW_FORM_exprloc] (OP_reg6 RBP) CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000071] = "bar") CHECK: DW_TAG_formal_parameter [16] -CHECK: DW_AT_location [DW_FORM_sec_offset] (0x00000025) +CHECK: DW_AT_location [DW_FORM_sec_offset] (0x00000025 +CHECK: 0x0000000100000f90 - 0x0000000100000f9f: OP_reg5 RDI, OP_piece 0x4 +CHECK: 0x0000000100000fa9 - 0x0000000100000fad: OP_reg5 RDI, OP_piece 0x4) CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000060] = "arg") CHECK: DW_TAG_inlined_subroutine [17] CHECK: DW_AT_abstract_origin [DW_FORM_ref4] (cu + 0x0044 => {0x0000015f} "inc") @@ -118,17 +121,13 @@ CHECK: .debug_loc contents: -CHECK-NEXT: 0x00000000: Beginning address offset: 0x0000000000000000 -CHECK-NEXT: Ending address offset: 0x000000000000000c -CHECK-NEXT: Location description: 55 93 04 -CHECK-NEXT: {{^$}} -CHECK-NEXT: 0x00000025: Beginning address offset: 0x0000000000000000 -CHECK-NEXT: Ending address offset: 0x000000000000000f -CHECK-NEXT: Location description: 55 93 04 -CHECK-NEXT: {{^$}} -CHECK-NEXT: Beginning address offset: 0x0000000000000019 -CHECK-NEXT: Ending address offset: 0x000000000000001d -CHECK-NEXT: Location description: 55 93 04 +CHECK-NEXT: 0x00000000: +CHECK-NEXT: 0x0000000100000f40 - 0x0000000100000f4c: OP_reg5 RDI, OP_piece 0x4 +CHECK-NOT: : +CHECK: 0x00000025: +CHECK-NEXT: 0x0000000100000f40 - 0x0000000100000f4f: OP_reg5 RDI, OP_piece 0x4 +CHECK-NEXT: 0x0000000100000f59 - 0x0000000100000f5d: OP_reg5 RDI, OP_piece 0x4 + CHECK: .debug_aranges contents: CHECK-NEXT: Address Range Header: length = 0x0000002c, version = 0x0002, cu_offset = 0x00000000, addr_size = 0x08, seg_size = 0x00 Index: llvm/test/tools/dsymutil/X86/basic-lto-linking-x86.test =================================================================== --- llvm/test/tools/dsymutil/X86/basic-lto-linking-x86.test +++ llvm/test/tools/dsymutil/X86/basic-lto-linking-x86.test @@ -24,15 +24,15 @@ CHECK: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public) CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000f40) CHECK: DW_AT_high_pc [DW_FORM_addr] (0x0000000100000f4b) -CHECK: DW_AT_frame_base [DW_FORM_block1] (<0x01> 56 ) +CHECK: DW_AT_frame_base [DW_FORM_block1] (OP_reg6 RBP) CHECK: DW_TAG_formal_parameter [3] CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000056] = "argc") CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x0063 => {0x00000063}) -CHECK: DW_AT_location [DW_FORM_block1] (<0x03> 55 93 04 ) +CHECK: DW_AT_location [DW_FORM_block1] (OP_reg5 RDI, OP_piece 0x4) CHECK: DW_TAG_formal_parameter [3] CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000005b] = "argv") CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x006a => {0x0000006a}) -CHECK: DW_AT_location [DW_FORM_block1] (<0x01> 54 ) +CHECK: DW_AT_location [DW_FORM_block1] (OP_reg4 RSI) CHECK: NULL CHECK: DW_TAG_base_type [4] CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000060] = "int") @@ -62,21 +62,22 @@ CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000072] = "private_int") CHECK: DW_AT_type [DW_FORM_ref_addr] (0x0000000000000063) CHECK: DW_AT_decl_file [DW_FORM_data1] ("/Inputs{{[/\\]}}basic2.c") -CHECK: DW_AT_location [DW_FORM_block1] (<0x09> 03 08 10 00 00 01 00 00 00 ) +CHECK: DW_AT_location [DW_FORM_block1] (OP_addr 0x100001008) CHECK: DW_TAG_variable [7] CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000007e] = "baz") CHECK: DW_AT_type [DW_FORM_ref_addr] (0x0000000000000063) -CHECK: DW_AT_location [DW_FORM_block1] (<0x09> 03 00 10 00 00 01 00 00 00 ) +CHECK: DW_AT_location [DW_FORM_block1] (OP_addr 0x100001000) CHECK: DW_TAG_subprogram [8] * CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000082] = "foo") CHECK: DW_AT_type [DW_FORM_ref_addr] (0x0000000000000063) CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000f50) CHECK: DW_AT_high_pc [DW_FORM_addr] (0x0000000100000f89) -CHECK: DW_AT_frame_base [DW_FORM_block1] (<0x01> 56 ) +CHECK: DW_AT_frame_base [DW_FORM_block1] (OP_reg6 RBP) CHECK: DW_TAG_formal_parameter [9] CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000086] = "arg") CHECK: DW_AT_type [DW_FORM_ref_addr] (0x0000000000000063) -CHECK: DW_AT_location [DW_FORM_data4] (0x00000000) +CHECK: DW_AT_location [DW_FORM_data4] (0x00000000 +CHECK: 0x0000000100000f50 - 0x0000000100000f5e: OP_reg5 RDI, OP_piece 0x4) CHECK: DW_TAG_inlined_subroutine [10] CHECK: DW_AT_abstract_origin [DW_FORM_ref4] (cu + 0x00a7 => {0x00000128} "inc") CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000f63) @@ -101,7 +102,7 @@ CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000097] = "val") CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x003c => {0x00000176}) CHECK: DW_AT_decl_file [DW_FORM_data1] ("/Inputs{{[/\\]}}basic3.c") -CHECK: DW_AT_location [DW_FORM_block1] (<0x09> 03 04 10 00 00 01 00 00 00 ) +CHECK: DW_AT_location [DW_FORM_block1] (OP_addr 0x100001004) CHECK: DW_TAG_volatile_type [13] CHECK: DW_AT_type [DW_FORM_ref_addr] (0x0000000000000063) CHECK: DW_TAG_subprogram [8] * @@ -109,11 +110,13 @@ CHECK: DW_AT_type [DW_FORM_ref_addr] (0x0000000000000063) CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000f90) CHECK: DW_AT_high_pc [DW_FORM_addr] (0x0000000100000fb4) -CHECK: DW_AT_frame_base [DW_FORM_block1] (<0x01> 56 ) +CHECK: DW_AT_frame_base [DW_FORM_block1] (OP_reg6 RBP) CHECK: DW_TAG_formal_parameter [9] CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000086] = "arg") CHECK: DW_AT_type [DW_FORM_ref_addr] (0x0000000000000063) -CHECK: DW_AT_location [DW_FORM_data4] (0x00000025) +CHECK: DW_AT_location [DW_FORM_data4] (0x00000025 +CHECK: 0x0000000100000f90 - 0x0000000100000f9f: OP_reg5 RDI, OP_piece 0x4 +CHECK: 0x0000000100000fa9 - 0x0000000100000fad: OP_reg5 RDI, OP_piece 0x4) CHECK: DW_TAG_lexical_block [14] * CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000f94) CHECK: DW_AT_high_pc [DW_FORM_addr] (0x0000000100000fa7) @@ -129,18 +132,13 @@ CHECK: DW_AT_type [DW_FORM_ref_addr] (0x0000000000000063) CHECK: NULL -CHECK:.debug_loc contents: -CHECK-NEXT: 0x00000000: Beginning address offset: 0x0000000000000000 -CHECK-NEXT: Ending address offset: 0x000000000000000e -CHECK-NEXT: Location description: 55 93 04 -CHECK-NEXT: {{^$}} -CHECK-NEXT: 0x00000025: Beginning address offset: 0x0000000000000000 -CHECK-NEXT: Ending address offset: 0x000000000000000f -CHECK-NEXT: Location description: 55 93 04 -CHECK-NEXT: {{^$}} -CHECK-NEXT: Beginning address offset: 0x0000000000000019 -CHECK-NEXT: Ending address offset: 0x000000000000001d -CHECK-NEXT: Location description: 55 93 04 +CHECK: .debug_loc contents: +CHECK-NEXT: 0x00000000: +CHECK-NEXT: 0x0000000100000f40 - 0x0000000100000f4e: OP_reg5 RDI, OP_piece 0x4 +CHECK-NOT: : +CHECK: 0x00000025: +CHECK-NEXT: 0x0000000100000f40 - 0x0000000100000f4f: OP_reg5 RDI, OP_piece 0x4 +CHECK-NEXT: 0x0000000100000f59 - 0x0000000100000f5d: OP_reg5 RDI, OP_piece 0x4 CHECK: .debug_aranges contents: CHECK-NEXT: Address Range Header: length = 0x0000002c, version = 0x0002, cu_offset = 0x00000000, addr_size = 0x08, seg_size = 0x00 Index: llvm/test/tools/dsymutil/X86/common-sym.test =================================================================== --- llvm/test/tools/dsymutil/X86/common-sym.test +++ llvm/test/tools/dsymutil/X86/common-sym.test @@ -11,7 +11,7 @@ CHECK: DW_TAG_variable CHECK: DW_AT_name {{.*}} "common" CHECK-NOT: {{NULL|DW_TAG}} -CHECK: DW_AT_location {{.*}} (<0x09> 03 00 10 00 00 01 00 00 00 ) +CHECK: DW_AT_location {{.*}} (OP_addr 0x100001000) CHECK: DW_TAG_subprogram CHECK-NEXT: DW_AT_low_pc{{.*}}(0x0000000100000f80) Index: llvm/tools/llvm-dwarfdump/CMakeLists.txt =================================================================== --- llvm/tools/llvm-dwarfdump/CMakeLists.txt +++ llvm/tools/llvm-dwarfdump/CMakeLists.txt @@ -1,5 +1,8 @@ set(LLVM_LINK_COMPONENTS DebugInfoDWARF + AllTargetsDescs + AllTargetsInfos + MC Object Support ) Index: llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp =================================================================== --- llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp +++ llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp @@ -26,6 +26,7 @@ #include "llvm/Support/Path.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Signals.h" +#include "llvm/Support/TargetSelect.h" #include "llvm/Support/raw_ostream.h" #include #include @@ -94,7 +95,9 @@ } static void DumpObjectFile(ObjectFile &Obj, Twine Filename) { - std::unique_ptr DICtx = DWARFContext::create(Obj); + std::unique_ptr DICtx = DWARFContext::create(Obj); + logAllUnhandledErrors(DICtx->loadRegisterInfo(Obj), errs(), + Filename.str() + ": "); outs() << Filename.str() << ":\tfile format " << Obj.getFileFormatName() << "\n\n"; @@ -209,6 +212,9 @@ PrettyStackTraceProgram X(argc, argv); llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. + llvm::InitializeAllTargetInfos(); + llvm::InitializeAllTargetMCs(); + cl::ParseCommandLineOptions(argc, argv, "llvm dwarf dumper\n"); // Defaults to a.out if no filenames specified.