[PATCH] D156571: [DebugInfo] Alternate MD5 fix, NFC

Paul Robinson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 1 10:12:08 PDT 2023


probinson updated this revision to Diff 546115.
probinson added a comment.

Use the main FileID instead of expensive string compares.

Figured this out after staring at CreateCompileUnit for long enough. Seeding the DIFileCache with the DIFile created there made another test unhappy (difile_entry.cpp) but this fix doesn't.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156571/new/

https://reviews.llvm.org/D156571

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/test/CodeGenCXX/debug-info-function-context.cpp


Index: clang/test/CodeGenCXX/debug-info-function-context.cpp
===================================================================
--- clang/test/CodeGenCXX/debug-info-function-context.cpp
+++ clang/test/CodeGenCXX/debug-info-function-context.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-pc-linux-gnu %s \
-// RUN:     -dwarf-version=5 -main-file-name %s  -o - | FileCheck %s
+// RUN:     -dwarf-version=5 -main-file-name debug-info-function-context.cpp  -o - | FileCheck %s
 
 struct C {
   void member_function();
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,7 @@
     // createFile() below for canonicalization if the source file was specified
     // with an absolute path.
     FileName = TheCU->getFile()->getFilename();
+    FID = SM.getMainFileID();
   } else {
     PresumedLoc PLoc = SM.getPresumedLoc(Loc);
     FileName = PLoc.getFilename();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156571.546115.patch
Type: text/x-patch
Size: 1653 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230801/613ac9c8/attachment-0001.bin>


More information about the cfe-commits mailing list