[llvm] r355882 - Add Swift enumerator value for CodeView::SourceLanguage
Nathan Lanza via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 11 16:27:59 PDT 2019
Author: lanza
Date: Mon Mar 11 16:27:59 2019
New Revision: 355882
URL: http://llvm.org/viewvc/llvm-project?rev=355882&view=rev
Log:
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
Added:
llvm/trunk/test/DebugInfo/COFF/swift.ll
Modified:
llvm/trunk/include/llvm/DebugInfo/CodeView/CodeView.h
llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/trunk/lib/DebugInfo/CodeView/EnumTables.cpp
llvm/trunk/lib/DebugInfo/PDB/PDBExtras.cpp
llvm/trunk/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp
llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/CodeView.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/CodeView.h?rev=355882&r1=355881&r2=355882&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/CodeView.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/CodeView.h Mon Mar 11 16:27:59 2019
@@ -159,9 +159,10 @@ enum SourceLanguage : uint8_t {
MSIL = 0x0f,
HLSL = 0x10,
- /// The DMD compiler emits 'D' for the CV source language. Microsoft doesn't
- /// have an enumerator for it yet.
+ /// The DMD & Swift compilers emit 'D' and 'S', respectively, for the CV
+ /// source language. Microsoft does not have enumerators for them yet.
D = 'D',
+ Swift = 'S',
};
/// These values correspond to the CV_call_e enumeration, and are documented
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=355882&r1=355881&r2=355882&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp Mon Mar 11 16:27:59 2019
@@ -699,6 +699,8 @@ static SourceLanguage MapDWLangToCVLang(
return SourceLanguage::Java;
case dwarf::DW_LANG_D:
return SourceLanguage::D;
+ case dwarf::DW_LANG_Swift:
+ return SourceLanguage::Swift;
default:
// There's no CodeView representation for this language, and CV doesn't
// have an "unknown" option for the language field, so we'll use MASM,
Modified: llvm/trunk/lib/DebugInfo/CodeView/EnumTables.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/EnumTables.cpp?rev=355882&r1=355881&r2=355882&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/EnumTables.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/EnumTables.cpp Mon Mar 11 16:27:59 2019
@@ -86,6 +86,7 @@ static const EnumEntry<codeview::SourceL
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),
};
static const EnumEntry<uint32_t> CompileSym2FlagNames[] = {
Modified: llvm/trunk/lib/DebugInfo/PDB/PDBExtras.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/PDBExtras.cpp?rev=355882&r1=355881&r2=355882&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/PDBExtras.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/PDBExtras.cpp Mon Mar 11 16:27:59 2019
@@ -192,6 +192,7 @@ raw_ostream &llvm::pdb::operator<<(raw_o
CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, MSIL, OS)
CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, HLSL, OS)
CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, D, OS)
+ CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Swift, OS)
}
return OS;
}
Modified: llvm/trunk/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp?rev=355882&r1=355881&r2=355882&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp Mon Mar 11 16:27:59 2019
@@ -90,16 +90,16 @@ std::string PDBSymbolCompiland::getSourc
PDB_Lang Lang = Details ? Details->getLanguage() : PDB_Lang::Cpp;
auto SrcFiles = Session.getSourceFilesForCompiland(*this);
if (SrcFiles) {
- bool LangC = (Lang == PDB_Lang::Cpp || Lang == PDB_Lang::C);
while (auto File = SrcFiles->getNext()) {
std::string FileName = File->getFileName();
auto file_extension = sys::path::extension(FileName);
if (StringSwitch<bool>(file_extension.lower())
- .Case(".cpp", LangC)
- .Case(".c", LangC)
- .Case(".cc", LangC)
- .Case(".cxx", LangC)
+ .Case(".cpp", Lang == PDB_Lang::Cpp)
+ .Case(".cc", Lang == PDB_Lang::Cpp)
+ .Case(".cxx", Lang == PDB_Lang::Cpp)
+ .Case(".c", Lang == PDB_Lang::C)
.Case(".asm", Lang == PDB_Lang::Masm)
+ .Case(".swift", Lang == PDB_Lang::Swift)
.Default(false))
return File->getFileName();
}
Added: llvm/trunk/test/DebugInfo/COFF/swift.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/swift.ll?rev=355882&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/swift.ll (added)
+++ llvm/trunk/test/DebugInfo/COFF/swift.ll Mon Mar 11 16:27:59 2019
@@ -0,0 +1,42 @@
+; RUN: llc < %s | FileCheck %s --check-prefix=ASM
+; 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: .short 208 # CPUType
+
+; OBJ-LABEL: Compile3Sym {
+; OBJ-NEXT: Kind: S_COMPILE3 (0x113C)
+; OBJ-NEXT: Language: Swift (0x53)
+; OBJ-NEXT: Flags [ (0x0)
+; OBJ-NEXT: ]
+; OBJ-NEXT: Machine: X64 (0xD0)
+; OBJ-NEXT: FrontendVersion: {{[0-9.]*}}
+; OBJ-NEXT: BackendVersion: {{[0-9.]*}}
+; OBJ-NEXT: VersionName: Apple Swift version 5.0 (swiftlang-1001.0.45.7 clang-1001.0.37.7)
+; OBJ-NEXT: }
+
+
+; ModuleID = 't.c'
+source_filename = "t.swift"
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc19.0.24215"
+
+define void @f() !dbg !8 {
+entry:
+ ret void, !dbg !11
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+
+!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)
+!1 = !DIFile(filename: "t.d", directory: "asdf")
+!2 = !{}
+!3 = !{i32 2, !"CodeView", i32 1}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"Swift Version", i32 6}
+!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)
+!9 = !DISubroutineType(types: !10)
+!10 = !{null}
+!11 = !DILocation(line: 1, column: 11, scope: !8)
Modified: llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp?rev=355882&r1=355881&r2=355882&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp Mon Mar 11 16:27:59 2019
@@ -206,6 +206,7 @@ static std::string formatSourceLanguage(
RETURN_CASE(SourceLanguage, MSIL, "msil");
RETURN_CASE(SourceLanguage, HLSL, "hlsl");
RETURN_CASE(SourceLanguage, D, "d");
+ RETURN_CASE(SourceLanguage, Swift, "swift");
}
return formatUnknownEnum(Lang);
}
More information about the llvm-commits
mailing list