[Lldb-commits] [lldb] 5c9e20d - [PDB] Add char8_t type

Zequan Wu via lldb-commits lldb-commits at lists.llvm.org
Tue Mar 1 13:40:00 PST 2022


Author: Zequan Wu
Date: 2022-03-01T13:39:51-08:00
New Revision: 5c9e20d7d0a71439a95875ba6067f9c0fc7a4e04

URL: https://github.com/llvm/llvm-project/commit/5c9e20d7d0a71439a95875ba6067f9c0fc7a4e04
DIFF: https://github.com/llvm/llvm-project/commit/5c9e20d7d0a71439a95875ba6067f9c0fc7a4e04.diff

LOG: [PDB] Add char8_t type

Differential Revision: https://reviews.llvm.org/D120690

Added: 
    lld/test/COFF/pdb_char8_t.ll

Modified: 
    lldb/include/lldb/lldb-enumerations.h
    lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
    lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
    llvm/docs/PDB/TpiStream.rst
    llvm/include/llvm/DebugInfo/CodeView/TypeIndex.h
    llvm/include/llvm/DebugInfo/PDB/PDBTypes.h
    llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
    llvm/lib/DebugInfo/CodeView/TypeIndex.cpp
    llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp
    llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp
    llvm/lib/DebugInfo/PDB/PDBExtras.cpp
    llvm/tools/llvm-pdbutil/PrettyBuiltinDumper.cpp

Removed: 
    


################################################################################
diff  --git a/lld/test/COFF/pdb_char8_t.ll b/lld/test/COFF/pdb_char8_t.ll
new file mode 100644
index 0000000000000..0bae6e03a6178
--- /dev/null
+++ b/lld/test/COFF/pdb_char8_t.ll
@@ -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)

diff  --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h
index f5cabc02bd84e..529ab001a761f 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -749,6 +749,7 @@ enum BasicType {
   eBasicTypeUnsignedWChar,
   eBasicTypeChar16,
   eBasicTypeChar32,
+  eBasicTypeChar8,
   eBasicTypeShort,
   eBasicTypeUnsignedShort,
   eBasicTypeInt,

diff  --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
index b5a16447d9cfb..6efad1219852c 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
@@ -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:

diff  --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
index 8ecfadf777169..14bb21b357086 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -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:

diff  --git a/llvm/docs/PDB/TpiStream.rst b/llvm/docs/PDB/TpiStream.rst
index d0565e269ff8d..a6d6daad2abc0 100644
--- a/llvm/docs/PDB/TpiStream.rst
+++ b/llvm/docs/PDB/TpiStream.rst
@@ -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

diff  --git a/llvm/include/llvm/DebugInfo/CodeView/TypeIndex.h b/llvm/include/llvm/DebugInfo/CodeView/TypeIndex.h
index b7ac6d214cbab..653eafa04e0ab 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/TypeIndex.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/TypeIndex.h
@@ -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

diff  --git a/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h b/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h
index e7c2ded1bee1d..b6a794ad7e760 100644
--- a/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h
+++ b/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h
@@ -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

diff  --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 6cc30ebe5ce9f..27d03356dbfcc 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -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;
     }

diff  --git a/llvm/lib/DebugInfo/CodeView/TypeIndex.cpp b/llvm/lib/DebugInfo/CodeView/TypeIndex.cpp
index 604d342448d3f..3aead9d500412 100644
--- a/llvm/lib/DebugInfo/CodeView/TypeIndex.cpp
+++ b/llvm/lib/DebugInfo/CodeView/TypeIndex.cpp
@@ -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},

diff  --git a/llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp
index f347e0d22f56f..fcb642ffa940a 100644
--- a/llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp
@@ -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:

diff  --git a/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp b/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp
index b3efbf97b4630..37ff5c69f1226 100644
--- a/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp
@@ -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},

diff  --git a/llvm/lib/DebugInfo/PDB/PDBExtras.cpp b/llvm/lib/DebugInfo/PDB/PDBExtras.cpp
index 45503aecef3a6..571510e6bad9c 100644
--- a/llvm/lib/DebugInfo/PDB/PDBExtras.cpp
+++ b/llvm/lib/DebugInfo/PDB/PDBExtras.cpp
@@ -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;
 }

diff  --git a/llvm/tools/llvm-pdbutil/PrettyBuiltinDumper.cpp b/llvm/tools/llvm-pdbutil/PrettyBuiltinDumper.cpp
index cd01a40048191..a33c033cd83de 100644
--- a/llvm/tools/llvm-pdbutil/PrettyBuiltinDumper.cpp
+++ b/llvm/tools/llvm-pdbutil/PrettyBuiltinDumper.cpp
@@ -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 "...";
   }


        


More information about the lldb-commits mailing list