diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-08-21 18:13:02 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-08-21 18:13:02 +0000 |
commit | 54db30ce18663e6c2991958f3b5d18362e8e93c4 (patch) | |
tree | 4aa6442802570767398cc83ba484e97b1309bdc2 /contrib/llvm/lib/DebugInfo/CodeView | |
parent | 35284c22e9c8348159b7ce032ea45f2cdeb65298 (diff) | |
parent | e6d1592492a3a379186bfb02bd0f4eda0669c0d5 (diff) |
Merge llvm trunk r366426, resolve conflicts, and update FREEBSD-Xlist.
Notes
Notes:
svn path=/projects/clang900-import/; revision=351344
Diffstat (limited to 'contrib/llvm/lib/DebugInfo/CodeView')
40 files changed, 498 insertions, 374 deletions
diff --git a/contrib/llvm/lib/DebugInfo/CodeView/AppendingTypeTableBuilder.cpp b/contrib/llvm/lib/DebugInfo/CodeView/AppendingTypeTableBuilder.cpp index 8828671d9be9..86a6f9eebfa2 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/AppendingTypeTableBuilder.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/AppendingTypeTableBuilder.cpp @@ -1,9 +1,8 @@ //===- AppendingTypeTableBuilder.cpp --------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -50,13 +49,8 @@ Optional<TypeIndex> AppendingTypeTableBuilder::getNext(TypeIndex Prev) { return Prev; } -CVType AppendingTypeTableBuilder::getType(TypeIndex Index) { - CVType Type; - Type.RecordData = SeenRecords[Index.toArrayIndex()]; - const RecordPrefix *P = - reinterpret_cast<const RecordPrefix *>(Type.RecordData.data()); - Type.Type = static_cast<TypeLeafKind>(uint16_t(P->RecordKind)); - return Type; +CVType AppendingTypeTableBuilder::getType(TypeIndex Index){ + return CVType(SeenRecords[Index.toArrayIndex()]); } StringRef AppendingTypeTableBuilder::getTypeName(TypeIndex Index) { diff --git a/contrib/llvm/lib/DebugInfo/CodeView/CVSymbolVisitor.cpp b/contrib/llvm/lib/DebugInfo/CodeView/CVSymbolVisitor.cpp index cbcaa5692828..48b9b0496ffe 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/CVSymbolVisitor.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/CVSymbolVisitor.cpp @@ -1,9 +1,8 @@ //===- CVSymbolVisitor.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -21,7 +20,7 @@ CVSymbolVisitor::CVSymbolVisitor(SymbolVisitorCallbacks &Callbacks) template <typename T> static Error visitKnownRecord(CVSymbol &Record, SymbolVisitorCallbacks &Callbacks) { - SymbolRecordKind RK = static_cast<SymbolRecordKind>(Record.Type); + SymbolRecordKind RK = static_cast<SymbolRecordKind>(Record.kind()); T KnownRecord(RK); if (auto EC = Callbacks.visitKnownRecord(Record, KnownRecord)) return EC; @@ -30,7 +29,7 @@ static Error visitKnownRecord(CVSymbol &Record, static Error finishVisitation(CVSymbol &Record, SymbolVisitorCallbacks &Callbacks) { - switch (Record.Type) { + switch (Record.kind()) { default: if (auto EC = Callbacks.visitUnknownSymbol(Record)) return EC; diff --git a/contrib/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp b/contrib/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp index a4182a3b2fa1..ec4773d571c8 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp @@ -1,9 +1,8 @@ //===- CVTypeVisitor.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,7 +22,7 @@ using namespace llvm::codeview; template <typename T> static Error visitKnownRecord(CVType &Record, TypeVisitorCallbacks &Callbacks) { - TypeRecordKind RK = static_cast<TypeRecordKind>(Record.Type); + TypeRecordKind RK = static_cast<TypeRecordKind>(Record.kind()); T KnownRecord(RK); if (auto EC = Callbacks.visitKnownRecord(Record, KnownRecord)) return EC; @@ -97,7 +96,7 @@ CVTypeVisitor::CVTypeVisitor(TypeVisitorCallbacks &Callbacks) : Callbacks(Callbacks) {} Error CVTypeVisitor::finishVisitation(CVType &Record) { - switch (Record.Type) { + switch (Record.kind()) { default: if (auto EC = Callbacks.visitUnknownType(Record)) return EC; @@ -210,6 +209,14 @@ struct VisitHelper { } } + VisitHelper(TypeVisitorCallbackPipeline &Callbacks, VisitorDataSource Source) + : Visitor((Source == VDS_BytesPresent) ? Pipeline : Callbacks) { + if (Source == VDS_BytesPresent) { + Pipeline = Callbacks; + Pipeline.addCallbackToPipelineFront(Deserializer); + } + } + TypeDeserializer Deserializer; TypeVisitorCallbackPipeline Pipeline; CVTypeVisitor Visitor; @@ -223,6 +230,13 @@ Error llvm::codeview::visitTypeRecord(CVType &Record, TypeIndex Index, return V.Visitor.visitTypeRecord(Record, Index); } +Error llvm::codeview::visitTypeRecord(CVType &Record, TypeIndex Index, + TypeVisitorCallbackPipeline &Callbacks, + VisitorDataSource Source) { + VisitHelper V(Callbacks, Source); + return V.Visitor.visitTypeRecord(Record, Index); +} + Error llvm::codeview::visitTypeRecord(CVType &Record, TypeVisitorCallbacks &Callbacks, VisitorDataSource Source) { diff --git a/contrib/llvm/lib/DebugInfo/CodeView/CodeViewError.cpp b/contrib/llvm/lib/DebugInfo/CodeView/CodeViewError.cpp index 2a9753add311..69390c708f59 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/CodeViewError.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/CodeViewError.cpp @@ -1,9 +1,8 @@ //===- CodeViewError.cpp - Error extensions for CodeView --------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -14,6 +13,7 @@ using namespace llvm; using namespace llvm::codeview; +namespace { // FIXME: This class is only here to support the transition to llvm::Error. It // will be removed once this transition is complete. Clients should prefer to // deal with the Error value directly, rather than converting to error_code. @@ -39,6 +39,7 @@ public: llvm_unreachable("Unrecognized cv_error_code"); } }; +} // namespace static llvm::ManagedStatic<CodeViewErrorCategory> CodeViewErrCategory; const std::error_category &llvm::codeview::CVErrorCategory() { diff --git a/contrib/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp b/contrib/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp index 4fc14480578e..2f49474115a1 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp @@ -1,9 +1,8 @@ //===- CodeViewRecordIO.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -21,6 +20,7 @@ Error CodeViewRecordIO::beginRecord(Optional<uint32_t> MaxLength) { Limit.MaxLength = MaxLength; Limit.BeginOffset = getCurrentOffset(); Limits.push_back(Limit); + resetStreamedLen(); return Error::success(); } @@ -35,10 +35,29 @@ Error CodeViewRecordIO::endRecord() { // we don't know how big the record is until we're finished writing it, so // even though we don't commit the extraneous data, we still can't guarantee // we're at the end of the allocated data. + + if (isStreaming()) { + // For streaming mode, add padding to align with 4 byte boundaries for each + // record + uint32_t Align = getStreamedLen() % 4; + if (Align == 0) + return Error::success(); + + int PaddingBytes = 4 - Align; + while (PaddingBytes > 0) { + char Pad = static_cast<uint8_t>(LF_PAD0 + PaddingBytes); + StringRef BytesSR = StringRef(&Pad, sizeof(Pad)); + Streamer->EmitBytes(BytesSR); + --PaddingBytes; + } + } return Error::success(); } uint32_t CodeViewRecordIO::maxFieldLength() const { + if (isStreaming()) + return 0; + assert(!Limits.empty() && "Not in a record!"); // The max length of the next field is the minimum of all lengths that would @@ -78,8 +97,13 @@ Error CodeViewRecordIO::skipPadding() { return Reader->skip(BytesToAdvance); } -Error CodeViewRecordIO::mapByteVectorTail(ArrayRef<uint8_t> &Bytes) { - if (isWriting()) { +Error CodeViewRecordIO::mapByteVectorTail(ArrayRef<uint8_t> &Bytes, + const Twine &Comment) { + if (isStreaming()) { + emitComment(Comment); + Streamer->EmitBinaryData(toStringRef(Bytes)); + incrStreamedLen(Bytes.size()); + } else if (isWriting()) { if (auto EC = Writer->writeBytes(Bytes)) return EC; } else { @@ -89,9 +113,10 @@ Error CodeViewRecordIO::mapByteVectorTail(ArrayRef<uint8_t> &Bytes) { return Error::success(); } -Error CodeViewRecordIO::mapByteVectorTail(std::vector<uint8_t> &Bytes) { +Error CodeViewRecordIO::mapByteVectorTail(std::vector<uint8_t> &Bytes, + const Twine &Comment) { ArrayRef<uint8_t> BytesRef(Bytes); - if (auto EC = mapByteVectorTail(BytesRef)) + if (auto EC = mapByteVectorTail(BytesRef, Comment)) return EC; if (!isWriting()) Bytes.assign(BytesRef.begin(), BytesRef.end()); @@ -99,22 +124,31 @@ Error CodeViewRecordIO::mapByteVectorTail(std::vector<uint8_t> &Bytes) { return Error::success(); } -Error CodeViewRecordIO::mapInteger(TypeIndex &TypeInd) { - if (isWriting()) { +Error CodeViewRecordIO::mapInteger(TypeIndex &TypeInd, const Twine &Comment) { + if (isStreaming()) { + emitComment(Comment); + Streamer->EmitIntValue(TypeInd.getIndex(), sizeof(TypeInd.getIndex())); + incrStreamedLen(sizeof(TypeInd.getIndex())); + } else if (isWriting()) { if (auto EC = Writer->writeInteger(TypeInd.getIndex())) return EC; - return Error::success(); + } else { + uint32_t I; + if (auto EC = Reader->readInteger(I)) + return EC; + TypeInd.setIndex(I); } - - uint32_t I; - if (auto EC = Reader->readInteger(I)) - return EC; - TypeInd.setIndex(I); return Error::success(); } -Error CodeViewRecordIO::mapEncodedInteger(int64_t &Value) { - if (isWriting()) { +Error CodeViewRecordIO::mapEncodedInteger(int64_t &Value, + const Twine &Comment) { + if (isStreaming()) { + if (Value >= 0) + emitEncodedUnsignedInteger(static_cast<uint64_t>(Value), Comment); + else + emitEncodedSignedInteger(Value, Comment); + } else if (isWriting()) { if (Value >= 0) { if (auto EC = writeEncodedUnsignedInteger(static_cast<uint64_t>(Value))) return EC; @@ -132,8 +166,11 @@ Error CodeViewRecordIO::mapEncodedInteger(int64_t &Value) { return Error::success(); } -Error CodeViewRecordIO::mapEncodedInteger(uint64_t &Value) { - if (isWriting()) { +Error CodeViewRecordIO::mapEncodedInteger(uint64_t &Value, + const Twine &Comment) { + if (isStreaming()) + emitEncodedUnsignedInteger(Value, Comment); + else if (isWriting()) { if (auto EC = writeEncodedUnsignedInteger(Value)) return EC; } else { @@ -145,18 +182,28 @@ Error CodeViewRecordIO::mapEncodedInteger(uint64_t &Value) { return Error::success(); } -Error CodeViewRecordIO::mapEncodedInteger(APSInt &Value) { - if (isWriting()) { +Error CodeViewRecordIO::mapEncodedInteger(APSInt &Value, const Twine &Comment) { + if (isStreaming()) { + if (Value.isSigned()) + emitEncodedSignedInteger(Value.getSExtValue(), Comment); + else + emitEncodedUnsignedInteger(Value.getZExtValue(), Comment); + } else if (isWriting()) { if (Value.isSigned()) return writeEncodedSignedInteger(Value.getSExtValue()); return writeEncodedUnsignedInteger(Value.getZExtValue()); - } - - return consume(*Reader, Value); + } else + return consume(*Reader, Value); + return Error::success(); } -Error CodeViewRecordIO::mapStringZ(StringRef &Value) { - if (isWriting()) { +Error CodeViewRecordIO::mapStringZ(StringRef &Value, const Twine &Comment) { + if (isStreaming()) { + auto NullTerminatedString = StringRef(Value.data(), Value.size() + 1); + emitComment(Comment); + Streamer->EmitBytes(NullTerminatedString); + incrStreamedLen(NullTerminatedString.size()); + } else if (isWriting()) { // Truncate if we attempt to write too much. StringRef S = Value.take_front(maxFieldLength() - 1); if (auto EC = Writer->writeCString(S)) @@ -168,8 +215,18 @@ Error CodeViewRecordIO::mapStringZ(StringRef &Value) { return Error::success(); } -Error CodeViewRecordIO::mapGuid(GUID &Guid) { +Error CodeViewRecordIO::mapGuid(GUID &Guid, const Twine &Comment) { constexpr uint32_t GuidSize = 16; + + if (isStreaming()) { + StringRef GuidSR = + StringRef((reinterpret_cast<const char *>(&Guid)), GuidSize); + emitComment(Comment); + Streamer->EmitBytes(GuidSR); + incrStreamedLen(GuidSize); + return Error::success(); + } + if (maxFieldLength() < GuidSize) return make_error<CodeViewError>(cv_error_code::insufficient_buffer); @@ -185,13 +242,17 @@ Error CodeViewRecordIO::mapGuid(GUID &Guid) { return Error::success(); } -Error CodeViewRecordIO::mapStringZVectorZ(std::vector<StringRef> &Value) { - if (isWriting()) { +Error CodeViewRecordIO::mapStringZVectorZ(std::vector<StringRef> &Value, + const Twine &Comment) { + + if (!isReading()) { + emitComment(Comment); for (auto V : Value) { if (auto EC = mapStringZ(V)) return EC; } - if (auto EC = Writer->writeInteger<uint8_t>(0)) + uint8_t FinalZero = 0; + if (auto EC = mapInteger(FinalZero)) return EC; } else { StringRef S; @@ -206,6 +267,56 @@ Error CodeViewRecordIO::mapStringZVectorZ(std::vector<StringRef> &Value) { return Error::success(); } +void CodeViewRecordIO::emitEncodedSignedInteger(const int64_t &Value, + const Twine &Comment) { + assert(Value < 0 && "Encoded integer is not signed!"); + if (Value >= std::numeric_limits<int8_t>::min()) { + Streamer->EmitIntValue(LF_CHAR, 2); + emitComment(Comment); + Streamer->EmitIntValue(Value, 1); + incrStreamedLen(3); + } else if (Value >= std::numeric_limits<int16_t>::min()) { + Streamer->EmitIntValue(LF_SHORT, 2); + emitComment(Comment); + Streamer->EmitIntValue(Value, 2); + incrStreamedLen(4); + } else if (Value >= std::numeric_limits<int32_t>::min()) { + Streamer->EmitIntValue(LF_LONG, 2); + emitComment(Comment); + Streamer->EmitIntValue(Value, 4); + incrStreamedLen(6); + } else { + Streamer->EmitIntValue(LF_QUADWORD, 2); + emitComment(Comment); + Streamer->EmitIntValue(Value, 4); + incrStreamedLen(6); + } +} + +void CodeViewRecordIO::emitEncodedUnsignedInteger(const uint64_t &Value, + const Twine &Comment) { + if (Value < LF_NUMERIC) { + emitComment(Comment); + Streamer->EmitIntValue(Value, 2); + incrStreamedLen(2); + } else if (Value <= std::numeric_limits<uint16_t>::max()) { + Streamer->EmitIntValue(LF_USHORT, 2); + emitComment(Comment); + Streamer->EmitIntValue(Value, 2); + incrStreamedLen(4); + } else if (Value <= std::numeric_limits<uint32_t>::max()) { + Streamer->EmitIntValue(LF_ULONG, 2); + emitComment(Comment); + Streamer->EmitIntValue(Value, 4); + incrStreamedLen(6); + } else { + Streamer->EmitIntValue(LF_UQUADWORD, 2); + emitComment(Comment); + Streamer->EmitIntValue(Value, 8); + incrStreamedLen(6); + } +} + Error CodeViewRecordIO::writeEncodedSignedInteger(const int64_t &Value) { assert(Value < 0 && "Encoded integer is not signed!"); if (Value >= std::numeric_limits<int8_t>::min()) { diff --git a/contrib/llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp b/contrib/llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp index f180fc6990fc..799cffb7116e 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp @@ -66,14 +66,11 @@ void ContinuationRecordBuilder::begin(ContinuationRecordKind RecordKind) { InjectedSegmentBytes = ArrayRef<uint8_t>(FLIB, FLIB + sizeof(SegmentInjection)); - CVType Type; - Type.Type = getTypeLeafKind(RecordKind); + // Seed the first record with an appropriate record prefix. + RecordPrefix Prefix(getTypeLeafKind(RecordKind)); + CVType Type(&Prefix, sizeof(Prefix)); cantFail(Mapping.visitTypeBegin(Type)); - // Seed the first trecord with an appropriate record prefix. - RecordPrefix Prefix; - Prefix.RecordLen = 0; - Prefix.RecordKind = Type.Type; cantFail(SegmentWriter.writeObject(Prefix)); } @@ -156,14 +153,9 @@ CVType ContinuationRecordBuilder::createSegmentRecord( MutableArrayRef<uint8_t> Data = Buffer.data(); Data = Data.slice(OffBegin, OffEnd - OffBegin); - CVType Type; - Type.Type = getTypeLeafKind(*Kind); - Type.RecordData = Data; - // Write the length to the RecordPrefix, making sure it does not include // sizeof(RecordPrefix.Length) RecordPrefix *Prefix = reinterpret_cast<RecordPrefix *>(Data.data()); - assert(Prefix->RecordKind == Type.Type); Prefix->RecordLen = Data.size() - sizeof(RecordPrefix::RecordLen); if (RefersTo.hasValue()) { @@ -175,12 +167,12 @@ CVType ContinuationRecordBuilder::createSegmentRecord( CR->IndexRef = RefersTo->getIndex(); } - return Type; + return CVType(Data); } std::vector<CVType> ContinuationRecordBuilder::end(TypeIndex Index) { - CVType Type; - Type.Type = getTypeLeafKind(*Kind); + RecordPrefix Prefix(getTypeLeafKind(*Kind)); + CVType Type(&Prefix, sizeof(Prefix)); cantFail(Mapping.visitTypeEnd(Type)); // We're now done, and we have a series of segments each beginning at an diff --git a/contrib/llvm/lib/DebugInfo/CodeView/DebugChecksumsSubsection.cpp b/contrib/llvm/lib/DebugInfo/CodeView/DebugChecksumsSubsection.cpp index 0f155a95d607..3d28bac00c44 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/DebugChecksumsSubsection.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/DebugChecksumsSubsection.cpp @@ -1,9 +1,8 @@ //===- DebugChecksumsSubsection.cpp ---------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/contrib/llvm/lib/DebugInfo/CodeView/DebugCrossExSubsection.cpp b/contrib/llvm/lib/DebugInfo/CodeView/DebugCrossExSubsection.cpp index cef27787cfd1..b23410409f88 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/DebugCrossExSubsection.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/DebugCrossExSubsection.cpp @@ -1,9 +1,8 @@ //===- DebugCrossExSubsection.cpp -----------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/contrib/llvm/lib/DebugInfo/CodeView/DebugCrossImpSubsection.cpp b/contrib/llvm/lib/DebugInfo/CodeView/DebugCrossImpSubsection.cpp index 4001741f560a..dbadafd3aaf3 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/DebugCrossImpSubsection.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/DebugCrossImpSubsection.cpp @@ -1,9 +1,8 @@ //===- DebugCrossImpSubsection.cpp ----------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/contrib/llvm/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp b/contrib/llvm/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp index 5881bf177a55..be8c32d5b294 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp @@ -1,9 +1,8 @@ //===- DebugFrameDataSubsection.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/contrib/llvm/lib/DebugInfo/CodeView/DebugInlineeLinesSubsection.cpp b/contrib/llvm/lib/DebugInfo/CodeView/DebugInlineeLinesSubsection.cpp index 077c103a615b..48ec7e4ecdd6 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/DebugInlineeLinesSubsection.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/DebugInlineeLinesSubsection.cpp @@ -1,9 +1,8 @@ //===- DebugInlineeLinesSubsection.cpp ------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/contrib/llvm/lib/DebugInfo/CodeView/DebugLinesSubsection.cpp b/contrib/llvm/lib/DebugInfo/CodeView/DebugLinesSubsection.cpp index 57ad40819fbc..ea16c0a6c671 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/DebugLinesSubsection.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/DebugLinesSubsection.cpp @@ -1,9 +1,8 @@ //===- DebugLinesSubsection.cpp -------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/contrib/llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp b/contrib/llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp index 9b251f5931b3..63342749918d 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp @@ -1,9 +1,8 @@ //===- DebugStringTableSubsection.cpp - CodeView String Table -------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/contrib/llvm/lib/DebugInfo/CodeView/DebugSubsection.cpp b/contrib/llvm/lib/DebugInfo/CodeView/DebugSubsection.cpp index 67b428bfa713..3f93463fe6d6 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/DebugSubsection.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/DebugSubsection.cpp @@ -1,9 +1,8 @@ //===- DebugSubsection.cpp -----------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/contrib/llvm/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp b/contrib/llvm/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp index 55f343c11e7f..0f704f286ee9 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp @@ -1,9 +1,8 @@ //===- DebugSubsectionRecord.cpp ------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/contrib/llvm/lib/DebugInfo/CodeView/DebugSubsectionVisitor.cpp b/contrib/llvm/lib/DebugInfo/CodeView/DebugSubsectionVisitor.cpp index 9b824333369b..7968b6a2d757 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/DebugSubsectionVisitor.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/DebugSubsectionVisitor.cpp @@ -1,9 +1,8 @@ //===- DebugSubsectionVisitor.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/contrib/llvm/lib/DebugInfo/CodeView/DebugSymbolRVASubsection.cpp b/contrib/llvm/lib/DebugInfo/CodeView/DebugSymbolRVASubsection.cpp index 60fbf9d747b2..52328967357b 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/DebugSymbolRVASubsection.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/DebugSymbolRVASubsection.cpp @@ -1,9 +1,8 @@ //===- DebugSymbolRVASubsection.cpp ---------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/contrib/llvm/lib/DebugInfo/CodeView/DebugSymbolsSubsection.cpp b/contrib/llvm/lib/DebugInfo/CodeView/DebugSymbolsSubsection.cpp index dc8ba8c929ae..c833103663e4 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/DebugSymbolsSubsection.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/DebugSymbolsSubsection.cpp @@ -1,9 +1,8 @@ //===- DebugSymbolsSubsection.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -31,4 +30,4 @@ Error DebugSymbolsSubsection::commit(BinaryStreamWriter &Writer) const { void DebugSymbolsSubsection::addSymbol(CVSymbol Symbol) { Records.push_back(Symbol); Length += Symbol.length(); -}
\ No newline at end of file +} diff --git a/contrib/llvm/lib/DebugInfo/CodeView/EnumTables.cpp b/contrib/llvm/lib/DebugInfo/CodeView/EnumTables.cpp index ef4e42f79ebc..54e68ae4ea9f 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/EnumTables.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/EnumTables.cpp @@ -1,9 +1,8 @@ //===- EnumTables.cpp - Enum to string conversion tables ------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -32,10 +31,20 @@ static const EnumEntry<TypeLeafKind> TypeLeafNames[] = { #undef CV_TYPE }; -static const EnumEntry<uint16_t> RegisterNames[] = { +static const EnumEntry<uint16_t> RegisterNames_X86[] = { +#define CV_REGISTERS_X86 +#define CV_REGISTER(name, val) CV_ENUM_CLASS_ENT(RegisterId, name), +#include "llvm/DebugInfo/CodeView/CodeViewRegisters.def" +#undef CV_REGISTER +#undef CV_REGISTERS_X86 +}; + +static const EnumEntry<uint16_t> RegisterNames_ARM64[] = { +#define CV_REGISTERS_ARM64 #define CV_REGISTER(name, val) CV_ENUM_CLASS_ENT(RegisterId, name), #include "llvm/DebugInfo/CodeView/CodeViewRegisters.def" #undef CV_REGISTER +#undef CV_REGISTERS_ARM64 }; static const EnumEntry<uint32_t> PublicSymFlagNames[] = { @@ -87,6 +96,7 @@ static const EnumEntry<codeview::SourceLanguage> SourceLanguages[] = { CV_ENUM_ENT(SourceLanguage, ILAsm), CV_ENUM_ENT(SourceLanguage, Java), CV_ENUM_ENT(SourceLanguage, JScript), CV_ENUM_ENT(SourceLanguage, MSIL), CV_ENUM_ENT(SourceLanguage, HLSL), CV_ENUM_ENT(SourceLanguage, D), + CV_ENUM_ENT(SourceLanguage, Swift), }; static const EnumEntry<uint32_t> CompileSym2FlagNames[] = { @@ -171,6 +181,7 @@ static const EnumEntry<unsigned> CPUTypeNames[] = { CV_ENUM_CLASS_ENT(CPUType, ARM_XMAC), CV_ENUM_CLASS_ENT(CPUType, ARM_WMMX), CV_ENUM_CLASS_ENT(CPUType, ARM7), + CV_ENUM_CLASS_ENT(CPUType, ARM64), CV_ENUM_CLASS_ENT(CPUType, Omni), CV_ENUM_CLASS_ENT(CPUType, Ia64), CV_ENUM_CLASS_ENT(CPUType, Ia64_2), @@ -300,8 +311,11 @@ ArrayRef<EnumEntry<TypeLeafKind>> getTypeLeafNames() { return makeArrayRef(TypeLeafNames); } -ArrayRef<EnumEntry<uint16_t>> getRegisterNames() { - return makeArrayRef(RegisterNames); +ArrayRef<EnumEntry<uint16_t>> getRegisterNames(CPUType Cpu) { + if (Cpu == CPUType::ARM64) { + return makeArrayRef(RegisterNames_ARM64); + } + return makeArrayRef(RegisterNames_X86); } ArrayRef<EnumEntry<uint32_t>> getPublicSymFlagNames() { diff --git a/contrib/llvm/lib/DebugInfo/CodeView/Formatters.cpp b/contrib/llvm/lib/DebugInfo/CodeView/Formatters.cpp index b8d89c76da3b..a7a8c7ff82bf 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/Formatters.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/Formatters.cpp @@ -1,9 +1,8 @@ //===- Formatters.cpp -----------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/contrib/llvm/lib/DebugInfo/CodeView/GlobalTypeTableBuilder.cpp b/contrib/llvm/lib/DebugInfo/CodeView/GlobalTypeTableBuilder.cpp index e76f9e12f0af..a7ad1d045f04 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/GlobalTypeTableBuilder.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/GlobalTypeTableBuilder.cpp @@ -1,9 +1,8 @@ //===- GlobalTypeTableBuilder.cpp -----------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -53,14 +52,7 @@ Optional<TypeIndex> GlobalTypeTableBuilder::getNext(TypeIndex Prev) { } CVType GlobalTypeTableBuilder::getType(TypeIndex Index) { - CVType Type; - Type.RecordData = SeenRecords[Index.toArrayIndex()]; - if (!Type.RecordData.empty()) { - assert(Type.RecordData.size() >= sizeof(RecordPrefix)); - const RecordPrefix *P = - reinterpret_cast<const RecordPrefix *>(Type.RecordData.data()); - Type.Type = static_cast<TypeLeafKind>(uint16_t(P->RecordKind)); - } + CVType Type(SeenRecords[Index.toArrayIndex()]); return Type; } diff --git a/contrib/llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp b/contrib/llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp index ddcad8c631d7..dc1253b7a39f 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp @@ -1,9 +1,8 @@ //===- LazyRandomTypeCollection.cpp ---------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/contrib/llvm/lib/DebugInfo/CodeView/Line.cpp b/contrib/llvm/lib/DebugInfo/CodeView/Line.cpp index 4cb766b5fd26..53adc8cac511 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/Line.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/Line.cpp @@ -1,9 +1,8 @@ //===-- Line.cpp ----------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/contrib/llvm/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp b/contrib/llvm/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp index 8aee4aa2e2ae..4d7cd468f3ee 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/MergingTypeTableBuilder.cpp @@ -1,9 +1,8 @@ //===- MergingTypeTableBuilder.cpp ----------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -53,11 +52,7 @@ Optional<TypeIndex> MergingTypeTableBuilder::getNext(TypeIndex Prev) { } CVType MergingTypeTableBuilder::getType(TypeIndex Index) { - CVType Type; - Type.RecordData = SeenRecords[Index.toArrayIndex()]; - const RecordPrefix *P = - reinterpret_cast<const RecordPrefix *>(Type.RecordData.data()); - Type.Type = static_cast<TypeLeafKind>(uint16_t(P->RecordKind)); + CVType Type(SeenRecords[Index.toArrayIndex()]); return Type; } diff --git a/contrib/llvm/lib/DebugInfo/CodeView/RecordName.cpp b/contrib/llvm/lib/DebugInfo/CodeView/RecordName.cpp index d868ae237a44..cfaad1581159 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/RecordName.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/RecordName.cpp @@ -1,9 +1,8 @@ //===- RecordName.cpp ----------------------------------------- *- C++ --*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/contrib/llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp b/contrib/llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp index bff9a619a846..e7f032f9c670 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp @@ -1,9 +1,8 @@ //===-- RecordSerialization.cpp -------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/contrib/llvm/lib/DebugInfo/CodeView/SimpleTypeSerializer.cpp b/contrib/llvm/lib/DebugInfo/CodeView/SimpleTypeSerializer.cpp index d28b7c3c2d83..654c40a7470d 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/SimpleTypeSerializer.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/SimpleTypeSerializer.cpp @@ -3,13 +3,6 @@ using namespace llvm; using namespace llvm::codeview; -static void writeRecordPrefix(BinaryStreamWriter &Writer, TypeLeafKind Kind) { - RecordPrefix Prefix; - Prefix.RecordKind = Kind; - Prefix.RecordLen = 0; - cantFail(Writer.writeObject(Prefix)); -} - static void addPadding(BinaryStreamWriter &Writer) { uint32_t Align = Writer.getOffset() % 4; if (Align == 0) @@ -32,10 +25,12 @@ ArrayRef<uint8_t> SimpleTypeSerializer::serialize(T &Record) { BinaryStreamWriter Writer(ScratchBuffer, support::little); TypeRecordMapping Mapping(Writer); - CVType CVT; - CVT.Type = static_cast<TypeLeafKind>(Record.getKind()); + // Write the record prefix first with a dummy length but real kind. + RecordPrefix DummyPrefix(uint16_t(Record.getKind())); + cantFail(Writer.writeObject(DummyPrefix)); - writeRecordPrefix(Writer, CVT.Type); + RecordPrefix *Prefix = reinterpret_cast<RecordPrefix *>(ScratchBuffer.data()); + CVType CVT(Prefix, sizeof(RecordPrefix)); cantFail(Mapping.visitTypeBegin(CVT)); cantFail(Mapping.visitKnownRecord(CVT, Record)); @@ -43,8 +38,7 @@ ArrayRef<uint8_t> SimpleTypeSerializer::serialize(T &Record) { addPadding(Writer); - RecordPrefix *Prefix = reinterpret_cast<RecordPrefix *>(ScratchBuffer.data()); - + // Update the size and kind after serialization. Prefix->RecordKind = CVT.kind(); Prefix->RecordLen = Writer.getOffset() - sizeof(uint16_t); diff --git a/contrib/llvm/lib/DebugInfo/CodeView/StringsAndChecksums.cpp b/contrib/llvm/lib/DebugInfo/CodeView/StringsAndChecksums.cpp index 85d9dbb8c7df..9e204eec8604 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/StringsAndChecksums.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/StringsAndChecksums.cpp @@ -1,9 +1,8 @@ //===- StringsAndChecksums.cpp --------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/contrib/llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp b/contrib/llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp index 04e0bab745d3..27cb7e35234b 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp @@ -1,9 +1,8 @@ //===-- SymbolDumper.cpp - CodeView symbol info dumper ----------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -102,10 +101,10 @@ void CVSymbolDumperImpl::printTypeIndex(StringRef FieldName, TypeIndex TI) { } Error CVSymbolDumperImpl::visitSymbolBegin(CVSymbol &CVR) { - W.startLine() << getSymbolKindName(CVR.Type); + W.startLine() << getSymbolKindName(CVR.kind()); W.getOStream() << " {\n"; W.indent(); - W.printEnum("Kind", unsigned(CVR.Type), getSymbolTypeNames()); + W.printEnum("Kind", unsigned(CVR.kind()), getSymbolTypeNames()); return Error::success(); } @@ -326,7 +325,7 @@ Error CVSymbolDumperImpl::visitKnownRecord( Error CVSymbolDumperImpl::visitKnownRecord( CVSymbol &CVR, DefRangeRegisterRelSym &DefRangeRegisterRel) { W.printEnum("BaseRegister", uint16_t(DefRangeRegisterRel.Hdr.Register), - getRegisterNames()); + getRegisterNames(CompilationCPUType)); W.printBoolean("HasSpilledUDTMember", DefRangeRegisterRel.hasSpilledUDTMember()); W.printNumber("OffsetInParent", DefRangeRegisterRel.offsetInParent()); @@ -340,7 +339,7 @@ Error CVSymbolDumperImpl::visitKnownRecord( Error CVSymbolDumperImpl::visitKnownRecord( CVSymbol &CVR, DefRangeRegisterSym &DefRangeRegister) { W.printEnum("Register", uint16_t(DefRangeRegister.Hdr.Register), - getRegisterNames()); + getRegisterNames(CompilationCPUType)); W.printNumber("MayHaveNoName", DefRangeRegister.Hdr.MayHaveNoName); printLocalVariableAddrRange(DefRangeRegister.Range, DefRangeRegister.getRelocationOffset()); @@ -351,7 +350,7 @@ Error CVSymbolDumperImpl::visitKnownRecord( Error CVSymbolDumperImpl::visitKnownRecord( CVSymbol &CVR, DefRangeSubfieldRegisterSym &DefRangeSubfieldRegister) { W.printEnum("Register", uint16_t(DefRangeSubfieldRegister.Hdr.Register), - getRegisterNames()); + getRegisterNames(CompilationCPUType)); W.printNumber("MayHaveNoName", DefRangeSubfieldRegister.Hdr.MayHaveNoName); W.printNumber("OffsetInParent", DefRangeSubfieldRegister.Hdr.OffsetInParent); printLocalVariableAddrRange(DefRangeSubfieldRegister.Range, @@ -404,7 +403,8 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, FrameCookie.getRelocationOffset(), FrameCookie.CodeOffset, &LinkageName); } - W.printEnum("Register", uint16_t(FrameCookie.Register), getRegisterNames()); + W.printEnum("Register", uint16_t(FrameCookie.Register), + getRegisterNames(CompilationCPUType)); W.printEnum("CookieKind", uint16_t(FrameCookie.CookieKind), getFrameCookieKindNames()); W.printHex("Flags", FrameCookie.Flags); @@ -425,10 +425,10 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, getFrameProcSymFlagNames()); W.printEnum("LocalFramePtrReg", uint16_t(FrameProc.getLocalFramePtrReg(CompilationCPUType)), - getRegisterNames()); + getRegisterNames(CompilationCPUType)); W.printEnum("ParamFramePtrReg", uint16_t(FrameProc.getParamFramePtrReg(CompilationCPUType)), - getRegisterNames()); + getRegisterNames(CompilationCPUType)); return Error::success(); } @@ -506,7 +506,8 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, RegisterSym &Register) { printTypeIndex("Type", Register.Index); - W.printEnum("Seg", uint16_t(Register.Register), getRegisterNames()); + W.printEnum("Seg", uint16_t(Register.Register), + getRegisterNames(CompilationCPUType)); W.printString("Name", Register.Name); return Error::success(); } @@ -600,7 +601,8 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, RegRelativeSym &RegRel) { W.printHex("Offset", RegRel.Offset); printTypeIndex("Type", RegRel.Type); - W.printEnum("Register", uint16_t(RegRel.Register), getRegisterNames()); + W.printEnum("Register", uint16_t(RegRel.Register), + getRegisterNames(CompilationCPUType)); W.printString("VarName", RegRel.Name); return Error::success(); } @@ -631,6 +633,18 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, return Error::success(); } +Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, + AnnotationSym &Annot) { + W.printHex("Offset", Annot.CodeOffset); + W.printHex("Segment", Annot.Segment); + + ListScope S(W, "Strings"); + for (StringRef Str : Annot.Strings) + W.printString(Str); + + return Error::success(); +} + Error CVSymbolDumperImpl::visitUnknownSymbol(CVSymbol &CVR) { W.printNumber("Length", CVR.length()); return Error::success(); diff --git a/contrib/llvm/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp b/contrib/llvm/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp index 01746138ad1f..51a5a9e9243e 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp @@ -1,9 +1,8 @@ //===- SymbolRecordHelpers.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/contrib/llvm/lib/DebugInfo/CodeView/SymbolRecordMapping.cpp b/contrib/llvm/lib/DebugInfo/CodeView/SymbolRecordMapping.cpp index 2af8205cebc3..70889839ef48 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/SymbolRecordMapping.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/SymbolRecordMapping.cpp @@ -1,9 +1,8 @@ //===- SymbolRecordMapping.cpp -----------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -472,6 +471,18 @@ Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, return Error::success(); } +Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, + AnnotationSym &Annot) { + + error(IO.mapInteger(Annot.CodeOffset)); + error(IO.mapInteger(Annot.Segment)); + error(IO.mapVectorN<uint16_t>( + Annot.Strings, + [](CodeViewRecordIO &IO, StringRef &S) { return IO.mapStringZ(S); })); + + return Error::success(); +} + RegisterId codeview::decodeFramePtrReg(EncodedFramePtrReg EncodedReg, CPUType CPU) { assert(unsigned(EncodedReg) < 4); diff --git a/contrib/llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp b/contrib/llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp index 0071ecc85685..de9bb42b1798 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp @@ -1,9 +1,8 @@ //===- SymbolSerializer.cpp -----------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/contrib/llvm/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp b/contrib/llvm/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp index f5d3bea43a14..d5fea5ee5e29 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp @@ -1,9 +1,8 @@ //===-- TypeDumpVisitor.cpp - CodeView type info dumper ----------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -172,11 +171,11 @@ Error TypeDumpVisitor::visitTypeBegin(CVType &Record) { } Error TypeDumpVisitor::visitTypeBegin(CVType &Record, TypeIndex Index) { - W->startLine() << getLeafTypeName(Record.Type); + W->startLine() << getLeafTypeName(Record.kind()); W->getOStream() << " (" << HexNumber(Index.getIndex()) << ")"; W->getOStream() << " {\n"; W->indent(); - W->printEnum("TypeLeafKind", unsigned(Record.Type), + W->printEnum("TypeLeafKind", unsigned(Record.kind()), makeArrayRef(LeafTypeNames)); return Error::success(); } diff --git a/contrib/llvm/lib/DebugInfo/CodeView/TypeHashing.cpp b/contrib/llvm/lib/DebugInfo/CodeView/TypeHashing.cpp index 826faef35875..2dbc11a84f0b 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/TypeHashing.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/TypeHashing.cpp @@ -1,9 +1,8 @@ //===- TypeHashing.cpp -------------------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -55,10 +54,16 @@ GloballyHashedType::hashType(ArrayRef<uint8_t> RecordData, reinterpret_cast<const TypeIndex *>(RefData.data()), Ref.Count); for (TypeIndex TI : Indices) { ArrayRef<uint8_t> BytesToHash; - if (TI.isSimple() || TI.isNoneType() || TI.toArrayIndex() >= Prev.size()) { + if (TI.isSimple() || TI.isNoneType()) { const uint8_t *IndexBytes = reinterpret_cast<const uint8_t *>(&TI); BytesToHash = makeArrayRef(IndexBytes, sizeof(TypeIndex)); } else { + if (TI.toArrayIndex() >= Prev.size() || + Prev[TI.toArrayIndex()].empty()) { + // There are references to yet-unhashed records. Suspend hashing for + // this record until all the other records are processed. + return {}; + } BytesToHash = Prev[TI.toArrayIndex()].Hash; } S.update(BytesToHash); diff --git a/contrib/llvm/lib/DebugInfo/CodeView/TypeIndex.cpp b/contrib/llvm/lib/DebugInfo/CodeView/TypeIndex.cpp index 332d67470da5..604d342448d3 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/TypeIndex.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/TypeIndex.cpp @@ -1,9 +1,8 @@ //===-- TypeIndex.cpp - CodeView type index ---------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/contrib/llvm/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp b/contrib/llvm/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp index 839ab6f0a705..e84e1c9cea78 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp @@ -1,9 +1,8 @@ //===- TypeIndexDiscovery.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "llvm/DebugInfo/CodeView/TypeIndexDiscovery.h" @@ -364,14 +363,16 @@ static bool discoverTypeIndices(ArrayRef<uint8_t> Content, SymbolKind Kind, // values. One idea is to define some structures representing these types // that would allow the use of offsetof(). switch (Kind) { - case SymbolKind::S_GPROC32: - case SymbolKind::S_LPROC32: case SymbolKind::S_GPROC32_ID: case SymbolKind::S_LPROC32_ID: case SymbolKind::S_LPROC32_DPC: case SymbolKind::S_LPROC32_DPC_ID: Refs.push_back({TiRefKind::IndexRef, 24, 1}); // LF_FUNC_ID break; + case SymbolKind::S_GPROC32: + case SymbolKind::S_LPROC32: + Refs.push_back({TiRefKind::TypeRef, 24, 1}); // Type + break; case SymbolKind::S_UDT: Refs.push_back({TiRefKind::TypeRef, 0, 1}); // UDT break; diff --git a/contrib/llvm/lib/DebugInfo/CodeView/TypeRecordHelpers.cpp b/contrib/llvm/lib/DebugInfo/CodeView/TypeRecordHelpers.cpp index 2a66474cf5b6..8e632f3be460 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/TypeRecordHelpers.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/TypeRecordHelpers.cpp @@ -1,9 +1,8 @@ //===- TypeRecordHelpers.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/contrib/llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp b/contrib/llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp index 3203ff64d3b1..47928c2eef64 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp @@ -1,9 +1,8 @@ //===- TypeRecordMapping.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -22,19 +21,19 @@ struct MapOneMethodRecord { : IsFromOverloadList(IsFromOverloadList) {} Error operator()(CodeViewRecordIO &IO, OneMethodRecord &Method) const { - error(IO.mapInteger(Method.Attrs.Attrs)); + error(IO.mapInteger(Method.Attrs.Attrs, "AccessSpecifier")); if (IsFromOverloadList) { uint16_t Padding = 0; - error(IO.mapInteger(Padding)); + error(IO.mapInteger(Padding, "Padding")); } - error(IO.mapInteger(Method.Type)); + error(IO.mapInteger(Method.Type, "Type")); if (Method.isIntroducingVirtual()) { - error(IO.mapInteger(Method.VFTableOffset)); - } else if (!IO.isWriting()) + error(IO.mapInteger(Method.VFTableOffset, "VFTableOffset")); + } else if (IO.isReading()) Method.VFTableOffset = -1; if (!IsFromOverloadList) - error(IO.mapStringZ(Method.Name)); + error(IO.mapStringZ(Method.Name, "Name")); return Error::success(); } @@ -73,9 +72,12 @@ static Error mapNameAndUniqueName(CodeViewRecordIO &IO, StringRef &Name, error(IO.mapStringZ(N)); } } else { - error(IO.mapStringZ(Name)); + // Reading & Streaming mode come after writing mode is executed for each + // record. Truncating large names are done during writing, so its not + // necessary to do it while reading or streaming. + error(IO.mapStringZ(Name, "Name")); if (HasUniqueName) - error(IO.mapStringZ(UniqueName)); + error(IO.mapStringZ(UniqueName, "LinkageName")); } return Error::success(); @@ -89,14 +91,18 @@ Error TypeRecordMapping::visitTypeBegin(CVType &CVR) { // split with continuation records. All other record types cannot be // longer than the maximum record length. Optional<uint32_t> MaxLen; - if (CVR.Type != TypeLeafKind::LF_FIELDLIST && - CVR.Type != TypeLeafKind::LF_METHODLIST) + if (CVR.kind() != TypeLeafKind::LF_FIELDLIST && + CVR.kind() != TypeLeafKind::LF_METHODLIST) MaxLen = MaxRecordLength - sizeof(RecordPrefix); error(IO.beginRecord(MaxLen)); - TypeKind = CVR.Type; + TypeKind = CVR.kind(); return Error::success(); } +Error TypeRecordMapping::visitTypeBegin(CVType &CVR, TypeIndex Index) { + return visitTypeBegin(CVR); +} + Error TypeRecordMapping::visitTypeEnd(CVType &Record) { assert(TypeKind.hasValue() && "Not in a type mapping!"); assert(!MemberKind.hasValue() && "Still in a member mapping!"); @@ -127,7 +133,7 @@ Error TypeRecordMapping::visitMemberEnd(CVMemberRecord &Record) { assert(TypeKind.hasValue() && "Not in a type mapping!"); assert(MemberKind.hasValue() && "Not in a member mapping!"); - if (!IO.isWriting()) { + if (IO.isReading()) { if (auto EC = IO.skipPadding()) return EC; } @@ -138,33 +144,32 @@ Error TypeRecordMapping::visitMemberEnd(CVMemberRecord &Record) { } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, ModifierRecord &Record) { - error(IO.mapInteger(Record.ModifiedType)); - error(IO.mapEnum(Record.Modifiers)); - + error(IO.mapInteger(Record.ModifiedType, "ModifiedType")); + error(IO.mapEnum(Record.Modifiers, "Modifiers")); return Error::success(); } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, ProcedureRecord &Record) { - error(IO.mapInteger(Record.ReturnType)); - error(IO.mapEnum(Record.CallConv)); - error(IO.mapEnum(Record.Options)); - error(IO.mapInteger(Record.ParameterCount)); - error(IO.mapInteger(Record.ArgumentList)); + error(IO.mapInteger(Record.ReturnType, "ReturnType")); + error(IO.mapEnum(Record.CallConv, "CallingConvention")); + error(IO.mapEnum(Record.Options, "FunctionOptions")); + error(IO.mapInteger(Record.ParameterCount, "NumParameters")); + error(IO.mapInteger(Record.ArgumentList, "ArgListType")); return Error::success(); } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, MemberFunctionRecord &Record) { - error(IO.mapInteger(Record.ReturnType)); - error(IO.mapInteger(Record.ClassType)); - error(IO.mapInteger(Record.ThisType)); - error(IO.mapEnum(Record.CallConv)); - error(IO.mapEnum(Record.Options)); - error(IO.mapInteger(Record.ParameterCount)); - error(IO.mapInteger(Record.ArgumentList)); - error(IO.mapInteger(Record.ThisPointerAdjustment)); + error(IO.mapInteger(Record.ReturnType, "ReturnType")); + error(IO.mapInteger(Record.ClassType, "ClassType")); + error(IO.mapInteger(Record.ThisType, "ThisType")); + error(IO.mapEnum(Record.CallConv, "CallingConvention")); + error(IO.mapEnum(Record.Options, "FunctionOptions")); + error(IO.mapInteger(Record.ParameterCount, "NumParameters")); + error(IO.mapInteger(Record.ArgumentList, "ArgListType")); + error(IO.mapInteger(Record.ThisPointerAdjustment, "ThisAdjustment")); return Error::success(); } @@ -172,8 +177,10 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, Error TypeRecordMapping::visitKnownRecord(CVType &CVR, ArgListRecord &Record) { error(IO.mapVectorN<uint32_t>( Record.ArgIndices, - [](CodeViewRecordIO &IO, TypeIndex &N) { return IO.mapInteger(N); })); - + [](CodeViewRecordIO &IO, TypeIndex &N) { + return IO.mapInteger(N, "Argument"); + }, + "NumArgs")); return Error::success(); } @@ -181,47 +188,50 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, StringListRecord &Record) { error(IO.mapVectorN<uint32_t>( Record.StringIndices, - [](CodeViewRecordIO &IO, TypeIndex &N) { return IO.mapInteger(N); })); + [](CodeViewRecordIO &IO, TypeIndex &N) { + return IO.mapInteger(N, "Strings"); + }, + "NumStrings")); return Error::success(); } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, PointerRecord &Record) { - error(IO.mapInteger(Record.ReferentType)); - error(IO.mapInteger(Record.Attrs)); + error(IO.mapInteger(Record.ReferentType, "PointeeType")); + error(IO.mapInteger(Record.Attrs, "Attributes")); if (Record.isPointerToMember()) { - if (!IO.isWriting()) + if (IO.isReading()) Record.MemberInfo.emplace(); MemberPointerInfo &M = *Record.MemberInfo; - error(IO.mapInteger(M.ContainingType)); - error(IO.mapEnum(M.Representation)); + error(IO.mapInteger(M.ContainingType, "ClassType")); + error(IO.mapEnum(M.Representation, "Representation")); } return Error::success(); } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, ArrayRecord &Record) { - error(IO.mapInteger(Record.ElementType)); - error(IO.mapInteger(Record.IndexType)); - error(IO.mapEncodedInteger(Record.Size)); - error(IO.mapStringZ(Record.Name)); + error(IO.mapInteger(Record.ElementType, "ElementType")); + error(IO.mapInteger(Record.IndexType, "IndexType")); + error(IO.mapEncodedInteger(Record.Size, "SizeOf")); + error(IO.mapStringZ(Record.Name, "Name")); return Error::success(); } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, ClassRecord &Record) { - assert((CVR.Type == TypeLeafKind::LF_STRUCTURE) || - (CVR.Type == TypeLeafKind::LF_CLASS) || - (CVR.Type == TypeLeafKind::LF_INTERFACE)); - - error(IO.mapInteger(Record.MemberCount)); - error(IO.mapEnum(Record.Options)); - error(IO.mapInteger(Record.FieldList)); - error(IO.mapInteger(Record.DerivationList)); - error(IO.mapInteger(Record.VTableShape)); - error(IO.mapEncodedInteger(Record.Size)); + assert((CVR.kind() == TypeLeafKind::LF_STRUCTURE) || + (CVR.kind() == TypeLeafKind::LF_CLASS) || + (CVR.kind() == TypeLeafKind::LF_INTERFACE)); + + error(IO.mapInteger(Record.MemberCount, "MemberCount")); + error(IO.mapEnum(Record.Options, "Properties")); + error(IO.mapInteger(Record.FieldList, "FieldList")); + error(IO.mapInteger(Record.DerivationList, "DerivedFrom")); + error(IO.mapInteger(Record.VTableShape, "VShape")); + error(IO.mapEncodedInteger(Record.Size, "SizeOf")); error(mapNameAndUniqueName(IO, Record.Name, Record.UniqueName, Record.hasUniqueName())); @@ -229,10 +239,10 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, ClassRecord &Record) { } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, UnionRecord &Record) { - error(IO.mapInteger(Record.MemberCount)); - error(IO.mapEnum(Record.Options)); - error(IO.mapInteger(Record.FieldList)); - error(IO.mapEncodedInteger(Record.Size)); + error(IO.mapInteger(Record.MemberCount, "MemberCount")); + error(IO.mapEnum(Record.Options, "Properties")); + error(IO.mapInteger(Record.FieldList, "FieldList")); + error(IO.mapEncodedInteger(Record.Size, "SizeOf")); error(mapNameAndUniqueName(IO, Record.Name, Record.UniqueName, Record.hasUniqueName())); @@ -240,10 +250,10 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, UnionRecord &Record) { } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, EnumRecord &Record) { - error(IO.mapInteger(Record.MemberCount)); - error(IO.mapEnum(Record.Options)); - error(IO.mapInteger(Record.UnderlyingType)); - error(IO.mapInteger(Record.FieldList)); + error(IO.mapInteger(Record.MemberCount, "NumEnumerators")); + error(IO.mapEnum(Record.Options, "Properties")); + error(IO.mapInteger(Record.UnderlyingType, "UnderlyingType")); + error(IO.mapInteger(Record.FieldList, "FieldListType")); error(mapNameAndUniqueName(IO, Record.Name, Record.UniqueName, Record.hasUniqueName())); @@ -251,9 +261,9 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, EnumRecord &Record) { } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, BitFieldRecord &Record) { - error(IO.mapInteger(Record.Type)); - error(IO.mapInteger(Record.BitSize)); - error(IO.mapInteger(Record.BitOffset)); + error(IO.mapInteger(Record.Type, "Type")); + error(IO.mapInteger(Record.BitSize, "BitSize")); + error(IO.mapInteger(Record.BitOffset, "BitOffset")); return Error::success(); } @@ -261,10 +271,10 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, BitFieldRecord &Record) { Error TypeRecordMapping::visitKnownRecord(CVType &CVR, VFTableShapeRecord &Record) { uint16_t Size; - if (IO.isWriting()) { + if (!IO.isReading()) { ArrayRef<VFTableSlotKind> Slots = Record.getSlots(); Size = Slots.size(); - error(IO.mapInteger(Size)); + error(IO.mapInteger(Size, "VFEntryCount")); for (size_t SlotIndex = 0; SlotIndex < Slots.size(); SlotIndex += 2) { uint8_t Byte = static_cast<uint8_t>(Slots[SlotIndex]) << 4; @@ -288,61 +298,64 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, VFTableRecord &Record) { - error(IO.mapInteger(Record.CompleteClass)); - error(IO.mapInteger(Record.OverriddenVFTable)); - error(IO.mapInteger(Record.VFPtrOffset)); + error(IO.mapInteger(Record.CompleteClass, "CompleteClass")); + error(IO.mapInteger(Record.OverriddenVFTable, "OverriddenVFTable")); + error(IO.mapInteger(Record.VFPtrOffset, "VFPtrOffset")); uint32_t NamesLen = 0; - if (IO.isWriting()) { + if (!IO.isReading()) { for (auto Name : Record.MethodNames) NamesLen += Name.size() + 1; } error(IO.mapInteger(NamesLen)); error(IO.mapVectorTail( Record.MethodNames, - [](CodeViewRecordIO &IO, StringRef &S) { return IO.mapStringZ(S); })); + [](CodeViewRecordIO &IO, StringRef &S) { + return IO.mapStringZ(S, "MethodName"); + }, + "VFTableName")); return Error::success(); } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, StringIdRecord &Record) { - error(IO.mapInteger(Record.Id)); - error(IO.mapStringZ(Record.String)); + error(IO.mapInteger(Record.Id, "Id")); + error(IO.mapStringZ(Record.String, "StringData")); return Error::success(); } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, UdtSourceLineRecord &Record) { - error(IO.mapInteger(Record.UDT)); - error(IO.mapInteger(Record.SourceFile)); - error(IO.mapInteger(Record.LineNumber)); + error(IO.mapInteger(Record.UDT, "UDT")); + error(IO.mapInteger(Record.SourceFile, "SourceFile")); + error(IO.mapInteger(Record.LineNumber, "LineNumber")); return Error::success(); } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, UdtModSourceLineRecord &Record) { - error(IO.mapInteger(Record.UDT)); - error(IO.mapInteger(Record.SourceFile)); - error(IO.mapInteger(Record.LineNumber)); - error(IO.mapInteger(Record.Module)); + error(IO.mapInteger(Record.UDT, "UDT")); + error(IO.mapInteger(Record.SourceFile, "SourceFile")); + error(IO.mapInteger(Record.LineNumber, "LineNumber")); + error(IO.mapInteger(Record.Module, "Module")); return Error::success(); } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, FuncIdRecord &Record) { - error(IO.mapInteger(Record.ParentScope)); - error(IO.mapInteger(Record.FunctionType)); - error(IO.mapStringZ(Record.Name)); + error(IO.mapInteger(Record.ParentScope, "ParentScope")); + error(IO.mapInteger(Record.FunctionType, "FunctionType")); + error(IO.mapStringZ(Record.Name, "Name")); return Error::success(); } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, MemberFuncIdRecord &Record) { - error(IO.mapInteger(Record.ClassType)); - error(IO.mapInteger(Record.FunctionType)); - error(IO.mapStringZ(Record.Name)); + error(IO.mapInteger(Record.ClassType, "ClassType")); + error(IO.mapInteger(Record.FunctionType, "FunctionType")); + error(IO.mapStringZ(Record.Name, "Name")); return Error::success(); } @@ -351,7 +364,10 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, BuildInfoRecord &Record) { error(IO.mapVectorN<uint16_t>( Record.ArgIndices, - [](CodeViewRecordIO &IO, TypeIndex &N) { return IO.mapInteger(N); })); + [](CodeViewRecordIO &IO, TypeIndex &N) { + return IO.mapInteger(N, "Argument"); + }, + "NumArgs")); return Error::success(); } @@ -360,7 +376,7 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, MethodOverloadListRecord &Record) { // TODO: Split the list into multiple records if it's longer than 64KB, using // a subrecord of TypeRecordKind::Index to chain the records together. - error(IO.mapVectorTail(Record.Methods, MapOneMethodRecord(true))); + error(IO.mapVectorTail(Record.Methods, MapOneMethodRecord(true), "Method")); return Error::success(); } @@ -374,22 +390,22 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, Error TypeRecordMapping::visitKnownRecord(CVType &CVR, TypeServer2Record &Record) { - error(IO.mapGuid(Record.Guid)); - error(IO.mapInteger(Record.Age)); - error(IO.mapStringZ(Record.Name)); + error(IO.mapGuid(Record.Guid, "Guid")); + error(IO.mapInteger(Record.Age, "Age")); + error(IO.mapStringZ(Record.Name, "Name")); return Error::success(); } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, LabelRecord &Record) { - error(IO.mapEnum(Record.Mode)); + error(IO.mapEnum(Record.Mode, "Mode")); return Error::success(); } Error TypeRecordMapping::visitKnownMember(CVMemberRecord &CVR, BaseClassRecord &Record) { - error(IO.mapInteger(Record.Attrs.Attrs)); - error(IO.mapInteger(Record.Type)); - error(IO.mapEncodedInteger(Record.Offset)); + error(IO.mapInteger(Record.Attrs.Attrs, "AccessSpecifier")); + error(IO.mapInteger(Record.Type, "BaseType")); + error(IO.mapEncodedInteger(Record.Offset, "BaseOffset")); return Error::success(); } @@ -399,27 +415,27 @@ Error TypeRecordMapping::visitKnownMember(CVMemberRecord &CVR, error(IO.mapInteger(Record.Attrs.Attrs)); // FIXME: Handle full APInt such as __int128. - error(IO.mapEncodedInteger(Record.Value)); - error(IO.mapStringZ(Record.Name)); + error(IO.mapEncodedInteger(Record.Value, "EnumValue")); + error(IO.mapStringZ(Record.Name, "Name")); return Error::success(); } Error TypeRecordMapping::visitKnownMember(CVMemberRecord &CVR, DataMemberRecord &Record) { - error(IO.mapInteger(Record.Attrs.Attrs)); - error(IO.mapInteger(Record.Type)); - error(IO.mapEncodedInteger(Record.FieldOffset)); - error(IO.mapStringZ(Record.Name)); + error(IO.mapInteger(Record.Attrs.Attrs, "AccessSpecifier")); + error(IO.mapInteger(Record.Type, "Type")); + error(IO.mapEncodedInteger(Record.FieldOffset, "FieldOffset")); + error(IO.mapStringZ(Record.Name, "Name")); return Error::success(); } Error TypeRecordMapping::visitKnownMember(CVMemberRecord &CVR, OverloadedMethodRecord &Record) { - error(IO.mapInteger(Record.NumOverloads)); - error(IO.mapInteger(Record.MethodList)); - error(IO.mapStringZ(Record.Name)); + error(IO.mapInteger(Record.NumOverloads, "MethodCount")); + error(IO.mapInteger(Record.MethodList, "MethodListIndex")); + error(IO.mapStringZ(Record.Name, "Name")); return Error::success(); } @@ -434,9 +450,9 @@ Error TypeRecordMapping::visitKnownMember(CVMemberRecord &CVR, Error TypeRecordMapping::visitKnownMember(CVMemberRecord &CVR, NestedTypeRecord &Record) { uint16_t Padding = 0; - error(IO.mapInteger(Padding)); - error(IO.mapInteger(Record.Type)); - error(IO.mapStringZ(Record.Name)); + error(IO.mapInteger(Padding, "Padding")); + error(IO.mapInteger(Record.Type, "Type")); + error(IO.mapStringZ(Record.Name, "Name")); return Error::success(); } @@ -444,9 +460,9 @@ Error TypeRecordMapping::visitKnownMember(CVMemberRecord &CVR, Error TypeRecordMapping::visitKnownMember(CVMemberRecord &CVR, StaticDataMemberRecord &Record) { - error(IO.mapInteger(Record.Attrs.Attrs)); - error(IO.mapInteger(Record.Type)); - error(IO.mapStringZ(Record.Name)); + error(IO.mapInteger(Record.Attrs.Attrs, "AccessSpecifier")); + error(IO.mapInteger(Record.Type, "Type")); + error(IO.mapStringZ(Record.Name, "Name")); return Error::success(); } @@ -454,11 +470,11 @@ Error TypeRecordMapping::visitKnownMember(CVMemberRecord &CVR, Error TypeRecordMapping::visitKnownMember(CVMemberRecord &CVR, VirtualBaseClassRecord &Record) { - error(IO.mapInteger(Record.Attrs.Attrs)); - error(IO.mapInteger(Record.BaseType)); - error(IO.mapInteger(Record.VBPtrType)); - error(IO.mapEncodedInteger(Record.VBPtrOffset)); - error(IO.mapEncodedInteger(Record.VTableIndex)); + error(IO.mapInteger(Record.Attrs.Attrs, "AccessSpecifier")); + error(IO.mapInteger(Record.BaseType, "BaseType")); + error(IO.mapInteger(Record.VBPtrType, "VBPtrType")); + error(IO.mapEncodedInteger(Record.VBPtrOffset, "VBPtrOffset")); + error(IO.mapEncodedInteger(Record.VTableIndex, "VBTableIndex")); return Error::success(); } @@ -466,8 +482,8 @@ Error TypeRecordMapping::visitKnownMember(CVMemberRecord &CVR, Error TypeRecordMapping::visitKnownMember(CVMemberRecord &CVR, VFPtrRecord &Record) { uint16_t Padding = 0; - error(IO.mapInteger(Padding)); - error(IO.mapInteger(Record.Type)); + error(IO.mapInteger(Padding, "Padding")); + error(IO.mapInteger(Record.Type, "Type")); return Error::success(); } @@ -475,23 +491,23 @@ Error TypeRecordMapping::visitKnownMember(CVMemberRecord &CVR, Error TypeRecordMapping::visitKnownMember(CVMemberRecord &CVR, ListContinuationRecord &Record) { uint16_t Padding = 0; - error(IO.mapInteger(Padding)); - error(IO.mapInteger(Record.ContinuationIndex)); + error(IO.mapInteger(Padding, "Padding")); + error(IO.mapInteger(Record.ContinuationIndex, "ContinuationIndex")); return Error::success(); } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, PrecompRecord &Precomp) { - error(IO.mapInteger(Precomp.StartTypeIndex)); - error(IO.mapInteger(Precomp.TypesCount)); - error(IO.mapInteger(Precomp.Signature)); - error(IO.mapStringZ(Precomp.PrecompFilePath)); + error(IO.mapInteger(Precomp.StartTypeIndex, "StartIndex")); + error(IO.mapInteger(Precomp.TypesCount, "Count")); + error(IO.mapInteger(Precomp.Signature, "Signature")); + error(IO.mapStringZ(Precomp.PrecompFilePath, "PrecompFile")); return Error::success(); } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, EndPrecompRecord &EndPrecomp) { - error(IO.mapInteger(EndPrecomp.Signature)); + error(IO.mapInteger(EndPrecomp.Signature, "Signature")); return Error::success(); } diff --git a/contrib/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp b/contrib/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp index bae11ce6a6a1..aba0e96d606e 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp @@ -1,9 +1,8 @@ //===-- TypeStreamMerger.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/contrib/llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp b/contrib/llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp index cf951baa5111..e13068b5b1eb 100644 --- a/contrib/llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp +++ b/contrib/llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp @@ -1,9 +1,8 @@ //===- TypeTableCollection.cpp -------------------------------- *- C++ --*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -37,11 +36,7 @@ Optional<TypeIndex> TypeTableCollection::getNext(TypeIndex Prev) { CVType TypeTableCollection::getType(TypeIndex Index) { assert(Index.toArrayIndex() < Records.size()); - ArrayRef<uint8_t> Bytes = Records[Index.toArrayIndex()]; - const RecordPrefix *Prefix = - reinterpret_cast<const RecordPrefix *>(Bytes.data()); - TypeLeafKind Kind = static_cast<TypeLeafKind>(uint16_t(Prefix->RecordKind)); - return CVType(Kind, Bytes); + return CVType(Records[Index.toArrayIndex()]); } StringRef TypeTableCollection::getTypeName(TypeIndex Index) { |