Skip to content

Commit

Permalink
Temporarily revert "Changes to improve CodeView debug info type recor…
Browse files Browse the repository at this point in the history
…d inline comments"

due to a sanitizer failure.

This reverts commit 367623.

llvm-svn: 367640
  • Loading branch information
echristo committed Aug 2, 2019
1 parent 975c51c commit 5a00b07
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 635 deletions.
10 changes: 1 addition & 9 deletions llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ class CodeViewRecordStreamer {
virtual void EmitIntValue(uint64_t Value, unsigned Size) = 0;
virtual void EmitBinaryData(StringRef Data) = 0;
virtual void AddComment(const Twine &T) = 0;
virtual void AddRawComment(const Twine &T) = 0;
virtual bool isVerboseAsm() = 0;
virtual StringRef getTypeName(TypeIndex TI) = 0;
virtual ~CodeViewRecordStreamer() = default;
};

Expand Down Expand Up @@ -209,11 +206,6 @@ class CodeViewRecordIO {
return 0;
}

void emitRawComment(const Twine &T) {
if (isStreaming())
Streamer->AddRawComment(T);
}

private:
void emitEncodedSignedInteger(const int64_t &Value,
const Twine &Comment = "");
Expand All @@ -233,7 +225,7 @@ class CodeViewRecordIO {
}

