From f4f0edfc5efaf79451df8579039881a64016be82 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Thu, 22 Oct 2020 20:08:54 -0700 Subject: [PATCH] DebugInfo: Hash DIE referevences (DW_OP_convert) when computing Split DWARF signatures --- include/llvm/CodeGen/DIE.h | 1 + lib/CodeGen/AsmPrinter/DIEHash.cpp | 11 ++++++++++- lib/CodeGen/AsmPrinter/DIEHash.h | 4 +++- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 2 +- test/DebugInfo/X86/convert-debugloc.ll | 5 +++++ 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/include/llvm/CodeGen/DIE.h b/include/llvm/CodeGen/DIE.h index fa554be64e7..eaa700f9e1e 100644 --- a/include/llvm/CodeGen/DIE.h +++ b/include/llvm/CodeGen/DIE.h @@ -247,6 +247,7 @@ public: unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const; void print(raw_ostream &O) const; + uint64_t getIndex() const { return Index; } }; //===--------------------------------------------------------------------===// diff --git a/lib/CodeGen/AsmPrinter/DIEHash.cpp b/lib/CodeGen/AsmPrinter/DIEHash.cpp index f26ef63eede..da9997efc01 100644 --- a/lib/CodeGen/AsmPrinter/DIEHash.cpp +++ b/lib/CodeGen/AsmPrinter/DIEHash.cpp @@ -12,6 +12,7 @@ #include "DIEHash.h" #include "ByteStreamer.h" +#include "DwarfCompileUnit.h" #include "DwarfDebug.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" @@ -214,7 +215,15 @@ void DIEHash::hashDIEEntry(dwarf::Attribute Attribute, dwarf::Tag Tag, // all of the data is going to be added as integers. void DIEHash::hashBlockData(const DIE::const_value_range &Values) { for (const auto &V : Values) - Hash.update((uint64_t)V.getDIEInteger().getValue()); + if (V.getType() == DIEValue::isBaseTypeRef) { + const DIE &C = + *CU->ExprRefedBaseTypes[V.getDIEBaseTypeRef().getIndex()].Die; + StringRef Name = getDIEStringAttr(C, dwarf::DW_AT_name); + assert(!Name.empty() && + "Base types referenced from DW_OP_convert should have a name"); + hashNestedType(C, Name); + } else + Hash.update((uint64_t)V.getDIEInteger().getValue()); } // Hash the contents of a loclistptr class. diff --git a/lib/CodeGen/AsmPrinter/DIEHash.h b/lib/CodeGen/AsmPrinter/DIEHash.h index 1a69f677287..29e1da4c5d6 100644 --- a/lib/CodeGen/AsmPrinter/DIEHash.h +++ b/lib/CodeGen/AsmPrinter/DIEHash.h @@ -31,7 +31,8 @@ class DIEHash { }; public: - DIEHash(AsmPrinter *A = nullptr) : AP(A) {} + DIEHash(AsmPrinter *A = nullptr, DwarfCompileUnit *CU = nullptr) + : AP(A), CU(CU) {} /// Computes the CU signature. uint64_t computeCUSignature(StringRef DWOName, const DIE &Die); @@ -101,6 +102,7 @@ private: private: MD5 Hash; AsmPrinter *AP; + DwarfCompileUnit *CU; DenseMap Numbering; }; } diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index f49790551fe..130df99bb18 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1288,7 +1288,7 @@ void DwarfDebug::finalizeModuleInfo() { Asm->TM.Options.MCOptions.SplitDwarfFile); // Emit a unique identifier for this CU. uint64_t ID = - DIEHash(Asm).computeCUSignature(DWOName, TheCU.getUnitDie()); + DIEHash(Asm, &TheCU).computeCUSignature(DWOName, TheCU.getUnitDie()); if (getDwarfVersion() >= 5) { TheCU.setDWOId(ID); SkCU->setDWOId(ID); diff --git a/test/DebugInfo/X86/convert-debugloc.ll b/test/DebugInfo/X86/convert-debugloc.ll index afe2cb368f5..2aafacfd80b 100644 --- a/test/DebugInfo/X86/convert-debugloc.ll +++ b/test/DebugInfo/X86/convert-debugloc.ll @@ -19,6 +19,11 @@ ; RUN: llc -mtriple=x86_64-pc-linux-gnu -dwarf-version=5 -filetype=obj -O0 < %s -debugger-tune=lldb -dwarf-op-convert=Enable | llvm-dwarfdump - \ ; RUN: | FileCheck %s --check-prefix=CONV "--implicit-check-not={{DW_TAG|NULL}}" +; Test DW_OP_convert + Split DWARF +; RUN: llc -mtriple=x86_64-pc-linux-gnu -dwarf-version=5 -filetype=obj -O0 < %s -debugger-tune=lldb -dwarf-op-convert=Enable -split-dwarf-file=baz.dwo | llvm-dwarfdump - \ +; RUN: | FileCheck %s --check-prefix=CONV --check-prefix=SPLITCONV --check-prefix=SPLIT "--implicit-check-not={{DW_TAG|NULL}}" + +; SPLITCONV: Compile Unit:{{.*}} DWO_id = 0xe91d8d1d7f9782c0 ; SPLIT: DW_TAG_skeleton_unit ; CONV: DW_TAG_compile_unit