llvm.org GIT mirror llvm / e348e50
Add Swift enumerator value for CodeView::SourceLanguage Summary: Swift now generates PDBs for debugging on Windows. llvm and lldb need a language enumerator value too properly handle the output emitted by swiftc. Subscribers: jdoerfert, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59231 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355882 91177308-0d34-0410-b5e6-96231b3b80d8 Nathan Lanza 5 months ago
7 changed file(s) with 55 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
158158 MSIL = 0x0f,
159159 HLSL = 0x10,
160160
161 /// The DMD compiler emits 'D' for the CV source language. Microsoft doesn't
162 /// have an enumerator for it yet.
161 /// The DMD & Swift compilers emit 'D' and 'S', respectively, for the CV
162 /// source language. Microsoft does not have enumerators for them yet.
163163 D = 'D',
164 Swift = 'S',
164165 };
165166
166167 /// These values correspond to the CV_call_e enumeration, and are documented
698698 return SourceLanguage::Java;
699699 case dwarf::DW_LANG_D:
700700 return SourceLanguage::D;
701 case dwarf::DW_LANG_Swift:
702 return SourceLanguage::Swift;
701703 default:
702704 // There's no CodeView representation for this language, and CV doesn't
703705 // have an "unknown" option for the language field, so we'll use MASM,
8585 CV_ENUM_ENT(SourceLanguage, ILAsm), CV_ENUM_ENT(SourceLanguage, Java),
8686 CV_ENUM_ENT(SourceLanguage, JScript), CV_ENUM_ENT(SourceLanguage, MSIL),
8787 CV_ENUM_ENT(SourceLanguage, HLSL), CV_ENUM_ENT(SourceLanguage, D),
88 CV_ENUM_ENT(SourceLanguage, Swift),
8889 };
8990
9091 static const EnumEntry CompileSym2FlagNames[] = {
191191 CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, MSIL, OS)
192192 CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, HLSL, OS)
193193 CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, D, OS)
194 CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Swift, OS)
194195 }
195196 return OS;
196197 }
8989 PDB_Lang Lang = Details ? Details->getLanguage() : PDB_Lang::Cpp;
9090 auto SrcFiles = Session.getSourceFilesForCompiland(*this);
9191 if (SrcFiles) {
92 bool LangC = (Lang == PDB_Lang::Cpp || Lang == PDB_Lang::C);
9392 while (auto File = SrcFiles->getNext()) {
9493 std::string FileName = File->getFileName();
9594 auto file_extension = sys::path::extension(FileName);
9695 if (StringSwitch(file_extension.lower())
97 .Case(".cpp", LangC)
98 .Case(".c", LangC)
99 .Case(".cc", LangC)
100 .Case(".cxx", LangC)
96 .Case(".cpp", Lang == PDB_Lang::Cpp)
97 .Case(".cc", Lang == PDB_Lang::Cpp)
98 .Case(".cxx", Lang == PDB_Lang::Cpp)
99 .Case(".c", Lang == PDB_Lang::C)
101100 .Case(".asm", Lang == PDB_Lang::Masm)
101 .Case(".swift", Lang == PDB_Lang::Swift)
102102 .Default(false))
103103 return File->getFileName();
104104 }
0 ; RUN: llc < %s | FileCheck %s --check-prefix=ASM
1 ; RUN: llc -filetype=obj < %s | llvm-readobj -codeview | FileCheck %s --check-prefix=OBJ
2
3 ; ASM: .short 4412 # Record kind: S_COMPILE3
4 ; ASM-NEXT: .long 83 # Flags and language
5 ; ASM-NEXT: .short 208 # CPUType
6
7 ; OBJ-LABEL: Compile3Sym {
8 ; OBJ-NEXT: Kind: S_COMPILE3 (0x113C)
9 ; OBJ-NEXT: Language: Swift (0x53)
10 ; OBJ-NEXT: Flags [ (0x0)
11 ; OBJ-NEXT: ]
12 ; OBJ-NEXT: Machine: X64 (0xD0)
13 ; OBJ-NEXT: FrontendVersion: {{[0-9.]*}}
14 ; OBJ-NEXT: BackendVersion: {{[0-9.]*}}
15 ; OBJ-NEXT: VersionName: Apple Swift version 5.0 (swiftlang-1001.0.45.7 clang-1001.0.37.7)
16 ; OBJ-NEXT: }
17
18
19 ; ModuleID = 't.c'
20 source_filename = "t.swift"
21 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
22 target triple = "x86_64-pc-windows-msvc19.0.24215"
23
24 define void @f() !dbg !8 {
25 entry:
26 ret void, !dbg !11
27 }
28
29 !llvm.dbg.cu = !{!0}
30 !llvm.module.flags = !{!3, !4, !5}
31
32 !0 = distinct !DICompileUnit(language: DW_LANG_Swift, file: !1, producer: "Apple Swift version 5.0 (swiftlang-1001.0.45.7 clang-1001.0.37.7)", isOptimized: false, runtimeVersion: 5, emissionKind: FullDebug, enums: !2)
33 !1 = !DIFile(filename: "t.d", directory: "asdf")
34 !2 = !{}
35 !3 = !{i32 2, !"CodeView", i32 1}
36 !4 = !{i32 2, !"Debug Info Version", i32 3}
37 !5 = !{i32 1, !"Swift Version", i32 6}
38 !8 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !9, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: false, unit: !0, retainedNodes: !2)
39 !9 = !DISubroutineType(types: !10)
40 !10 = !{null}
41 !11 = !DILocation(line: 1, column: 11, scope: !8)
205205 RETURN_CASE(SourceLanguage, MSIL, "msil");
206206 RETURN_CASE(SourceLanguage, HLSL, "hlsl");
207207 RETURN_CASE(SourceLanguage, D, "d");
208 RETURN_CASE(SourceLanguage, Swift, "swift");
208209 }
209210 return formatUnknownEnum(Lang);
210211 }