Reinstate DW_AT_comp_dir support after D55519.
The DIFile used by the CU is special and distinct from the main source file. Its directory part specifies what becomes the DW_AT_comp_dir (the compilation directory), even if the source file was specified with an absolute path. To support the .dwo workflow, a valid DW_AT_comp_dir is necessary even if source files were specified with an absolute path. llvm-svn: 349065
This commit is contained in:
parent
8b325fc706
commit
046d100b41
|
@ -416,7 +416,6 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
|
|||
|
||||
// Cache the results.
|
||||
auto It = DIFileCache.find(FileName.data());
|
||||
|
||||
if (It != DIFileCache.end()) {
|
||||
// Verify that the information still exists.
|
||||
if (llvm::Metadata *V = It->second)
|
||||
|
@ -595,22 +594,27 @@ void CGDebugInfo::CreateCompileUnit() {
|
|||
break;
|
||||
}
|
||||
|
||||
uint64_t DwoId = 0;
|
||||
auto &CGOpts = CGM.getCodeGenOpts();
|
||||
// The DIFile used by the CU is distinct from the main source
|
||||
// file. Its directory part specifies what becomes the
|
||||
// DW_AT_comp_dir (the compilation directory), even if the source
|
||||
// file was specified with an absolute path.
|
||||
if (CSKind)
|
||||
CSInfo.emplace(*CSKind, Checksum);
|
||||
llvm::DIFile *CUFile = DBuilder.createFile(
|
||||
remapDIPath(MainFileName), remapDIPath(getCurrentDirname()), CSInfo,
|
||||
getSource(SM, SM.getMainFileID()));
|
||||
|
||||
// Create new compile unit.
|
||||
// FIXME - Eliminate TheCU.
|
||||
auto &CGOpts = CGM.getCodeGenOpts();
|
||||
TheCU = DBuilder.createCompileUnit(
|
||||
LangTag,
|
||||
createFile(MainFileName, CSInfo, getSource(SM, SM.getMainFileID())),
|
||||
CGOpts.EmitVersionIdentMetadata ? Producer : "",
|
||||
LangTag, CUFile, CGOpts.EmitVersionIdentMetadata ? Producer : "",
|
||||
LO.Optimize || CGOpts.PrepareForLTO || CGOpts.PrepareForThinLTO,
|
||||
CGOpts.DwarfDebugFlags, RuntimeVers,
|
||||
(CGOpts.getSplitDwarfMode() != CodeGenOptions::NoFission)
|
||||
? ""
|
||||
: CGOpts.SplitDwarfFile,
|
||||
EmissionKind, 0 /* DWOid */, CGOpts.SplitDwarfInlining,
|
||||
EmissionKind, DwoId, CGOpts.SplitDwarfInlining,
|
||||
CGOpts.DebugInfoForProfiling,
|
||||
CGM.getTarget().getTriple().isNVPTX()
|
||||
? llvm::DICompileUnit::DebugNameTableKind::None
|
||||
|
|
|
@ -8,12 +8,29 @@
|
|||
// RUN: cp %s %t.c
|
||||
// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
|
||||
// RUN: %t.c -emit-llvm -o - | FileCheck %s --check-prefix=INTREE
|
||||
|
||||
// RUN: cd %t/UNIQUEISH_SENTINEL
|
||||
// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
|
||||
// RUN: debug-info-abspath.c -emit-obj -o /tmp/t.o
|
||||
// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
|
||||
// RUN: debug-info-abspath.c -emit-llvm -o - \
|
||||
// RUN: | FileCheck %s --check-prefix=CURDIR
|
||||
// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
|
||||
// RUN: %s -emit-llvm -o - | FileCheck %s --check-prefix=CURDIR
|
||||
|
||||
void foo() {}
|
||||
|
||||
// Since %s is an absolute path, directory should be the common
|
||||
// prefix, but the directory part should be part of the filename.
|
||||
|
||||
// CHECK: DIFile(filename: "{{.*}}UNIQUEISH_SENTINEL{{.*}}debug-info-abspath.c"
|
||||
// CHECK-NOT: directory: "{{.*}}UNIQUEISH_SENTINEL
|
||||
// CHECK: = distinct !DISubprogram({{.*}}file: ![[SPFILE:[0-9]+]]
|
||||
// CHECK: ![[SPFILE]] = !DIFile(filename: "{{.*}}UNIQUEISH_SENTINEL
|
||||
// CHECK-SAME: debug-info-abspath.c"
|
||||
// CHECK-NOT: directory: "{{.*}}UNIQUEISH_SENTINEL
|
||||
|
||||
// INTREE: = distinct !DISubprogram({{.*}}![[SPFILE:[0-9]+]]
|
||||
// INTREE: DIFile({{.*}}directory: "{{.+}}CodeGen{{.*}}")
|
||||
|
||||
// CURDIR: = distinct !DICompileUnit({{.*}}file: ![[CUFILE:[0-9]+]]
|
||||
// CURDIR: ![[CUFILE]] = !DIFile({{.*}}directory: "{{.+}}UNIQUEISH_SENTINEL")
|
||||
|
||||
|
|
Loading…
Reference in New Issue