LLVM 19.0.0git
DIEHash.h
Go to the documentation of this file.
1//===-- llvm/CodeGen/DIEHash.h - Dwarf Hashing Framework -------*- C++ -*--===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains support for DWARF4 hashing of DIEs.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DIEHASH_H
14#define LLVM_LIB_CODEGEN_ASMPRINTER_DIEHASH_H
15
16#include "llvm/ADT/DenseMap.h"
17#include "llvm/CodeGen/DIE.h"
18#include "llvm/Support/MD5.h"
19
20namespace llvm {
21
22class AsmPrinter;
23
24/// An object containing the capability of hashing and adding hash
25/// attributes onto a DIE.
26class DIEHash {
27 // Collection of all attributes used in hashing a particular DIE.
28 struct DIEAttrs {
29#define HANDLE_DIE_HASH_ATTR(NAME) DIEValue NAME;
30#include "DIEHashAttributes.def"
31 };
32
33public:
34 DIEHash(AsmPrinter *A = nullptr, DwarfCompileUnit *CU = nullptr)
35 : AP(A), CU(CU) {}
36
37 /// Computes the CU signature.
38 uint64_t computeCUSignature(StringRef DWOName, const DIE &Die);
39
40 /// Computes the type signature.
42
43 // Helper routines to process parts of a DIE.
44private:
45 /// Adds the parent context of \param Parent to the hash.
46 void addParentContext(const DIE &Parent);
47
48 /// Adds the attributes of \param Die to the hash.
49 void addAttributes(const DIE &Die);
50
51 /// Computes the full DWARF4 7.27 hash of the DIE.
52 void computeHash(const DIE &Die);
53
54 // Routines that add DIEValues to the hash.
55public:
56 /// Adds \param Value to the hash.
57 void update(uint8_t Value) { Hash.update(Value); }
58
59 /// Encodes and adds \param Value to the hash as a ULEB128.
61
62 /// Encodes and adds \param Value to the hash as a SLEB128.
63 void addSLEB128(int64_t Value);
64
65 void hashRawTypeReference(const DIE &Entry);
66
67private:
68 /// Adds \param Str to the hash and includes a NULL byte.
69 void addString(StringRef Str);
70
71 /// Collects the attributes of DIE \param Die into the \param Attrs
72 /// structure.
73 void collectAttributes(const DIE &Die, DIEAttrs &Attrs);
74
75 /// Hashes the attributes in \param Attrs in order.
76 void hashAttributes(const DIEAttrs &Attrs, dwarf::Tag Tag);
77
78 /// Hashes the data in a block like DIEValue, e.g. DW_FORM_block or
79 /// DW_FORM_exprloc.
80 void hashBlockData(const DIE::const_value_range &Values);
81
82 /// Hashes the contents pointed to in the .debug_loc section.
83 void hashLocList(const DIELocList &LocList);
84
85 /// Hashes an individual attribute.
86 void hashAttribute(const DIEValue &Value, dwarf::Tag Tag);
87
88 /// Hashes an attribute that refers to another DIE.
89 void hashDIEEntry(dwarf::Attribute Attribute, dwarf::Tag Tag,
90 const DIE &Entry);
91
92 /// Hashes a reference to a named type in such a way that is
93 /// independent of whether that type is described by a declaration or a
94 /// definition.
95 void hashShallowTypeReference(dwarf::Attribute Attribute, const DIE &Entry,
97
98 /// Hashes a reference to a previously referenced type DIE.
99 void hashRepeatedTypeReference(dwarf::Attribute Attribute,
100 unsigned DieNumber);
101
102 void hashNestedType(const DIE &Die, StringRef Name);
103
104private:
105 MD5 Hash;
106 AsmPrinter *AP;
109};
110}
111
112#endif
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
This file defines the DenseMap class.
std::string Name
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:84
An object containing the capability of hashing and adding hash attributes onto a DIE.
Definition: DIEHash.h:26
void update(uint8_t Value)
Adds.
Definition: DIEHash.h:57
void hashRawTypeReference(const DIE &Entry)
Definition: DIEHash.cpp:209
uint64_t computeTypeSignature(const DIE &Die)
Computes the type signature.
Definition: DIEHash.cpp:422
DIEHash(AsmPrinter *A=nullptr, DwarfCompileUnit *CU=nullptr)
Definition: DIEHash.h:34
void addSLEB128(int64_t Value)
Encodes and adds.
Definition: DIEHash.cpp:63
uint64_t computeCUSignature(StringRef DWOName, const DIE &Die)
Computes the CU signature.
Definition: DIEHash.cpp:399
void addULEB128(uint64_t Value)
Encodes and adds.
Definition: DIEHash.cpp:52
Represents a pointer to a location list in the debug_loc section.
Definition: DIE.h:337
A structured debug information entry.
Definition: DIE.h:819
Definition: MD5.h:41
void update(ArrayRef< uint8_t > Data)
Updates the hash for the byte stream provided.
Definition: MD5.cpp:189
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
LLVM Value Representation.
Definition: Value.h:74
A range adaptor for a pair of iterators.
Attribute
Attributes.
Definition: Dwarf.h:123
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18