Skip to content

[DebugInfo] Update CodeView enums #71038

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions llvm/include/llvm/DebugInfo/CodeView/CodeView.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,13 @@ enum class CPUType : uint16_t {
HybridX86ARM64 = 0xf7,
ARM64EC = 0xf8,
ARM64X = 0xf9,
Unknown = 0xff,
D3D11_Shader = 0x100,
};

/// These values correspond to the CV_CFL_LANG enumeration in the Microsoft
/// Debug Interface Access SDK
/// Debug Interface Access SDK, and are documented here:
/// https://learn.microsoft.com/en-us/visualstudio/debugger/debug-interface-access/cv-cfl-lang
enum SourceLanguage : uint8_t {
C = 0x00,
Cpp = 0x01,
Expand All @@ -161,13 +163,17 @@ enum SourceLanguage : uint8_t {
HLSL = 0x10,
ObjC = 0x11,
ObjCpp = 0x12,

Swift = 0x13,
AliasObj = 0x14,
Rust = 0x15,
Go = 0x16,

/// The DMD & Swift compilers emit 'D' and 'S', respectively, for the CV
/// source language. Microsoft does not have enumerators for them yet.
/// The DMD compiler emits 'D' for the CV source language. Microsoft does not
/// have an enumerator for it yet.
D = 'D',
Swift = 'S',
/// The Swift compiler used to emit 'S' for the CV source language, but
/// current versions emit the enumerator defined above.
OldSwift = 'S',
};

/// These values correspond to the CV_call_e enumeration, and are documented
Expand Down Expand Up @@ -200,7 +206,8 @@ enum class CallingConvention : uint8_t {
ClrCall = 0x16, // clr call
Inline =
0x17, // Marker for routines always inlined and thus lacking a convention
NearVector = 0x18 // near left to right push with regs, callee pops stack
NearVector = 0x18, // near left to right push with regs, callee pops stack
Swift = 0x19, // Swift call
};

enum class ClassOptions : uint16_t {
Expand Down
26 changes: 15 additions & 11 deletions llvm/lib/DebugInfo/CodeView/EnumTables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,19 @@ static const EnumEntry<uint8_t> FrameCookieKinds[] = {
};

static const EnumEntry<codeview::SourceLanguage> SourceLanguages[] = {
CV_ENUM_ENT(SourceLanguage, C), CV_ENUM_ENT(SourceLanguage, Cpp),
CV_ENUM_ENT(SourceLanguage, Fortran), CV_ENUM_ENT(SourceLanguage, Masm),
CV_ENUM_ENT(SourceLanguage, Pascal), CV_ENUM_ENT(SourceLanguage, Basic),
CV_ENUM_ENT(SourceLanguage, Cobol), CV_ENUM_ENT(SourceLanguage, Link),
CV_ENUM_ENT(SourceLanguage, Cvtres), CV_ENUM_ENT(SourceLanguage, Cvtpgd),
CV_ENUM_ENT(SourceLanguage, CSharp), CV_ENUM_ENT(SourceLanguage, VB),
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), CV_ENUM_ENT(SourceLanguage, Rust),
CV_ENUM_ENT(SourceLanguage, ObjC), CV_ENUM_ENT(SourceLanguage, ObjCpp),
CV_ENUM_ENT(SourceLanguage, C), CV_ENUM_ENT(SourceLanguage, Cpp),
CV_ENUM_ENT(SourceLanguage, Fortran), CV_ENUM_ENT(SourceLanguage, Masm),
CV_ENUM_ENT(SourceLanguage, Pascal), CV_ENUM_ENT(SourceLanguage, Basic),
CV_ENUM_ENT(SourceLanguage, Cobol), CV_ENUM_ENT(SourceLanguage, Link),
CV_ENUM_ENT(SourceLanguage, Cvtres), CV_ENUM_ENT(SourceLanguage, Cvtpgd),
CV_ENUM_ENT(SourceLanguage, CSharp), CV_ENUM_ENT(SourceLanguage, VB),
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), CV_ENUM_ENT(SourceLanguage, Rust),
CV_ENUM_ENT(SourceLanguage, ObjC), CV_ENUM_ENT(SourceLanguage, ObjCpp),
CV_ENUM_ENT(SourceLanguage, AliasObj), CV_ENUM_ENT(SourceLanguage, Go),
{"Swift", SourceLanguage::OldSwift},
};

