[llvm] r347072 - [codeview] Expose -gcodeview-ghash for global type hashing

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 16 10:47:41 PST 2018


Author: rnk
Date: Fri Nov 16 10:47:41 2018
New Revision: 347072

URL: http://llvm.org/viewvc/llvm-project?rev=347072&view=rev
Log:
[codeview] Expose -gcodeview-ghash for global type hashing

Summary:
Experience has shown that the functionality is useful. It makes linking
optimized clang with debug info for me a lot faster, 20s to 13s. The
type merging phase of PDB writing goes from 10s to 3s.

This removes the LLVM cl::opt and replaces it with a metadata flag.

After this change, users can do the following to use ghash:
- add -gcodeview-ghash to compiler flags
- replace /DEBUG with /DEBUG:GHASH in linker flags

Reviewers: zturner, hans, thakis, takuto.ikuta

Subscribers: aprantl, hiraditya, JDevlieghere, llvm-commits

Differential Revision: https://reviews.llvm.org/D54370

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h
    llvm/trunk/test/DebugInfo/COFF/global-type-hashes.ll

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=347072&r1=347071&r2=347072&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp Fri Nov 16 10:47:41 2018
@@ -92,9 +92,6 @@
 using namespace llvm;
 using namespace llvm::codeview;
 
-static cl::opt<bool> EmitDebugGlobalHashes("emit-codeview-ghash-section",
-                                           cl::ReallyHidden, cl::init(false));
-
 static CPUType mapArchToCVCPUType(Triple::ArchType Type) {
   switch (Type) {
   case Triple::ArchType::x86:
@@ -125,6 +122,11 @@ CodeViewDebug::CodeViewDebug(AsmPrinter
 
   TheCPU =
       mapArchToCVCPUType(Triple(MMI->getModule()->getTargetTriple()).getArch());
+
+  // Check if we should emit type record hashes.
+  ConstantInt *GH = mdconst::extract_or_null<ConstantInt>(
+      MMI->getModule()->getModuleFlag("CodeViewGHash"));
+  EmitDebugGlobalHashes = GH && !GH->isZero();
 }
 
 StringRef CodeViewDebug::getFullFilepath(const DIFile *File) {

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h?rev=347072&r1=347071&r2=347072&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h Fri Nov 16 10:47:41 2018
@@ -54,6 +54,9 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDe
   BumpPtrAllocator Allocator;
   codeview::GlobalTypeTableBuilder TypeTable;
 
+  /// Whether to emit type record hashes into .debug$H.
+  bool EmitDebugGlobalHashes = false;
+
   /// The codeview CPU type used by the translation unit.
   codeview::CPUType TheCPU;
 

Modified: llvm/trunk/test/DebugInfo/COFF/global-type-hashes.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/global-type-hashes.ll?rev=347072&r1=347071&r2=347072&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/global-type-hashes.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/global-type-hashes.ll Fri Nov 16 10:47:41 2018
@@ -1,7 +1,6 @@
-; RUN: llc -filetype=obj -emit-codeview-ghash-section < %s > %t.obj
+; RUN: llc -filetype=obj < %s > %t.obj
 ; RUN: obj2yaml %t.obj | FileCheck %s --check-prefix=YAML
-; RUN: llc -filetype=asm -emit-codeview-ghash-section < %s \
-; RUN:   | FileCheck %s --check-prefix=ASM
+; RUN: llc -filetype=asm < %s | FileCheck %s --check-prefix=ASM
 
 ; C++ source to regenerate:
 ; $ cat t.cpp
@@ -96,14 +95,16 @@ attributes #1 = { nounwind readnone spec
 attributes #2 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
 
 !llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!3, !4, !5, !6}
+!llvm.module.flags = !{!3, !4, !5, !6, !100}
 !llvm.ident = !{!7}
 
+
 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 6.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
 !1 = !DIFile(filename: "<stdin>", directory: "D:\5Csrc\5Cllvmbuild\5Cclang\5CDebug\5Cx86", checksumkind: CSK_MD5, checksum: "6279449503d9075c38e615e8387667c3")
 !2 = !{}
 !3 = !{i32 1, !"NumRegisterParameters", i32 0}
 !4 = !{i32 2, !"CodeView", i32 1}
+!100 = !{i32 2, !"CodeViewGHash", i32 1}
 !5 = !{i32 2, !"Debug Info Version", i32 3}
 !6 = !{i32 1, !"wchar_size", i32 2}
 !7 = !{!"clang version 6.0.0 "}




More information about the llvm-commits mailing list