r333311 - [DebugInfo] Don't bother with MD5 checksums of preprocessed files.

via cfe-commits cfe-commits at lists.llvm.org
Fri May 25 15:43:41 PDT 2018


Reverted in r333319 because I got failure notices from
http://lab.llvm.org:8011/builders/clang-ppc64le-linux/builds/17262
and (for stage 1, but not stage 2, which is pretty weird)
http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/10824

The Bots Know when I'm about to go out of town... I'll have to
revisit this later.
--paulr

> -----Original Message-----
> From: cfe-commits [mailto:cfe-commits-bounces at lists.llvm.org] On Behalf Of
> Paul Robinson via cfe-commits
> Sent: Friday, May 25, 2018 4:59 PM
> To: cfe-commits at lists.llvm.org
> Subject: r333311 - [DebugInfo] Don't bother with MD5 checksums of
> preprocessed files.
> 
> Author: probinson
> Date: Fri May 25 13:59:29 2018
> New Revision: 333311
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=333311&view=rev
> Log:
> [DebugInfo] Don't bother with MD5 checksums of preprocessed files.
> 
> The checksum will not reflect the real source, so there's no clear
> reason to include them in the debug info.  Also this was causing a
> crash on the DWARF side.
> 
> Differential Revision: https://reviews.llvm.org/D47260
> 
> Added:
>     cfe/trunk/test/CodeGen/md5-checksum-crash.c
> Modified:
>     cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>     cfe/trunk/lib/CodeGen/CGDebugInfo.h
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=333311&r1=333310&r2=3333
> 11&view=diff
> ==========================================================================
> ====
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri May 25 13:59:29 2018
> @@ -67,6 +67,8 @@ CGDebugInfo::CGDebugInfo(CodeGenModule &
>        DBuilder(CGM.getModule()) {
>    for (const auto &KV : CGM.getCodeGenOpts().DebugPrefixMap)
>      DebugPrefixMap[KV.first] = KV.second;
> +  EmitFileChecksums = CGM.getCodeGenOpts().EmitCodeView ||
> +                      CGM.getCodeGenOpts().DwarfVersion >= 5;
>    CreateCompileUnit();
>  }
> 
> @@ -365,15 +367,21 @@ Optional<llvm::DIFile::ChecksumKind>
>  CGDebugInfo::computeChecksum(FileID FID, SmallString<32> &Checksum) const
> {
>    Checksum.clear();
> 
> -  if (!CGM.getCodeGenOpts().EmitCodeView &&
> -      CGM.getCodeGenOpts().DwarfVersion < 5)
> +  if (!EmitFileChecksums)
>      return None;
> 
>    SourceManager &SM = CGM.getContext().getSourceManager();
>    bool Invalid;
> -  llvm::MemoryBuffer *MemBuffer = SM.getBuffer(FID, &Invalid);
> -  if (Invalid)
> +  const SrcMgr::SLocEntry &Entry = SM.getSLocEntry(FID, &Invalid);
> +  if (Invalid || !Entry.isFile())
>      return None;
> +  if (Entry.getFile().hasLineDirectives()) {
> +    // This must be a preprocessed file; its content won't match the
> original
> +    // source; therefore checksumming the text we have is pointless or
> wrong.
> +    EmitFileChecksums = false;
> +    return None;
> +  }
> +  llvm::MemoryBuffer *MemBuffer = SM.getBuffer(FID);
> 
>    llvm::MD5 Hash;
>    llvm::MD5::MD5Result Result;
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=333311&r1=333310&r2=333311
> &view=diff
> ==========================================================================
> ====
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Fri May 25 13:59:29 2018
> @@ -57,6 +57,7 @@ class CGDebugInfo {
>    CodeGenModule &CGM;
>    const codegenoptions::DebugInfoKind DebugKind;
>    bool DebugTypeExtRefs;
> +  mutable bool EmitFileChecksums;
>    llvm::DIBuilder DBuilder;
>    llvm::DICompileUnit *TheCU = nullptr;
>    ModuleMap *ClangModuleMap = nullptr;
> 
> Added: cfe/trunk/test/CodeGen/md5-checksum-crash.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/md5-
> checksum-crash.c?rev=333311&view=auto
> ==========================================================================
> ====
> --- cfe/trunk/test/CodeGen/md5-checksum-crash.c (added)
> +++ cfe/trunk/test/CodeGen/md5-checksum-crash.c Fri May 25 13:59:29 2018
> @@ -0,0 +1,13 @@
> +// RUN: %clang_cc1 -triple %itanium_abi_triple -debug-info-kind=limited -
> dwarf-version=5 %s -emit-llvm -o- | FileCheck %s
> +// RUN: %clang_cc1 -triple %ms_abi_triple -gcodeview -debug-info-
> kind=limited %s -emit-llvm -o- | FileCheck %s
> +
> +// This had been crashing, no MD5 checksum for string.h.
> +// Now if there are #line directives, don't bother with checksums
> +// as a preprocessed file won't properly reflect the original source.
> +#define __NTH fct
> +void fn1() {}
> +# 7 "/usr/include/string.h"
> +void __NTH() {}
> +// Verify no checksum attributes on these files.
> +// CHECK-DAG: DIFile(filename: "{{.*}}.c", directory: "{{[^"]*}}")
> +// CHECK-DAG: DIFile(filename: "{{.*}}string.h", directory: "{{[^"]*}}")
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


More information about the cfe-commits mailing list