Author: adrian Date: Thu Dec 13 09:53:29 2018 New Revision: 349065 URL: http://llvm.org/viewvc/llvm-project?rev=349065&view=rev Log: 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. Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/test/CodeGen/debug-info-abspath.c Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=349065&r1=349064&r2=349065&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Dec 13 09:53:29 2018 @@ -416,7 +416,6 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi // 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 Modified: cfe/trunk/test/CodeGen/debug-info-abspath.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-abspath.c?rev=349065&r1=349064&r2=349065&view=diff ============================================================================== --- cfe/trunk/test/CodeGen/debug-info-abspath.c (original) +++ cfe/trunk/test/CodeGen/debug-info-abspath.c Thu Dec 13 09:53:29 2018 @@ -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") + _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits