[PDB] Add char8_t type

Differential Revision: https://reviews.llvm.org/D120690
This commit is contained in:
Zequan Wu 2022-02-28 17:22:56 -08:00
parent d88dfd2b31
commit 5c9e20d7d0
13 changed files with 63 additions and 1 deletions

View File

@ -0,0 +1,45 @@
; RUN: llc -mtriple x86_64-windows-msvc -filetype obj -o %t.obj %s
; RUN: lld-link /nodefaultlib /noentry /dll /debug /out:%t.exe /pdb:%t.pdb %t.obj
; RUN: llvm-pdbutil dump -type-index=0x7c %t.pdb
; CHECK: 0x007C (char8_t) | char8_t
define dso_local i32 @main() #0 !dbg !9 {
%1 = alloca i32, align 4
%2 = alloca i8, align 1
store i32 0, i32* %1, align 4
call void @llvm.dbg.declare(metadata i8* %2, metadata !13, metadata !DIExpression()), !dbg !15
store i8 0, i8* %2, align 1, !dbg !15
%3 = load i8, i8* %2, align 1, !dbg !16
%4 = zext i8 %3 to i32, !dbg !16
ret i32 %4, !dbg !16
}
; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
attributes #0 = { mustprogress noinline norecurse nounwind optnone uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
!llvm.dbg.cu = !{!0}
!llvm.linker.options = !{}
!llvm.module.flags = !{!3, !4, !5, !6, !7}
!llvm.ident = !{!8}
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 13.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
!1 = !DIFile(filename: "pdb_char8_t.cpp", directory: "C:\\src", checksumkind: CSK_MD5, checksum: "a00748d29f4e59003184945cd3e17ee3")
!2 = !{}
!3 = !{i32 2, !"CodeView", i32 1}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = !{i32 1, !"wchar_size", i32 2}
!6 = !{i32 7, !"PIC Level", i32 2}
!7 = !{i32 7, !"uwtable", i32 1}
!8 = !{!"clang version 13.0.0"}
!9 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 1, type: !10, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
!10 = !DISubroutineType(types: !11)
!11 = !{!12}
!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!13 = !DILocalVariable(name: "local", scope: !9, file: !1, line: 3, type: !14)
!14 = !DIBasicType(name: "char8_t", size: 8, encoding: DW_ATE_UTF)
!15 = !DILocation(line: 3, scope: !9)
!16 = !DILocation(line: 4, scope: !9)

View File

