Skip to content

Commit 32eb95c

Browse files
authored
[DebugInfo] Update CodeView enums (#71038)
This adds the following values to the CodeView.h enums (and updates the various functions that use them): * CPUType: * Added `Unknown` * This is not currently documented in the online documentation, but this is present in `cvconst.h` in the latest DIA SDK (Visual Studio 2022, 17.7.6) * `Unknown` is the CPUType that is emitted by `aliasobj.exe` in the Compile3Sym records, and can be found in objects that link with `oldnames.lib` ![image](https://github.com/llvm/llvm-project/assets/69168929/8ee7b032-761b-45da-8439-d07aba797940) * SourceLanguage (All of these are documented at https://learn.microsoft.com/en-us/visualstudio/debugger/debug-interface-access/cv-cfl-lang?view=vs-2022 and are present in `cvconst.h` in the latest DIA SDK (Visual Studio 2022, 17.7.6)) * Added Go * Added AliasObj * emitted by `aliasobj.exe` in certain records, can be found in PDBs that link with `oldnames.lib` * Changed Swift to the official Microsoft enumeration * Added `OldSwift` * The old Swift enumeration of `S` was changed to `OldSwift` to allow pdb dumping utilities to continue to emit correct source language information for old PDBs ### WARNING The `Swift` change is a potentially breaking change, as the swift compiler will now emit `0x13` for the SourceLanguage type in PDB records instead of `S`. This could potentially break utilities that relied on the old enum value. * CallType * Added Swift * This is not currently documented in the online documentation, but this is present in `cvconst.h` in the latest DIA SDK (Visual Studio 2022, 17.7.6)
1 parent 85598ae commit 32eb95c

File tree

8 files changed

+41
-19
lines changed

8 files changed

+41
-19
lines changed

llvm/include/llvm/DebugInfo/CodeView/CodeView.h

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,13 @@ enum class CPUType : uint16_t {
136136
HybridX86ARM64 = 0xf7,
137137
ARM64EC = 0xf8,
138138
ARM64X = 0xf9,
139+
Unknown = 0xff,
139140
D3D11_Shader = 0x100,
140141
};
141142

142143
/// These values correspond to the CV_CFL_LANG enumeration in the Microsoft
143-
/// Debug Interface Access SDK
144+
/// Debug Interface Access SDK, and are documented here:
145+
/// https://learn.microsoft.com/en-us/visualstudio/debugger/debug-interface-access/cv-cfl-lang
144146
enum SourceLanguage : uint8_t {
145147
C = 0x00,
146148
Cpp = 0x01,
@@ -161,13 +163,17 @@ enum SourceLanguage : uint8_t {
161163
HLSL = 0x10,
162164
ObjC = 0x11,
163165
ObjCpp = 0x12,
164-
166+
Swift = 0x13,
167+
AliasObj = 0x14,
165168
Rust = 0x15,
169+
Go = 0x16,
166170

167-
/// The DMD & Swift compilers emit 'D' and 'S', respectively, for the CV
168-
/// source language. Microsoft does not have enumerators for them yet.
171+
/// The DMD compiler emits 'D' for the CV source language. Microsoft does not
172+
/// have an enumerator for it yet.
169173
D = 'D',
170-
Swift = 'S',
174+
/// The Swift compiler used to emit 'S' for the CV source language, but
175+
/// current versions emit the enumerator defined above.
176+
OldSwift = 'S',
171177
};
172178

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

206213
enum class ClassOptions : uint16_t {

llvm/lib/DebugInfo/CodeView/EnumTables.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,19 @@ static const EnumEntry<uint8_t> FrameCookieKinds[] = {
9595
};
9696

9797
static const EnumEntry<codeview::SourceLanguage> SourceLanguages[] = {
98-
CV_ENUM_ENT(SourceLanguage, C), CV_ENUM_ENT(SourceLanguage, Cpp),
99-
CV_ENUM_ENT(SourceLanguage, Fortran), CV_ENUM_ENT(SourceLanguage, Masm),
100-
CV_ENUM_ENT(SourceLanguage, Pascal), CV_ENUM_ENT(SourceLanguage, Basic),
101-
CV_ENUM_ENT(SourceLanguage, Cobol), CV_ENUM_ENT(SourceLanguage, Link),
102-
CV_ENUM_ENT(SourceLanguage, Cvtres), CV_ENUM_ENT(SourceLanguage, Cvtpgd),
103-
CV_ENUM_ENT(SourceLanguage, CSharp), CV_ENUM_ENT(SourceLanguage, VB),
104-
CV_ENUM_ENT(SourceLanguage, ILAsm), CV_ENUM_ENT(SourceLanguage, Java),
105-
CV_ENUM_ENT(SourceLanguage, JScript), CV_ENUM_ENT(SourceLanguage, MSIL),
106-
CV_ENUM_ENT(SourceLanguage, HLSL), CV_ENUM_ENT(SourceLanguage, D),
107-
CV_ENUM_ENT(SourceLanguage, Swift), CV_ENUM_ENT(SourceLanguage, Rust),
108-
CV_ENUM_ENT(SourceLanguage, ObjC), CV_ENUM_ENT(SourceLanguage, ObjCpp),
98+
CV_ENUM_ENT(SourceLanguage, C), CV_ENUM_ENT(SourceLanguage, Cpp),
99+
CV_ENUM_ENT(SourceLanguage, Fortran), CV_ENUM_ENT(SourceLanguage, Masm),
100+
CV_ENUM_ENT(SourceLanguage, Pascal), CV_ENUM_ENT(SourceLanguage, Basic),
101+
CV_ENUM_ENT(SourceLanguage, Cobol), CV_ENUM_ENT(SourceLanguage, Link),
102+
CV_ENUM_ENT(SourceLanguage, Cvtres), CV_ENUM_ENT(SourceLanguage, Cvtpgd),
103+
CV_ENUM_ENT(SourceLanguage, CSharp), CV_ENUM_ENT(SourceLanguage, VB),
104+
CV_ENUM_ENT(SourceLanguage, ILAsm), CV_ENUM_ENT(SourceLanguage, Java),
105+
CV_ENUM_ENT(SourceLanguage, JScript), CV_ENUM_ENT(SourceLanguage, MSIL),
106+
CV_ENUM_ENT(SourceLanguage, HLSL), CV_ENUM_ENT(SourceLanguage, D),
107+
CV_ENUM_ENT(SourceLanguage, Swift), CV_ENUM_ENT(SourceLanguage, Rust),
108+
CV_ENUM_ENT(SourceLanguage, ObjC), CV_ENUM_ENT(SourceLanguage, ObjCpp),
109+
CV_ENUM_ENT(SourceLanguage, AliasObj), CV_ENUM_ENT(SourceLanguage, Go),
110+
{"Swift", SourceLanguage::OldSwift},
109111
};
110112

111113
static const EnumEntry<uint32_t> CompileSym2FlagNames[] = {
@@ -205,6 +207,7 @@ static const EnumEntry<unsigned> CPUTypeNames[] = {
205207
CV_ENUM_CLASS_ENT(CPUType, HybridX86ARM64),
206208
CV_ENUM_CLASS_ENT(CPUType, ARM64EC),
207209
CV_ENUM_CLASS_ENT(CPUType, ARM64X),
210+
CV_ENUM_CLASS_ENT(CPUType, Unknown),
208211
CV_ENUM_CLASS_ENT(CPUType, D3D11_Shader),
209212
};
210213

@@ -421,6 +424,7 @@ static const EnumEntry<uint8_t> CallingConventions[] = {
421424
CV_ENUM_CLASS_ENT(CallingConvention, ClrCall),
422425
CV_ENUM_CLASS_ENT(CallingConvention, Inline),
423426
CV_ENUM_CLASS_ENT(CallingConvention, NearVector),
427+
CV_ENUM_CLASS_ENT(CallingConvention, Swift),
424428
};
425429

426430
static const EnumEntry<uint8_t> FunctionOptionEnum[] = {

llvm/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ static const EnumEntry<uint8_t> CallingConventions[] = {
133133
ENUM_ENTRY(CallingConvention, ClrCall),
134134
ENUM_ENTRY(CallingConvention, Inline),
135135
ENUM_ENTRY(CallingConvention, NearVector),
136+
ENUM_ENTRY(CallingConvention, Swift),
136137
};
137138

138139
static const EnumEntry<uint8_t> FunctionOptionEnum[] = {

llvm/lib/DebugInfo/PDB/PDBExtras.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
9696
CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, ClrCall , "clrcall", OS)
9797
CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Inline , "inlinecall", OS)
9898
CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearVector , "vectorcall", OS)
99+
CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Swift, "swiftcall", OS)
99100
}
100101
return OS;
101102
}
@@ -234,6 +235,9 @@ raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const PDB_Lang &Lang) {
234235
CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Rust, OS)
235236
CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, ObjC, OS)
236237
CASE_OUTPUT_ENUM_CLASS_STR(PDB_Lang, ObjCpp, "ObjC++", OS)
238+
CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, AliasObj, OS)
239+
CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Go, OS)
240+
CASE_OUTPUT_ENUM_CLASS_STR(PDB_Lang, OldSwift, "Swift", OS)
237241
}
238242
return OS;
239243
}

