[clang] 8374bf4 - [CodeView] Fix generated command-line expansion in LF_BUILDINFO. Fix the 'pdb' entry which was previously a null reference, now an empty string.
Alexandre Ganea via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 18 07:07:41 PDT 2020
Author: Alexandre Ganea
Date: 2020-06-18T10:07:30-04:00
New Revision: 8374bf43634725dc02a262a77b5f940fca25938c
URL: https://github.com/llvm/llvm-project/commit/8374bf43634725dc02a262a77b5f940fca25938c
DIFF: https://github.com/llvm/llvm-project/commit/8374bf43634725dc02a262a77b5f940fca25938c.diff
LOG: [CodeView] Fix generated command-line expansion in LF_BUILDINFO. Fix the 'pdb' entry which was previously a null reference, now an empty string.
Previously, the DIA SDK didn't like the empty reference in the 'pdb' entry.
Added:
Modified:
clang/test/CodeGen/debug-info-codeview-buildinfo.c
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/test/DebugInfo/COFF/build-info.ll
llvm/test/DebugInfo/COFF/global-type-hashes.ll
llvm/test/DebugInfo/COFF/types-basic.ll
llvm/test/DebugInfo/COFF/types-data-members.ll
Removed:
################################################################################
diff --git a/clang/test/CodeGen/debug-info-codeview-buildinfo.c b/clang/test/CodeGen/debug-info-codeview-buildinfo.c
index d08fadbbf1a9..5d37162b7325 100644
--- a/clang/test/CodeGen/debug-info-codeview-buildinfo.c
+++ b/clang/test/CodeGen/debug-info-codeview-buildinfo.c
@@ -1,6 +1,6 @@
// RUN: %clang_cl /c /Z7 /Fo%t.obj -- %s
// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s
-// RUN: %clang_cl /c /Z7 %s /Fo%t.obj -fdebug-compilation-dir .
+// RUN: %clang_cl /c /Z7 /Fo%t.obj -fdebug-compilation-dir . -- %s
// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix RELATIVE
int main() { return 42; }
@@ -9,13 +9,14 @@ int main() { return 42; }
// CHECK: ============================================================
// CHECK: 0x[[PWD:.+]] | LF_STRING_ID [size = {{.+}}] ID: <no type>, String: [[PWDVAL:.+]]
// CHECK: 0x[[FILEPATH:.+]] | LF_STRING_ID [size = {{.+}}] ID: <no type>, String: [[FILEPATHVAL:.+[\\/]debug-info-codeview-buildinfo.c]]
+// CHECK: 0x[[ZIPDB:.+]] | LF_STRING_ID [size = {{.+}}] ID: <no type>, String:
// CHECK: 0x[[TOOL:.+]] | LF_STRING_ID [size = {{.+}}] ID: <no type>, String: [[TOOLVAL:.+[\\/]clang.*]]
// CHECK: 0x[[CMDLINE:.+]] | LF_STRING_ID [size = {{.+}}] ID: <no type>, String: "-cc1
// CHECK: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}]
// CHECK: 0x[[PWD]]: `[[PWDVAL]]`
// CHECK: 0x[[TOOL]]: `[[TOOLVAL]]`
// CHECK: 0x[[FILEPATH]]: `[[FILEPATHVAL]]`
-// CHECK: <no type>: ``
+// CHECK: 0x[[ZIPDB]]: ``
// CHECK: 0x[[CMDLINE]]: `"-cc1
// RELATIVE: Types (.debug$T)
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 7f47849e3aa8..cf3c38c57f6d 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -849,10 +849,11 @@ static std::string flattenCommandLine(ArrayRef<const char *> Args,
continue;
}
if (!LastArg.empty())
- FlatCmdLine += " ";
+ OS << " ";
llvm::sys::printArg(OS, Arg, /*Quote=*/true);
LastArg = Arg;
}
+ OS.flush();
return FlatCmdLine;
}
@@ -876,6 +877,9 @@ void CodeViewDebug::emitBuildInfo() {
getStringIdTypeIdx(TypeTable, MainSourceFile->getDirectory());
BuildInfoArgs[BuildInfoRecord::SourceFile] =
getStringIdTypeIdx(TypeTable, MainSourceFile->getFilename());
+ // FIXME: PDB is intentionally blank unless we implement /Zi type servers.
+ BuildInfoArgs[BuildInfoRecord::TypeServerPDB] =
+ getStringIdTypeIdx(TypeTable, "");
if (Asm->TM.Options.MCOptions.Argv0 != nullptr) {
BuildInfoArgs[BuildInfoRecord::BuildTool] =
getStringIdTypeIdx(TypeTable, Asm->TM.Options.MCOptions.Argv0);
@@ -883,7 +887,6 @@ void CodeViewDebug::emitBuildInfo() {
TypeTable, flattenCommandLine(Asm->TM.Options.MCOptions.CommandLineArgs,
MainSourceFile->getFilename()));
}
- // FIXME: PDB is intentionally blank unless we implement /Zi type servers.
BuildInfoRecord BIR(BuildInfoArgs);
TypeIndex BuildInfoIndex = TypeTable.writeLeafType(BIR);
diff --git a/llvm/test/DebugInfo/COFF/build-info.ll b/llvm/test/DebugInfo/COFF/build-info.ll
index 94f006c3b093..983aa22214bc 100644
--- a/llvm/test/DebugInfo/COFF/build-info.ll
+++ b/llvm/test/DebugInfo/COFF/build-info.ll
@@ -5,7 +5,7 @@
; CHECK-NEXT: 0x{{.*}}: `D:\src\scopes\clang`
; CHECK-NEXT: <no type>: ``
; CHECK-NEXT: 0x{{.*}}: `D:\src\scopes\foo.cpp`
-; CHECK-NEXT: <no type>: ``
+; CHECK-NEXT: 0x{{.*}}: ``
; CHECK-NEXT: <no type>: ``
; CHECK: {{.*}} | S_BUILDINFO [size = 8] BuildId = `[[INFO_IDX]]`
diff --git a/llvm/test/DebugInfo/COFF/global-type-hashes.ll b/llvm/test/DebugInfo/COFF/global-type-hashes.ll
index 70f9df156a5b..3c6c27301b20 100644
--- a/llvm/test/DebugInfo/COFF/global-type-hashes.ll
+++ b/llvm/test/DebugInfo/COFF/global-type-hashes.ll
@@ -295,7 +295,8 @@ attributes #2 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-ma
; YAML: - 4470750F2E319329
; YAML: - 0FB556FD1FAB66D7
; YAML: - 5970EFB4874D0F3F
-; YAML: - EDB1D74C120CF44A
+; YAML: - D8EF11198C33843F
+; YAML: - D81F744D7366282B
; ...
diff --git a/llvm/test/DebugInfo/COFF/types-basic.ll b/llvm/test/DebugInfo/COFF/types-basic.ll
index 81e0c25d17cd..6455452d125a 100644
--- a/llvm/test/DebugInfo/COFF/types-basic.ll
+++ b/llvm/test/DebugInfo/COFF/types-basic.ll
@@ -511,14 +511,22 @@
; ASM: .asciz "t.cpp" # StringData
; ASM: .byte 242
; ASM: .byte 241
-; ASM: # BuildInfo (0x1015)
+; ASM: # StringId (0x1015)
+; ASM: .short 0xa # Record length
+; ASM: .short 0x1605 # Record kind: LF_STRING_ID
+; ASM: .long 0x0 # Id
+; ASM: .byte 0 # StringData
+; ASM: .byte 243
+; ASM: .byte 242
+; ASM: .byte 241
+; ASM: # BuildInfo (0x1016)
; ASM: .short 0x1a # Record length
; ASM: .short 0x1603 # Record kind: LF_BUILDINFO
; ASM: .short 0x5 # NumArgs
; ASM: .long 0x1013 # Argument: D:\src\llvm\build
; ASM: .long 0x0 # Argument
; ASM: .long 0x1014 # Argument: t.cpp
-; ASM: .long 0x0 # Argument
+; ASM: .long 0x1015 # Argument
; ASM: .long 0x0 # Argument
; ASM: .byte 242
; ASM: .byte 241
diff --git a/llvm/test/DebugInfo/COFF/types-data-members.ll b/llvm/test/DebugInfo/COFF/types-data-members.ll
index 87fde74b989c..1e699efdf8ed 100644
--- a/llvm/test/DebugInfo/COFF/types-data-members.ll
+++ b/llvm/test/DebugInfo/COFF/types-data-members.ll
@@ -727,14 +727,22 @@
; ASM: .asciz "t.cpp" # StringData
; ASM: .byte 242
; ASM: .byte 241
-; ASM: # BuildInfo (0x1022)
+; ASM: # StringId (0x1022)
+; ASM: .short 0xa # Record length
+; ASM: .short 0x1605 # Record kind: LF_STRING_ID
+; ASM: .long 0x0 # Id
+; ASM: .byte 0 # StringData
+; ASM: .byte 243
+; ASM: .byte 242
+; ASM: .byte 241
+; ASM: # BuildInfo (0x1023)
; ASM: .short 0x1a # Record length
; ASM: .short 0x1603 # Record kind: LF_BUILDINFO
; ASM: .short 0x5 # NumArgs
; ASM: .long 0x1020 # Argument: D:\src\llvm\build
; ASM: .long 0x0 # Argument
; ASM: .long 0x1021 # Argument: t.cpp
-; ASM: .long 0x0 # Argument
+; ASM: .long 0x1022 # Argument
; ASM: .long 0x0 # Argument
; ASM: .byte 242
; ASM: .byte 241
More information about the cfe-commits
mailing list