26#define DEBUG_TYPE "dwarfdebug"
33 for (
const auto &V : Die.
values())
34 if (V.getAttribute() == Attr)
35 return V.getDIEString().getString();
45 Hash.update(
ArrayRef((uint8_t)
'\0'));
69 More = !((((
Value == 0) && ((Byte & 0x40) == 0)) ||
70 ((
Value == -1) && ((Byte & 0x40) != 0))));
78void DIEHash::addParentContext(
const DIE &Parent) {
85 const DIE *Cur = &Parent;
87 Parents.push_back(Cur);
91 Cur->
getTag() == dwarf::DW_TAG_type_unit);
111void DIEHash::collectAttributes(
const DIE &Die, DIEAttrs &Attrs) {
113 for (
const auto &V : Die.
values()) {
117 switch (
V.getAttribute()) {
118#define HANDLE_DIE_HASH_ATTR(NAME) \
122#include "DIEHashAttributes.def"
138 if (
const DIE *Parent =
Entry.getParent())
139 addParentContext(*Parent);
156 unsigned DieNumber) {
170 assert(
Tag != dwarf::DW_TAG_friend &&
"No current LLVM clients emit friend "
171 "tags. Add support here when there's "
175 if ((
Tag == dwarf::DW_TAG_pointer_type ||
176 Tag == dwarf::DW_TAG_reference_type ||
177 Tag == dwarf::DW_TAG_rvalue_reference_type ||
178 Tag == dwarf::DW_TAG_ptr_to_member_type) &&
187 hashShallowTypeReference(
Attribute, Entry, Name);
192 unsigned &DieNumber = Numbering[&
Entry];
194 hashRepeatedTypeReference(
Attribute, DieNumber);
205 DieNumber = Numbering.size();
210 unsigned &DieNumber = Numbering[&Entry];
216 DieNumber = Numbering.size();
224 for (
const auto &V : Values)
225 if (V.getType() == DIEValue::isBaseTypeRef) {
227 *
CU->ExprRefedBaseTypes[V.getDIEBaseTypeRef().getIndex()].Die;
230 "Base types referenced from DW_OP_convert should have a name");
231 hashNestedType(
C, Name);
233 Hash.
update(V.getDIEInteger().getValue());
237void DIEHash::hashLocList(
const DIELocList &LocList) {
238 HashingByteStreamer Streamer(*
this);
239 DwarfDebug &DD = *AP->getDwarfDebug();
258 switch (
Value.getType()) {
265 case DIEValue::isEntry:
268 case DIEValue::isInteger: {
271 switch (
Value.getForm()) {
272 case dwarf::DW_FORM_data1:
273 case dwarf::DW_FORM_data2:
274 case dwarf::DW_FORM_data4:
275 case dwarf::DW_FORM_data8:
276 case dwarf::DW_FORM_udata:
277 case dwarf::DW_FORM_sdata:
283 case dwarf::DW_FORM_flag_present:
284 case dwarf::DW_FORM_flag:
293 case DIEValue::isString:
297 addString(
Value.getDIEString().getString());
299 case DIEValue::isInlineString:
303 addString(
Value.getDIEInlineString().getString());
305 case DIEValue::isBlock:
306 case DIEValue::isLoc:
307 case DIEValue::isLocList:
311 if (
Value.getType() == DIEValue::isBlock) {
313 hashBlockData(
Value.getDIEBlock().values());
314 }
else if (
Value.getType() == DIEValue::isLoc) {
316 hashBlockData(
Value.getDIELoc().values());
321 hashLocList(
Value.getDIELocList());
325 case DIEValue::isExpr:
326 case DIEValue::isLabel:
327 case DIEValue::isBaseTypeRef:
328 case DIEValue::isDelta:
329 case DIEValue::isAddrOffset:
336void DIEHash::hashAttributes(
const DIEAttrs &Attrs,
dwarf::Tag Tag) {
337#define HANDLE_DIE_HASH_ATTR(NAME) \
340 hashAttribute(Attrs.NAME, Tag); \
342#include "DIEHashAttributes.def"
347void DIEHash::addAttributes(
const DIE &Die) {
349 collectAttributes(Die, Attrs);
350 hashAttributes(Attrs, Die.
getTag());
353void DIEHash::hashNestedType(
const DIE &Die,
StringRef Name) {
368void DIEHash::computeHash(
const DIE &Die) {
380 if (
isType(
C.getTag()) || (
C.getTag() == dwarf::DW_TAG_subprogram &&
isType(
C.getParent()->getTag()))) {
384 hashNestedType(
C, Name);
392 Hash.update(
ArrayRef((uint8_t)
'\0'));
403 if (!DWOName.
empty())
404 Hash.update(DWOName);
415 return Result.high();
427 addParentContext(*Parent);
439 return Result.high();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static StringRef getDIEStringAttr(const DIE &Die, uint16_t Attr)
Grabs the string in whichever attribute is passed in and returns a reference to it.
This file contains constants used for implementing Dwarf debug support.
static bool isType(const Metadata *MD)
Functions, function parameters, and return types can have attributes to indicate how they should be t...
void hashRawTypeReference(const DIE &Entry)
LLVM_ABI_FOR_TEST uint64_t computeTypeSignature(const DIE &Die)
Computes the type signature.
void addSLEB128(int64_t Value)
Encodes and adds.
uint64_t computeCUSignature(StringRef DWOName, const DIE &Die)
Computes the CU signature.
void addULEB128(uint64_t Value)
Encodes and adds.
Represents a pointer to a location list in the debug_loc section.
size_t getValue() const
Grab the current index out.
iterator_range< const_value_iterator > const_value_range
A structured debug information entry.
dwarf::Tag getTag() const
LLVM_ABI DIE * getParent() const
const List & getList(size_t LI) const
ArrayRef< Entry > getEntries(const List &L) const
void emitDebugLocEntry(ByteStreamer &Streamer, const DebugLocStream::Entry &Entry, const DwarfCompileUnit *CU)
Emit an entry for the debug loc section.
const DebugLocStream & getDebugLocs() const
Returns the entries for the .debug_loc section.
LLVM_ABI void update(ArrayRef< uint8_t > Data)
Updates the hash for the byte stream provided.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
LLVM Value Representation.
LLVM_ABI StringRef AttributeString(unsigned Attribute)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
auto reverse(ContainerTy &&C)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
ArrayRef(const T &OneElt) -> ArrayRef< T >