void emitComment(const Twine &Comment) {
if (isStreaming() && Streamer->isVerboseAsm()) {
if (isStreaming()) {
Twine TComment(Comment);
if (!TComment.isTriviallyEmpty())
Streamer->AddComment(TComment);
Expand Down
11 changes: 0 additions & 11 deletions llvm/include/llvm/DebugInfo/CodeView/EnumTables.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,6 @@ ArrayRef<EnumEntry<uint8_t>> getThunkOrdinalNames();
ArrayRef<EnumEntry<uint16_t>> getTrampolineNames();
ArrayRef<EnumEntry<COFF::SectionCharacteristics>>
getImageSectionCharacteristicNames();
ArrayRef<EnumEntry<uint16_t>> getClassOptionNames();
ArrayRef<EnumEntry<uint8_t>> getMemberAccessNames();
ArrayRef<EnumEntry<uint16_t>> getMethodOptionNames();
ArrayRef<EnumEntry<uint16_t>> getMemberKindNames();
ArrayRef<EnumEntry<uint8_t>> getPtrKindNames();
ArrayRef<EnumEntry<uint8_t>> getPtrModeNames();
ArrayRef<EnumEntry<uint16_t>> getPtrMemberRepNames();
ArrayRef<EnumEntry<uint16_t>> getTypeModifierNames();
ArrayRef<EnumEntry<uint8_t>> getCallingConventions();
ArrayRef<EnumEntry<uint8_t>> getFunctionOptionEnum();
ArrayRef<EnumEntry<uint16_t>> getLabelTypeEnum();

} // end namespace codeview
} // end namespace llvm
Expand Down
40 changes: 20 additions & 20 deletions llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ using namespace llvm::codeview;
namespace {
class CVMCAdapter : public CodeViewRecordStreamer {
public:
CVMCAdapter(MCStreamer &OS, TypeCollection &TypeTable)
: OS(&OS), TypeTable(TypeTable) {}
CVMCAdapter(MCStreamer &OS) : OS(&OS) {}

void EmitBytes(StringRef Data) { OS->EmitBytes(Data); }

Expand All @@ -111,24 +110,8 @@ class CVMCAdapter : public CodeViewRecordStreamer {

void AddComment(const Twine &T) { OS->AddComment(T); }

void AddRawComment(const Twine &T) { OS->emitRawComment(T); }

bool isVerboseAsm() { return OS->isVerboseAsm(); }

StringRef getTypeName(TypeIndex TI) {
StringRef TypeName;
if (!TI.isNoneType()) {
if (TI.isSimple())
TypeName = TypeIndex::simpleTypeName(TI);
else
TypeName = TypeTable.getTypeName(TI);
}
return TypeName;
}

private:
MCStreamer *OS = nullptr;
TypeCollection &TypeTable;
};
} // namespace

Expand Down Expand Up @@ -634,6 +617,13 @@ emitNullTerminatedSymbolName(MCStreamer &OS, StringRef S,
OS.EmitBytes(NullTerminatedString);
}

static StringRef getTypeLeafName(TypeLeafKind TypeKind) {
for (const EnumEntry<TypeLeafKind> &EE : getTypeLeafNames())
if (EE.Value == TypeKind)
return EE.Name;
return "";
}

void CodeViewDebug::emitTypeInformation() {
if (TypeTable.empty())
return;
Expand All @@ -650,11 +640,11 @@ void CodeViewDebug::emitTypeInformation() {
}

TypeTableCollection Table(TypeTable.records());
TypeVisitorCallbackPipeline Pipeline;
SmallString<512> CommentBlock;
raw_svector_ostream CommentOS(CommentBlock);
std::unique_ptr<ScopedPrinter> SP;
std::unique_ptr<TypeDumpVisitor> TDV;
TypeVisitorCallbackPipeline Pipeline;

if (OS.isVerboseAsm()) {
// To construct block comment describing the type record for readability.
Expand All @@ -665,7 +655,7 @@ void CodeViewDebug::emitTypeInformation() {
}

// To emit type record using Codeview MCStreamer adapter
CVMCAdapter CVMCOS(OS, Table);
CVMCAdapter CVMCOS(OS);
TypeRecordMapping typeMapping(CVMCOS);
Pipeline.addCallbackToPipeline(typeMapping);

Expand All @@ -675,6 +665,16 @@ void CodeViewDebug::emitTypeInformation() {
CVType Record = Table.getType(*B);

CommentBlock.clear();

auto RecordLen = Record.length();
auto RecordKind = Record.kind();
if (OS.isVerboseAsm())
CVMCOS.AddComment("Record length");
CVMCOS.EmitIntValue(RecordLen - 2, 2);
if (OS.isVerboseAsm())
CVMCOS.AddComment("Record kind: " + getTypeLeafName(RecordKind));
CVMCOS.EmitIntValue(RecordKind, sizeof(RecordKind));

Error E = codeview::visitTypeRecord(Record, *B, Pipeline);

if (E) {
Expand Down
6 changes: 1 addition & 5 deletions llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,7 @@ Error CodeViewRecordIO::mapByteVectorTail(std::vector<uint8_t> &Bytes,

Error CodeViewRecordIO::mapInteger(TypeIndex &TypeInd, const Twine &Comment) {
if (isStreaming()) {
StringRef TypeNameStr = Streamer->getTypeName(TypeInd);
if (!TypeNameStr.empty())
emitComment(Comment + ": " + TypeNameStr);
else
emitComment(Comment);
emitComment(Comment);
Streamer->EmitIntValue(TypeInd.getIndex(), sizeof(TypeInd.getIndex()));
incrStreamedLen(sizeof(TypeInd.getIndex()));
} else if (isWriting()) {
Expand Down
166 changes: 0 additions & 166 deletions llvm/lib/DebugInfo/CodeView/EnumTables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,128 +300,6 @@ static const EnumEntry<COFF::SectionCharacteristics>
CV_ENUM_ENT(COFF, IMAGE_SCN_MEM_READ),
CV_ENUM_ENT(COFF, IMAGE_SCN_MEM_WRITE)};

static const EnumEntry<uint16_t> ClassOptionNames[] = {
CV_ENUM_CLASS_ENT(ClassOptions, Packed),
CV_ENUM_CLASS_ENT(ClassOptions, HasConstructorOrDestructor),
CV_ENUM_CLASS_ENT(ClassOptions, HasOverloadedOperator),
CV_ENUM_CLASS_ENT(ClassOptions, Nested),
CV_ENUM_CLASS_ENT(ClassOptions, ContainsNestedClass),
CV_ENUM_CLASS_ENT(ClassOptions, HasOverloadedAssignmentOperator),
CV_ENUM_CLASS_ENT(ClassOptions, HasConversionOperator),
CV_ENUM_CLASS_ENT(ClassOptions, ForwardReference),
CV_ENUM_CLASS_ENT(ClassOptions, Scoped),
CV_ENUM_CLASS_ENT(ClassOptions, HasUniqueName),
CV_ENUM_CLASS_ENT(ClassOptions, Sealed),
CV_ENUM_CLASS_ENT(ClassOptions, Intrinsic),
};

static const EnumEntry<uint8_t> MemberAccessNames[] = {
CV_ENUM_CLASS_ENT(MemberAccess, None),
CV_ENUM_CLASS_ENT(MemberAccess, Private),
CV_ENUM_CLASS_ENT(MemberAccess, Protected),
CV_ENUM_CLASS_ENT(MemberAccess, Public),
};

static const EnumEntry<uint16_t> MethodOptionNames[] = {
CV_ENUM_CLASS_ENT(MethodOptions, Pseudo),
CV_ENUM_CLASS_ENT(MethodOptions, NoInherit),
CV_ENUM_CLASS_ENT(MethodOptions, NoConstruct),
CV_ENUM_CLASS_ENT(MethodOptions, CompilerGenerated),
CV_ENUM_CLASS_ENT(MethodOptions, Sealed),
};

static const EnumEntry<uint16_t> MemberKindNames[] = {
CV_ENUM_CLASS_ENT(MethodKind, Vanilla),
CV_ENUM_CLASS_ENT(MethodKind, Virtual),
CV_ENUM_CLASS_ENT(MethodKind, Static),
CV_ENUM_CLASS_ENT(MethodKind, Friend),
CV_ENUM_CLASS_ENT(MethodKind, IntroducingVirtual),
CV_ENUM_CLASS_ENT(MethodKind, PureVirtual),
CV_ENUM_CLASS_ENT(MethodKind, PureIntroducingVirtual),
};

static const EnumEntry<uint8_t> PtrKindNames[] = {
CV_ENUM_CLASS_ENT(PointerKind, Near16),
CV_ENUM_CLASS_ENT(PointerKind, Far16),
CV_ENUM_CLASS_ENT(PointerKind, Huge16),
CV_ENUM_CLASS_ENT(PointerKind, BasedOnSegment),
CV_ENUM_CLASS_ENT(PointerKind, BasedOnValue),
CV_ENUM_CLASS_ENT(PointerKind, BasedOnSegmentValue),
CV_ENUM_CLASS_ENT(PointerKind, BasedOnAddress),
CV_ENUM_CLASS_ENT(PointerKind, BasedOnSegmentAddress),
CV_ENUM_CLASS_ENT(PointerKind, BasedOnType),
CV_ENUM_CLASS_ENT(PointerKind, BasedOnSelf),
CV_ENUM_CLASS_ENT(PointerKind, Near32),
CV_ENUM_CLASS_ENT(PointerKind, Far32),
CV_ENUM_CLASS_ENT(PointerKind, Near64),
};

static const EnumEntry<uint8_t> PtrModeNames[] = {
CV_ENUM_CLASS_ENT(PointerMode, Pointer),
CV_ENUM_CLASS_ENT(PointerMode, LValueReference),
CV_ENUM_CLASS_ENT(PointerMode, PointerToDataMember),
CV_ENUM_CLASS_ENT(PointerMode, PointerToMemberFunction),
CV_ENUM_CLASS_ENT(PointerMode, RValueReference),
};

static const EnumEntry<uint16_t> PtrMemberRepNames[] = {
CV_ENUM_CLASS_ENT(PointerToMemberRepresentation, Unknown),
CV_ENUM_CLASS_ENT(PointerToMemberRepresentation, SingleInheritanceData),
CV_ENUM_CLASS_ENT(PointerToMemberRepresentation, MultipleInheritanceData),
CV_ENUM_CLASS_ENT(PointerToMemberRepresentation, VirtualInheritanceData),
CV_ENUM_CLASS_ENT(PointerToMemberRepresentation, GeneralData),
CV_ENUM_CLASS_ENT(PointerToMemberRepresentation, SingleInheritanceFunction),
CV_ENUM_CLASS_ENT(PointerToMemberRepresentation,
MultipleInheritanceFunction),
CV_ENUM_CLASS_ENT(PointerToMemberRepresentation,
VirtualInheritanceFunction),
CV_ENUM_CLASS_ENT(PointerToMemberRepresentation, GeneralFunction),
};

static const EnumEntry<uint16_t> TypeModifierNames[] = {
CV_ENUM_CLASS_ENT(ModifierOptions, Const),
CV_ENUM_CLASS_ENT(ModifierOptions, Volatile),
CV_ENUM_CLASS_ENT(ModifierOptions, Unaligned),
};

static const EnumEntry<uint8_t> CallingConventions[] = {
CV_ENUM_CLASS_ENT(CallingConvention, NearC),
CV_ENUM_CLASS_ENT(CallingConvention, FarC),
CV_ENUM_CLASS_ENT(CallingConvention, NearPascal),
CV_ENUM_CLASS_ENT(CallingConvention, FarPascal),
CV_ENUM_CLASS_ENT(CallingConvention, NearFast),
CV_ENUM_CLASS_ENT(CallingConvention, FarFast),
CV_ENUM_CLASS_ENT(CallingConvention, NearStdCall),
CV_ENUM_CLASS_ENT(CallingConvention, FarStdCall),
CV_ENUM_CLASS_ENT(CallingConvention, NearSysCall),
CV_ENUM_CLASS_ENT(CallingConvention, FarSysCall),
CV_ENUM_CLASS_ENT(CallingConvention, ThisCall),
CV_ENUM_CLASS_ENT(CallingConvention, MipsCall),
CV_ENUM_CLASS_ENT(CallingConvention, Generic),
CV_ENUM_CLASS_ENT(CallingConvention, AlphaCall),
CV_ENUM_CLASS_ENT(CallingConvention, PpcCall),
CV_ENUM_CLASS_ENT(CallingConvention, SHCall),
CV_ENUM_CLASS_ENT(CallingConvention, ArmCall),
CV_ENUM_CLASS_ENT(CallingConvention, AM33Call),
CV_ENUM_CLASS_ENT(CallingConvention, TriCall),
CV_ENUM_CLASS_ENT(CallingConvention, SH5Call),
CV_ENUM_CLASS_ENT(CallingConvention, M32RCall),
CV_ENUM_CLASS_ENT(CallingConvention, ClrCall),
CV_ENUM_CLASS_ENT(CallingConvention, Inline),
CV_ENUM_CLASS_ENT(CallingConvention, NearVector),
};

static const EnumEntry<uint8_t> FunctionOptionEnum[] = {
CV_ENUM_CLASS_ENT(FunctionOptions, CxxReturnUdt),
CV_ENUM_CLASS_ENT(FunctionOptions, Constructor),
CV_ENUM_CLASS_ENT(FunctionOptions, ConstructorWithVirtualBases),
};

static const EnumEntry<uint16_t> LabelTypeEnum[] = {
CV_ENUM_CLASS_ENT(LabelType, Near),
CV_ENUM_CLASS_ENT(LabelType, Far),
};

namespace llvm {
namespace codeview {

Expand Down Expand Up @@ -501,49 +379,5 @@ getImageSectionCharacteristicNames() {
return makeArrayRef(ImageSectionCharacteristicNames);
}

ArrayRef<EnumEntry<uint16_t>> getClassOptionNames() {
return makeArrayRef(ClassOptionNames);
}

ArrayRef<EnumEntry<uint8_t>> getMemberAccessNames() {
return makeArrayRef(MemberAccessNames);
}

ArrayRef<EnumEntry<uint16_t>> getMethodOptionNames() {
return makeArrayRef(MethodOptionNames);
}

ArrayRef<EnumEntry<uint16_t>> getMemberKindNames() {
return makeArrayRef(MemberKindNames);
}

ArrayRef<EnumEntry<uint8_t>> getPtrKindNames() {
return makeArrayRef(PtrKindNames);
}

ArrayRef<EnumEntry<uint8_t>> getPtrModeNames() {
return makeArrayRef(PtrModeNames);
}

ArrayRef<EnumEntry<uint16_t>> getPtrMemberRepNames() {
return makeArrayRef(PtrMemberRepNames);
}

ArrayRef<EnumEntry<uint16_t>> getTypeModifierNames() {
return makeArrayRef(TypeModifierNames);
}

ArrayRef<EnumEntry<uint8_t>> getCallingConventions() {
return makeArrayRef(CallingConventions);
}

ArrayRef<EnumEntry<uint8_t>> getFunctionOptionEnum() {
return makeArrayRef(FunctionOptionEnum);
}

ArrayRef<EnumEntry<uint16_t>> getLabelTypeEnum() {
return makeArrayRef(LabelTypeEnum);
}

} // end namespace codeview
} // end namespace llvm
Loading

0 comments on commit 5a00b07

Please sign in to comment.