probinson created this revision. probinson added reviewers: dblaikie, nikic. probinson added a project: debug-info. Herald added a subscriber: StephenFan. Herald added a project: All. probinson requested review of this revision.
Should have lower memory and time cost than D155991 <https://reviews.llvm.org/D155991>. https://reviews.llvm.org/D156571 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CGDebugInfo.h Index: clang/lib/CodeGen/CGDebugInfo.h =================================================================== --- clang/lib/CodeGen/CGDebugInfo.h +++ clang/lib/CodeGen/CGDebugInfo.h @@ -148,7 +148,7 @@ llvm::BumpPtrAllocator DebugInfoNames; StringRef CWDName; - llvm::StringMap<llvm::TrackingMDRef> DIFileCache; + llvm::DenseMap<const char *, llvm::TrackingMDRef> DIFileCache; llvm::DenseMap<const FunctionDecl *, llvm::TrackingMDRef> SPCache; /// Cache declarations relevant to DW_TAG_imported_declarations (C++ /// using declarations and global alias variables) that aren't covered Index: clang/lib/CodeGen/CGDebugInfo.cpp =================================================================== --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -397,6 +397,17 @@ // createFile() below for canonicalization if the source file was specified // with an absolute path. FileName = TheCU->getFile()->getFilename(); + for (auto It : DIFileCache) { + // StringRef operator== does a content comparison. + if (FileName == It.first) { + // Got a string match, use the existing DIFile if possible. + if (llvm::Metadata *V = It.second) + return cast<llvm::DIFile>(V); + // Fall through to create the DIFile but use the original string. + FileName = It.first; + break; + } + } } else { PresumedLoc PLoc = SM.getPresumedLoc(Loc); FileName = PLoc.getFilename();
Index: clang/lib/CodeGen/CGDebugInfo.h =================================================================== --- clang/lib/CodeGen/CGDebugInfo.h +++ clang/lib/CodeGen/CGDebugInfo.h @@ -148,7 +148,7 @@ llvm::BumpPtrAllocator DebugInfoNames; StringRef CWDName; - llvm::StringMap<llvm::TrackingMDRef> DIFileCache; + llvm::DenseMap<const char *, llvm::TrackingMDRef> DIFileCache; llvm::DenseMap<const FunctionDecl *, llvm::TrackingMDRef> SPCache; /// Cache declarations relevant to DW_TAG_imported_declarations (C++ /// using declarations and global alias variables) that aren't covered Index: clang/lib/CodeGen/CGDebugInfo.cpp =================================================================== --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -397,6 +397,17 @@ // createFile() below for canonicalization if the source file was specified // with an absolute path. FileName = TheCU->getFile()->getFilename(); + for (auto It : DIFileCache) { + // StringRef operator== does a content comparison. + if (FileName == It.first) { + // Got a string match, use the existing DIFile if possible. + if (llvm::Metadata *V = It.second) + return cast<llvm::DIFile>(V); + // Fall through to create the DIFile but use the original string. + FileName = It.first; + break; + } + } } else { PresumedLoc PLoc = SM.getPresumedLoc(Loc); FileName = PLoc.getFilename();
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits