Coverage Report

Created: 2017-10-03 07:32

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/lib/CodeGen/AsmPrinter/DIEHash.h
Line
Count
Source
1
//===-- llvm/CodeGen/DIEHash.h - Dwarf Hashing Framework -------*- C++ -*--===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This file contains support for DWARF4 hashing of DIEs.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DIEHASH_H
15
#define LLVM_LIB_CODEGEN_ASMPRINTER_DIEHASH_H
16
17
#include "llvm/ADT/DenseMap.h"
18
#include "llvm/CodeGen/DIE.h"
19
#include "llvm/Support/MD5.h"
20
21
namespace llvm {
22
23
class AsmPrinter;
24
class CompileUnit;
25
26
/// \brief An object containing the capability of hashing and adding hash
27
/// attributes onto a DIE.
28
class DIEHash {
29
  // Collection of all attributes used in hashing a particular DIE.
30
  struct DIEAttrs {
31
#define HANDLE_DIE_HASH_ATTR(NAME) DIEValue NAME;
32
#include "DIEHashAttributes.def"
33
  };
34
35
public:
36
49
  DIEHash(AsmPrinter *A = nullptr) : AP(A) {}
37
38
  /// \brief Computes the CU signature.
39
  uint64_t computeCUSignature(StringRef DWOName, const DIE &Die);
40
41
  /// \brief Computes the type signature.
42
  uint64_t computeTypeSignature(const DIE &Die);
43
44
  // Helper routines to process parts of a DIE.
45
private:
46
  /// \brief Adds the parent context of \param Die to the hash.
47
  void addParentContext(const DIE &Die);
48
49
  /// \brief Adds the attributes of \param Die to the hash.
50
  void addAttributes(const DIE &Die);
51
52
  /// \brief Computes the full DWARF4 7.27 hash of the DIE.
53
  void computeHash(const DIE &Die);
54
55
  // Routines that add DIEValues to the hash.
56
public:
57
  /// \brief Adds \param Value to the hash.
58
7
  void update(uint8_t Value) { Hash.update(Value); }
59
60
  /// \brief Encodes and adds \param Value to the hash as a ULEB128.
61
  void addULEB128(uint64_t Value);
62
63
  /// \brief Encodes and adds \param Value to the hash as a SLEB128.
64
  void addSLEB128(int64_t Value);
65
66
private:
67
  /// \brief Adds \param Str to the hash and includes a NULL byte.
68
  void addString(StringRef Str);
69
70
  /// \brief Collects the attributes of DIE \param Die into the \param Attrs
71
  /// structure.
72
  void collectAttributes(const DIE &Die, DIEAttrs &Attrs);
73
74
  /// \brief Hashes the attributes in \param Attrs in order.
75
  void hashAttributes(const DIEAttrs &Attrs, dwarf::Tag Tag);
76
77
  /// \brief Hashes the data in a block like DIEValue, e.g. DW_FORM_block or
78
  /// DW_FORM_exprloc.
79
  void hashBlockData(const DIE::const_value_range &Values);
80
81
  /// \brief Hashes the contents pointed to in the .debug_loc section.
82
  void hashLocList(const DIELocList &LocList);
83
84
  /// \brief Hashes an individual attribute.
85
  void hashAttribute(const DIEValue &Value, dwarf::Tag Tag);
86
87
  /// \brief Hashes an attribute that refers to another DIE.
88
  void hashDIEEntry(dwarf::Attribute Attribute, dwarf::Tag Tag,
89
                    const DIE &Entry);
90
91
  /// \brief Hashes a reference to a named type in such a way that is
92
  /// independent of whether that type is described by a declaration or a
93
  /// definition.
94
  void hashShallowTypeReference(dwarf::Attribute Attribute, const DIE &Entry,
95
                                StringRef Name);
96
97
  /// \brief Hashes a reference to a previously referenced type DIE.
98
  void hashRepeatedTypeReference(dwarf::Attribute Attribute,
99
                                 unsigned DieNumber);
100
101
  void hashNestedType(const DIE &Die, StringRef Name);
102
103
private:
104
  MD5 Hash;
105
  AsmPrinter *AP;
106
  DenseMap<const DIE *, unsigned> Numbering;
107
};
108
}
109
110
#endif