llvm/lib/ObjectYAML/CodeViewYAMLTypes.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ void ScalarEnumerationTraits<CallingConvention>::enumeration(
259259
IO.enumCase(Value, "ClrCall", CallingConvention::ClrCall);
260260
IO.enumCase(Value, "Inline", CallingConvention::Inline);
261261
IO.enumCase(Value, "NearVector", CallingConvention::NearVector);
262+
IO.enumCase(Value, "Swift", CallingConvention::Swift);
262263
}
263264

264265
void ScalarEnumerationTraits<PointerKind>::enumeration(IO &IO,

llvm/test/DebugInfo/COFF/swift.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
; RUN: llc -filetype=obj < %s | llvm-readobj --codeview - | FileCheck %s --check-prefix=OBJ
33

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

88
; OBJ-LABEL: Compile3Sym {
99
; OBJ-NEXT: Kind: S_COMPILE3 (0x113C)
10-
; OBJ-NEXT: Language: Swift (0x53)
10+
; OBJ-NEXT: Language: Swift (0x13)
1111
; OBJ-NEXT: Flags [ (0x0)
1212
; OBJ-NEXT: ]
1313
; OBJ-NEXT: Machine: X64 (0xD0)

llvm/tools/llvm-pdbutil/MinimalSymbolDumper.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ static std::string formatSourceLanguage(SourceLanguage Lang) {
213213
RETURN_CASE(SourceLanguage, Rust, "rust");
214214
RETURN_CASE(SourceLanguage, ObjC, "objc");
215215
RETURN_CASE(SourceLanguage, ObjCpp, "objc++");
216+
RETURN_CASE(SourceLanguage, AliasObj, "aliasobj");
217+
RETURN_CASE(SourceLanguage, Go, "go");
218+
RETURN_CASE(SourceLanguage, OldSwift, "swift");
216219
}
217220
return formatUnknownEnum(Lang);
218221
}
@@ -282,6 +285,7 @@ static std::string formatMachineType(CPUType Cpu) {
282285
RETURN_CASE(CPUType, Thumb, "thumb");
283286
RETURN_CASE(CPUType, ARMNT, "arm nt");
284287
RETURN_CASE(CPUType, D3D11_Shader, "d3d11 shader");
288+
RETURN_CASE(CPUType, Unknown, "unknown");
285289
}
286290
return formatUnknownEnum(Cpu);
287291
}

llvm/tools/llvm-pdbutil/MinimalTypeDumper.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ static std::string formatCallingConvention(CallingConvention Convention) {
125125
RETURN_CASE(CallingConvention, PpcCall, "ppccall");
126126
RETURN_CASE(CallingConvention, SHCall, "shcall");
127127
RETURN_CASE(CallingConvention, SH5Call, "sh5call");
128+
RETURN_CASE(CallingConvention, Swift, "swift");
128129
RETURN_CASE(CallingConvention, ThisCall, "thiscall");
129130
RETURN_CASE(CallingConvention, TriCall, "tricall");
130131
}

0 commit comments

Comments
 (0)