Author: ibiryukov Date: Tue Dec 4 08:30:45 2018 New Revision: 348280 URL: http://llvm.org/viewvc/llvm-project?rev=348280&view=rev Log: Revert "Avoid emitting redundant or unusable directories in DIFile metadata entries."
This reverts commit r348154 and follow-up commits r348211 and r3248213. Reason: the original commit broke compiler-rt tests and a follow-up fix (r348203) broke our integrate and was reverted. Removed: cfe/trunk/test/CodeGen/debug-info-abspath.c Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CodeGenAction.cpp cfe/trunk/test/CodeGen/debug-prefix-map.c cfe/trunk/test/Modules/module-debuginfo-prefix.m Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=348280&r1=348279&r2=348280&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Dec 4 08:30:45 2018 @@ -181,7 +181,8 @@ void CGDebugInfo::setLocation(SourceLoca SourceManager &SM = CGM.getContext().getSourceManager(); auto *Scope = cast<llvm::DIScope>(LexicalBlockStack.back()); PresumedLoc PCLoc = SM.getPresumedLoc(CurLoc); - if (PCLoc.isInvalid() || Scope->getFile() == getOrCreateFile(CurLoc)) + + if (PCLoc.isInvalid() || Scope->getFilename() == PCLoc.getFilename()) return; if (auto *LBF = dyn_cast<llvm::DILexicalBlockFile>(Scope)) { @@ -409,13 +410,13 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi SourceManager &SM = CGM.getContext().getSourceManager(); PresumedLoc PLoc = SM.getPresumedLoc(Loc); - StringRef FileName = PLoc.getFilename(); - if (PLoc.isInvalid() || FileName.empty()) + if (PLoc.isInvalid() || StringRef(PLoc.getFilename()).empty()) // If the location is not valid then use main input file. return getOrCreateMainFile(); // Cache the results. - auto It = DIFileCache.find(FileName.data()); + const char *fname = PLoc.getFilename(); + auto It = DIFileCache.find(fname); if (It != DIFileCache.end()) { // Verify that the information still exists. @@ -430,41 +431,11 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi if (CSKind) CSInfo.emplace(*CSKind, Checksum); - StringRef Dir; - StringRef File; - std::string RemappedFile = remapDIPath(FileName); - std::string CurDir = remapDIPath(getCurrentDirname()); - SmallString<128> DirBuf; - SmallString<128> FileBuf; - if (llvm::sys::path::is_absolute(RemappedFile)) { - // Strip the common prefix (if it is more than just "/") from current - // directory and FileName for a more space-efficient encoding. - auto FileIt = llvm::sys::path::begin(RemappedFile); - auto FileE = llvm::sys::path::end(RemappedFile); - auto CurDirIt = llvm::sys::path::begin(CurDir); - auto CurDirE = llvm::sys::path::end(CurDir); - for (; CurDirIt != CurDirE && *CurDirIt == *FileIt; ++CurDirIt, ++FileIt) - llvm::sys::path::append(DirBuf, *CurDirIt); - if (std::distance(llvm::sys::path::begin(CurDir), CurDirIt) == 1) { - // The common prefix only the root; stripping it would cause - // LLVM diagnostic locations to be more confusing. - Dir = {}; - File = RemappedFile; - } else { - for (; FileIt != FileE; ++FileIt) - llvm::sys::path::append(FileBuf, *FileIt); - Dir = DirBuf; - File = FileBuf; - } - } else { - Dir = CurDir; - File = RemappedFile; - } - llvm::DIFile *F = - DBuilder.createFile(File, Dir, CSInfo, - getSource(SM, SM.getFileID(Loc))); + llvm::DIFile *F = DBuilder.createFile( + remapDIPath(PLoc.getFilename()), remapDIPath(getCurrentDirname()), CSInfo, + getSource(SM, SM.getFileID(Loc))); - DIFileCache[FileName.data()].reset(F); + DIFileCache[fname].reset(F); return F; } Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=348280&r1=348279&r2=348280&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Tue Dec 4 08:30:45 2018 @@ -549,16 +549,12 @@ const FullSourceLoc BackendConsumer::get SourceLocation DILoc; if (D.isLocationAvailable()) { - D.getLocation(Filename, Line, Column); - if (Line > 0) { - const FileEntry *FE = FileMgr.getFile(Filename); - if (!FE) - FE = FileMgr.getFile(D.getAbsolutePath()); - if (FE) { - // If -gcolumn-info was not used, Column will be 0. This upsets the - // source manager, so pass 1 if Column is not set. - DILoc = SourceMgr.translateFileLineCol(FE, Line, Column ? Column : 1); - } + D.getLocation(&Filename, &Line, &Column); + const FileEntry *FE = FileMgr.getFile(Filename); + if (FE && Line > 0) { + // If -gcolumn-info was not used, Column will be 0. This upsets the + // source manager, so pass 1 if Column is not set. + DILoc = SourceMgr.translateFileLineCol(FE, Line, Column ? Column : 1); } BadDebugInfo = DILoc.isInvalid(); } Removed: cfe/trunk/test/CodeGen/debug-info-abspath.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-abspath.c?rev=348279&view=auto ============================================================================== --- cfe/trunk/test/CodeGen/debug-info-abspath.c (original) +++ cfe/trunk/test/CodeGen/debug-info-abspath.c (removed) @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \ -// RUN: %s -emit-llvm -o - | FileCheck %s - -// 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 -void foo() {} - -// Since %s is an absolute path, directory should be a nonempty -// prefix, but the CodeGen part should be part of the filename. - -// CHECK: DIFile(filename: "{{.*}}CodeGen{{.*}}debug-info-abspath.c" -// CHECK-SAME: directory: "{{.+}}") - -// INTREE: DIFile({{.*}}directory: "{{.+}}CodeGen{{.*}}") Modified: cfe/trunk/test/CodeGen/debug-prefix-map.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-prefix-map.c?rev=348280&r1=348279&r2=348280&view=diff ============================================================================== --- cfe/trunk/test/CodeGen/debug-prefix-map.c (original) +++ cfe/trunk/test/CodeGen/debug-prefix-map.c Tue Dec 4 08:30:45 2018 @@ -17,24 +17,18 @@ void test_rewrite_includes() { } // CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "/var/empty{{/|\\5C}}<stdin>" -// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "/var/empty{{[/\\]}}{{.*}}", -// Dir should always be empty, but on Windows we can't recognize /var -// as being an absolute path. -// CHECK-NO-MAIN-FILE-NAME-SAME: directory: "{{()|(.*:.*)}}") -// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "/var/empty{{[/\\]}}Inputs/stdio.h", -// CHECK-NO-MAIN-FILE-NAME-SAME: directory: "{{()|(.*:.*)}}") +// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "/var/empty{{[/\\]}}{{.*}}" +// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "/var/empty{{[/\\]}}Inputs/stdio.h" // CHECK-NO-MAIN-FILE-NAME-NOT: !DIFile(filename: // CHECK-EVIL: !DIFile(filename: "/var=empty{{[/\\]}}{{.*}}" -// CHECK-EVIL: !DIFile(filename: "/var=empty{{[/\\]}}{{.*}}Inputs/stdio.h", -// CHECK-EVIL-SAME: directory: "{{()|(.*:.*)}}") +// CHECK-EVIL: !DIFile(filename: "/var=empty{{[/\\]}}Inputs/stdio.h" // CHECK-EVIL-NOT: !DIFile(filename: // CHECK: !DIFile(filename: "/var/empty{{[/\\]}}{{.*}}" -// CHECK: !DIFile(filename: "/var/empty{{[/\\]}}{{.*}}Inputs/stdio.h", -// CHECK-SAME: directory: "{{()|(.*:.*)}}") +// CHECK: !DIFile(filename: "/var/empty{{[/\\]}}Inputs/stdio.h" // CHECK-NOT: !DIFile(filename: -// CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}", directory: "/var/empty") -// CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}Inputs/stdio.h", directory: "/var/empty") +// CHECK-COMPILATION-DIR: !DIFile(filename: "/var/empty{{[/\\]}}{{.*}}", directory: "/var/empty") +// CHECK-COMPILATION-DIR: !DIFile(filename: "/var/empty{{[/\\]}}Inputs/stdio.h", directory: "/var/empty") // CHECK-COMPILATION-DIR-NOT: !DIFile(filename: Modified: cfe/trunk/test/Modules/module-debuginfo-prefix.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/module-debuginfo-prefix.m?rev=348280&r1=348279&r2=348280&view=diff ============================================================================== --- cfe/trunk/test/Modules/module-debuginfo-prefix.m (original) +++ cfe/trunk/test/Modules/module-debuginfo-prefix.m Tue Dec 4 08:30:45 2018 @@ -20,6 +20,4 @@ @import DebugObjC; #endif -// Dir should always be empty, but on Windows we can't recognize /var -// as being an absolute path. -// CHECK: !DIFile(filename: "/OVERRIDE/DebugObjC.h", directory: "{{()|(.*:.*)}}") +// CHECK: !DIFile({{.*}}"/OVERRIDE/DebugObjC.h" _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits