diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-05-30 17:37:31 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-05-30 17:37:31 +0000 |
commit | ee2f195dd3e40f49698ca4dc2666ec09c770e80d (patch) | |
tree | 66fa9a69e5789356dfe844991e64bac9222f3a35 /include/llvm | |
parent | ab44ce3d598882e51a25eb82eb7ae6308de85ae6 (diff) |
Notes
Diffstat (limited to 'include/llvm')
24 files changed, 361 insertions, 213 deletions
diff --git a/include/llvm/Analysis/ScalarEvolution.h b/include/llvm/Analysis/ScalarEvolution.h index 4a6fc245c2254..1d715b590ab7d 100644 --- a/include/llvm/Analysis/ScalarEvolution.h +++ b/include/llvm/Analysis/ScalarEvolution.h @@ -1536,8 +1536,7 @@ public: /// Determine if the SCEV can be evaluated at loop's entry. It is true if it /// doesn't depend on a SCEVUnknown of an instruction which is dominated by /// the header of loop L. - bool isAvailableAtLoopEntry(const SCEV *S, const Loop *L, DominatorTree &DT, - LoopInfo &LI); + bool isAvailableAtLoopEntry(const SCEV *S, const Loop *L); /// Return true if the given SCEV changes value in a known way in the /// specified loop. This property being true implies that the value is diff --git a/include/llvm/CodeGen/DIE.h b/include/llvm/CodeGen/DIE.h index 4be44e62fa923..4f47ba6e38529 100644 --- a/include/llvm/CodeGen/DIE.h +++ b/include/llvm/CodeGen/DIE.h @@ -383,11 +383,11 @@ private: return; #define HANDLE_DIEVALUE_SMALL(T) \ case is##T: \ - destruct<DIE##T>(); + destruct<DIE##T>(); \ return; #define HANDLE_DIEVALUE_LARGE(T) \ case is##T: \ - destruct<const DIE##T *>(); + destruct<const DIE##T *>(); \ return; #include "llvm/CodeGen/DIEValue.def" } diff --git a/include/llvm/DebugInfo/CodeView/CodeView.h b/include/llvm/DebugInfo/CodeView/CodeView.h index f881ad0c9d805..3316e71916edb 100644 --- a/include/llvm/DebugInfo/CodeView/CodeView.h +++ b/include/llvm/DebugInfo/CodeView/CodeView.h @@ -13,6 +13,8 @@ #include <cinttypes> #include <type_traits> +#include "llvm/Support/Endian.h" + namespace llvm { namespace codeview { @@ -291,7 +293,7 @@ enum class ModifierOptions : uint16_t { }; CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ModifierOptions) -enum class ModuleDebugFragmentKind : uint32_t { +enum class DebugSubsectionKind : uint32_t { None = 0, Symbols = 0xf1, Lines = 0xf2, @@ -550,6 +552,24 @@ enum LineFlags : uint16_t { LF_None = 0, LF_HaveColumns = 1, // CV_LINES_HAVE_COLUMNS }; + +/// Data in the the SUBSEC_FRAMEDATA subection. +struct FrameData { + support::ulittle32_t RvaStart; + support::ulittle32_t CodeSize; + support::ulittle32_t LocalSize; + support::ulittle32_t ParamsSize; + support::ulittle32_t MaxStackSize; + support::ulittle32_t FrameFunc; + support::ulittle16_t PrologSize; + support::ulittle16_t SavedRegsSize; + support::ulittle32_t Flags; + enum : uint32_t { + HasSEH = 1 << 0, + HasEH = 1 << 1, + IsFunctionStart = 1 << 2, + }; +}; } } diff --git a/include/llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h b/include/llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h index 6c08c9aa21370..e7036033d2d97 100644 --- a/include/llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h +++ b/include/llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h @@ -1,4 +1,4 @@ -//===- ModuleDebugFileChecksumFragment.h ------------------------*- C++ -*-===// +//===- DebugChecksumsSubsection.h -------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,12 +7,12 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFILECHECKSUMFRAGMENT_H -#define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFILECHECKSUMFRAGMENT_H +#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGCHECKSUMSSUBSECTION_H +#define LLVM_DEBUGINFO_CODEVIEW_DEBUGCHECKSUMSSUBSECTION_H #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" -#include "llvm/DebugInfo/CodeView/ModuleDebugFragment.h" +#include "llvm/DebugInfo/CodeView/DebugSubsection.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/BinaryStreamArray.h" #include "llvm/Support/BinaryStreamReader.h" @@ -21,7 +21,7 @@ namespace llvm { namespace codeview { -class StringTable; +class DebugStringTableSubsection; struct FileChecksumEntry { uint32_t FileNameOffset; // Byte offset of filename in global stringtable. @@ -43,19 +43,22 @@ public: namespace llvm { namespace codeview { -class ModuleDebugFileChecksumFragmentRef final : public ModuleDebugFragmentRef { +class DebugChecksumsSubsectionRef final : public DebugSubsectionRef { typedef VarStreamArray<codeview::FileChecksumEntry> FileChecksumArray; typedef FileChecksumArray::Iterator Iterator; public: - ModuleDebugFileChecksumFragmentRef() - : ModuleDebugFragmentRef(ModuleDebugFragmentKind::FileChecksums) {} + DebugChecksumsSubsectionRef() + : DebugSubsectionRef(DebugSubsectionKind::FileChecksums) {} - static bool classof(const ModuleDebugFragmentRef *S) { - return S->kind() == ModuleDebugFragmentKind::FileChecksums; + static bool classof(const DebugSubsectionRef *S) { + return S->kind() == DebugSubsectionKind::FileChecksums; } + bool valid() const { return Checksums.valid(); } + Error initialize(BinaryStreamReader Reader); + Error initialize(BinaryStreamRef Stream); Iterator begin() { return Checksums.begin(); } Iterator end() { return Checksums.end(); } @@ -66,23 +69,23 @@ private: FileChecksumArray Checksums; }; -class ModuleDebugFileChecksumFragment final : public ModuleDebugFragment { +class DebugChecksumsSubsection final : public DebugSubsection { public: - explicit ModuleDebugFileChecksumFragment(StringTable &Strings); + explicit DebugChecksumsSubsection(DebugStringTableSubsection &Strings); - static bool classof(const ModuleDebugFragment *S) { - return S->kind() == ModuleDebugFragmentKind::FileChecksums; + static bool classof(const DebugSubsection *S) { + return S->kind() == DebugSubsectionKind::FileChecksums; } void addChecksum(StringRef FileName, FileChecksumKind Kind, ArrayRef<uint8_t> Bytes); - uint32_t calculateSerializedLength() override; - Error commit(BinaryStreamWriter &Writer) override; + uint32_t calculateSerializedSize() const override; + Error commit(BinaryStreamWriter &Writer) const override; uint32_t mapChecksumOffset(StringRef FileName) const; private: - StringTable &Strings; + DebugStringTableSubsection &Strings; DenseMap<uint32_t, uint32_t> OffsetMap; uint32_t SerializedSize = 0; diff --git a/include/llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h b/include/llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h new file mode 100644 index 0000000000000..686b5c4f242e3 --- /dev/null +++ b/include/llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h @@ -0,0 +1,59 @@ +//===- DebugFrameDataSubsection.h ------------------------------*- 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_CODEVIEW_DEBUGFRAMEDATASUBSECTION_H +#define LLVM_DEBUGINFO_CODEVIEW_DEBUGFRAMEDATASUBSECTION_H + +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/DebugSubsection.h" +#include "llvm/Support/BinaryStreamReader.h" +#include "llvm/Support/Error.h" + +namespace llvm { +namespace codeview { +class DebugFrameDataSubsectionRef final : public DebugSubsectionRef { +public: + DebugFrameDataSubsectionRef() + : DebugSubsectionRef(DebugSubsectionKind::FrameData) {} + static bool classof(const DebugSubsection *S) { + return S->kind() == DebugSubsectionKind::FrameData; + } + + Error initialize(BinaryStreamReader Reader); + + FixedStreamArray<FrameData>::Iterator begin() const { return Frames.begin(); } + FixedStreamArray<FrameData>::Iterator end() const { return Frames.end(); } + + const void *getRelocPtr() const { return RelocPtr; } + +private: + const uint32_t *RelocPtr = nullptr; + FixedStreamArray<FrameData> Frames; +}; + +class DebugFrameDataSubsection final : public DebugSubsection { +public: + DebugFrameDataSubsection() + : DebugSubsection(DebugSubsectionKind::FrameData) {} + static bool classof(const DebugSubsection *S) { + return S->kind() == DebugSubsectionKind::FrameData; + } + + uint32_t calculateSerializedSize() const override; + Error commit(BinaryStreamWriter &Writer) const override; + + void addFrameData(const FrameData &Frame); + +private: + std::vector<FrameData> Frames; +}; +} +} + +#endif diff --git a/include/llvm/DebugInfo/CodeView/ModuleDebugInlineeLinesFragment.h b/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h index 348497cbf7f2a..e2cfc3c992337 100644 --- a/include/llvm/DebugInfo/CodeView/ModuleDebugInlineeLinesFragment.h +++ b/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h @@ -1,4 +1,4 @@ -//===- ModuleDebugInlineeLinesFragment.h ------------------------*- C++ -*-===// +//===- DebugInlineeLinesSubsection.h ----------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,11 +7,11 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGINLINEELINESFRAGMENT_H -#define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGINLINEELINESFRAGMENT_H +#ifndef LLVM_DEBUGINFO_CODEVIEW_BUGINLINEELINESSUBSECTION_H +#define LLVM_DEBUGINFO_CODEVIEW_BUGINLINEELINESSUBSECTION_H +#include "llvm/DebugInfo/CodeView/DebugSubsection.h" #include "llvm/DebugInfo/CodeView/Line.h" -#include "llvm/DebugInfo/CodeView/ModuleDebugFragment.h" #include "llvm/Support/BinaryStreamArray.h" #include "llvm/Support/BinaryStreamReader.h" #include "llvm/Support/Error.h" @@ -19,9 +19,8 @@ namespace llvm { namespace codeview { -class ModuleDebugInlineeLineFragmentRef; -class ModuleDebugFileChecksumFragment; -class StringTable; +class DebugInlineeLinesSubsectionsRef; +class DebugChecksumsSubsection; enum class InlineeLinesSignature : uint32_t { Normal, // CV_INLINEE_SOURCE_LINE_SIGNATURE @@ -51,15 +50,15 @@ template <> struct VarStreamArrayExtractor<codeview::InlineeSourceLine> { }; namespace codeview { -class ModuleDebugInlineeLineFragmentRef final : public ModuleDebugFragmentRef { +class DebugInlineeLinesSubsectionRef final : public DebugSubsectionRef { typedef VarStreamArray<InlineeSourceLine> LinesArray; typedef LinesArray::Iterator Iterator; public: - ModuleDebugInlineeLineFragmentRef(); + DebugInlineeLinesSubsectionRef(); - static bool classof(const ModuleDebugFragmentRef *S) { - return S->kind() == ModuleDebugFragmentKind::InlineeLines; + static bool classof(const DebugSubsectionRef *S) { + return S->kind() == DebugSubsectionKind::InlineeLines; } Error initialize(BinaryStreamReader Reader); @@ -73,23 +72,23 @@ private: VarStreamArray<InlineeSourceLine> Lines; }; -class ModuleDebugInlineeLineFragment final : public ModuleDebugFragment { +class DebugInlineeLinesSubsection final : public DebugSubsection { public: - ModuleDebugInlineeLineFragment(ModuleDebugFileChecksumFragment &Checksums, - bool HasExtraFiles); + DebugInlineeLinesSubsection(DebugChecksumsSubsection &Checksums, + bool HasExtraFiles); - static bool classof(const ModuleDebugFragment *S) { - return S->kind() == ModuleDebugFragmentKind::InlineeLines; + static bool classof(const DebugSubsection *S) { + return S->kind() == DebugSubsectionKind::InlineeLines; } - Error commit(BinaryStreamWriter &Writer) override; - uint32_t calculateSerializedLength() override; + Error commit(BinaryStreamWriter &Writer) const override; + uint32_t calculateSerializedSize() const override; void addInlineSite(TypeIndex FuncId, StringRef FileName, uint32_t SourceLine); void addExtraFile(StringRef FileName); private: - ModuleDebugFileChecksumFragment &Checksums; + DebugChecksumsSubsection &Checksums; bool HasExtraFiles = false; uint32_t ExtraFileCount = 0; diff --git a/include/llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h b/include/llvm/DebugInfo/CodeView/DebugLinesSubsection.h index 3124236b8fb1b..1b63af59c2ed6 100644 --- a/include/llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h +++ b/include/llvm/DebugInfo/CodeView/DebugLinesSubsection.h @@ -1,4 +1,4 @@ -//===- ModuleDebugLineFragment.h --------------------------------*- C++ -*-===// +//===- DebugLinesSubsection.h --------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -10,8 +10,8 @@ #ifndef LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGLINEFRAGMENT_H #define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGLINEFRAGMENT_H +#include "llvm/DebugInfo/CodeView/DebugSubsection.h" #include "llvm/DebugInfo/CodeView/Line.h" -#include "llvm/DebugInfo/CodeView/ModuleDebugFragment.h" #include "llvm/Support/BinaryStreamArray.h" #include "llvm/Support/BinaryStreamReader.h" #include "llvm/Support/Error.h" @@ -19,8 +19,8 @@ namespace llvm { namespace codeview { -class ModuleDebugFileChecksumFragment; -class StringTable; +class DebugChecksumsSubsection; +class DebugStringTableSubsection; // Corresponds to the `CV_DebugSLinesHeader_t` structure. struct LineFragmentHeader { @@ -70,16 +70,16 @@ public: LineColumnEntry &Item, const LineFragmentHeader *Ctx); }; -class ModuleDebugLineFragmentRef final : public ModuleDebugFragmentRef { +class DebugLinesSubsectionRef final : public DebugSubsectionRef { friend class LineColumnExtractor; typedef VarStreamArray<LineColumnEntry, LineColumnExtractor> LineInfoArray; typedef LineInfoArray::Iterator Iterator; public: - ModuleDebugLineFragmentRef(); + DebugLinesSubsectionRef(); - static bool classof(const ModuleDebugFragmentRef *S) { - return S->kind() == ModuleDebugFragmentKind::Lines; + static bool classof(const DebugSubsectionRef *S) { + return S->kind() == DebugSubsectionKind::Lines; } Error initialize(BinaryStreamReader Reader); @@ -96,7 +96,7 @@ private: LineInfoArray LinesAndColumns; }; -class ModuleDebugLineFragment final : public ModuleDebugFragment { +class DebugLinesSubsection final : public DebugSubsection { struct Block { Block(uint32_t ChecksumBufferOffset) : ChecksumBufferOffset(ChecksumBufferOffset) {} @@ -107,11 +107,11 @@ class ModuleDebugLineFragment final : public ModuleDebugFragment { }; public: - ModuleDebugLineFragment(ModuleDebugFileChecksumFragment &Checksums, - StringTable &Strings); + DebugLinesSubsection(DebugChecksumsSubsection &Checksums, + DebugStringTableSubsection &Strings); - static bool classof(const ModuleDebugFragment *S) { - return S->kind() == ModuleDebugFragmentKind::Lines; + static bool classof(const DebugSubsection *S) { + return S->kind() == DebugSubsectionKind::Lines; } void createBlock(StringRef FileName); @@ -119,8 +119,8 @@ public: void addLineAndColumnInfo(uint32_t Offset, const LineInfo &Line, uint32_t ColStart, uint32_t ColEnd); - uint32_t calculateSerializedLength() override; - Error commit(BinaryStreamWriter &Writer) override; + uint32_t calculateSerializedSize() const override; + Error commit(BinaryStreamWriter &Writer) const override; void setRelocationAddress(uint16_t Segment, uint16_t Offset); void setCodeSize(uint32_t Size); @@ -129,7 +129,7 @@ public: bool hasColumnInfo() const; private: - ModuleDebugFileChecksumFragment &Checksums; + DebugChecksumsSubsection &Checksums; uint16_t RelocOffset = 0; uint16_t RelocSegment = 0; diff --git a/include/llvm/DebugInfo/CodeView/StringTable.h b/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h index 05dc02ee849f3..fbe39cb16f090 100644 --- a/include/llvm/DebugInfo/CodeView/StringTable.h +++ b/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h @@ -1,4 +1,4 @@ -//===- StringTable.h - CodeView String Table Reader/Writer ------*- C++ -*-===// +//===- DebugStringTableSubsection.h - CodeView String Table -----*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,12 +7,12 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DEBUGINFO_CODEVIEW_STRINGTABLE_H -#define LLVM_DEBUGINFO_CODEVIEW_STRINGTABLE_H +#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGSTRINGTABLESUBSECTION_H +#define LLVM_DEBUGINFO_CODEVIEW_DEBUGSTRINGTABLESUBSECTION_H #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" - +#include "llvm/DebugInfo/CodeView/DebugSubsection.h" #include "llvm/Support/BinaryStreamRef.h" #include "llvm/Support/Error.h" @@ -28,11 +28,15 @@ namespace codeview { /// Represents a read-only view of a CodeView string table. This is a very /// simple flat buffer consisting of null-terminated strings, where strings -/// are retrieved by their offset in the buffer. StringTableRef does not own -/// the underlying storage for the buffer. -class StringTableRef { +/// are retrieved by their offset in the buffer. DebugStringTableSubsectionRef +/// does not own the underlying storage for the buffer. +class DebugStringTableSubsectionRef : public DebugSubsectionRef { public: - StringTableRef(); + DebugStringTableSubsectionRef(); + + static bool classof(const DebugSubsectionRef *S) { + return S->kind() == DebugSubsectionKind::StringTable; + } Error initialize(BinaryStreamRef Contents); @@ -44,11 +48,18 @@ private: BinaryStreamRef Stream; }; -/// Represents a read-write view of a CodeView string table. StringTable owns -/// the underlying storage for the table, and is capable of serializing the -/// string table into a format understood by StringTableRef. -class StringTable { +/// Represents a read-write view of a CodeView string table. +/// DebugStringTableSubsection owns the underlying storage for the table, and is +/// capable of serializing the string table into a format understood by +/// DebugStringTableSubsectionRef. +class DebugStringTableSubsection : public DebugSubsection { public: + DebugStringTableSubsection(); + + static bool classof(const DebugSubsection *S) { + return S->kind() == DebugSubsectionKind::StringTable; + } + // If string S does not exist in the string table, insert it. // Returns the ID for S. uint32_t insert(StringRef S); @@ -56,8 +67,8 @@ public: // Return the ID for string S. Assumes S exists in the table. uint32_t getStringId(StringRef S) const; - uint32_t calculateSerializedSize() const; - Error commit(BinaryStreamWriter &Writer) const; + uint32_t calculateSerializedSize() const override; + Error commit(BinaryStreamWriter &Writer) const override; uint32_t size() const; diff --git a/include/llvm/DebugInfo/CodeView/DebugSubsection.h b/include/llvm/DebugInfo/CodeView/DebugSubsection.h new file mode 100644 index 0000000000000..e427e0006a55b --- /dev/null +++ b/include/llvm/DebugInfo/CodeView/DebugSubsection.h @@ -0,0 +1,52 @@ +//===- DebugSubsection.h ------------------------------------*- 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_CODEVIEW_MODULEDEBUGFRAGMENT_H +#define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENT_H + +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/Support/BinaryStreamWriter.h" +#include "llvm/Support/Casting.h" + +namespace llvm { +namespace codeview { + +class DebugSubsectionRef { +public: + explicit DebugSubsectionRef(DebugSubsectionKind Kind) : Kind(Kind) {} + virtual ~DebugSubsectionRef(); + + static bool classof(const DebugSubsectionRef *S) { return true; } + + DebugSubsectionKind kind() const { return Kind; } + +protected: + DebugSubsectionKind Kind; +}; + +class DebugSubsection { +public: + explicit DebugSubsection(DebugSubsectionKind Kind) : Kind(Kind) {} + virtual ~DebugSubsection(); + + static bool classof(const DebugSubsection *S) { return true; } + + DebugSubsectionKind kind() const { return Kind; } + + virtual Error commit(BinaryStreamWriter &Writer) const = 0; + virtual uint32_t calculateSerializedSize() const = 0; + +protected: + DebugSubsectionKind Kind; +}; + +} // namespace codeview +} // namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENT_H diff --git a/include/llvm/DebugInfo/CodeView/ModuleDebugFragmentRecord.h b/include/llvm/DebugInfo/CodeView/DebugSubsectionRecord.h index f68f21b224f19..b2e1131e5968b 100644 --- a/include/llvm/DebugInfo/CodeView/ModuleDebugFragmentRecord.h +++ b/include/llvm/DebugInfo/CodeView/DebugSubsectionRecord.h @@ -1,4 +1,4 @@ -//===- ModuleDebugFragment.h ------------------------------------*- C++ -*-===// +//===- DebugSubsection.h ------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -20,52 +20,49 @@ namespace llvm { namespace codeview { -class ModuleDebugFragment; +class DebugSubsection; // Corresponds to the `CV_DebugSSubsectionHeader_t` structure. -struct ModuleDebugFragmentHeader { - support::ulittle32_t Kind; // codeview::ModuleDebugFragmentKind enum +struct DebugSubsectionHeader { + support::ulittle32_t Kind; // codeview::DebugSubsectionKind enum support::ulittle32_t Length; // number of bytes occupied by this record. }; -class ModuleDebugFragmentRecord { +class DebugSubsectionRecord { public: - ModuleDebugFragmentRecord(); - ModuleDebugFragmentRecord(ModuleDebugFragmentKind Kind, BinaryStreamRef Data); + DebugSubsectionRecord(); + DebugSubsectionRecord(DebugSubsectionKind Kind, BinaryStreamRef Data); - static Error initialize(BinaryStreamRef Stream, - ModuleDebugFragmentRecord &Info); + static Error initialize(BinaryStreamRef Stream, DebugSubsectionRecord &Info); uint32_t getRecordLength() const; - ModuleDebugFragmentKind kind() const; + DebugSubsectionKind kind() const; BinaryStreamRef getRecordData() const; private: - ModuleDebugFragmentKind Kind; + DebugSubsectionKind Kind; BinaryStreamRef Data; }; -class ModuleDebugFragmentRecordBuilder { +class DebugSubsectionRecordBuilder { public: - ModuleDebugFragmentRecordBuilder(ModuleDebugFragmentKind Kind, - ModuleDebugFragment &Frag); + DebugSubsectionRecordBuilder(DebugSubsectionKind Kind, DebugSubsection &Frag); uint32_t calculateSerializedLength(); Error commit(BinaryStreamWriter &Writer); private: - ModuleDebugFragmentKind Kind; - ModuleDebugFragment &Frag; + DebugSubsectionKind Kind; + DebugSubsection &Frag; }; } // namespace codeview -template <> -struct VarStreamArrayExtractor<codeview::ModuleDebugFragmentRecord> { +template <> struct VarStreamArrayExtractor<codeview::DebugSubsectionRecord> { typedef void ContextType; static Error extract(BinaryStreamRef Stream, uint32_t &Length, - codeview::ModuleDebugFragmentRecord &Info) { - if (auto EC = codeview::ModuleDebugFragmentRecord::initialize(Stream, Info)) + codeview::DebugSubsectionRecord &Info) { + if (auto EC = codeview::DebugSubsectionRecord::initialize(Stream, Info)) return EC; Length = Info.getRecordLength(); return Error::success(); @@ -73,7 +70,7 @@ struct VarStreamArrayExtractor<codeview::ModuleDebugFragmentRecord> { }; namespace codeview { -typedef VarStreamArray<ModuleDebugFragmentRecord> ModuleDebugFragmentArray; +typedef VarStreamArray<DebugSubsectionRecord> DebugSubsectionArray; } } // namespace llvm diff --git a/include/llvm/DebugInfo/CodeView/ModuleDebugFragmentVisitor.h b/include/llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h index 1f55d2024203a..55bef491c97ed 100644 --- a/include/llvm/DebugInfo/CodeView/ModuleDebugFragmentVisitor.h +++ b/include/llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h @@ -1,4 +1,4 @@ -//===- ModuleDebugFragmentVisitor.h -----------------------------*- C++ -*-===// +//===- DebugSubsectionVisitor.h -----------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -17,43 +17,41 @@ namespace llvm { namespace codeview { -class ModuleDebugFileChecksumFragmentRef; -class ModuleDebugFragmentRecord; -class ModuleDebugInlineeLineFragmentRef; -class ModuleDebugLineFragmentRef; -class ModuleDebugUnknownFragmentRef; +class DebugChecksumsSubsectionRef; +class DebugSubsectionRecord; +class DebugInlineeLinesSubsectionRef; +class DebugLinesSubsectionRef; +class DebugUnknownSubsectionRef; -class ModuleDebugFragmentVisitor { +class DebugSubsectionVisitor { public: - virtual ~ModuleDebugFragmentVisitor() = default; + virtual ~DebugSubsectionVisitor() = default; - virtual Error visitUnknown(ModuleDebugUnknownFragmentRef &Unknown) { + virtual Error visitUnknown(DebugUnknownSubsectionRef &Unknown) { return Error::success(); } - virtual Error visitLines(ModuleDebugLineFragmentRef &Lines) { + virtual Error visitLines(DebugLinesSubsectionRef &Lines) { return Error::success(); } - virtual Error - visitFileChecksums(ModuleDebugFileChecksumFragmentRef &Checksums) { + virtual Error visitFileChecksums(DebugChecksumsSubsectionRef &Checksums) { return Error::success(); } - virtual Error visitInlineeLines(ModuleDebugInlineeLineFragmentRef &Inlinees) { + virtual Error visitInlineeLines(DebugInlineeLinesSubsectionRef &Inlinees) { return Error::success(); } virtual Error finished() { return Error::success(); } }; -Error visitModuleDebugFragment(const ModuleDebugFragmentRecord &R, - ModuleDebugFragmentVisitor &V); +Error visitDebugSubsection(const DebugSubsectionRecord &R, + DebugSubsectionVisitor &V); template <typename T> -Error visitModuleDebugFragments(T &&FragmentRange, - ModuleDebugFragmentVisitor &V) { +Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V) { for (const auto &L : FragmentRange) { - if (auto EC = visitModuleDebugFragment(L, V)) + if (auto EC = visitDebugSubsection(L, V)) return EC; } if (auto EC = V.finished()) diff --git a/include/llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h b/include/llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h new file mode 100644 index 0000000000000..3d1eb27ba270c --- /dev/null +++ b/include/llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h @@ -0,0 +1,53 @@ +//===- DebugSymbolsSubsection.h --------------------------------*- 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_CODEVIEW_DEBUGSYMBOLSSUBSECTION_H +#define LLVM_DEBUGINFO_CODEVIEW_DEBUGSYMBOLSSUBSECTION_H + +#include "llvm/DebugInfo/CodeView/DebugSubsection.h" +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/Support/Error.h" + +namespace llvm { +namespace codeview { +class DebugSymbolsSubsectionRef final : public DebugSubsectionRef { +public: + DebugSymbolsSubsectionRef() + : DebugSubsectionRef(DebugSubsectionKind::Symbols) {} + + static bool classof(const DebugSubsectionRef *S) { + return S->kind() == DebugSubsectionKind::Symbols; + } + + Error initialize(BinaryStreamReader Reader); + +private: + CVSymbolArray Records; +}; + +class DebugSymbolsSubsection final : public DebugSubsection { +public: + DebugSymbolsSubsection() : DebugSubsection(DebugSubsectionKind::Symbols) {} + static bool classof(const DebugSubsection *S) { + return S->kind() == DebugSubsectionKind::Symbols; + } + + uint32_t calculateSerializedSize() const override; + Error commit(BinaryStreamWriter &Writer) const override; + + void addSymbol(CVSymbol Symbol); + +private: + uint32_t Length = 0; + std::vector<CVSymbol> Records; +}; +} +} + +#endif diff --git a/include/llvm/DebugInfo/CodeView/ModuleDebugUnknownFragment.h b/include/llvm/DebugInfo/CodeView/DebugUnknownSubsection.h index b8c1c02e5cf15..ea9a96ca8d68e 100644 --- a/include/llvm/DebugInfo/CodeView/ModuleDebugUnknownFragment.h +++ b/include/llvm/DebugInfo/CodeView/DebugUnknownSubsection.h @@ -1,4 +1,4 @@ -//===- ModuleDebugUnknownFragment.h -----------------------------*- C++ -*-===// +//===- DebugUnknownSubsection.h -----------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -10,17 +10,16 @@ #ifndef LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGUNKNOWNFRAGMENT_H #define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGUNKNOWNFRAGMENT_H -#include "llvm/DebugInfo/CodeView/ModuleDebugFragment.h" +#include "llvm/DebugInfo/CodeView/DebugSubsection.h" #include "llvm/Support/BinaryStreamRef.h" namespace llvm { namespace codeview { -class ModuleDebugUnknownFragmentRef final : public ModuleDebugFragmentRef { +class DebugUnknownSubsectionRef final : public DebugSubsectionRef { public: - ModuleDebugUnknownFragmentRef(ModuleDebugFragmentKind Kind, - BinaryStreamRef Data) - : ModuleDebugFragmentRef(Kind), Data(Data) {} + DebugUnknownSubsectionRef(DebugSubsectionKind Kind, BinaryStreamRef Data) + : DebugSubsectionRef(Kind), Data(Data) {} BinaryStreamRef getData() const { return Data; } diff --git a/include/llvm/DebugInfo/CodeView/ModuleDebugFragment.h b/include/llvm/DebugInfo/CodeView/ModuleDebugFragment.h deleted file mode 100644 index a5311cae9480a..0000000000000 --- a/include/llvm/DebugInfo/CodeView/ModuleDebugFragment.h +++ /dev/null @@ -1,48 +0,0 @@ -//===- ModuleDebugFragment.h ------------------------------------*- 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_CODEVIEW_MODULEDEBUGFRAGMENT_H -#define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENT_H - -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/Support/BinaryStreamWriter.h" -#include "llvm/Support/Casting.h" - -namespace llvm { -namespace codeview { - -class ModuleDebugFragmentRef { -public: - explicit ModuleDebugFragmentRef(ModuleDebugFragmentKind Kind) : Kind(Kind) {} - virtual ~ModuleDebugFragmentRef(); - - ModuleDebugFragmentKind kind() const { return Kind; } - -protected: - ModuleDebugFragmentKind Kind; -}; - -class ModuleDebugFragment { -public: - explicit ModuleDebugFragment(ModuleDebugFragmentKind Kind) : Kind(Kind) {} - virtual ~ModuleDebugFragment(); - - ModuleDebugFragmentKind kind() const { return Kind; } - - virtual Error commit(BinaryStreamWriter &Writer) = 0; - virtual uint32_t calculateSerializedLength() = 0; - -protected: - ModuleDebugFragmentKind Kind; -}; - -} // namespace codeview -} // namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENT_H diff --git a/include/llvm/DebugInfo/CodeView/SymbolVisitorDelegate.h b/include/llvm/DebugInfo/CodeView/SymbolVisitorDelegate.h index 96c8a47a36690..a2a3c6f18fba1 100644 --- a/include/llvm/DebugInfo/CodeView/SymbolVisitorDelegate.h +++ b/include/llvm/DebugInfo/CodeView/SymbolVisitorDelegate.h @@ -19,7 +19,7 @@ class BinaryStreamReader; namespace codeview { -class StringTableRef; +class DebugStringTableSubsectionRef; class SymbolVisitorDelegate { public: @@ -27,7 +27,7 @@ public: virtual uint32_t getRecordOffset(BinaryStreamReader Reader) = 0; virtual StringRef getFileNameForFileOffset(uint32_t FileOffset) = 0; - virtual StringTableRef getStringTable() = 0; + virtual DebugStringTableSubsectionRef getStringTable() = 0; }; } // end namespace codeview diff --git a/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h b/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h index 8cc5db981f565..e5858d0f45e3b 100644 --- a/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h +++ b/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h @@ -11,9 +11,9 @@ #define LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTORBUILDER_H #include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h" -#include "llvm/DebugInfo/CodeView/ModuleDebugInlineeLinesFragment.h" -#include "llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h" +#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h" +#include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h" +#include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h" #include "llvm/DebugInfo/CodeView/SymbolRecord.h" #include "llvm/DebugInfo/PDB/Native/RawTypes.h" #include "llvm/Support/Error.h" @@ -25,7 +25,7 @@ namespace llvm { class BinaryStreamWriter; namespace codeview { -class ModuleDebugFragmentRecordBuilder; +class DebugSubsectionRecordBuilder; } namespace msf { @@ -49,11 +49,11 @@ public: void setObjFileName(StringRef Name); void addSymbol(codeview::CVSymbol Symbol); - void addC13Fragment(std::unique_ptr<codeview::ModuleDebugLineFragment> Lines); + void addC13Fragment(std::unique_ptr<codeview::DebugLinesSubsection> Lines); void addC13Fragment( - std::unique_ptr<codeview::ModuleDebugInlineeLineFragment> Inlinees); + std::unique_ptr<codeview::DebugInlineeLinesSubsection> Inlinees); void setC13FileChecksums( - std::unique_ptr<codeview::ModuleDebugFileChecksumFragment> Checksums); + std::unique_ptr<codeview::DebugChecksumsSubsection> Checksums); uint16_t getStreamIndex() const; StringRef getModuleName() const { return ModuleName; } @@ -83,12 +83,11 @@ private: std::vector<std::string> SourceFiles; std::vector<codeview::CVSymbol> Symbols; - std::unique_ptr<codeview::ModuleDebugFileChecksumFragment> ChecksumInfo; - std::vector<std::unique_ptr<codeview::ModuleDebugLineFragment>> LineInfo; - std::vector<std::unique_ptr<codeview::ModuleDebugInlineeLineFragment>> - Inlinees; + std::unique_ptr<codeview::DebugChecksumsSubsection> ChecksumInfo; + std::vector<std::unique_ptr<codeview::DebugLinesSubsection>> LineInfo; + std::vector<std::unique_ptr<codeview::DebugInlineeLinesSubsection>> Inlinees; - std::vector<std::unique_ptr<codeview::ModuleDebugFragmentRecordBuilder>> + std::vector<std::unique_ptr<codeview::DebugSubsectionRecordBuilder>> C13Builders; ModuleInfoHeader Layout; diff --git a/include/llvm/DebugInfo/PDB/Native/DbiStream.h b/include/llvm/DebugInfo/PDB/Native/DbiStream.h index 8f95481f41521..dc35f8c72cd91 100644 --- a/include/llvm/DebugInfo/PDB/Native/DbiStream.h +++ b/include/llvm/DebugInfo/PDB/Native/DbiStream.h @@ -10,7 +10,7 @@ #ifndef LLVM_DEBUGINFO_PDB_RAW_PDBDBISTREAM_H #define LLVM_DEBUGINFO_PDB_RAW_PDBDBISTREAM_H -#include "llvm/DebugInfo/CodeView/ModuleDebugFragment.h" +#include "llvm/DebugInfo/CodeView/DebugSubsection.h" #include "llvm/DebugInfo/MSF/MappedBlockStream.h" #include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h" #include "llvm/DebugInfo/PDB/Native/DbiModuleList.h" @@ -19,8 +19,6 @@ #include "llvm/DebugInfo/PDB/Native/RawTypes.h" #include "llvm/DebugInfo/PDB/PDBTypes.h" #include "llvm/Support/BinaryStreamArray.h" -#include "llvm/Support/BinaryStreamArray.h" -#include "llvm/Support/BinaryStreamRef.h" #include "llvm/Support/BinaryStreamRef.h" #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" diff --git a/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h b/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h index 2c95690ed5806..822ce3ce13d3a 100644 --- a/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h +++ b/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h @@ -12,7 +12,7 @@ #include "llvm/ADT/iterator_range.h" #include "llvm/DebugInfo/CodeView/CVRecord.h" -#include "llvm/DebugInfo/CodeView/ModuleDebugFragmentRecord.h" +#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h" #include "llvm/DebugInfo/CodeView/SymbolRecord.h" #include "llvm/DebugInfo/MSF/MappedBlockStream.h" #include "llvm/Support/BinaryStreamArray.h" @@ -25,8 +25,7 @@ class PDBFile; class DbiModuleDescriptor; class ModuleDebugStreamRef { - typedef codeview::ModuleDebugFragmentArray::Iterator - LinesAndChecksumsIterator; + typedef codeview::DebugSubsectionArray::Iterator LinesAndChecksumsIterator; public: ModuleDebugStreamRef(const DbiModuleDescriptor &Module, @@ -58,7 +57,7 @@ private: BinaryStreamRef C13LinesSubstream; BinaryStreamRef GlobalRefsSubstream; - codeview::ModuleDebugFragmentArray LinesAndChecksums; + codeview::DebugSubsectionArray LinesAndChecksums; }; } } diff --git a/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h b/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h index 7c7f16bd1c732..6aeb0a5479cbd 100644 --- a/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h +++ b/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h @@ -12,7 +12,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/CodeView/StringTable.h" +#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h" #include "llvm/Support/BinaryStreamArray.h" #include "llvm/Support/BinaryStreamRef.h" #include "llvm/Support/Endian.h" @@ -52,7 +52,7 @@ private: Error readEpilogue(BinaryStreamReader &Reader); const PDBStringTableHeader *Header = nullptr; - codeview::StringTableRef Strings; + codeview::DebugStringTableSubsectionRef Strings; FixedStreamArray<support::ulittle32_t> IDs; uint32_t ByteSize = 0; uint32_t NameCount = 0; diff --git a/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h b/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h index 6f85e7a4a0741..0faa02dc45255 100644 --- a/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h +++ b/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h @@ -16,7 +16,7 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/CodeView/StringTable.h" +#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h" #include "llvm/Support/Error.h" #include <vector> @@ -41,8 +41,10 @@ public: uint32_t calculateSerializedSize() const; Error commit(BinaryStreamWriter &Writer) const; - codeview::StringTable &getStrings() { return Strings; } - const codeview::StringTable &getStrings() const { return Strings; } + codeview::DebugStringTableSubsection &getStrings() { return Strings; } + const codeview::DebugStringTableSubsection &getStrings() const { + return Strings; + } private: uint32_t calculateHashTableSize() const; @@ -51,7 +53,7 @@ private: Error writeHashTable(BinaryStreamWriter &Writer) const; Error writeEpilogue(BinaryStreamWriter &Writer) const; - codeview::StringTable Strings; + codeview::DebugStringTableSubsection Strings; }; } // end namespace pdb diff --git a/include/llvm/MC/ConstantPools.h b/include/llvm/MC/ConstantPools.h index 5d4e32a672ddd..ef33250204ecf 100644 --- a/include/llvm/MC/ConstantPools.h +++ b/include/llvm/MC/ConstantPools.h @@ -19,6 +19,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/Support/SMLoc.h" #include <cstdint> +#include <map> namespace llvm { @@ -44,7 +45,7 @@ struct ConstantPoolEntry { class ConstantPool { using EntryVecTy = SmallVector<ConstantPoolEntry, 4>; EntryVecTy Entries; - DenseMap<int64_t, const MCSymbolRefExpr *> CachedEntries; + std::map<int64_t, const MCSymbolRefExpr *> CachedEntries; public: // Initialize a new empty constant pool diff --git a/include/llvm/Support/ManagedStatic.h b/include/llvm/Support/ManagedStatic.h index 7ce86eee95d24..b4bf3210cc738 100644 --- a/include/llvm/Support/ManagedStatic.h +++ b/include/llvm/Support/ManagedStatic.h @@ -14,25 +14,22 @@ #ifndef LLVM_SUPPORT_MANAGEDSTATIC_H #define LLVM_SUPPORT_MANAGEDSTATIC_H -#include "llvm/Support/Compiler.h" #include <atomic> #include <cstddef> namespace llvm { /// object_creator - Helper method for ManagedStatic. -template<class C> -LLVM_LIBRARY_VISIBILITY void* object_creator() { - return new C(); -} +template <class C> struct object_creator { + static void *call() { return new C(); } +}; /// object_deleter - Helper method for ManagedStatic. /// -template <typename T> struct LLVM_LIBRARY_VISIBILITY object_deleter { +template <typename T> struct object_deleter { static void call(void *Ptr) { delete (T *)Ptr; } }; -template <typename T, size_t N> -struct LLVM_LIBRARY_VISIBILITY object_deleter<T[N]> { +template <typename T, size_t N> struct object_deleter<T[N]> { static void call(void *Ptr) { delete[](T *)Ptr; } }; @@ -59,14 +56,15 @@ public: /// libraries that link in LLVM components) and for making destruction be /// explicit through the llvm_shutdown() function call. /// -template<class C> +template <class C, class Creator = object_creator<C>, + class Deleter = object_deleter<C>> class ManagedStatic : public ManagedStaticBase { public: // Accessors. C &operator*() { void *Tmp = Ptr.load(std::memory_order_acquire); if (!Tmp) - RegisterManagedStatic(object_creator<C>, object_deleter<C>::call); + RegisterManagedStatic(Creator::call, Deleter::call); return *static_cast<C *>(Ptr.load(std::memory_order_relaxed)); } @@ -76,7 +74,7 @@ public: const C &operator*() const { void *Tmp = Ptr.load(std::memory_order_acquire); if (!Tmp) - RegisterManagedStatic(object_creator<C>, object_deleter<C>::call); + RegisterManagedStatic(Creator::call, Deleter::call); return *static_cast<C *>(Ptr.load(std::memory_order_relaxed)); } diff --git a/include/llvm/TableGen/Record.h b/include/llvm/TableGen/Record.h index d14a56cb87e00..437f68b24e575 100644 --- a/include/llvm/TableGen/Record.h +++ b/include/llvm/TableGen/Record.h @@ -1189,6 +1189,9 @@ public: return Init ? Init->getValue() : StringRef(); } + ArrayRef<Init *> getArgs() const { + return makeArrayRef(getTrailingObjects<Init *>(), NumArgs); + } ArrayRef<StringInit *> getArgNames() const { return makeArrayRef(getTrailingObjects<StringInit *>(), NumArgNames); } @@ -1200,19 +1203,16 @@ public: typedef SmallVectorImpl<Init*>::const_iterator const_arg_iterator; typedef SmallVectorImpl<StringInit*>::const_iterator const_name_iterator; - inline const_arg_iterator arg_begin() const { return getTrailingObjects<Init *>(); } - inline const_arg_iterator arg_end () const { return arg_begin() + NumArgs; } - inline iterator_range<const_arg_iterator> args() const { - return llvm::make_range(arg_begin(), arg_end()); - } + inline const_arg_iterator arg_begin() const { return getArgs().begin(); } + inline const_arg_iterator arg_end () const { return getArgs().end(); } - inline size_t arg_size () const { return NumArgs; } + inline size_t arg_size () const { return NumArgs; } inline bool arg_empty() const { return NumArgs == 0; } - inline const_name_iterator name_begin() const { return getTrailingObjects<StringInit *>(); } - inline const_name_iterator name_end () const { return name_begin() + NumArgNames; } + inline const_name_iterator name_begin() const { return getArgNames().begin();} + inline const_name_iterator name_end () const { return getArgNames().end(); } - inline size_t name_size () const { return NumArgNames; } + inline size_t name_size () const { return NumArgNames; } inline bool name_empty() const { return NumArgNames == 0; } Init *getBit(unsigned Bit) const override { diff --git a/include/llvm/Transforms/Scalar/GVNExpression.h b/include/llvm/Transforms/Scalar/GVNExpression.h index a971df975b6fa..324ebca46de20 100644 --- a/include/llvm/Transforms/Scalar/GVNExpression.h +++ b/include/llvm/Transforms/Scalar/GVNExpression.h @@ -58,10 +58,11 @@ class Expression { private: ExpressionType EType; unsigned Opcode; + mutable hash_code HashVal; public: Expression(ExpressionType ET = ET_Base, unsigned O = ~2U) - : EType(ET), Opcode(O) {} + : EType(ET), Opcode(O), HashVal(0) {} Expression(const Expression &) = delete; Expression &operator=(const Expression &) = delete; virtual ~Expression(); @@ -82,6 +83,14 @@ public: return equals(Other); } + hash_code getComputedHash() const { + // It's theoretically possible for a thing to hash to zero. In that case, + // we will just compute the hash a few extra times, which is no worse that + // we did before, which was to compute it always. + if (static_cast<unsigned>(HashVal) == 0) + HashVal = getHashValue(); + return HashVal; + } virtual bool equals(const Expression &Other) const { return true; } |