static const EnumEntry<uint32_t> CompileSym2FlagNames[] = {
Expand Down Expand Up @@ -205,6 +207,7 @@ static const EnumEntry<unsigned> CPUTypeNames[] = {
CV_ENUM_CLASS_ENT(CPUType, HybridX86ARM64),
CV_ENUM_CLASS_ENT(CPUType, ARM64EC),
CV_ENUM_CLASS_ENT(CPUType, ARM64X),
CV_ENUM_CLASS_ENT(CPUType, Unknown),
CV_ENUM_CLASS_ENT(CPUType, D3D11_Shader),
};

Expand Down Expand Up @@ -421,6 +424,7 @@ static const EnumEntry<uint8_t> CallingConventions[] = {
CV_ENUM_CLASS_ENT(CallingConvention, ClrCall),
CV_ENUM_CLASS_ENT(CallingConvention, Inline),
CV_ENUM_CLASS_ENT(CallingConvention, NearVector),
CV_ENUM_CLASS_ENT(CallingConvention, Swift),
};

static const EnumEntry<uint8_t> FunctionOptionEnum[] = {
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ static const EnumEntry<uint8_t> CallingConventions[] = {
ENUM_ENTRY(CallingConvention, ClrCall),
ENUM_ENTRY(CallingConvention, Inline),
ENUM_ENTRY(CallingConvention, NearVector),
ENUM_ENTRY(CallingConvention, Swift),
};

static const EnumEntry<uint8_t> FunctionOptionEnum[] = {
Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/DebugInfo/PDB/PDBExtras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, ClrCall , "clrcall", OS)
CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Inline , "inlinecall", OS)
CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearVector , "vectorcall", OS)
CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Swift, "swiftcall", OS)
}
return OS;
}
Expand Down Expand Up @@ -234,6 +235,9 @@ raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const PDB_Lang &Lang) {
CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Rust, OS)
CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, ObjC, OS)
CASE_OUTPUT_ENUM_CLASS_STR(PDB_Lang, ObjCpp, "ObjC++", OS)
CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, AliasObj, OS)
CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Go, OS)
CASE_OUTPUT_ENUM_CLASS_STR(PDB_Lang, OldSwift, "Swift", OS)
}
return OS;
}
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/ObjectYAML/CodeViewYAMLTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ void ScalarEnumerationTraits<CallingConvention>::enumeration(
IO.enumCase(Value, "ClrCall", CallingConvention::ClrCall);
IO.enumCase(Value, "Inline", CallingConvention::Inline);
IO.enumCase(Value, "NearVector", CallingConvention::NearVector);
IO.enumCase(Value, "Swift", CallingConvention::Swift);
}

void ScalarEnumerationTraits<PointerKind>::enumeration(IO &IO,
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/DebugInfo/COFF/swift.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
; RUN: llc -filetype=obj < %s | llvm-readobj --codeview - | FileCheck %s --check-prefix=OBJ

; ASM: .short 4412 # Record kind: S_COMPILE3
; ASM-NEXT: .long 83 # Flags and language
; ASM-NEXT: .long 19 # Flags and language
; ASM-NEXT: .short 208 # CPUType

; OBJ-LABEL: Compile3Sym {
; OBJ-NEXT: Kind: S_COMPILE3 (0x113C)
; OBJ-NEXT: Language: Swift (0x53)
; OBJ-NEXT: Language: Swift (0x13)
; OBJ-NEXT: Flags [ (0x0)
; OBJ-NEXT: ]
; OBJ-NEXT: Machine: X64 (0xD0)
Expand Down
4 changes: 4 additions & 0 deletions llvm/tools/llvm-pdbutil/MinimalSymbolDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ static std::string formatSourceLanguage(SourceLanguage Lang) {
RETURN_CASE(SourceLanguage, Rust, "rust");
RETURN_CASE(SourceLanguage, ObjC, "objc");
RETURN_CASE(SourceLanguage, ObjCpp, "objc++");
RETURN_CASE(SourceLanguage, AliasObj, "aliasobj");
RETURN_CASE(SourceLanguage, Go, "go");
RETURN_CASE(SourceLanguage, OldSwift, "swift");
}
return formatUnknownEnum(Lang);
}
Expand Down Expand Up @@ -282,6 +285,7 @@ static std::string formatMachineType(CPUType Cpu) {
RETURN_CASE(CPUType, Thumb, "thumb");
RETURN_CASE(CPUType, ARMNT, "arm nt");
RETURN_CASE(CPUType, D3D11_Shader, "d3d11 shader");
RETURN_CASE(CPUType, Unknown, "unknown");
}
return formatUnknownEnum(Cpu);
}
Expand Down
1 change: 1 addition & 0 deletions llvm/tools/llvm-pdbutil/MinimalTypeDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ static std::string formatCallingConvention(CallingConvention Convention) {
RETURN_CASE(CallingConvention, PpcCall, "ppccall");
RETURN_CASE(CallingConvention, SHCall, "shcall");
RETURN_CASE(CallingConvention, SH5Call, "sh5call");
RETURN_CASE(CallingConvention, Swift, "swift");
RETURN_CASE(CallingConvention, ThisCall, "thiscall");
RETURN_CASE(CallingConvention, TriCall, "tricall");
}
Expand Down