Skip to content

Commit fddd368

Browse files
committed
Emit 0 instead of incomplete information
1 parent fb0e512 commit fddd368

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -903,18 +903,18 @@ void CodeViewDebug::emitCompilerInformation() {
903903
OS.AddComment("CPUType");
904904
OS.emitInt16(static_cast<uint64_t>(TheCPU));
905905

906+
StringRef CompilerVersion = "0";
906907
auto CUs = MMI->getModule()->debug_compile_units();
907-
if (CUs.empty())
908-
return;
909-
910-
const MDNode *Node = *CUs.begin();
911-
const auto *CU = cast<DICompileUnit>(Node);
908+
if (!CUs.empty()) {
909+
const MDNode *Node = *CUs.begin();
910+
const auto *CU = cast<DICompileUnit>(Node);
912911

913-
StringRef CompilerVersion = CU->getProducer();
914-
Version FrontVer = parseVersion(CompilerVersion);
915-
OS.AddComment("Frontend version");
916-
for (int N : FrontVer.Part) {
917-
OS.emitInt16(N);
912+
CompilerVersion = CU->getProducer();
913+
Version FrontVer = parseVersion(CompilerVersion);
914+
OS.AddComment("Frontend version");
915+
for (int N : FrontVer.Part) {
916+
OS.emitInt16(N);
917+
}
918918
}
919919

920920
// Some Microsoft tools, like Binscope, expect a backend version number of at

llvm/test/DebugInfo/X86/codeview-empty-dbg-cu-crash.ll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
; CHECK-NEXT: .short 4412 # Record kind: S_COMPILE3
2020
; CHECK-NEXT: .long 3 # Flags and language
2121
; CHECK-NEXT: .short 208 # CPUType
22+
; CHECK-NEXT: .short 22000 # Backend version
23+
; CHECK-NEXT: .short 0
24+
; CHECK-NEXT: .short 0
25+
; CHECK-NEXT: .short 0
26+
; CHECK-NEXT: .asciz "0" # Null-terminated compiler version string
27+
; CHECK-NEXT: .p2align 2, 0x0
28+
; CHECK-NEXT: .Ltmp5:
2229
; CHECK-NEXT: .Ltmp1:
2330
; CHECK-NEXT: .p2align 2, 0x0
2431
; CHECK-NEXT: .cv_filechecksums # File index to string table offset subsection

0 commit comments

Comments
 (0)