Skip to content

Commit

Permalink
Revert "[DebugInfo] Alternate (more efficient) MD5 fix"
Browse files Browse the repository at this point in the history
This reverts commit ca1295c.
It seems to be the culprit for at least some of today's bot failures,
for example https://lab.llvm.org/buildbot/#/builders/238/builds/4952
  • Loading branch information
pogo59 committed Aug 17, 2023
1 parent 30c4b97 commit 21e7f73
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
14 changes: 6 additions & 8 deletions clang/lib/CodeGen/CGDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,14 +391,12 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
SourceManager &SM = CGM.getContext().getSourceManager();
StringRef FileName;
FileID FID;
std::optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo;

if (Loc.isInvalid()) {
// The DIFile used by the CU is distinct from the main source file. Call
// createFile() below for canonicalization if the source file was specified
// with an absolute path.
FileName = TheCU->getFile()->getFilename();
CSInfo = TheCU->getFile()->getChecksum();
} else {
PresumedLoc PLoc = SM.getPresumedLoc(Loc);
FileName = PLoc.getFilename();
Expand All @@ -419,13 +417,13 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
return cast<llvm::DIFile>(V);
}

if (!CSInfo) {
SmallString<64> Checksum;
std::optional<llvm::DIFile::ChecksumKind> CSKind =
SmallString<64> Checksum;

std::optional<llvm::DIFile::ChecksumKind> CSKind =
computeChecksum(FID, Checksum);
if (CSKind)
CSInfo.emplace(*CSKind, Checksum);
}
std::optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo;
if (CSKind)
CSInfo.emplace(*CSKind, Checksum);
return createFile(FileName, CSInfo, getSource(SM, SM.getFileID(Loc)));
}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGDebugInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class CGDebugInfo {
llvm::BumpPtrAllocator DebugInfoNames;
StringRef CWDName;

llvm::DenseMap<const char *, llvm::TrackingMDRef> DIFileCache;
llvm::StringMap<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
Expand Down
6 changes: 3 additions & 3 deletions clang/test/CodeGenCXX/debug-info-function-context.cpp
Original file line number Diff line number Diff line change
@@ -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 debug-info-function-context.cpp -o - | FileCheck %s
// RUN: -dwarf-version=5 -main-file-name %s -o - | FileCheck %s

struct C {
void member_function();
Expand Down Expand Up @@ -31,8 +31,8 @@ int global_initialized_variable = C::static_member_function();

// The first DIFile is for the CU, the second is what everything else uses.
// We're using DWARF v5 so both should have MD5 checksums.
// CHECK: !DIFile(filename: "{{.*}}context.cpp",{{.*}} checksumkind: CSK_MD5, checksum: [[CKSUM:".*"]]
// CHECK: ![[FILE:[0-9]+]] = !DIFile(filename: "{{.*}}context.cpp",{{.*}} checksumkind: CSK_MD5, checksum: [[CKSUM]]
// CHECK: !DIFile(filename: "{{.*}}context.cpp",{{.*}} checksumkind: CSK_MD5
// CHECK: ![[FILE:[0-9]+]] = !DIFile(filename: "{{.*}}context.cpp",{{.*}} checksumkind: CSK_MD5
// CHECK: ![[C:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "C",
// CHECK: ![[NS:.*]] = !DINamespace(name: "ns"
// CHECK: !DISubprogram(name: "member_function",{{.*}} scope: ![[C]],{{.*}} DISPFlagDefinition
Expand Down

0 comments on commit 21e7f73

Please sign in to comment.