//===-- llvm/CodeGen/DIEHash.cpp - Dwarf Hashing Framework ----------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file contains support for DWARF4 hashing of DIEs. // //===----------------------------------------------------------------------===// #include "DIEHash.h" #include "ByteStreamer.h" #include "DwarfCompileUnit.h" #include "DwarfDebug.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" #include "llvm/BinaryFormat/Dwarf.h" #include "llvm/CodeGen/AsmPrinter.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" usingnamespacellvm; #define DEBUG_TYPE … /// Grabs the string in whichever attribute is passed in and returns /// a reference to it. static StringRef getDIEStringAttr(const DIE &Die, uint16_t Attr) { … } /// Adds the string in \p Str to the hash. This also hashes /// a trailing NULL with the string. void DIEHash::addString(StringRef Str) { … } // FIXME: The LEB128 routines are copied and only slightly modified out of // LEB128.h. /// Adds the unsigned in \p Value to the hash encoded as a ULEB128. void DIEHash::addULEB128(uint64_t Value) { … } void DIEHash::addSLEB128(int64_t Value) { … } /// Including \p Parent adds the context of Parent to the hash.. void DIEHash::addParentContext(const DIE &Parent) { … } // Collect all of the attributes for a particular DIE in single structure. void DIEHash::collectAttributes(const DIE &Die, DIEAttrs &Attrs) { … } void DIEHash::hashShallowTypeReference(dwarf::Attribute Attribute, const DIE &Entry, StringRef Name) { … } void DIEHash::hashRepeatedTypeReference(dwarf::Attribute Attribute, unsigned DieNumber) { … } void DIEHash::hashDIEEntry(dwarf::Attribute Attribute, dwarf::Tag Tag, const DIE &Entry) { … } void DIEHash::hashRawTypeReference(const DIE &Entry) { … } // Hash all of the values in a block like set of values. This assumes that // all of the data is going to be added as integers. void DIEHash::hashBlockData(const DIE::const_value_range &Values) { … } // Hash the contents of a loclistptr class. void DIEHash::hashLocList(const DIELocList &LocList) { … } // Hash an individual attribute \param Attr based on the type of attribute and // the form. void DIEHash::hashAttribute(const DIEValue &Value, dwarf::Tag Tag) { … } // Go through the attributes from \param Attrs in the order specified in 7.27.4 // and hash them. void DIEHash::hashAttributes(const DIEAttrs &Attrs, dwarf::Tag Tag) { … } // Add all of the attributes for \param Die to the hash. void DIEHash::addAttributes(const DIE &Die) { … } void DIEHash::hashNestedType(const DIE &Die, StringRef Name) { … } // Compute the hash of a DIE. This is based on the type signature computation // given in section 7.27 of the DWARF4 standard. It is the md5 hash of a // flattened description of the DIE. void DIEHash::computeHash(const DIE &Die) { … } /// This is based on the type signature computation given in section 7.27 of the /// DWARF4 standard. It is an md5 hash of the flattened description of the DIE /// with the inclusion of the full CU and all top level CU entities. // TODO: Initialize the type chain at 0 instead of 1 for CU signatures. uint64_t DIEHash::computeCUSignature(StringRef DWOName, const DIE &Die) { … } /// This is based on the type signature computation given in section 7.27 of the /// DWARF4 standard. It is an md5 hash of the flattened description of the DIE /// with the inclusion of additional forms not specifically called out in the /// standard. uint64_t DIEHash::computeTypeSignature(const DIE &Die) { … }