Index: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h =================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h +++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h @@ -191,6 +191,8 @@ void emitTypeInformation(); + void emitCompilerInformation(); + void emitInlineeLinesSubsection(); void emitDebugInfoForFunction(const Function *GV, FunctionInfo &FI); Index: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp =================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -504,6 +504,131 @@ }); } +namespace { + +static SourceLanguage MapDWLangToCVLang(unsigned DWLang) { + switch (DWLang) { + case dwarf::DW_LANG_C: + case dwarf::DW_LANG_C89: + case dwarf::DW_LANG_C99: + case dwarf::DW_LANG_C11: + case dwarf::DW_LANG_ObjC: + return SourceLanguage::C; + case dwarf::DW_LANG_C_plus_plus: + case dwarf::DW_LANG_C_plus_plus_03: + case dwarf::DW_LANG_C_plus_plus_11: + case dwarf::DW_LANG_C_plus_plus_14: + return SourceLanguage::Cpp; + case dwarf::DW_LANG_Fortran77: + case dwarf::DW_LANG_Fortran90: + case dwarf::DW_LANG_Fortran03: + case dwarf::DW_LANG_Fortran08: + return SourceLanguage::Fortran; + case dwarf::DW_LANG_Pascal83: + return SourceLanguage::Pascal; + case dwarf::DW_LANG_Cobol74: + case dwarf::DW_LANG_Cobol85: + return SourceLanguage::Cobol; + case dwarf::DW_LANG_Java: + return SourceLanguage::Java; + 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, + // as it's very low level. + return SourceLanguage::Masm; + } +} + +struct Version { + int Part[4]; +}; + +// Takes a StringRef like "clang 4.0.0.0 (other nonsense 123)" and parses out +// the version number. +static Version parseVersion(StringRef Name) { + Version V = {0}; + int N = 0; + for (const char C : Name) { + if (isdigit(C)) { + V.Part[N] *= 10; + V.Part[N] += C - '0'; + } else if (C == '.') { + ++N; + if (N >= 4) + return V; + } else if (N > 0) + return V; + } + return V; +} + +static CPUType mapArchToCVCPUType(Triple::ArchType Type) { + switch (Type) { + case Triple::ArchType::x86: + return CPUType::Pentium3; + case Triple::ArchType::x86_64: + return CPUType::X64; + case Triple::ArchType::thumb: + return CPUType::Thumb; + default: + report_fatal_error("target architecture doesn't map to a CodeView " + "CPUType"); + } +} + +} // anonymous namespace + +void CodeViewDebug::emitCompilerInformation() { + MCContext &Context = MMI->getContext(); + MCSymbol *CompilerBegin = Context.createTempSymbol(), + *CompilerEnd = Context.createTempSymbol(); + OS.AddComment("Record length"); + OS.emitAbsoluteSymbolDiff(CompilerEnd, CompilerBegin, 2); + OS.EmitLabel(CompilerBegin); + OS.AddComment("Record kind: S_COMPILE3"); + OS.EmitIntValue(SymbolKind::S_COMPILE3, 2); + uint32_t Flags = 0; + + NamedMDNode *CUs = MMI->getModule()->getNamedMetadata("llvm.dbg.cu"); + const MDNode *Node = *CUs->operands().begin(); + const auto *CU = cast(Node); + + // The low byte of the flags indicates the source language. + Flags = MapDWLangToCVLang(CU->getSourceLanguage()); + // TODO: Figure out which other flags need to be set. + + OS.AddComment("Flags and language"); + OS.EmitIntValue(Flags, 4); + + OS.AddComment("CPUType"); + CPUType CPU = + mapArchToCVCPUType(Triple(MMI->getModule()->getTargetTriple()).getArch()); + OS.EmitIntValue(static_cast(CPU), 2); + + StringRef CompilerVersion = CU->getProducer(); + Version FrontVer = parseVersion(CompilerVersion); + OS.AddComment("Frontend version"); + for (int N = 0; N < 4; ++N) + OS.EmitIntValue(FrontVer.Part[N], 2); + + // Some Microsoft tools, like Binscope, expect a backend version number of at + // least 8.something, so we'll coerce the LLVM version into a form that + // guarantees it'll be big enough without really lying about the version. + Version BackVer = { + 1000 * LLVM_VERSION_MAJOR + + 10 * LLVM_VERSION_MINOR + + LLVM_VERSION_PATCH, + 0, 0, 0 }; + OS.AddComment("Backend version"); + for (int N = 0; N < 4; ++N) + OS.EmitIntValue(BackVer.Part[N], 2); + + OS.AddComment("Null-terminated compiler version string"); + emitNullTerminatedSymbolName(OS, CompilerVersion); + + OS.EmitLabel(CompilerEnd); +} + void CodeViewDebug::emitInlineeLinesSubsection() { if (InlinedSubprograms.empty()) return; @@ -1971,6 +2096,8 @@ OS.AddComment("Subsection size"); OS.emitAbsoluteSymbolDiff(EndLabel, BeginLabel, 4); OS.EmitLabel(BeginLabel); + if (Kind == ModuleSubstreamKind::Symbols) + emitCompilerInformation(); return EndLabel; } Index: llvm/trunk/test/DebugInfo/COFF/asm.ll =================================================================== --- llvm/trunk/test/DebugInfo/COFF/asm.ll +++ llvm/trunk/test/DebugInfo/COFF/asm.ll @@ -27,7 +27,10 @@ ; Symbol subsection ; X86-NEXT: .long 241 ; X86-NEXT: .long [[F1_END:.*]]-[[F1_START:.*]] # +; Compiler information record ; X86-NEXT: [[F1_START]]: +; X86-NEXT: .short [[C1_END:.*]]-[[C1_START:.*]] # +; X86: [[C1_END]]: ; X86-NEXT: .short [[PROC_SEGMENT_END:.*]]-[[PROC_SEGMENT_START:.*]] # ; X86-NEXT: [[PROC_SEGMENT_START]]: ; X86-NEXT: .short 4423 @@ -59,15 +62,14 @@ ; OBJ32: Characteristics [ (0x42300040) ; OBJ32: ] ; OBJ32: Relocations [ -; OBJ32-NEXT: 0x2C IMAGE_REL_I386_SECREL _f -; OBJ32-NEXT: 0x30 IMAGE_REL_I386_SECTION _f -; OBJ32-NEXT: 0x44 IMAGE_REL_I386_SECREL _f -; OBJ32-NEXT: 0x48 IMAGE_REL_I386_SECTION _f +; OBJ32-NEXT: 0x59 IMAGE_REL_I386_SECREL _f +; OBJ32-NEXT: 0x5D IMAGE_REL_I386_SECTION _f +; OBJ32-NEXT: 0x70 IMAGE_REL_I386_SECREL _f +; OBJ32-NEXT: 0x74 IMAGE_REL_I386_SECTION _f ; OBJ32-NEXT: ] ; OBJ32: CodeViewDebugInfo [ ; OBJ32: Subsection [ ; OBJ32-NEXT: SubSectionType: Symbols (0xF1) -; OBJ32-NOT: ] ; OBJ32: ProcStart { ; OBJ32: CodeSize: 0x6 ; OBJ32: DisplayName: f @@ -120,7 +122,10 @@ ; Symbol subsection ; X64-NEXT: .long 241 ; X64-NEXT: .long [[F1_END:.*]]-[[F1_START:.*]] # +; Compiler information record ; X64-NEXT: [[F1_START]]: +; X64-NEXT: .short [[C1_END:.*]]-[[C1_START:.*]] # +; X64: [[C1_END]]: ; X64-NEXT: .short [[PROC_SEGMENT_END:.*]]-[[PROC_SEGMENT_START:.*]] # ; X64-NEXT: [[PROC_SEGMENT_START]]: ; X64-NEXT: .short 4423 @@ -152,14 +157,13 @@ ; OBJ64: Characteristics [ (0x42300040) ; OBJ64: ] ; OBJ64: Relocations [ -; OBJ64-NEXT: 0x2C IMAGE_REL_AMD64_SECREL f -; OBJ64-NEXT: 0x30 IMAGE_REL_AMD64_SECTION f -; OBJ64-NEXT: 0x44 IMAGE_REL_AMD64_SECREL f -; OBJ64-NEXT: 0x48 IMAGE_REL_AMD64_SECTION f +; OBJ64-NEXT: 0x59 IMAGE_REL_AMD64_SECREL f +; OBJ64-NEXT: 0x5D IMAGE_REL_AMD64_SECTION f +; OBJ64-NEXT: 0x70 IMAGE_REL_AMD64_SECREL f +; OBJ64-NEXT: 0x74 IMAGE_REL_AMD64_SECTION f ; OBJ64-NEXT: ] ; OBJ64: Subsection [ ; OBJ64-NEXT: SubSectionType: Symbols (0xF1) -; OBJ64-NOT: ] ; OBJ64: ProcStart { ; OBJ64: CodeSize: 0xE ; OBJ64: DisplayName: f Index: llvm/trunk/test/DebugInfo/COFF/globals.ll =================================================================== --- llvm/trunk/test/DebugInfo/COFF/globals.ll +++ llvm/trunk/test/DebugInfo/COFF/globals.ll @@ -100,7 +100,6 @@ ; OBJ: Magic: 0x4 ; OBJ: Subsection [ ; OBJ: SubSectionType: Symbols (0xF1) -; OBJ: SubSectionSize: 0x15 ; OBJ: DataSym { ; OBJ: DataOffset: ?comdat@?$A@X@@2HB+0x0 ; OBJ: Type: const int (0x1000) Index: llvm/trunk/test/DebugInfo/COFF/multifile.ll =================================================================== --- llvm/trunk/test/DebugInfo/COFF/multifile.ll +++ llvm/trunk/test/DebugInfo/COFF/multifile.ll @@ -36,7 +36,10 @@ ; Symbol subsection ; X86-NEXT: .long 241 ; X86-NEXT: .long [[F1_END:.*]]-[[F1_START:.*]] # +; Compiler information record ; X86-NEXT: [[F1_START]]: +; X86-NEXT: .short [[C1_END:.*]]-[[C1_START:.*]] # +; X86: [[C1_END]]: ; X86-NEXT: .short [[PROC_SEGMENT_END:.*]]-[[PROC_SEGMENT_START:.*]] # ; X86-NEXT: [[PROC_SEGMENT_START]]: ; X86-NEXT: .short 4423 @@ -68,14 +71,13 @@ ; OBJ32: Characteristics [ (0x42300040) ; OBJ32: ] ; OBJ32: Relocations [ -; OBJ32-NEXT: 0x2C IMAGE_REL_I386_SECREL _f -; OBJ32-NEXT: 0x30 IMAGE_REL_I386_SECTION _f -; OBJ32-NEXT: 0x44 IMAGE_REL_I386_SECREL _f -; OBJ32-NEXT: 0x48 IMAGE_REL_I386_SECTION _f +; OBJ32-NEXT: 0x59 IMAGE_REL_I386_SECREL _f +; OBJ32-NEXT: 0x5D IMAGE_REL_I386_SECTION _f +; OBJ32-NEXT: 0x70 IMAGE_REL_I386_SECREL _f +; OBJ32-NEXT: 0x74 IMAGE_REL_I386_SECTION _f ; OBJ32-NEXT: ] ; OBJ32: Subsection [ ; OBJ32-NEXT: SubSectionType: Symbols (0xF1) -; OBJ32-NOT: ] ; OBJ32: ProcStart { ; OBJ32: CodeSize: 0x10 ; OBJ32: DisplayName: f @@ -144,7 +146,10 @@ ; Symbol subsection ; X64-NEXT: .long 241 ; X64-NEXT: .long [[F1_END:.*]]-[[F1_START:.*]] # +; Compiler information record ; X64-NEXT: [[F1_START]]: +; X64-NEXT: .short [[C1_END:.*]]-[[C1_START:.*]] # +; X64: [[C1_END]]: ; X64-NEXT: .short [[PROC_SEGMENT_END:.*]]-[[PROC_SEGMENT_START:.*]] # ; X64-NEXT: [[PROC_SEGMENT_START]]: ; X64-NEXT: .short 4423 @@ -173,14 +178,13 @@ ; OBJ64: Characteristics [ (0x42300040) ; OBJ64: ] ; OBJ64: Relocations [ -; OBJ64-NEXT: 0x2C IMAGE_REL_AMD64_SECREL f -; OBJ64-NEXT: 0x30 IMAGE_REL_AMD64_SECTION f -; OBJ64-NEXT: 0x44 IMAGE_REL_AMD64_SECREL f -; OBJ64-NEXT: 0x48 IMAGE_REL_AMD64_SECTION f +; OBJ64-NEXT: 0x59 IMAGE_REL_AMD64_SECREL f +; OBJ64-NEXT: 0x5D IMAGE_REL_AMD64_SECTION f +; OBJ64-NEXT: 0x70 IMAGE_REL_AMD64_SECREL f +; OBJ64-NEXT: 0x74 IMAGE_REL_AMD64_SECTION f ; OBJ64-NEXT: ] ; OBJ64: Subsection [ ; OBJ64-NEXT: SubSectionType: Symbols (0xF1) -; OBJ64-NOT: ] ; OBJ64: ProcStart { ; OBJ64: CodeSize: 0x18 ; OBJ64: DisplayName: f Index: llvm/trunk/test/DebugInfo/COFF/multifunction.ll =================================================================== --- llvm/trunk/test/DebugInfo/COFF/multifunction.ll +++ llvm/trunk/test/DebugInfo/COFF/multifunction.ll @@ -57,7 +57,10 @@ ; Symbol subsection for x ; X86-NEXT: .long 241 ; X86-NEXT: .long [[F1_END:.*]]-[[F1_START:.*]] # +; Compiler information record ; X86-NEXT: [[F1_START]]: +; X86-NEXT: .short [[C1_END:.*]]-[[C1_START:.*]] # +; X86: [[C1_END]]: ; X86-NEXT: .short [[PROC_SEGMENT_END:.*]]-[[PROC_SEGMENT_START:.*]] # ; X86-NEXT: [[PROC_SEGMENT_START]]: ; X86-NEXT: .short 4422 @@ -82,7 +85,10 @@ ; Symbol subsection for y ; X86-NEXT: .long 241 ; X86-NEXT: .long [[F1_END:.*]]-[[F1_START:.*]] # +; Compiler information record ; X86-NEXT: [[F1_START]]: +; X86-NEXT: .short [[C1_END:.*]]-[[C1_START:.*]] # +; X86: [[C1_END]]: ; X86-NEXT: .short [[PROC_SEGMENT_END:.*]]-[[PROC_SEGMENT_START:.*]] # ; X86-NEXT: [[PROC_SEGMENT_START]]: ; X86-NEXT: .short 4423 @@ -107,7 +113,10 @@ ; Symbol subsection for f ; X86-NEXT: .long 241 ; X86-NEXT: .long [[F1_END:.*]]-[[F1_START:.*]] # +; Compiler information record ; X86-NEXT: [[F1_START]]: +; X86-NEXT: .short [[C1_END:.*]]-[[C1_START:.*]] # +; X86: [[C1_END]]: ; X86-NEXT: .short [[PROC_SEGMENT_END:.*]]-[[PROC_SEGMENT_START:.*]] # ; X86-NEXT: [[PROC_SEGMENT_START]]: ; X86-NEXT: .short 4423 @@ -137,22 +146,21 @@ ; OBJ32: Characteristics [ (0x42300040) ; OBJ32: ] ; OBJ32: Relocations [ -; OBJ32-NEXT: 0x2C IMAGE_REL_I386_SECREL _x -; OBJ32-NEXT: 0x30 IMAGE_REL_I386_SECTION _x -; OBJ32-NEXT: 0x44 IMAGE_REL_I386_SECREL _x -; OBJ32-NEXT: 0x48 IMAGE_REL_I386_SECTION _x -; OBJ32-NEXT: 0x9C IMAGE_REL_I386_SECREL _y -; OBJ32-NEXT: 0xA0 IMAGE_REL_I386_SECTION _y -; OBJ32-NEXT: 0xB4 IMAGE_REL_I386_SECREL _y -; OBJ32-NEXT: 0xB8 IMAGE_REL_I386_SECTION _y -; OBJ32-NEXT: 0x10C IMAGE_REL_I386_SECREL _f -; OBJ32-NEXT: 0x110 IMAGE_REL_I386_SECTION _f -; OBJ32-NEXT: 0x124 IMAGE_REL_I386_SECREL _f -; OBJ32-NEXT: 0x128 IMAGE_REL_I386_SECTION _f +; OBJ32-NEXT: 0x59 IMAGE_REL_I386_SECREL _x +; OBJ32-NEXT: 0x5D IMAGE_REL_I386_SECTION _x +; OBJ32-NEXT: 0x70 IMAGE_REL_I386_SECREL _x +; OBJ32-NEXT: 0x74 IMAGE_REL_I386_SECTION _x +; OBJ32-NEXT: 0xF5 IMAGE_REL_I386_SECREL _y +; OBJ32-NEXT: 0xF9 IMAGE_REL_I386_SECTION _y +; OBJ32-NEXT: 0x10C IMAGE_REL_I386_SECREL _y +; OBJ32-NEXT: 0x110 IMAGE_REL_I386_SECTION _y +; OBJ32-NEXT: 0x191 IMAGE_REL_I386_SECREL _f +; OBJ32-NEXT: 0x195 IMAGE_REL_I386_SECTION _f +; OBJ32-NEXT: 0x1A8 IMAGE_REL_I386_SECREL _f +; OBJ32-NEXT: 0x1AC IMAGE_REL_I386_SECTION _f ; OBJ32-NEXT: ] ; OBJ32: Subsection [ ; OBJ32-NEXT: SubSectionType: Symbols (0xF1) -; OBJ32-NOT: ] ; OBJ32: ProcStart { ; OBJ32: Kind: S_LPROC32_ID (0x1146) ; OBJ32: CodeSize: 0x6 @@ -167,7 +175,6 @@ ; OBJ32: ] ; OBJ32: Subsection [ ; OBJ32-NEXT: SubSectionType: Symbols (0xF1) -; OBJ32-NOT: ] ; OBJ32: ProcStart { ; OBJ32: Kind: S_GPROC32_ID (0x1147) ; OBJ32: CodeSize: 0x6 @@ -182,7 +189,6 @@ ; OBJ32: ] ; OBJ32: Subsection [ ; OBJ32-NEXT: SubSectionType: Symbols (0xF1) -; OBJ32-NOT: ] ; OBJ32: ProcStart { ; OBJ32: Kind: S_GPROC32_ID (0x1147) ; OBJ32: CodeSize: 0x10 @@ -324,7 +330,10 @@ ; Symbol subsection for x ; X64-NEXT: .long 241 ; X64-NEXT: .long [[F1_END:.*]]-[[F1_START:.*]] # +; Compiler information record ; X64-NEXT: [[F1_START]]: +; X64-NEXT: .short [[C1_END:.*]]-[[C1_START:.*]] # +; X64: [[C1_END]]: ; X64-NEXT: .short [[PROC_SEGMENT_END:.*]]-[[PROC_SEGMENT_START:.*]] # ; X64-NEXT: [[PROC_SEGMENT_START]]: ; X64-NEXT: .short 4422 @@ -349,7 +358,10 @@ ; Symbol subsection for y ; X64-NEXT: .long 241 ; X64-NEXT: .long [[F1_END:.*]]-[[F1_START:.*]] # +; Compiler information record ; X64-NEXT: [[F1_START]]: +; X64-NEXT: .short [[C1_END:.*]]-[[C1_START:.*]] # +; X64: [[C1_END]]: ; X64-NEXT: .short [[PROC_SEGMENT_END:.*]]-[[PROC_SEGMENT_START:.*]] # ; X64-NEXT: [[PROC_SEGMENT_START]]: ; X64-NEXT: .short 4423 @@ -374,7 +386,10 @@ ; Symbol subsection for f ; X64-NEXT: .long 241 ; X64-NEXT: .long [[F1_END:.*]]-[[F1_START:.*]] # +; Compiler information record ; X64-NEXT: [[F1_START]]: +; X64-NEXT: .short [[C1_END:.*]]-[[C1_START:.*]] # +; X64: [[C1_END]]: ; X64-NEXT: .short [[PROC_SEGMENT_END:.*]]-[[PROC_SEGMENT_START:.*]] # ; X64-NEXT: [[PROC_SEGMENT_START]]: ; X64-NEXT: .short 4423 @@ -406,22 +421,21 @@ ; OBJ64: Characteristics [ (0x42300040) ; OBJ64: ] ; OBJ64: Relocations [ -; OBJ64-NEXT: 0x2C IMAGE_REL_AMD64_SECREL x -; OBJ64-NEXT: 0x30 IMAGE_REL_AMD64_SECTION x -; OBJ64-NEXT: 0x44 IMAGE_REL_AMD64_SECREL x -; OBJ64-NEXT: 0x48 IMAGE_REL_AMD64_SECTION x -; OBJ64-NEXT: 0xA8 IMAGE_REL_AMD64_SECREL y -; OBJ64-NEXT: 0xAC IMAGE_REL_AMD64_SECTION y -; OBJ64-NEXT: 0xC0 IMAGE_REL_AMD64_SECREL y -; OBJ64-NEXT: 0xC4 IMAGE_REL_AMD64_SECTION y -; OBJ64-NEXT: 0x124 IMAGE_REL_AMD64_SECREL f -; OBJ64-NEXT: 0x128 IMAGE_REL_AMD64_SECTION f -; OBJ64-NEXT: 0x13C IMAGE_REL_AMD64_SECREL f -; OBJ64-NEXT: 0x140 IMAGE_REL_AMD64_SECTION f +; OBJ64-NEXT: 0x59 IMAGE_REL_AMD64_SECREL x +; OBJ64-NEXT: 0x5D IMAGE_REL_AMD64_SECTION x +; OBJ64-NEXT: 0x70 IMAGE_REL_AMD64_SECREL x +; OBJ64-NEXT: 0x74 IMAGE_REL_AMD64_SECTION x +; OBJ64-NEXT: 0x101 IMAGE_REL_AMD64_SECREL y +; OBJ64-NEXT: 0x105 IMAGE_REL_AMD64_SECTION y +; OBJ64-NEXT: 0x118 IMAGE_REL_AMD64_SECREL y +; OBJ64-NEXT: 0x11C IMAGE_REL_AMD64_SECTION y +; OBJ64-NEXT: 0x1A9 IMAGE_REL_AMD64_SECREL f +; OBJ64-NEXT: 0x1AD IMAGE_REL_AMD64_SECTION f +; OBJ64-NEXT: 0x1C0 IMAGE_REL_AMD64_SECREL f +; OBJ64-NEXT: 0x1C4 IMAGE_REL_AMD64_SECTION f ; OBJ64-NEXT: ] ; OBJ64: Subsection [ ; OBJ64-NEXT: SubSectionType: Symbols (0xF1) -; OBJ64-NOT: ] ; OBJ64: ProcStart { ; OBJ64: Kind: S_LPROC32_ID (0x1146) ; OBJ64: CodeSize: 0xE @@ -436,7 +450,6 @@ ; OBJ64: ] ; OBJ64: Subsection [ ; OBJ64-NEXT: SubSectionType: Symbols (0xF1) -; OBJ64-NOT: ] ; OBJ64: ProcStart { ; OBJ64: Kind: S_GPROC32_ID (0x1147) ; OBJ64: CodeSize: 0xE @@ -451,7 +464,6 @@ ; OBJ64: ] ; OBJ64: Subsection [ ; OBJ64-NEXT: SubSectionType: Symbols (0xF1) -; OBJ64-NOT: ] ; OBJ64: ProcStart { ; OBJ64: Kind: S_GPROC32_ID (0x1147) ; OBJ64: CodeSize: 0x18 Index: llvm/trunk/test/DebugInfo/COFF/simple.ll =================================================================== --- llvm/trunk/test/DebugInfo/COFF/simple.ll +++ llvm/trunk/test/DebugInfo/COFF/simple.ll @@ -26,7 +26,10 @@ ; Symbol subsection ; X86-NEXT: .long 241 ; X86-NEXT: .long [[F1_END:.*]]-[[F1_START:.*]] # +; Compiler information record ; X86-NEXT: [[F1_START]]: +; X86-NEXT: .short [[C1_END:.*]]-[[C1_START:.*]] # +; X86: [[C1_END]]: ; X86-NEXT: .short [[PROC_SEGMENT_END:.*]]-[[PROC_SEGMENT_START:.*]] # ; X86-NEXT: [[PROC_SEGMENT_START]]: ; X86-NEXT: .short 4423 @@ -58,14 +61,13 @@ ; OBJ32: Characteristics [ (0x42300040) ; OBJ32: ] ; OBJ32: Relocations [ -; OBJ32-NEXT: 0x2C IMAGE_REL_I386_SECREL _f -; OBJ32-NEXT: 0x30 IMAGE_REL_I386_SECTION _f -; OBJ32-NEXT: 0x44 IMAGE_REL_I386_SECREL _f -; OBJ32-NEXT: 0x48 IMAGE_REL_I386_SECTION _f +; OBJ32-NEXT: 0x59 IMAGE_REL_I386_SECREL _f +; OBJ32-NEXT: 0x5D IMAGE_REL_I386_SECTION _f +; OBJ32-NEXT: 0x70 IMAGE_REL_I386_SECREL _f +; OBJ32-NEXT: 0x74 IMAGE_REL_I386_SECTION _f ; OBJ32-NEXT: ] ; OBJ32: Subsection [ ; OBJ32-NEXT: SubSectionType: Symbols (0xF1) -; OBJ32-NOT: ] ; OBJ32: ProcStart { ; OBJ32: CodeSize: 0x6 ; OBJ32: DisplayName: f @@ -116,7 +118,10 @@ ; Symbol subsection ; X64-NEXT: .long 241 ; X64-NEXT: .long [[F1_END:.*]]-[[F1_START:.*]] # +; Compiler information record ; X64-NEXT: [[F1_START]]: +; X64-NEXT: .short [[C1_END:.*]]-[[C1_START:.*]] # +; X64: [[C1_END]]: ; X64-NEXT: .short [[PROC_SEGMENT_END:.*]]-[[PROC_SEGMENT_START:.*]] # ; X64-NEXT: [[PROC_SEGMENT_START]]: ; X64-NEXT: .short 4423 @@ -148,14 +153,13 @@ ; OBJ64: Characteristics [ (0x42300040) ; OBJ64: ] ; OBJ64: Relocations [ -; OBJ64-NEXT: 0x2C IMAGE_REL_AMD64_SECREL f -; OBJ64-NEXT: 0x30 IMAGE_REL_AMD64_SECTION f -; OBJ64-NEXT: 0x44 IMAGE_REL_AMD64_SECREL f -; OBJ64-NEXT: 0x48 IMAGE_REL_AMD64_SECTION f +; OBJ64-NEXT: 0x59 IMAGE_REL_AMD64_SECREL f +; OBJ64-NEXT: 0x5D IMAGE_REL_AMD64_SECTION f +; OBJ64-NEXT: 0x70 IMAGE_REL_AMD64_SECREL f +; OBJ64-NEXT: 0x74 IMAGE_REL_AMD64_SECTION f ; OBJ64-NEXT: ] ; OBJ64: Subsection [ ; OBJ64-NEXT: SubSectionType: Symbols (0xF1) -; OBJ64-NOT: ] ; OBJ64: ProcStart { ; OBJ64: CodeSize: 0xE ; OBJ64: DisplayName: f Index: llvm/trunk/test/DebugInfo/COFF/typedef.ll =================================================================== --- llvm/trunk/test/DebugInfo/COFF/typedef.ll +++ llvm/trunk/test/DebugInfo/COFF/typedef.ll @@ -10,7 +10,6 @@ ; CHECK: } ; CHECK: Subsection [ ; CHECK: SubSectionType: Symbols (0xF1) -; CHECK: SubSectionSize: 0xC ; CHECK: UDT { ; CHECK: Type: wchar_t (0x71) ; CHECK: UDTName: XYZ Index: llvm/trunk/test/DebugInfo/COFF/types-array.ll =================================================================== --- llvm/trunk/test/DebugInfo/COFF/types-array.ll +++ llvm/trunk/test/DebugInfo/COFF/types-array.ll @@ -46,7 +46,6 @@ ; CHECK: Magic: 0x4 ; CHECK: Subsection [ ; CHECK: SubSectionType: Symbols (0xF1) -; CHECK: SubSectionSize: 0x4D ; CHECK: ProcStart { ; CHECK: PtrParent: 0x0 ; CHECK: PtrEnd: 0x0 Index: llvm/trunk/test/MC/ARM/coff-debugging-secrel.ll =================================================================== --- llvm/trunk/test/MC/ARM/coff-debugging-secrel.ll +++ llvm/trunk/test/MC/ARM/coff-debugging-secrel.ll @@ -42,10 +42,10 @@ ; CHECK-MSVC: Relocations [ ; CHECK-MSVC: Section {{.*}} .debug$S { -; CHECK-MSVC: 0x2C IMAGE_REL_ARM_SECREL function -; CHECK-MSVC: 0x30 IMAGE_REL_ARM_SECTION function -; CHECK-MSVC: 0x48 IMAGE_REL_ARM_SECREL function -; CHECK-MSVC: 0x4C IMAGE_REL_ARM_SECTION function +; CHECK-MSVC: 0x5A IMAGE_REL_ARM_SECREL function +; CHECK-MSVC: 0x5E IMAGE_REL_ARM_SECTION function +; CHECK-MSVC: 0x78 IMAGE_REL_ARM_SECREL function +; CHECK-MSVC: 0x7C IMAGE_REL_ARM_SECTION function ; CHECK-MSVC: } ; CHECK-MSVC: ] Index: llvm/trunk/test/MC/COFF/cv-compiler-info.ll =================================================================== --- llvm/trunk/test/MC/COFF/cv-compiler-info.ll +++ llvm/trunk/test/MC/COFF/cv-compiler-info.ll @@ -0,0 +1,56 @@ +; RUN: llc -mtriple i686-pc-windows-msvc < %s | FileCheck %s +; ModuleID = 'D:\src\scopes\foo.cpp' +source_filename = "D:\5Csrc\5Cscopes\5Cfoo.cpp" +target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" +target triple = "i686-pc-windows-msvc19.0.23918" + +; Function Attrs: nounwind sspstrong +define i32 @"\01?foo@@YAHXZ"() #0 !dbg !10 { +entry: + ret i32 42, !dbg !14 +} + +attributes #0 = { nounwind sspstrong "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="pentium4" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !7, !8} +!llvm.ident = !{!9} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 4.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) +; The debug$S section should begin with an S_COMPILE3 record that identifies the +; source language and the version of the compiler based on the DICompileUnit. +; CHECK: .section .debug$S,"dr" +; CHECK: .p2align 2 +; CHECK: .long 4 # Debug section magic +; CHECK: .long 241 # Symbol subsection for foo +; CHECK: .long Ltmp3-Ltmp2 # Subsection size +; CHECK: Ltmp2: +; CHECK: .short Ltmp5-Ltmp4 # Record length +; CHECK: Ltmp4: +; CHECK: .short 4412 # Record kind: S_COMPILE3 +; CHECK: .long 1 # Flags and language +; CHECK: .short 7 # CPUType +; CHECK: .short 4 # Frontend version +; CHECK: .short 0 +; CHECK: .short 0 +; CHECK: .short 0 +; CHECK: .short [[BACKEND_VERSION:[0-9]+]] # Backend version +; CHECK: .short 0 +; CHECK: .short 0 +; CHECK: .short 0 +; CHECK: .asciz "clang version 4.0.0 " # Null-terminated compiler version string +; CHECK: Ltmp5: +!1 = !DIFile(filename: "D:\5Csrc\5Cscopes\5Cfoo.cpp", directory: "D:\5Csrc\5Cscopes\5Cclang") +!2 = !{} +!3 = !{i32 6, !"Linker Options", !4} +!4 = !{!5, !6} +!5 = !{!"/DEFAULTLIB:libcmtd.lib"} +!6 = !{!"/DEFAULTLIB:oldnames.lib"} +!7 = !{i32 2, !"CodeView", i32 1} +!8 = !{i32 2, !"Debug Info Version", i32 3} +!9 = !{!"clang version 4.0.0 "} +!10 = distinct !DISubprogram(name: "foo", linkageName: "\01?foo@@YAHXZ", scope: !1, file: !1, line: 1, type: !11, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) +!11 = !DISubroutineType(types: !12) +!12 = !{!13} +!13 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) +!14 = !DILocation(line: 2, scope: !10)