@ -749,6 +749,7 @@ enum BasicType {
eBasicTypeUnsignedWChar,
eBasicTypeChar16,
eBasicTypeChar32,
eBasicTypeChar8,
eBasicTypeShort,
eBasicTypeUnsignedShort,
eBasicTypeInt,

View File

@ -704,6 +704,8 @@ lldb_private::npdb::GetCompilerTypeForSimpleKind(SimpleTypeKind kind) {
return lldb::eBasicTypeChar16;
case SimpleTypeKind::Character32:
return lldb::eBasicTypeChar32;
case SimpleTypeKind::Character8:
return lldb::eBasicTypeChar8;
case SimpleTypeKind::Complex80:
return lldb::eBasicTypeLongDoubleComplex;
case SimpleTypeKind::Complex64:
@ -796,6 +798,7 @@ size_t lldb_private::npdb::GetTypeSizeForSimpleKind(SimpleTypeKind kind) {
case SimpleTypeKind::NarrowCharacter:
case SimpleTypeKind::SignedCharacter:
case SimpleTypeKind::SByte:
case SimpleTypeKind::Character8:
return 1;
case SimpleTypeKind::Void:
default:

View File

@ -173,6 +173,8 @@ static llvm::StringRef GetSimpleTypeName(SimpleTypeKind kind) {
return "char16_t";
case SimpleTypeKind::Character32:
return "char32_t";
case SimpleTypeKind::Character8:
return "char8_t";
case SimpleTypeKind::Complex80:
case SimpleTypeKind::Complex64:
case SimpleTypeKind::Complex32:

View File

@ -131,6 +131,7 @@ bitmask which can be decomposed as follows:
WideCharacter = 0x0071, // wide char
Character16 = 0x007a, // char16_t
Character32 = 0x007b, // char32_t
Character8 = 0x007c, // char8_t
SByte = 0x0068, // 8 bit signed int
Byte = 0x0069, // 8 bit unsigned int

View File

@ -35,6 +35,7 @@ enum class SimpleTypeKind : uint32_t {
WideCharacter = 0x0071, // wide char
Character16 = 0x007a, // char16_t
Character32 = 0x007b, // char32_t
Character8 = 0x007c, // char8_t
SByte = 0x0068, // 8 bit signed int
Byte = 0x0069, // 8 bit unsigned int

View File

@ -352,7 +352,8 @@ enum class PDB_BuiltinType {
BSTR = 30,
HResult = 31,
Char16 = 32,
Char32 = 33
Char32 = 33,
Char8 = 34,
};
/// These values correspond to the flags that can be combined to control the

View File

@ -1826,6 +1826,7 @@ TypeIndex CodeViewDebug::lowerTypeBasic(const DIBasicType *Ty) {
break;
case dwarf::DW_ATE_UTF:
switch (ByteSize) {
case 1: STK = SimpleTypeKind::Character8; break;
case 2: STK = SimpleTypeKind::Character16; break;
case 4: STK = SimpleTypeKind::Character32; break;
}

View File

@ -33,6 +33,7 @@ static const SimpleTypeEntry SimpleTypeNames[] = {
{"wchar_t*", SimpleTypeKind::WideCharacter},
{"char16_t*", SimpleTypeKind::Character16},
{"char32_t*", SimpleTypeKind::Character32},
{"char8_t*", SimpleTypeKind::Character8},
{"__int8*", SimpleTypeKind::SByte},
{"unsigned __int8*", SimpleTypeKind::Byte},
{"short*", SimpleTypeKind::Int16Short},

View File

@ -205,6 +205,8 @@ PDB_BuiltinType NativeTypeEnum::getBuiltinType() const {
return PDB_BuiltinType::Char16;
case SimpleTypeKind::Character32:
return PDB_BuiltinType::Char32;
case SimpleTypeKind::Character8:
return PDB_BuiltinType::Char8;
case SimpleTypeKind::Int128:
case SimpleTypeKind::Int128Oct:
case SimpleTypeKind::Int16:

View File

@ -67,6 +67,7 @@ static const struct BuiltinTypeEntry {
{codeview::SimpleTypeKind::WideCharacter, PDB_BuiltinType::WCharT, 2},
{codeview::SimpleTypeKind::Character16, PDB_BuiltinType::Char16, 2},
{codeview::SimpleTypeKind::Character32, PDB_BuiltinType::Char32, 4},
{codeview::SimpleTypeKind::Character8, PDB_BuiltinType::Char8, 1},
{codeview::SimpleTypeKind::SignedCharacter, PDB_BuiltinType::Char, 1},
{codeview::SimpleTypeKind::UnsignedCharacter, PDB_BuiltinType::UInt, 1},
{codeview::SimpleTypeKind::Float32, PDB_BuiltinType::Float, 4},

View File

@ -63,6 +63,7 @@ raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, HResult, OS)
CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Char16, OS)
CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Char32, OS)
CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Char8, OS)
}
return OS;
}

View File

@ -90,6 +90,8 @@ StringRef BuiltinDumper::getTypeName(const PDBSymbolTypeBuiltin &Symbol) {
return "char16_t";
case PDB_BuiltinType::Char32:
return "char32_t";
case PDB_BuiltinType::Char8:
return "char8_t";
case PDB_BuiltinType::None:
return "...";
}