mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[DebugInfo] Delete TypedDINodeRef
TypedDINodeRef<T> is a redundant wrapper of Metadata * that is actually a T *. Accordingly, change DI{Node,Scope,Type}Ref uses to DI{Node,Scope,Type} * or their const variants. This allows us to delete many resolve() calls that clutter the code. Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D61369 llvm-svn: 360108
This commit is contained in:
parent
d9a1aa7aba
commit
4dc78253e5
@ -129,7 +129,7 @@ public:
|
|||||||
const MCExpr *getFunctionLocalOffsetAfterInsn(const MachineInstr *MI);
|
const MCExpr *getFunctionLocalOffsetAfterInsn(const MachineInstr *MI);
|
||||||
|
|
||||||
/// If this type is derived from a base type then return base type size.
|
/// If this type is derived from a base type then return base type size.
|
||||||
static uint64_t getBaseTypeSize(const DITypeRef TyRef);
|
static uint64_t getBaseTypeSize(const DIType *Ty);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -60,44 +60,6 @@
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
/// Holds a subclass of DINode.
|
|
||||||
///
|
|
||||||
/// FIXME: This class doesn't currently make much sense. Previously it was a
|
|
||||||
/// union beteen MDString (for ODR-uniqued types) and things like DIType. To
|
|
||||||
/// support CodeView work, it wasn't deleted outright when MDString-based type
|
|
||||||
/// references were deleted; we'll soon need a similar concept for CodeView
|
|
||||||
/// DITypeIndex.
|
|
||||||
template <class T> class TypedDINodeRef {
|
|
||||||
const Metadata *MD = nullptr;
|
|
||||||
|
|
||||||
public:
|
|
||||||
TypedDINodeRef() = default;
|
|
||||||
TypedDINodeRef(std::nullptr_t) {}
|
|
||||||
TypedDINodeRef(const T *MD) : MD(MD) {}
|
|
||||||
|
|
||||||
explicit TypedDINodeRef(const Metadata *MD) : MD(MD) {
|
|
||||||
assert((!MD || isa<T>(MD)) && "Expected valid type ref");
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class U>
|
|
||||||
TypedDINodeRef(
|
|
||||||
const TypedDINodeRef<U> &X,
|
|
||||||
typename std::enable_if<std::is_convertible<U *, T *>::value>::type * =
|
|
||||||
nullptr)
|
|
||||||
: MD(X) {}
|
|
||||||
|
|
||||||
operator Metadata *() const { return const_cast<Metadata *>(MD); }
|
|
||||||
|
|
||||||
T *resolve() const { return const_cast<T *>(cast_or_null<T>(MD)); }
|
|
||||||
|
|
||||||
bool operator==(const TypedDINodeRef<T> &X) const { return MD == X.MD; }
|
|
||||||
bool operator!=(const TypedDINodeRef<T> &X) const { return MD != X.MD; }
|
|
||||||
};
|
|
||||||
|
|
||||||
using DINodeRef = TypedDINodeRef<DINode>;
|
|
||||||
using DIScopeRef = TypedDINodeRef<DIScope>;
|
|
||||||
using DITypeRef = TypedDINodeRef<DIType>;
|
|
||||||
|
|
||||||
class DITypeRefArray {
|
class DITypeRefArray {
|
||||||
const MDTuple *N = nullptr;
|
const MDTuple *N = nullptr;
|
||||||
|
|
||||||
@ -114,17 +76,19 @@ public:
|
|||||||
|
|
||||||
// FIXME: Fix callers and remove condition on N.
|
// FIXME: Fix callers and remove condition on N.
|
||||||
unsigned size() const { return N ? N->getNumOperands() : 0u; }
|
unsigned size() const { return N ? N->getNumOperands() : 0u; }
|
||||||
DITypeRef operator[](unsigned I) const { return DITypeRef(N->getOperand(I)); }
|
DIType *operator[](unsigned I) const {
|
||||||
|
return cast_or_null<DIType>(N->getOperand(I));
|
||||||
|
}
|
||||||
|
|
||||||
class iterator : std::iterator<std::input_iterator_tag, DITypeRef,
|
class iterator : std::iterator<std::input_iterator_tag, DIType *,
|
||||||
std::ptrdiff_t, void, DITypeRef> {
|
std::ptrdiff_t, void, DIType *> {
|
||||||
MDNode::op_iterator I = nullptr;
|
MDNode::op_iterator I = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
iterator() = default;
|
iterator() = default;
|
||||||
explicit iterator(MDNode::op_iterator I) : I(I) {}
|
explicit iterator(MDNode::op_iterator I) : I(I) {}
|
||||||
|
|
||||||
DITypeRef operator*() const { return DITypeRef(*I); }
|
DIType *operator*() const { return cast_or_null<DIType>(*I); }
|
||||||
|
|
||||||
iterator &operator++() {
|
iterator &operator++() {
|
||||||
++I;
|
++I;
|
||||||
@ -241,18 +205,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T> struct simplify_type<const TypedDINodeRef<T>> {
|
|
||||||
using SimpleType = Metadata *;
|
|
||||||
|
|
||||||
static SimpleType getSimplifiedValue(const TypedDINodeRef<T> &MD) {
|
|
||||||
return MD;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
struct simplify_type<TypedDINodeRef<T>>
|
|
||||||
: simplify_type<const TypedDINodeRef<T>> {};
|
|
||||||
|
|
||||||
/// Generic tagged DWARF-like metadata node.
|
/// Generic tagged DWARF-like metadata node.
|
||||||
///
|
///
|
||||||
/// An un-specialized DWARF-like metadata node. The first operand is a
|
/// An un-specialized DWARF-like metadata node. The first operand is a
|
||||||
@ -459,7 +411,7 @@ public:
|
|||||||
inline Optional<StringRef> getSource() const;
|
inline Optional<StringRef> getSource() const;
|
||||||
|
|
||||||
StringRef getName() const;
|
StringRef getName() const;
|
||||||
DIScopeRef getScope() const;
|
DIScope *getScope() const;
|
||||||
|
|
||||||
/// Return the raw underlying file.
|
/// Return the raw underlying file.
|
||||||
///
|
///
|
||||||
@ -673,7 +625,7 @@ public:
|
|||||||
uint64_t getOffsetInBits() const { return OffsetInBits; }
|
uint64_t getOffsetInBits() const { return OffsetInBits; }
|
||||||
DIFlags getFlags() const { return Flags; }
|
DIFlags getFlags() const { return Flags; }
|
||||||
|
|
||||||
DIScopeRef getScope() const { return DIScopeRef(getRawScope()); }
|
DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
|
||||||
StringRef getName() const { return getStringOperand(2); }
|
StringRef getName() const { return getStringOperand(2); }
|
||||||
|
|
||||||
|
|
||||||
@ -818,14 +770,12 @@ class DIDerivedType : public DIType {
|
|||||||
DWARFAddressSpace(DWARFAddressSpace) {}
|
DWARFAddressSpace(DWARFAddressSpace) {}
|
||||||
~DIDerivedType() = default;
|
~DIDerivedType() = default;
|
||||||
|
|
||||||
static DIDerivedType *getImpl(LLVMContext &Context, unsigned Tag,
|
static DIDerivedType *
|
||||||
StringRef Name, DIFile *File, unsigned Line,
|
getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, DIFile *File,
|
||||||
DIScopeRef Scope, DITypeRef BaseType,
|
unsigned Line, DIScope *Scope, DIType *BaseType, uint64_t SizeInBits,
|
||||||
uint64_t SizeInBits, uint32_t AlignInBits,
|
uint32_t AlignInBits, uint64_t OffsetInBits,
|
||||||
uint64_t OffsetInBits,
|
Optional<unsigned> DWARFAddressSpace, DIFlags Flags,
|
||||||
Optional<unsigned> DWARFAddressSpace,
|
Metadata *ExtraData, StorageType Storage, bool ShouldCreate = true) {
|
||||||
DIFlags Flags, Metadata *ExtraData,
|
|
||||||
StorageType Storage, bool ShouldCreate = true) {
|
|
||||||
return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File,
|
return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File,
|
||||||
Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits,
|
Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits,
|
||||||
DWARFAddressSpace, Flags, ExtraData, Storage, ShouldCreate);
|
DWARFAddressSpace, Flags, ExtraData, Storage, ShouldCreate);
|
||||||
@ -859,7 +809,7 @@ public:
|
|||||||
ExtraData))
|
ExtraData))
|
||||||
DEFINE_MDNODE_GET(DIDerivedType,
|
DEFINE_MDNODE_GET(DIDerivedType,
|
||||||
(unsigned Tag, StringRef Name, DIFile *File, unsigned Line,
|
(unsigned Tag, StringRef Name, DIFile *File, unsigned Line,
|
||||||
DIScopeRef Scope, DITypeRef BaseType, uint64_t SizeInBits,
|
DIScope *Scope, DIType *BaseType, uint64_t SizeInBits,
|
||||||
uint32_t AlignInBits, uint64_t OffsetInBits,
|
uint32_t AlignInBits, uint64_t OffsetInBits,
|
||||||
Optional<unsigned> DWARFAddressSpace, DIFlags Flags,
|
Optional<unsigned> DWARFAddressSpace, DIFlags Flags,
|
||||||
Metadata *ExtraData = nullptr),
|
Metadata *ExtraData = nullptr),
|
||||||
@ -870,7 +820,7 @@ public:
|
|||||||
TempDIDerivedType clone() const { return cloneImpl(); }
|
TempDIDerivedType clone() const { return cloneImpl(); }
|
||||||
|
|
||||||
/// Get the base type this is derived from.
|
/// Get the base type this is derived from.
|
||||||
DITypeRef getBaseType() const { return DITypeRef(getRawBaseType()); }
|
DIType *getBaseType() const { return cast_or_null<DIType>(getRawBaseType()); }
|
||||||
Metadata *getRawBaseType() const { return getOperand(3); }
|
Metadata *getRawBaseType() const { return getOperand(3); }
|
||||||
|
|
||||||
/// \returns The DWARF address space of the memory pointed to or referenced by
|
/// \returns The DWARF address space of the memory pointed to or referenced by
|
||||||
@ -890,9 +840,9 @@ public:
|
|||||||
|
|
||||||
/// Get casted version of extra data.
|
/// Get casted version of extra data.
|
||||||
/// @{
|
/// @{
|
||||||
DITypeRef getClassType() const {
|
DIType *getClassType() const {
|
||||||
assert(getTag() == dwarf::DW_TAG_ptr_to_member_type);
|
assert(getTag() == dwarf::DW_TAG_ptr_to_member_type);
|
||||||
return DITypeRef(getExtraData());
|
return cast_or_null<DIType>(getExtraData());
|
||||||
}
|
}
|
||||||
|
|
||||||
DIObjCProperty *getObjCProperty() const {
|
DIObjCProperty *getObjCProperty() const {
|
||||||
@ -964,12 +914,12 @@ class DICompositeType : public DIType {
|
|||||||
|
|
||||||
static DICompositeType *
|
static DICompositeType *
|
||||||
getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, Metadata *File,
|
getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, Metadata *File,
|
||||||
unsigned Line, DIScopeRef Scope, DITypeRef BaseType,
|
unsigned Line, DIScope *Scope, DIType *BaseType, uint64_t SizeInBits,
|
||||||
uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
|
uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags,
|
||||||
DIFlags Flags, DINodeArray Elements, unsigned RuntimeLang,
|
DINodeArray Elements, unsigned RuntimeLang, DIType *VTableHolder,
|
||||||
DITypeRef VTableHolder, DITemplateParameterArray TemplateParams,
|
DITemplateParameterArray TemplateParams, StringRef Identifier,
|
||||||
StringRef Identifier, DIDerivedType *Discriminator,
|
DIDerivedType *Discriminator, StorageType Storage,
|
||||||
StorageType Storage, bool ShouldCreate = true) {
|
bool ShouldCreate = true) {
|
||||||
return getImpl(
|
return getImpl(
|
||||||
Context, Tag, getCanonicalMDString(Context, Name), File, Line, Scope,
|
Context, Tag, getCanonicalMDString(Context, Name), File, Line, Scope,
|
||||||
BaseType, SizeInBits, AlignInBits, OffsetInBits, Flags, Elements.get(),
|
BaseType, SizeInBits, AlignInBits, OffsetInBits, Flags, Elements.get(),
|
||||||
@ -996,12 +946,13 @@ class DICompositeType : public DIType {
|
|||||||
public:
|
public:
|
||||||
DEFINE_MDNODE_GET(DICompositeType,
|
DEFINE_MDNODE_GET(DICompositeType,
|
||||||
(unsigned Tag, StringRef Name, DIFile *File, unsigned Line,
|
(unsigned Tag, StringRef Name, DIFile *File, unsigned Line,
|
||||||
DIScopeRef Scope, DITypeRef BaseType, uint64_t SizeInBits,
|
DIScope *Scope, DIType *BaseType, uint64_t SizeInBits,
|
||||||
uint32_t AlignInBits, uint64_t OffsetInBits,
|
uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags,
|
||||||
DIFlags Flags, DINodeArray Elements, unsigned RuntimeLang,
|
DINodeArray Elements, unsigned RuntimeLang,
|
||||||
DITypeRef VTableHolder,
|
DIType *VTableHolder,
|
||||||
DITemplateParameterArray TemplateParams = nullptr,
|
DITemplateParameterArray TemplateParams = nullptr,
|
||||||
StringRef Identifier = "", DIDerivedType *Discriminator = nullptr),
|
StringRef Identifier = "",
|
||||||
|
DIDerivedType *Discriminator = nullptr),
|
||||||
(Tag, Name, File, Line, Scope, BaseType, SizeInBits,
|
(Tag, Name, File, Line, Scope, BaseType, SizeInBits,
|
||||||
AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
|
AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
|
||||||
VTableHolder, TemplateParams, Identifier, Discriminator))
|
VTableHolder, TemplateParams, Identifier, Discriminator))
|
||||||
@ -1054,11 +1005,13 @@ public:
|
|||||||
unsigned RuntimeLang, Metadata *VTableHolder,
|
unsigned RuntimeLang, Metadata *VTableHolder,
|
||||||
Metadata *TemplateParams, Metadata *Discriminator);
|
Metadata *TemplateParams, Metadata *Discriminator);
|
||||||
|
|
||||||
DITypeRef getBaseType() const { return DITypeRef(getRawBaseType()); }
|
DIType *getBaseType() const { return cast_or_null<DIType>(getRawBaseType()); }
|
||||||
DINodeArray getElements() const {
|
DINodeArray getElements() const {
|
||||||
return cast_or_null<MDTuple>(getRawElements());
|
return cast_or_null<MDTuple>(getRawElements());
|
||||||
}
|
}
|
||||||
DITypeRef getVTableHolder() const { return DITypeRef(getRawVTableHolder()); }
|
DIType *getVTableHolder() const {
|
||||||
|
return cast_or_null<DIType>(getRawVTableHolder());
|
||||||
|
}
|
||||||
DITemplateParameterArray getTemplateParams() const {
|
DITemplateParameterArray getTemplateParams() const {
|
||||||
return cast_or_null<MDTuple>(getRawTemplateParams());
|
return cast_or_null<MDTuple>(getRawTemplateParams());
|
||||||
}
|
}
|
||||||
@ -1088,7 +1041,7 @@ public:
|
|||||||
replaceOperandWith(4, Elements.get());
|
replaceOperandWith(4, Elements.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void replaceVTableHolder(DITypeRef VTableHolder) {
|
void replaceVTableHolder(DIType *VTableHolder) {
|
||||||
replaceOperandWith(5, VTableHolder);
|
replaceOperandWith(5, VTableHolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1705,9 +1658,9 @@ private:
|
|||||||
~DISubprogram() = default;
|
~DISubprogram() = default;
|
||||||
|
|
||||||
static DISubprogram *
|
static DISubprogram *
|
||||||
getImpl(LLVMContext &Context, DIScopeRef Scope, StringRef Name,
|
getImpl(LLVMContext &Context, DIScope *Scope, StringRef Name,
|
||||||
StringRef LinkageName, DIFile *File, unsigned Line,
|
StringRef LinkageName, DIFile *File, unsigned Line,
|
||||||
DISubroutineType *Type, unsigned ScopeLine, DITypeRef ContainingType,
|
DISubroutineType *Type, unsigned ScopeLine, DIType *ContainingType,
|
||||||
unsigned VirtualIndex, int ThisAdjustment, DIFlags Flags,
|
unsigned VirtualIndex, int ThisAdjustment, DIFlags Flags,
|
||||||
DISPFlags SPFlags, DICompileUnit *Unit,
|
DISPFlags SPFlags, DICompileUnit *Unit,
|
||||||
DITemplateParameterArray TemplateParams, DISubprogram *Declaration,
|
DITemplateParameterArray TemplateParams, DISubprogram *Declaration,
|
||||||
@ -1742,9 +1695,9 @@ private:
|
|||||||
public:
|
public:
|
||||||
DEFINE_MDNODE_GET(
|
DEFINE_MDNODE_GET(
|
||||||
DISubprogram,
|
DISubprogram,
|
||||||
(DIScopeRef Scope, StringRef Name, StringRef LinkageName, DIFile *File,
|
(DIScope * Scope, StringRef Name, StringRef LinkageName, DIFile *File,
|
||||||
unsigned Line, DISubroutineType *Type, unsigned ScopeLine,
|
unsigned Line, DISubroutineType *Type, unsigned ScopeLine,
|
||||||
DITypeRef ContainingType, unsigned VirtualIndex, int ThisAdjustment,
|
DIType *ContainingType, unsigned VirtualIndex, int ThisAdjustment,
|
||||||
DIFlags Flags, DISPFlags SPFlags, DICompileUnit *Unit,
|
DIFlags Flags, DISPFlags SPFlags, DICompileUnit *Unit,
|
||||||
DITemplateParameterArray TemplateParams = nullptr,
|
DITemplateParameterArray TemplateParams = nullptr,
|
||||||
DISubprogram *Declaration = nullptr, DINodeArray RetainedNodes = nullptr,
|
DISubprogram *Declaration = nullptr, DINodeArray RetainedNodes = nullptr,
|
||||||
@ -1828,7 +1781,7 @@ public:
|
|||||||
// Returns true if this subprogram is a thunk generated by the compiler.
|
// Returns true if this subprogram is a thunk generated by the compiler.
|
||||||
bool isThunk() const { return getFlags() & FlagThunk; }
|
bool isThunk() const { return getFlags() & FlagThunk; }
|
||||||
|
|
||||||
DIScopeRef getScope() const { return DIScopeRef(getRawScope()); }
|
DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
|
||||||
|
|
||||||
StringRef getName() const { return getStringOperand(2); }
|
StringRef getName() const { return getStringOperand(2); }
|
||||||
StringRef getLinkageName() const { return getStringOperand(3); }
|
StringRef getLinkageName() const { return getStringOperand(3); }
|
||||||
@ -1836,8 +1789,8 @@ public:
|
|||||||
DISubroutineType *getType() const {
|
DISubroutineType *getType() const {
|
||||||
return cast_or_null<DISubroutineType>(getRawType());
|
return cast_or_null<DISubroutineType>(getRawType());
|
||||||
}
|
}
|
||||||
DITypeRef getContainingType() const {
|
DIType *getContainingType() const {
|
||||||
return DITypeRef(getRawContainingType());
|
return cast_or_null<DIType>(getRawContainingType());
|
||||||
}
|
}
|
||||||
|
|
||||||
DICompileUnit *getUnit() const {
|
DICompileUnit *getUnit() const {
|
||||||
@ -2182,7 +2135,7 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
StringRef getName() const { return getStringOperand(0); }
|
StringRef getName() const { return getStringOperand(0); }
|
||||||
DITypeRef getType() const { return DITypeRef(getRawType()); }
|
DIType *getType() const { return cast_or_null<DIType>(getRawType()); }
|
||||||
|
|
||||||
MDString *getRawName() const { return getOperandAs<MDString>(0); }
|
MDString *getRawName() const { return getOperandAs<MDString>(0); }
|
||||||
Metadata *getRawType() const { return getOperand(1); }
|
Metadata *getRawType() const { return getOperand(1); }
|
||||||
@ -2204,7 +2157,7 @@ class DITemplateTypeParameter : public DITemplateParameter {
|
|||||||
~DITemplateTypeParameter() = default;
|
~DITemplateTypeParameter() = default;
|
||||||
|
|
||||||
static DITemplateTypeParameter *getImpl(LLVMContext &Context, StringRef Name,
|
static DITemplateTypeParameter *getImpl(LLVMContext &Context, StringRef Name,
|
||||||
DITypeRef Type, StorageType Storage,
|
DIType *Type, StorageType Storage,
|
||||||
bool ShouldCreate = true) {
|
bool ShouldCreate = true) {
|
||||||
return getImpl(Context, getCanonicalMDString(Context, Name), Type, Storage,
|
return getImpl(Context, getCanonicalMDString(Context, Name), Type, Storage,
|
||||||
ShouldCreate);
|
ShouldCreate);
|
||||||
@ -2218,7 +2171,7 @@ class DITemplateTypeParameter : public DITemplateParameter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DEFINE_MDNODE_GET(DITemplateTypeParameter, (StringRef Name, DITypeRef Type),
|
DEFINE_MDNODE_GET(DITemplateTypeParameter, (StringRef Name, DIType *Type),
|
||||||
(Name, Type))
|
(Name, Type))
|
||||||
DEFINE_MDNODE_GET(DITemplateTypeParameter, (MDString * Name, Metadata *Type),
|
DEFINE_MDNODE_GET(DITemplateTypeParameter, (MDString * Name, Metadata *Type),
|
||||||
(Name, Type))
|
(Name, Type))
|
||||||
@ -2241,7 +2194,7 @@ class DITemplateValueParameter : public DITemplateParameter {
|
|||||||
~DITemplateValueParameter() = default;
|
~DITemplateValueParameter() = default;
|
||||||
|
|
||||||
static DITemplateValueParameter *getImpl(LLVMContext &Context, unsigned Tag,
|
static DITemplateValueParameter *getImpl(LLVMContext &Context, unsigned Tag,
|
||||||
StringRef Name, DITypeRef Type,
|
StringRef Name, DIType *Type,
|
||||||
Metadata *Value, StorageType Storage,
|
Metadata *Value, StorageType Storage,
|
||||||
bool ShouldCreate = true) {
|
bool ShouldCreate = true) {
|
||||||
return getImpl(Context, Tag, getCanonicalMDString(Context, Name), Type,
|
return getImpl(Context, Tag, getCanonicalMDString(Context, Name), Type,
|
||||||
@ -2258,8 +2211,9 @@ class DITemplateValueParameter : public DITemplateParameter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DEFINE_MDNODE_GET(DITemplateValueParameter, (unsigned Tag, StringRef Name,
|
DEFINE_MDNODE_GET(DITemplateValueParameter,
|
||||||
DITypeRef Type, Metadata *Value),
|
(unsigned Tag, StringRef Name, DIType *Type,
|
||||||
|
Metadata *Value),
|
||||||
(Tag, Name, Type, Value))
|
(Tag, Name, Type, Value))
|
||||||
DEFINE_MDNODE_GET(DITemplateValueParameter, (unsigned Tag, MDString *Name,
|
DEFINE_MDNODE_GET(DITemplateValueParameter, (unsigned Tag, MDString *Name,
|
||||||
Metadata *Type, Metadata *Value),
|
Metadata *Type, Metadata *Value),
|
||||||
@ -2291,7 +2245,7 @@ public:
|
|||||||
DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
|
DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
|
||||||
StringRef getName() const { return getStringOperand(1); }
|
StringRef getName() const { return getStringOperand(1); }
|
||||||
DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
|
DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
|
||||||
DITypeRef getType() const { return DITypeRef(getRawType()); }
|
DIType *getType() const { return cast_or_null<DIType>(getRawType()); }
|
||||||
uint32_t getAlignInBits() const { return AlignInBits; }
|
uint32_t getAlignInBits() const { return AlignInBits; }
|
||||||
uint32_t getAlignInBytes() const { return getAlignInBits() / CHAR_BIT; }
|
uint32_t getAlignInBytes() const { return getAlignInBits() / CHAR_BIT; }
|
||||||
/// Determines the size of the variable's type.
|
/// Determines the size of the variable's type.
|
||||||
@ -2300,7 +2254,7 @@ public:
|
|||||||
/// Return the signedness of this variable's type, or None if this type is
|
/// Return the signedness of this variable's type, or None if this type is
|
||||||
/// neither signed nor unsigned.
|
/// neither signed nor unsigned.
|
||||||
Optional<DIBasicType::Signedness> getSignedness() const {
|
Optional<DIBasicType::Signedness> getSignedness() const {
|
||||||
if (auto *BT = dyn_cast<DIBasicType>(getType().resolve()))
|
if (auto *BT = dyn_cast<DIBasicType>(getType()))
|
||||||
return BT->getSignedness();
|
return BT->getSignedness();
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
@ -2611,7 +2565,7 @@ class DIGlobalVariable : public DIVariable {
|
|||||||
|
|
||||||
static DIGlobalVariable *
|
static DIGlobalVariable *
|
||||||
getImpl(LLVMContext &Context, DIScope *Scope, StringRef Name,
|
getImpl(LLVMContext &Context, DIScope *Scope, StringRef Name,
|
||||||
StringRef LinkageName, DIFile *File, unsigned Line, DITypeRef Type,
|
StringRef LinkageName, DIFile *File, unsigned Line, DIType *Type,
|
||||||
bool IsLocalToUnit, bool IsDefinition,
|
bool IsLocalToUnit, bool IsDefinition,
|
||||||
DIDerivedType *StaticDataMemberDeclaration, MDTuple *TemplateParams,
|
DIDerivedType *StaticDataMemberDeclaration, MDTuple *TemplateParams,
|
||||||
uint32_t AlignInBits, StorageType Storage, bool ShouldCreate = true) {
|
uint32_t AlignInBits, StorageType Storage, bool ShouldCreate = true) {
|
||||||
@ -2638,7 +2592,7 @@ class DIGlobalVariable : public DIVariable {
|
|||||||
public:
|
public:
|
||||||
DEFINE_MDNODE_GET(DIGlobalVariable,
|
DEFINE_MDNODE_GET(DIGlobalVariable,
|
||||||
(DIScope * Scope, StringRef Name, StringRef LinkageName,
|
(DIScope * Scope, StringRef Name, StringRef LinkageName,
|
||||||
DIFile *File, unsigned Line, DITypeRef Type,
|
DIFile *File, unsigned Line, DIType *Type,
|
||||||
bool IsLocalToUnit, bool IsDefinition,
|
bool IsLocalToUnit, bool IsDefinition,
|
||||||
DIDerivedType *StaticDataMemberDeclaration,
|
DIDerivedType *StaticDataMemberDeclaration,
|
||||||
MDTuple *TemplateParams, uint32_t AlignInBits),
|
MDTuple *TemplateParams, uint32_t AlignInBits),
|
||||||
@ -2755,7 +2709,7 @@ class DILocalVariable : public DIVariable {
|
|||||||
|
|
||||||
static DILocalVariable *getImpl(LLVMContext &Context, DIScope *Scope,
|
static DILocalVariable *getImpl(LLVMContext &Context, DIScope *Scope,
|
||||||
StringRef Name, DIFile *File, unsigned Line,
|
StringRef Name, DIFile *File, unsigned Line,
|
||||||
DITypeRef Type, unsigned Arg, DIFlags Flags,
|
DIType *Type, unsigned Arg, DIFlags Flags,
|
||||||
uint32_t AlignInBits, StorageType Storage,
|
uint32_t AlignInBits, StorageType Storage,
|
||||||
bool ShouldCreate = true) {
|
bool ShouldCreate = true) {
|
||||||
return getImpl(Context, Scope, getCanonicalMDString(Context, Name), File,
|
return getImpl(Context, Scope, getCanonicalMDString(Context, Name), File,
|
||||||
@ -2776,8 +2730,8 @@ class DILocalVariable : public DIVariable {
|
|||||||
public:
|
public:
|
||||||
DEFINE_MDNODE_GET(DILocalVariable,
|
DEFINE_MDNODE_GET(DILocalVariable,
|
||||||
(DILocalScope * Scope, StringRef Name, DIFile *File,
|
(DILocalScope * Scope, StringRef Name, DIFile *File,
|
||||||
unsigned Line, DITypeRef Type, unsigned Arg,
|
unsigned Line, DIType *Type, unsigned Arg, DIFlags Flags,
|
||||||
DIFlags Flags, uint32_t AlignInBits),
|
uint32_t AlignInBits),
|
||||||
(Scope, Name, File, Line, Type, Arg, Flags, AlignInBits))
|
(Scope, Name, File, Line, Type, Arg, Flags, AlignInBits))
|
||||||
DEFINE_MDNODE_GET(DILocalVariable,
|
DEFINE_MDNODE_GET(DILocalVariable,
|
||||||
(Metadata * Scope, MDString *Name, Metadata *File,
|
(Metadata * Scope, MDString *Name, Metadata *File,
|
||||||
@ -2902,7 +2856,7 @@ class DIObjCProperty : public DINode {
|
|||||||
static DIObjCProperty *
|
static DIObjCProperty *
|
||||||
getImpl(LLVMContext &Context, StringRef Name, DIFile *File, unsigned Line,
|
getImpl(LLVMContext &Context, StringRef Name, DIFile *File, unsigned Line,
|
||||||
StringRef GetterName, StringRef SetterName, unsigned Attributes,
|
StringRef GetterName, StringRef SetterName, unsigned Attributes,
|
||||||
DITypeRef Type, StorageType Storage, bool ShouldCreate = true) {
|
DIType *Type, StorageType Storage, bool ShouldCreate = true) {
|
||||||
return getImpl(Context, getCanonicalMDString(Context, Name), File, Line,
|
return getImpl(Context, getCanonicalMDString(Context, Name), File, Line,
|
||||||
getCanonicalMDString(Context, GetterName),
|
getCanonicalMDString(Context, GetterName),
|
||||||
getCanonicalMDString(Context, SetterName), Attributes, Type,
|
getCanonicalMDString(Context, SetterName), Attributes, Type,
|
||||||
@ -2924,7 +2878,7 @@ public:
|
|||||||
DEFINE_MDNODE_GET(DIObjCProperty,
|
DEFINE_MDNODE_GET(DIObjCProperty,
|
||||||
(StringRef Name, DIFile *File, unsigned Line,
|
(StringRef Name, DIFile *File, unsigned Line,
|
||||||
StringRef GetterName, StringRef SetterName,
|
StringRef GetterName, StringRef SetterName,
|
||||||
unsigned Attributes, DITypeRef Type),
|
unsigned Attributes, DIType *Type),
|
||||||
(Name, File, Line, GetterName, SetterName, Attributes,
|
(Name, File, Line, GetterName, SetterName, Attributes,
|
||||||
Type))
|
Type))
|
||||||
DEFINE_MDNODE_GET(DIObjCProperty,
|
DEFINE_MDNODE_GET(DIObjCProperty,
|
||||||
@ -2942,7 +2896,7 @@ public:
|
|||||||
DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
|
DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
|
||||||
StringRef getGetterName() const { return getStringOperand(2); }
|
StringRef getGetterName() const { return getStringOperand(2); }
|
||||||
StringRef getSetterName() const { return getStringOperand(3); }
|
StringRef getSetterName() const { return getStringOperand(3); }
|
||||||
DITypeRef getType() const { return DITypeRef(getRawType()); }
|
DIType *getType() const { return cast_or_null<DIType>(getRawType()); }
|
||||||
|
|
||||||
StringRef getFilename() const {
|
StringRef getFilename() const {
|
||||||
if (auto *F = getFile())
|
if (auto *F = getFile())
|
||||||
@ -2986,8 +2940,8 @@ class DIImportedEntity : public DINode {
|
|||||||
~DIImportedEntity() = default;
|
~DIImportedEntity() = default;
|
||||||
|
|
||||||
static DIImportedEntity *getImpl(LLVMContext &Context, unsigned Tag,
|
static DIImportedEntity *getImpl(LLVMContext &Context, unsigned Tag,
|
||||||
DIScope *Scope, DINodeRef Entity,
|
DIScope *Scope, DINode *Entity, DIFile *File,
|
||||||
DIFile *File, unsigned Line, StringRef Name,
|
unsigned Line, StringRef Name,
|
||||||
StorageType Storage,
|
StorageType Storage,
|
||||||
bool ShouldCreate = true) {
|
bool ShouldCreate = true) {
|
||||||
return getImpl(Context, Tag, Scope, Entity, File, Line,
|
return getImpl(Context, Tag, Scope, Entity, File, Line,
|
||||||
@ -3006,8 +2960,8 @@ class DIImportedEntity : public DINode {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
DEFINE_MDNODE_GET(DIImportedEntity,
|
DEFINE_MDNODE_GET(DIImportedEntity,
|
||||||
(unsigned Tag, DIScope *Scope, DINodeRef Entity,
|
(unsigned Tag, DIScope *Scope, DINode *Entity, DIFile *File,
|
||||||
DIFile *File, unsigned Line, StringRef Name = ""),
|
unsigned Line, StringRef Name = ""),
|
||||||
(Tag, Scope, Entity, File, Line, Name))
|
(Tag, Scope, Entity, File, Line, Name))
|
||||||
DEFINE_MDNODE_GET(DIImportedEntity,
|
DEFINE_MDNODE_GET(DIImportedEntity,
|
||||||
(unsigned Tag, Metadata *Scope, Metadata *Entity,
|
(unsigned Tag, Metadata *Scope, Metadata *Entity,
|
||||||
@ -3018,7 +2972,7 @@ public:
|
|||||||
|
|
||||||
unsigned getLine() const { return Line; }
|
unsigned getLine() const { return Line; }
|
||||||
DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
|
DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
|
||||||
DINodeRef getEntity() const { return DINodeRef(getRawEntity()); }
|
DINode *getEntity() const { return cast_or_null<DINode>(getRawEntity()); }
|
||||||
StringRef getName() const { return getStringOperand(2); }
|
StringRef getName() const { return getStringOperand(2); }
|
||||||
DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
|
DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
|
||||||
|
|
||||||
|
@ -337,7 +337,7 @@ Metadata *BitcodeReaderMetadataList::resolveTypeRefArray(Metadata *MaybeTuple) {
|
|||||||
if (!Tuple || Tuple->isDistinct())
|
if (!Tuple || Tuple->isDistinct())
|
||||||
return MaybeTuple;
|
return MaybeTuple;
|
||||||
|
|
||||||
// Look through the DITypeRefArray, upgrading each DITypeRef.
|
// Look through the DITypeRefArray, upgrading each DIType *.
|
||||||
SmallVector<Metadata *, 32> Ops;
|
SmallVector<Metadata *, 32> Ops;
|
||||||
Ops.reserve(Tuple->getNumOperands());
|
Ops.reserve(Tuple->getNumOperands());
|
||||||
for (Metadata *MD : Tuple->operands())
|
for (Metadata *MD : Tuple->operands())
|
||||||
|
@ -272,7 +272,7 @@ static const DISubprogram *getQualifiedNameComponents(
|
|||||||
StringRef ScopeName = getPrettyScopeName(Scope);
|
StringRef ScopeName = getPrettyScopeName(Scope);
|
||||||
if (!ScopeName.empty())
|
if (!ScopeName.empty())
|
||||||
QualifiedNameComponents.push_back(ScopeName);
|
QualifiedNameComponents.push_back(ScopeName);
|
||||||
Scope = Scope->getScope().resolve();
|
Scope = Scope->getScope();
|
||||||
}
|
}
|
||||||
return ClosestSubprogram;
|
return ClosestSubprogram;
|
||||||
}
|
}
|
||||||
@ -308,7 +308,7 @@ struct CodeViewDebug::TypeLoweringScope {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static std::string getFullyQualifiedName(const DIScope *Ty) {
|
static std::string getFullyQualifiedName(const DIScope *Ty) {
|
||||||
const DIScope *Scope = Ty->getScope().resolve();
|
const DIScope *Scope = Ty->getScope();
|
||||||
return getFullyQualifiedName(Scope, getPrettyScopeName(Ty));
|
return getFullyQualifiedName(Scope, getPrettyScopeName(Ty));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,7 +343,7 @@ TypeIndex CodeViewDebug::getFuncIdForSubprogram(const DISubprogram *SP) {
|
|||||||
// MSVC.
|
// MSVC.
|
||||||
StringRef DisplayName = SP->getName().split('<').first;
|
StringRef DisplayName = SP->getName().split('<').first;
|
||||||
|
|
||||||
const DIScope *Scope = SP->getScope().resolve();
|
const DIScope *Scope = SP->getScope();
|
||||||
TypeIndex TI;
|
TypeIndex TI;
|
||||||
if (const auto *Class = dyn_cast_or_null<DICompositeType>(Scope)) {
|
if (const auto *Class = dyn_cast_or_null<DICompositeType>(Scope)) {
|
||||||
// If the scope is a DICompositeType, then this must be a method. Member
|
// If the scope is a DICompositeType, then this must be a method. Member
|
||||||
@ -375,7 +375,7 @@ getFunctionOptions(const DISubroutineType *Ty,
|
|||||||
const DIType *ReturnTy = nullptr;
|
const DIType *ReturnTy = nullptr;
|
||||||
if (auto TypeArray = Ty->getTypeArray()) {
|
if (auto TypeArray = Ty->getTypeArray()) {
|
||||||
if (TypeArray.size())
|
if (TypeArray.size())
|
||||||
ReturnTy = TypeArray[0].resolve();
|
ReturnTy = TypeArray[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto *ReturnDCTy = dyn_cast_or_null<DICompositeType>(ReturnTy)) {
|
if (auto *ReturnDCTy = dyn_cast_or_null<DICompositeType>(ReturnTy)) {
|
||||||
@ -974,8 +974,7 @@ void CodeViewDebug::emitDebugInfoForFunction(const Function *GV,
|
|||||||
// If we have a display name, build the fully qualified name by walking the
|
// If we have a display name, build the fully qualified name by walking the
|
||||||
// chain of scopes.
|
// chain of scopes.
|
||||||
if (!SP->getName().empty())
|
if (!SP->getName().empty())
|
||||||
FuncName =
|
FuncName = getFullyQualifiedName(SP->getScope(), SP->getName());
|
||||||
getFullyQualifiedName(SP->getScope().resolve(), SP->getName());
|
|
||||||
|
|
||||||
// If our DISubprogram name is empty, use the mangled name.
|
// If our DISubprogram name is empty, use the mangled name.
|
||||||
if (FuncName.empty())
|
if (FuncName.empty())
|
||||||
@ -1398,7 +1397,7 @@ static bool shouldEmitUdt(const DIType *T) {
|
|||||||
|
|
||||||
// MSVC does not emit UDTs for typedefs that are scoped to classes.
|
// MSVC does not emit UDTs for typedefs that are scoped to classes.
|
||||||
if (T->getTag() == dwarf::DW_TAG_typedef) {
|
if (T->getTag() == dwarf::DW_TAG_typedef) {
|
||||||
if (DIScope *Scope = T->getScope().resolve()) {
|
if (DIScope *Scope = T->getScope()) {
|
||||||
switch (Scope->getTag()) {
|
switch (Scope->getTag()) {
|
||||||
case dwarf::DW_TAG_structure_type:
|
case dwarf::DW_TAG_structure_type:
|
||||||
case dwarf::DW_TAG_class_type:
|
case dwarf::DW_TAG_class_type:
|
||||||
@ -1415,7 +1414,7 @@ static bool shouldEmitUdt(const DIType *T) {
|
|||||||
const DIDerivedType *DT = dyn_cast<DIDerivedType>(T);
|
const DIDerivedType *DT = dyn_cast<DIDerivedType>(T);
|
||||||
if (!DT)
|
if (!DT)
|
||||||
return true;
|
return true;
|
||||||
T = DT->getBaseType().resolve();
|
T = DT->getBaseType();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1428,8 +1427,8 @@ void CodeViewDebug::addToUDTs(const DIType *Ty) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
SmallVector<StringRef, 5> QualifiedNameComponents;
|
SmallVector<StringRef, 5> QualifiedNameComponents;
|
||||||
const DISubprogram *ClosestSubprogram = getQualifiedNameComponents(
|
const DISubprogram *ClosestSubprogram =
|
||||||
Ty->getScope().resolve(), QualifiedNameComponents);
|
getQualifiedNameComponents(Ty->getScope(), QualifiedNameComponents);
|
||||||
|
|
||||||
std::string FullyQualifiedName =
|
std::string FullyQualifiedName =
|
||||||
getQualifiedName(QualifiedNameComponents, getPrettyScopeName(Ty));
|
getQualifiedName(QualifiedNameComponents, getPrettyScopeName(Ty));
|
||||||
@ -1498,8 +1497,7 @@ TypeIndex CodeViewDebug::lowerType(const DIType *Ty, const DIType *ClassTy) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TypeIndex CodeViewDebug::lowerTypeAlias(const DIDerivedType *Ty) {
|
TypeIndex CodeViewDebug::lowerTypeAlias(const DIDerivedType *Ty) {
|
||||||
DITypeRef UnderlyingTypeRef = Ty->getBaseType();
|
TypeIndex UnderlyingTypeIndex = getTypeIndex(Ty->getBaseType());
|
||||||
TypeIndex UnderlyingTypeIndex = getTypeIndex(UnderlyingTypeRef);
|
|
||||||
StringRef TypeName = Ty->getName();
|
StringRef TypeName = Ty->getName();
|
||||||
|
|
||||||
addToUDTs(Ty);
|
addToUDTs(Ty);
|
||||||
@ -1515,14 +1513,14 @@ TypeIndex CodeViewDebug::lowerTypeAlias(const DIDerivedType *Ty) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TypeIndex CodeViewDebug::lowerTypeArray(const DICompositeType *Ty) {
|
TypeIndex CodeViewDebug::lowerTypeArray(const DICompositeType *Ty) {
|
||||||
DITypeRef ElementTypeRef = Ty->getBaseType();
|
const DIType *ElementType = Ty->getBaseType();
|
||||||
TypeIndex ElementTypeIndex = getTypeIndex(ElementTypeRef);
|
TypeIndex ElementTypeIndex = getTypeIndex(ElementType);
|
||||||
// IndexType is size_t, which depends on the bitness of the target.
|
// IndexType is size_t, which depends on the bitness of the target.
|
||||||
TypeIndex IndexType = getPointerSizeInBytes() == 8
|
TypeIndex IndexType = getPointerSizeInBytes() == 8
|
||||||
? TypeIndex(SimpleTypeKind::UInt64Quad)
|
? TypeIndex(SimpleTypeKind::UInt64Quad)
|
||||||
: TypeIndex(SimpleTypeKind::UInt32Long);
|
: TypeIndex(SimpleTypeKind::UInt32Long);
|
||||||
|
|
||||||
uint64_t ElementSize = getBaseTypeSize(ElementTypeRef) / 8;
|
uint64_t ElementSize = getBaseTypeSize(ElementType) / 8;
|
||||||
|
|
||||||
// Add subranges to array type.
|
// Add subranges to array type.
|
||||||
DINodeArray Elements = Ty->getElements();
|
DINodeArray Elements = Ty->getElements();
|
||||||
@ -1783,7 +1781,7 @@ TypeIndex CodeViewDebug::lowerTypeModifier(const DIDerivedType *Ty) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (IsModifier)
|
if (IsModifier)
|
||||||
BaseTy = cast<DIDerivedType>(BaseTy)->getBaseType().resolve();
|
BaseTy = cast<DIDerivedType>(BaseTy)->getBaseType();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the inner type will use an LF_POINTER record. If so, the
|
// Check if the inner type will use an LF_POINTER record. If so, the
|
||||||
@ -1816,8 +1814,8 @@ TypeIndex CodeViewDebug::lowerTypeModifier(const DIDerivedType *Ty) {
|
|||||||
|
|
||||||
TypeIndex CodeViewDebug::lowerTypeFunction(const DISubroutineType *Ty) {
|
TypeIndex CodeViewDebug::lowerTypeFunction(const DISubroutineType *Ty) {
|
||||||
SmallVector<TypeIndex, 8> ReturnAndArgTypeIndices;
|
SmallVector<TypeIndex, 8> ReturnAndArgTypeIndices;
|
||||||
for (DITypeRef ArgTypeRef : Ty->getTypeArray())
|
for (const DIType *ArgType : Ty->getTypeArray())
|
||||||
ReturnAndArgTypeIndices.push_back(getTypeIndex(ArgTypeRef));
|
ReturnAndArgTypeIndices.push_back(getTypeIndex(ArgType));
|
||||||
|
|
||||||
// MSVC uses type none for variadic argument.
|
// MSVC uses type none for variadic argument.
|
||||||
if (ReturnAndArgTypeIndices.size() > 1 &&
|
if (ReturnAndArgTypeIndices.size() > 1 &&
|
||||||
@ -1866,7 +1864,7 @@ TypeIndex CodeViewDebug::lowerTypeMemberFunction(const DISubroutineType *Ty,
|
|||||||
TypeIndex ThisTypeIndex;
|
TypeIndex ThisTypeIndex;
|
||||||
if (!IsStaticMethod && ReturnAndArgs.size() > Index) {
|
if (!IsStaticMethod && ReturnAndArgs.size() > Index) {
|
||||||
if (const DIDerivedType *PtrTy =
|
if (const DIDerivedType *PtrTy =
|
||||||
dyn_cast_or_null<DIDerivedType>(ReturnAndArgs[Index].resolve())) {
|
dyn_cast_or_null<DIDerivedType>(ReturnAndArgs[Index])) {
|
||||||
if (PtrTy->getTag() == dwarf::DW_TAG_pointer_type) {
|
if (PtrTy->getTag() == dwarf::DW_TAG_pointer_type) {
|
||||||
ThisTypeIndex = getTypeIndexForThisPtr(PtrTy, Ty);
|
ThisTypeIndex = getTypeIndexForThisPtr(PtrTy, Ty);
|
||||||
Index++;
|
Index++;
|
||||||
@ -1964,7 +1962,7 @@ static ClassOptions getCommonClassOptions(const DICompositeType *Ty) {
|
|||||||
// Put the Nested flag on a type if it appears immediately inside a tag type.
|
// Put the Nested flag on a type if it appears immediately inside a tag type.
|
||||||
// Do not walk the scope chain. Do not attempt to compute ContainsNestedClass
|
// Do not walk the scope chain. Do not attempt to compute ContainsNestedClass
|
||||||
// here. That flag is only set on definitions, and not forward declarations.
|
// here. That flag is only set on definitions, and not forward declarations.
|
||||||
const DIScope *ImmediateScope = Ty->getScope().resolve();
|
const DIScope *ImmediateScope = Ty->getScope();
|
||||||
if (ImmediateScope && isa<DICompositeType>(ImmediateScope))
|
if (ImmediateScope && isa<DICompositeType>(ImmediateScope))
|
||||||
CO |= ClassOptions::Nested;
|
CO |= ClassOptions::Nested;
|
||||||
|
|
||||||
@ -1977,7 +1975,7 @@ static ClassOptions getCommonClassOptions(const DICompositeType *Ty) {
|
|||||||
CO |= ClassOptions::Scoped;
|
CO |= ClassOptions::Scoped;
|
||||||
} else {
|
} else {
|
||||||
for (const DIScope *Scope = ImmediateScope; Scope != nullptr;
|
for (const DIScope *Scope = ImmediateScope; Scope != nullptr;
|
||||||
Scope = Scope->getScope().resolve()) {
|
Scope = Scope->getScope()) {
|
||||||
if (isa<DISubprogram>(Scope)) {
|
if (isa<DISubprogram>(Scope)) {
|
||||||
CO |= ClassOptions::Scoped;
|
CO |= ClassOptions::Scoped;
|
||||||
break;
|
break;
|
||||||
@ -2097,7 +2095,7 @@ void CodeViewDebug::collectMemberInfo(ClassInfo &Info,
|
|||||||
// succeeds, and drop the member if that fails.
|
// succeeds, and drop the member if that fails.
|
||||||
assert((DDTy->getOffsetInBits() % 8) == 0 && "Unnamed bitfield member!");
|
assert((DDTy->getOffsetInBits() % 8) == 0 && "Unnamed bitfield member!");
|
||||||
uint64_t Offset = DDTy->getOffsetInBits();
|
uint64_t Offset = DDTy->getOffsetInBits();
|
||||||
const DIType *Ty = DDTy->getBaseType().resolve();
|
const DIType *Ty = DDTy->getBaseType();
|
||||||
bool FullyResolved = false;
|
bool FullyResolved = false;
|
||||||
while (!FullyResolved) {
|
while (!FullyResolved) {
|
||||||
switch (Ty->getTag()) {
|
switch (Ty->getTag()) {
|
||||||
@ -2105,7 +2103,7 @@ void CodeViewDebug::collectMemberInfo(ClassInfo &Info,
|
|||||||
case dwarf::DW_TAG_volatile_type:
|
case dwarf::DW_TAG_volatile_type:
|
||||||
// FIXME: we should apply the qualifier types to the indirect fields
|
// FIXME: we should apply the qualifier types to the indirect fields
|
||||||
// rather than dropping them.
|
// rather than dropping them.
|
||||||
Ty = cast<DIDerivedType>(Ty)->getBaseType().resolve();
|
Ty = cast<DIDerivedType>(Ty)->getBaseType();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
FullyResolved = true;
|
FullyResolved = true;
|
||||||
@ -2388,7 +2386,7 @@ CodeViewDebug::lowerRecordFieldList(const DICompositeType *Ty) {
|
|||||||
|
|
||||||
// Create nested classes.
|
// Create nested classes.
|
||||||
for (const DIType *Nested : Info.NestedTypes) {
|
for (const DIType *Nested : Info.NestedTypes) {
|
||||||
NestedTypeRecord R(getTypeIndex(DITypeRef(Nested)), Nested->getName());
|
NestedTypeRecord R(getTypeIndex(Nested), Nested->getName());
|
||||||
ContinuationBuilder.writeMemberType(R);
|
ContinuationBuilder.writeMemberType(R);
|
||||||
MemberCount++;
|
MemberCount++;
|
||||||
}
|
}
|
||||||
@ -2415,10 +2413,7 @@ TypeIndex CodeViewDebug::getVBPTypeIndex() {
|
|||||||
return VBPType;
|
return VBPType;
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeIndex CodeViewDebug::getTypeIndex(DITypeRef TypeRef, DITypeRef ClassTyRef) {
|
TypeIndex CodeViewDebug::getTypeIndex(const DIType *Ty, const DIType *ClassTy) {
|
||||||
const DIType *Ty = TypeRef.resolve();
|
|
||||||
const DIType *ClassTy = ClassTyRef.resolve();
|
|
||||||
|
|
||||||
// The null DIType is the void type. Don't try to hash it.
|
// The null DIType is the void type. Don't try to hash it.
|
||||||
if (!Ty)
|
if (!Ty)
|
||||||
return TypeIndex::Void();
|
return TypeIndex::Void();
|
||||||
@ -2461,8 +2456,7 @@ CodeViewDebug::getTypeIndexForThisPtr(const DIDerivedType *PtrTy,
|
|||||||
return recordTypeIndexForDINode(PtrTy, TI, SubroutineTy);
|
return recordTypeIndexForDINode(PtrTy, TI, SubroutineTy);
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeIndex CodeViewDebug::getTypeIndexForReferenceTo(DITypeRef TypeRef) {
|
TypeIndex CodeViewDebug::getTypeIndexForReferenceTo(const DIType *Ty) {
|
||||||
DIType *Ty = TypeRef.resolve();
|
|
||||||
PointerRecord PR(getTypeIndex(Ty),
|
PointerRecord PR(getTypeIndex(Ty),
|
||||||
getPointerSizeInBytes() == 8 ? PointerKind::Near64
|
getPointerSizeInBytes() == 8 ? PointerKind::Near64
|
||||||
: PointerKind::Near32,
|
: PointerKind::Near32,
|
||||||
@ -2471,9 +2465,7 @@ TypeIndex CodeViewDebug::getTypeIndexForReferenceTo(DITypeRef TypeRef) {
|
|||||||
return TypeTable.writeLeafType(PR);
|
return TypeTable.writeLeafType(PR);
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeIndex CodeViewDebug::getCompleteTypeIndex(DITypeRef TypeRef) {
|
TypeIndex CodeViewDebug::getCompleteTypeIndex(const DIType *Ty) {
|
||||||
const DIType *Ty = TypeRef.resolve();
|
|
||||||
|
|
||||||
// The null DIType is the void type. Don't try to hash it.
|
// The null DIType is the void type. Don't try to hash it.
|
||||||
if (!Ty)
|
if (!Ty)
|
||||||
return TypeIndex::Void();
|
return TypeIndex::Void();
|
||||||
@ -2484,7 +2476,7 @@ TypeIndex CodeViewDebug::getCompleteTypeIndex(DITypeRef TypeRef) {
|
|||||||
if (Ty->getTag() == dwarf::DW_TAG_typedef)
|
if (Ty->getTag() == dwarf::DW_TAG_typedef)
|
||||||
(void)getTypeIndex(Ty);
|
(void)getTypeIndex(Ty);
|
||||||
while (Ty->getTag() == dwarf::DW_TAG_typedef)
|
while (Ty->getTag() == dwarf::DW_TAG_typedef)
|
||||||
Ty = cast<DIDerivedType>(Ty)->getBaseType().resolve();
|
Ty = cast<DIDerivedType>(Ty)->getBaseType();
|
||||||
|
|
||||||
// If this is a non-record type, the complete type index is the same as the
|
// If this is a non-record type, the complete type index is the same as the
|
||||||
// normal type index. Just call getTypeIndex.
|
// normal type index. Just call getTypeIndex.
|
||||||
|
@ -373,14 +373,14 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public DebugHandlerBase {
|
|||||||
|
|
||||||
/// Translates the DIType to codeview if necessary and returns a type index
|
/// Translates the DIType to codeview if necessary and returns a type index
|
||||||
/// for it.
|
/// for it.
|
||||||
codeview::TypeIndex getTypeIndex(DITypeRef TypeRef,
|
codeview::TypeIndex getTypeIndex(const DIType *Ty,
|
||||||
DITypeRef ClassTyRef = DITypeRef());
|
const DIType *ClassTy = nullptr);
|
||||||
|
|
||||||
codeview::TypeIndex
|
codeview::TypeIndex
|
||||||
getTypeIndexForThisPtr(const DIDerivedType *PtrTy,
|
getTypeIndexForThisPtr(const DIDerivedType *PtrTy,
|
||||||
const DISubroutineType *SubroutineTy);
|
const DISubroutineType *SubroutineTy);
|
||||||
|
|
||||||
codeview::TypeIndex getTypeIndexForReferenceTo(DITypeRef TypeRef);
|
codeview::TypeIndex getTypeIndexForReferenceTo(const DIType *Ty);
|
||||||
|
|
||||||
codeview::TypeIndex getMemberFunctionType(const DISubprogram *SP,
|
codeview::TypeIndex getMemberFunctionType(const DISubprogram *SP,
|
||||||
const DICompositeType *Class);
|
const DICompositeType *Class);
|
||||||
@ -419,7 +419,7 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public DebugHandlerBase {
|
|||||||
/// use this entry point when generating symbol records. The complete and
|
/// use this entry point when generating symbol records. The complete and
|
||||||
/// incomplete type indices only differ for record types. All other types use
|
/// incomplete type indices only differ for record types. All other types use
|
||||||
/// the same index.
|
/// the same index.
|
||||||
codeview::TypeIndex getCompleteTypeIndex(DITypeRef TypeRef);
|
codeview::TypeIndex getCompleteTypeIndex(const DIType *Ty);
|
||||||
|
|
||||||
codeview::TypeIndex lowerCompleteTypeClass(const DICompositeType *Ty);
|
codeview::TypeIndex lowerCompleteTypeClass(const DICompositeType *Ty);
|
||||||
codeview::TypeIndex lowerCompleteTypeUnion(const DICompositeType *Ty);
|
codeview::TypeIndex lowerCompleteTypeUnion(const DICompositeType *Ty);
|
||||||
|
@ -140,10 +140,9 @@ DebugHandlerBase::getFunctionLocalOffsetAfterInsn(const MachineInstr *MI) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// If this type is derived from a base type then return base type size.
|
/// If this type is derived from a base type then return base type size.
|
||||||
uint64_t DebugHandlerBase::getBaseTypeSize(const DITypeRef TyRef) {
|
uint64_t DebugHandlerBase::getBaseTypeSize(const DIType *Ty) {
|
||||||
DIType *Ty = TyRef.resolve();
|
|
||||||
assert(Ty);
|
assert(Ty);
|
||||||
DIDerivedType *DDTy = dyn_cast<DIDerivedType>(Ty);
|
const DIDerivedType *DDTy = dyn_cast<DIDerivedType>(Ty);
|
||||||
if (!DDTy)
|
if (!DDTy)
|
||||||
return Ty->getSizeInBits();
|
return Ty->getSizeInBits();
|
||||||
|
|
||||||
@ -154,7 +153,7 @@ uint64_t DebugHandlerBase::getBaseTypeSize(const DITypeRef TyRef) {
|
|||||||
Tag != dwarf::DW_TAG_restrict_type && Tag != dwarf::DW_TAG_atomic_type)
|
Tag != dwarf::DW_TAG_restrict_type && Tag != dwarf::DW_TAG_atomic_type)
|
||||||
return DDTy->getSizeInBits();
|
return DDTy->getSizeInBits();
|
||||||
|
|
||||||
DIType *BaseType = DDTy->getBaseType().resolve();
|
DIType *BaseType = DDTy->getBaseType();
|
||||||
|
|
||||||
if (!BaseType)
|
if (!BaseType)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -119,7 +119,7 @@ DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE(
|
|||||||
assert(GV);
|
assert(GV);
|
||||||
|
|
||||||
auto *GVContext = GV->getScope();
|
auto *GVContext = GV->getScope();
|
||||||
auto *GTy = DD->resolve(GV->getType());
|
const DIType *GTy = GV->getType();
|
||||||
|
|
||||||
// Construct the context before querying for the existence of the DIE in
|
// Construct the context before querying for the existence of the DIE in
|
||||||
// case such construction creates the DIE.
|
// case such construction creates the DIE.
|
||||||
@ -131,7 +131,7 @@ DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE(
|
|||||||
DIE *VariableDIE = &createAndAddDIE(GV->getTag(), *ContextDIE, GV);
|
DIE *VariableDIE = &createAndAddDIE(GV->getTag(), *ContextDIE, GV);
|
||||||
DIScope *DeclContext;
|
DIScope *DeclContext;
|
||||||
if (auto *SDMDecl = GV->getStaticDataMemberDeclaration()) {
|
if (auto *SDMDecl = GV->getStaticDataMemberDeclaration()) {
|
||||||
DeclContext = resolve(SDMDecl->getScope());
|
DeclContext = SDMDecl->getScope();
|
||||||
assert(SDMDecl->isStaticMember() && "Expected static member decl");
|
assert(SDMDecl->isStaticMember() && "Expected static member decl");
|
||||||
assert(GV->isDefinition());
|
assert(GV->isDefinition());
|
||||||
// We need the declaration DIE that is in the static member's class.
|
// We need the declaration DIE that is in the static member's class.
|
||||||
@ -139,7 +139,7 @@ DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE(
|
|||||||
addDIEEntry(*VariableDIE, dwarf::DW_AT_specification, *VariableSpecDIE);
|
addDIEEntry(*VariableDIE, dwarf::DW_AT_specification, *VariableSpecDIE);
|
||||||
// If the global variable's type is different from the one in the class
|
// If the global variable's type is different from the one in the class
|
||||||
// member type, assume that it's more specific and also emit it.
|
// member type, assume that it's more specific and also emit it.
|
||||||
if (GTy != DD->resolve(SDMDecl->getBaseType()))
|
if (GTy != SDMDecl->getBaseType())
|
||||||
addType(*VariableDIE, GTy);
|
addType(*VariableDIE, GTy);
|
||||||
} else {
|
} else {
|
||||||
DeclContext = GV->getScope();
|
DeclContext = GV->getScope();
|
||||||
@ -878,7 +878,7 @@ void DwarfCompileUnit::constructAbstractSubprogramScopeDIE(
|
|||||||
ContextDIE = &getUnitDie();
|
ContextDIE = &getUnitDie();
|
||||||
getOrCreateSubprogramDIE(SPDecl);
|
getOrCreateSubprogramDIE(SPDecl);
|
||||||
} else {
|
} else {
|
||||||
ContextDIE = getOrCreateContextDIE(resolve(SP->getScope()));
|
ContextDIE = getOrCreateContextDIE(SP->getScope());
|
||||||
// The scope may be shared with a subprogram that has already been
|
// The scope may be shared with a subprogram that has already been
|
||||||
// constructed in another CU, in which case we need to construct this
|
// constructed in another CU, in which case we need to construct this
|
||||||
// subprogram in the same CU.
|
// subprogram in the same CU.
|
||||||
@ -927,7 +927,7 @@ DIE *DwarfCompileUnit::constructImportedEntityDIE(
|
|||||||
DIE *IMDie = DIE::get(DIEValueAllocator, (dwarf::Tag)Module->getTag());
|
DIE *IMDie = DIE::get(DIEValueAllocator, (dwarf::Tag)Module->getTag());
|
||||||
insertDIE(Module, IMDie);
|
insertDIE(Module, IMDie);
|
||||||
DIE *EntityDie;
|
DIE *EntityDie;
|
||||||
auto *Entity = resolve(Module->getEntity());
|
auto *Entity = Module->getEntity();
|
||||||
if (auto *NS = dyn_cast<DINamespace>(Entity))
|
if (auto *NS = dyn_cast<DINamespace>(Entity))
|
||||||
EntityDie = getOrCreateNameSpace(NS);
|
EntityDie = getOrCreateNameSpace(NS);
|
||||||
else if (auto *M = dyn_cast<DIModule>(Entity))
|
else if (auto *M = dyn_cast<DIModule>(Entity))
|
||||||
@ -1192,7 +1192,7 @@ void DwarfCompileUnit::addAddressExpr(DIE &Die, dwarf::Attribute Attribute,
|
|||||||
void DwarfCompileUnit::applySubprogramAttributesToDefinition(
|
void DwarfCompileUnit::applySubprogramAttributesToDefinition(
|
||||||
const DISubprogram *SP, DIE &SPDie) {
|
const DISubprogram *SP, DIE &SPDie) {
|
||||||
auto *SPDecl = SP->getDeclaration();
|
auto *SPDecl = SP->getDeclaration();
|
||||||
auto *Context = resolve(SPDecl ? SPDecl->getScope() : SP->getScope());
|
auto *Context = SPDecl ? SPDecl->getScope() : SP->getScope();
|
||||||
applySubprogramAttributes(SP, SPDie, includeMinimalInlineScopes());
|
applySubprogramAttributes(SP, SPDie, includeMinimalInlineScopes());
|
||||||
addGlobalName(SP->getName(), SPDie, Context);
|
addGlobalName(SP->getName(), SPDie, Context);
|
||||||
}
|
}
|
||||||
|
@ -196,11 +196,11 @@ bool DebugLocDwarfExpression::isFrameRegister(const TargetRegisterInfo &TRI,
|
|||||||
|
|
||||||
bool DbgVariable::isBlockByrefVariable() const {
|
bool DbgVariable::isBlockByrefVariable() const {
|
||||||
assert(getVariable() && "Invalid complex DbgVariable!");
|
assert(getVariable() && "Invalid complex DbgVariable!");
|
||||||
return getVariable()->getType().resolve()->isBlockByrefStruct();
|
return getVariable()->getType()->isBlockByrefStruct();
|
||||||
}
|
}
|
||||||
|
|
||||||
const DIType *DbgVariable::getType() const {
|
const DIType *DbgVariable::getType() const {
|
||||||
DIType *Ty = getVariable()->getType().resolve();
|
DIType *Ty = getVariable()->getType();
|
||||||
// FIXME: isBlockByrefVariable should be reformulated in terms of complex
|
// FIXME: isBlockByrefVariable should be reformulated in terms of complex
|
||||||
// addresses instead.
|
// addresses instead.
|
||||||
if (Ty->isBlockByrefStruct()) {
|
if (Ty->isBlockByrefStruct()) {
|
||||||
@ -232,13 +232,13 @@ const DIType *DbgVariable::getType() const {
|
|||||||
uint16_t tag = Ty->getTag();
|
uint16_t tag = Ty->getTag();
|
||||||
|
|
||||||
if (tag == dwarf::DW_TAG_pointer_type)
|
if (tag == dwarf::DW_TAG_pointer_type)
|
||||||
subType = resolve(cast<DIDerivedType>(Ty)->getBaseType());
|
subType = cast<DIDerivedType>(Ty)->getBaseType();
|
||||||
|
|
||||||
auto Elements = cast<DICompositeType>(subType)->getElements();
|
auto Elements = cast<DICompositeType>(subType)->getElements();
|
||||||
for (unsigned i = 0, N = Elements.size(); i < N; ++i) {
|
for (unsigned i = 0, N = Elements.size(); i < N; ++i) {
|
||||||
auto *DT = cast<DIDerivedType>(Elements[i]);
|
auto *DT = cast<DIDerivedType>(Elements[i]);
|
||||||
if (getName() == DT->getName())
|
if (getName() == DT->getName())
|
||||||
return resolve(DT->getBaseType());
|
return DT->getBaseType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Ty;
|
return Ty;
|
||||||
|
@ -218,11 +218,6 @@ public:
|
|||||||
static bool classof(const DbgEntity *N) {
|
static bool classof(const DbgEntity *N) {
|
||||||
return N->getDbgEntityID() == DbgVariableKind;
|
return N->getDbgEntityID() == DbgVariableKind;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
|
|
||||||
return Ref.resolve();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
@ -253,11 +248,6 @@ public:
|
|||||||
static bool classof(const DbgEntity *N) {
|
static bool classof(const DbgEntity *N) {
|
||||||
return N->getDbgEntityID() == DbgLabelKind;
|
return N->getDbgEntityID() == DbgLabelKind;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
|
|
||||||
return Ref.resolve();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Helper used to pair up a symbol and its DWARF compile unit.
|
/// Helper used to pair up a symbol and its DWARF compile unit.
|
||||||
@ -702,11 +692,6 @@ public:
|
|||||||
void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry,
|
void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry,
|
||||||
const DwarfCompileUnit *CU);
|
const DwarfCompileUnit *CU);
|
||||||
|
|
||||||
/// Find the MDNode for the given reference.
|
|
||||||
template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
|
|
||||||
return Ref.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
void addSubprogramNames(const DICompileUnit &CU, const DISubprogram *SP,
|
void addSubprogramNames(const DICompileUnit &CU, const DISubprogram *SP,
|
||||||
DIE &Die);
|
DIE &Die);
|
||||||
|
|
||||||
|
@ -471,9 +471,8 @@ static bool isUnsignedDIType(DwarfDebug *DD, const DIType *Ty) {
|
|||||||
assert(T == dwarf::DW_TAG_typedef || T == dwarf::DW_TAG_const_type ||
|
assert(T == dwarf::DW_TAG_typedef || T == dwarf::DW_TAG_const_type ||
|
||||||
T == dwarf::DW_TAG_volatile_type ||
|
T == dwarf::DW_TAG_volatile_type ||
|
||||||
T == dwarf::DW_TAG_restrict_type || T == dwarf::DW_TAG_atomic_type);
|
T == dwarf::DW_TAG_restrict_type || T == dwarf::DW_TAG_atomic_type);
|
||||||
DITypeRef Deriv = DTy->getBaseType();
|
assert(DTy->getBaseType() && "Expected valid base type");
|
||||||
assert(Deriv && "Expected valid base type");
|
return isUnsignedDIType(DD, DTy->getBaseType());
|
||||||
return isUnsignedDIType(DD, DD->resolve(Deriv));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto *BTy = cast<DIBasicType>(Ty);
|
auto *BTy = cast<DIBasicType>(Ty);
|
||||||
@ -613,7 +612,7 @@ DIE *DwarfUnit::getOrCreateContextDIE(const DIScope *Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DIE *DwarfUnit::createTypeDIE(const DICompositeType *Ty) {
|
DIE *DwarfUnit::createTypeDIE(const DICompositeType *Ty) {
|
||||||
auto *Context = resolve(Ty->getScope());
|
auto *Context = Ty->getScope();
|
||||||
DIE *ContextDIE = getOrCreateContextDIE(Context);
|
DIE *ContextDIE = getOrCreateContextDIE(Context);
|
||||||
|
|
||||||
if (DIE *TyDIE = getDIE(Ty))
|
if (DIE *TyDIE = getDIE(Ty))
|
||||||
@ -666,15 +665,15 @@ DIE *DwarfUnit::getOrCreateTypeDIE(const MDNode *TyNode) {
|
|||||||
|
|
||||||
// DW_TAG_restrict_type is not supported in DWARF2
|
// DW_TAG_restrict_type is not supported in DWARF2
|
||||||
if (Ty->getTag() == dwarf::DW_TAG_restrict_type && DD->getDwarfVersion() <= 2)
|
if (Ty->getTag() == dwarf::DW_TAG_restrict_type && DD->getDwarfVersion() <= 2)
|
||||||
return getOrCreateTypeDIE(resolve(cast<DIDerivedType>(Ty)->getBaseType()));
|
return getOrCreateTypeDIE(cast<DIDerivedType>(Ty)->getBaseType());
|
||||||
|
|
||||||
// DW_TAG_atomic_type is not supported in DWARF < 5
|
// DW_TAG_atomic_type is not supported in DWARF < 5
|
||||||
if (Ty->getTag() == dwarf::DW_TAG_atomic_type && DD->getDwarfVersion() < 5)
|
if (Ty->getTag() == dwarf::DW_TAG_atomic_type && DD->getDwarfVersion() < 5)
|
||||||
return getOrCreateTypeDIE(resolve(cast<DIDerivedType>(Ty)->getBaseType()));
|
return getOrCreateTypeDIE(cast<DIDerivedType>(Ty)->getBaseType());
|
||||||
|
|
||||||
// Construct the context before querying for the existence of the DIE in case
|
// Construct the context before querying for the existence of the DIE in case
|
||||||
// such construction creates the DIE.
|
// such construction creates the DIE.
|
||||||
auto *Context = resolve(Ty->getScope());
|
auto *Context = Ty->getScope();
|
||||||
DIE *ContextDIE = getOrCreateContextDIE(Context);
|
DIE *ContextDIE = getOrCreateContextDIE(Context);
|
||||||
assert(ContextDIE);
|
assert(ContextDIE);
|
||||||
|
|
||||||
@ -721,8 +720,8 @@ std::string DwarfUnit::getParentContextString(const DIScope *Context) const {
|
|||||||
SmallVector<const DIScope *, 1> Parents;
|
SmallVector<const DIScope *, 1> Parents;
|
||||||
while (!isa<DICompileUnit>(Context)) {
|
while (!isa<DICompileUnit>(Context)) {
|
||||||
Parents.push_back(Context);
|
Parents.push_back(Context);
|
||||||
if (Context->getScope())
|
if (const DIScope *S = Context->getScope())
|
||||||
Context = resolve(Context->getScope());
|
Context = S;
|
||||||
else
|
else
|
||||||
// Structure, etc types will have a NULL context if they're at the top
|
// Structure, etc types will have a NULL context if they're at the top
|
||||||
// level.
|
// level.
|
||||||
@ -773,7 +772,7 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const DIDerivedType *DTy) {
|
|||||||
uint16_t Tag = Buffer.getTag();
|
uint16_t Tag = Buffer.getTag();
|
||||||
|
|
||||||
// Map to main type, void will not have a type.
|
// Map to main type, void will not have a type.
|
||||||
const DIType *FromTy = resolve(DTy->getBaseType());
|
const DIType *FromTy = DTy->getBaseType();
|
||||||
if (FromTy)
|
if (FromTy)
|
||||||
addType(Buffer, FromTy);
|
addType(Buffer, FromTy);
|
||||||
|
|
||||||
@ -789,9 +788,8 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const DIDerivedType *DTy) {
|
|||||||
addUInt(Buffer, dwarf::DW_AT_byte_size, None, Size);
|
addUInt(Buffer, dwarf::DW_AT_byte_size, None, Size);
|
||||||
|
|
||||||
if (Tag == dwarf::DW_TAG_ptr_to_member_type)
|
if (Tag == dwarf::DW_TAG_ptr_to_member_type)
|
||||||
addDIEEntry(
|
addDIEEntry(Buffer, dwarf::DW_AT_containing_type,
|
||||||
Buffer, dwarf::DW_AT_containing_type,
|
*getOrCreateTypeDIE(cast<DIDerivedType>(DTy)->getClassType()));
|
||||||
*getOrCreateTypeDIE(resolve(cast<DIDerivedType>(DTy)->getClassType())));
|
|
||||||
// Add source line info if available and TyDesc is not a forward declaration.
|
// Add source line info if available and TyDesc is not a forward declaration.
|
||||||
if (!DTy->isForwardDecl())
|
if (!DTy->isForwardDecl())
|
||||||
addSourceLine(Buffer, DTy);
|
addSourceLine(Buffer, DTy);
|
||||||
@ -806,7 +804,7 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const DIDerivedType *DTy) {
|
|||||||
|
|
||||||
void DwarfUnit::constructSubprogramArguments(DIE &Buffer, DITypeRefArray Args) {
|
void DwarfUnit::constructSubprogramArguments(DIE &Buffer, DITypeRefArray Args) {
|
||||||
for (unsigned i = 1, N = Args.size(); i < N; ++i) {
|
for (unsigned i = 1, N = Args.size(); i < N; ++i) {
|
||||||
const DIType *Ty = resolve(Args[i]);
|
const DIType *Ty = Args[i];
|
||||||
if (!Ty) {
|
if (!Ty) {
|
||||||
assert(i == N-1 && "Unspecified parameter must be the last argument");
|
assert(i == N-1 && "Unspecified parameter must be the last argument");
|
||||||
createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, Buffer);
|
createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, Buffer);
|
||||||
@ -823,7 +821,7 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const DISubroutineType *CTy) {
|
|||||||
// Add return type. A void return won't have a type.
|
// Add return type. A void return won't have a type.
|
||||||
auto Elements = cast<DISubroutineType>(CTy)->getTypeArray();
|
auto Elements = cast<DISubroutineType>(CTy)->getTypeArray();
|
||||||
if (Elements.size())
|
if (Elements.size())
|
||||||
if (auto RTy = resolve(Elements[0]))
|
if (auto RTy = Elements[0])
|
||||||
addType(Buffer, RTy);
|
addType(Buffer, RTy);
|
||||||
|
|
||||||
bool isPrototyped = true;
|
bool isPrototyped = true;
|
||||||
@ -894,7 +892,7 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
|
|||||||
else if (auto *DDTy = dyn_cast<DIDerivedType>(Element)) {
|
else if (auto *DDTy = dyn_cast<DIDerivedType>(Element)) {
|
||||||
if (DDTy->getTag() == dwarf::DW_TAG_friend) {
|
if (DDTy->getTag() == dwarf::DW_TAG_friend) {
|
||||||
DIE &ElemDie = createAndAddDIE(dwarf::DW_TAG_friend, Buffer);
|
DIE &ElemDie = createAndAddDIE(dwarf::DW_TAG_friend, Buffer);
|
||||||
addType(ElemDie, resolve(DDTy->getBaseType()), dwarf::DW_AT_friend);
|
addType(ElemDie, DDTy->getBaseType(), dwarf::DW_AT_friend);
|
||||||
} else if (DDTy->isStaticMember()) {
|
} else if (DDTy->isStaticMember()) {
|
||||||
getOrCreateStaticMemberDIE(DDTy);
|
getOrCreateStaticMemberDIE(DDTy);
|
||||||
} else if (Tag == dwarf::DW_TAG_variant_part) {
|
} else if (Tag == dwarf::DW_TAG_variant_part) {
|
||||||
@ -903,7 +901,7 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
|
|||||||
DIE &Variant = createAndAddDIE(dwarf::DW_TAG_variant, Buffer);
|
DIE &Variant = createAndAddDIE(dwarf::DW_TAG_variant, Buffer);
|
||||||
if (const ConstantInt *CI =
|
if (const ConstantInt *CI =
|
||||||
dyn_cast_or_null<ConstantInt>(DDTy->getDiscriminantValue())) {
|
dyn_cast_or_null<ConstantInt>(DDTy->getDiscriminantValue())) {
|
||||||
if (isUnsignedDIType(DD, resolve(Discriminator->getBaseType())))
|
if (isUnsignedDIType(DD, Discriminator->getBaseType()))
|
||||||
addUInt(Variant, dwarf::DW_AT_discr_value, None, CI->getZExtValue());
|
addUInt(Variant, dwarf::DW_AT_discr_value, None, CI->getZExtValue());
|
||||||
else
|
else
|
||||||
addSInt(Variant, dwarf::DW_AT_discr_value, None, CI->getSExtValue());
|
addSInt(Variant, dwarf::DW_AT_discr_value, None, CI->getSExtValue());
|
||||||
@ -917,7 +915,7 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
|
|||||||
StringRef PropertyName = Property->getName();
|
StringRef PropertyName = Property->getName();
|
||||||
addString(ElemDie, dwarf::DW_AT_APPLE_property_name, PropertyName);
|
addString(ElemDie, dwarf::DW_AT_APPLE_property_name, PropertyName);
|
||||||
if (Property->getType())
|
if (Property->getType())
|
||||||
addType(ElemDie, resolve(Property->getType()));
|
addType(ElemDie, Property->getType());
|
||||||
addSourceLine(ElemDie, Property);
|
addSourceLine(ElemDie, Property);
|
||||||
StringRef GetterName = Property->getGetterName();
|
StringRef GetterName = Property->getGetterName();
|
||||||
if (!GetterName.empty())
|
if (!GetterName.empty())
|
||||||
@ -943,7 +941,7 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
|
|||||||
// inside C++ composite types to point to the base class with the vtable.
|
// inside C++ composite types to point to the base class with the vtable.
|
||||||
// Rust uses DW_AT_containing_type to link a vtable to the type
|
// Rust uses DW_AT_containing_type to link a vtable to the type
|
||||||
// for which it was created.
|
// for which it was created.
|
||||||
if (auto *ContainingType = resolve(CTy->getVTableHolder()))
|
if (auto *ContainingType = CTy->getVTableHolder())
|
||||||
addDIEEntry(Buffer, dwarf::DW_AT_containing_type,
|
addDIEEntry(Buffer, dwarf::DW_AT_containing_type,
|
||||||
*getOrCreateTypeDIE(ContainingType));
|
*getOrCreateTypeDIE(ContainingType));
|
||||||
|
|
||||||
@ -1013,7 +1011,7 @@ void DwarfUnit::constructTemplateTypeParameterDIE(
|
|||||||
createAndAddDIE(dwarf::DW_TAG_template_type_parameter, Buffer);
|
createAndAddDIE(dwarf::DW_TAG_template_type_parameter, Buffer);
|
||||||
// Add the type if it exists, it could be void and therefore no type.
|
// Add the type if it exists, it could be void and therefore no type.
|
||||||
if (TP->getType())
|
if (TP->getType())
|
||||||
addType(ParamDIE, resolve(TP->getType()));
|
addType(ParamDIE, TP->getType());
|
||||||
if (!TP->getName().empty())
|
if (!TP->getName().empty())
|
||||||
addString(ParamDIE, dwarf::DW_AT_name, TP->getName());
|
addString(ParamDIE, dwarf::DW_AT_name, TP->getName());
|
||||||
}
|
}
|
||||||
@ -1025,12 +1023,12 @@ void DwarfUnit::constructTemplateValueParameterDIE(
|
|||||||
// Add the type if there is one, template template and template parameter
|
// Add the type if there is one, template template and template parameter
|
||||||
// packs will not have a type.
|
// packs will not have a type.
|
||||||
if (VP->getTag() == dwarf::DW_TAG_template_value_parameter)
|
if (VP->getTag() == dwarf::DW_TAG_template_value_parameter)
|
||||||
addType(ParamDIE, resolve(VP->getType()));
|
addType(ParamDIE, VP->getType());
|
||||||
if (!VP->getName().empty())
|
if (!VP->getName().empty())
|
||||||
addString(ParamDIE, dwarf::DW_AT_name, VP->getName());
|
addString(ParamDIE, dwarf::DW_AT_name, VP->getName());
|
||||||
if (Metadata *Val = VP->getValue()) {
|
if (Metadata *Val = VP->getValue()) {
|
||||||
if (ConstantInt *CI = mdconst::dyn_extract<ConstantInt>(Val))
|
if (ConstantInt *CI = mdconst::dyn_extract<ConstantInt>(Val))
|
||||||
addConstantValue(ParamDIE, CI, resolve(VP->getType()));
|
addConstantValue(ParamDIE, CI, VP->getType());
|
||||||
else if (GlobalValue *GV = mdconst::dyn_extract<GlobalValue>(Val)) {
|
else if (GlobalValue *GV = mdconst::dyn_extract<GlobalValue>(Val)) {
|
||||||
// We cannot describe the location of dllimport'd entities: the
|
// We cannot describe the location of dllimport'd entities: the
|
||||||
// computation of their address requires loads from the IAT.
|
// computation of their address requires loads from the IAT.
|
||||||
@ -1104,7 +1102,7 @@ DIE *DwarfUnit::getOrCreateSubprogramDIE(const DISubprogram *SP, bool Minimal) {
|
|||||||
// such construction creates the DIE (as is the case for member function
|
// such construction creates the DIE (as is the case for member function
|
||||||
// declarations).
|
// declarations).
|
||||||
DIE *ContextDIE =
|
DIE *ContextDIE =
|
||||||
Minimal ? &getUnitDie() : getOrCreateContextDIE(resolve(SP->getScope()));
|
Minimal ? &getUnitDie() : getOrCreateContextDIE(SP->getScope());
|
||||||
|
|
||||||
if (DIE *SPDie = getDIE(SP))
|
if (DIE *SPDie = getDIE(SP))
|
||||||
return SPDie;
|
return SPDie;
|
||||||
@ -1217,7 +1215,7 @@ void DwarfUnit::applySubprogramAttributes(const DISubprogram *SP, DIE &SPDie,
|
|||||||
// Add a return type. If this is a type like a C/C++ void type we don't add a
|
// Add a return type. If this is a type like a C/C++ void type we don't add a
|
||||||
// return type.
|
// return type.
|
||||||
if (Args.size())
|
if (Args.size())
|
||||||
if (auto Ty = resolve(Args[0]))
|
if (auto Ty = Args[0])
|
||||||
addType(SPDie, Ty);
|
addType(SPDie, Ty);
|
||||||
|
|
||||||
unsigned VK = SP->getVirtuality();
|
unsigned VK = SP->getVirtuality();
|
||||||
@ -1229,8 +1227,7 @@ void DwarfUnit::applySubprogramAttributes(const DISubprogram *SP, DIE &SPDie,
|
|||||||
addUInt(*Block, dwarf::DW_FORM_udata, SP->getVirtualIndex());
|
addUInt(*Block, dwarf::DW_FORM_udata, SP->getVirtualIndex());
|
||||||
addBlock(SPDie, dwarf::DW_AT_vtable_elem_location, Block);
|
addBlock(SPDie, dwarf::DW_AT_vtable_elem_location, Block);
|
||||||
}
|
}
|
||||||
ContainingTypeMap.insert(
|
ContainingTypeMap.insert(std::make_pair(&SPDie, SP->getContainingType()));
|
||||||
std::make_pair(&SPDie, resolve(SP->getContainingType())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SP->isDefinition()) {
|
if (!SP->isDefinition()) {
|
||||||
@ -1336,7 +1333,7 @@ static bool hasVectorBeenPadded(const DICompositeType *CTy) {
|
|||||||
const uint64_t ActualSize = CTy->getSizeInBits();
|
const uint64_t ActualSize = CTy->getSizeInBits();
|
||||||
|
|
||||||
// Obtain the size of each element in the vector.
|
// Obtain the size of each element in the vector.
|
||||||
DIType *BaseTy = CTy->getBaseType().resolve();
|
DIType *BaseTy = CTy->getBaseType();
|
||||||
assert(BaseTy && "Unknown vector element type.");
|
assert(BaseTy && "Unknown vector element type.");
|
||||||
const uint64_t ElementSize = BaseTy->getSizeInBits();
|
const uint64_t ElementSize = BaseTy->getSizeInBits();
|
||||||
|
|
||||||
@ -1364,7 +1361,7 @@ void DwarfUnit::constructArrayTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Emit the element type.
|
// Emit the element type.
|
||||||
addType(Buffer, resolve(CTy->getBaseType()));
|
addType(Buffer, CTy->getBaseType());
|
||||||
|
|
||||||
// Get an anonymous type for index type.
|
// Get an anonymous type for index type.
|
||||||
// FIXME: This type should be passed down from the front end
|
// FIXME: This type should be passed down from the front end
|
||||||
@ -1382,7 +1379,7 @@ void DwarfUnit::constructArrayTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DwarfUnit::constructEnumTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
|
void DwarfUnit::constructEnumTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
|
||||||
const DIType *DTy = resolve(CTy->getBaseType());
|
const DIType *DTy = CTy->getBaseType();
|
||||||
bool IsUnsigned = DTy && isUnsignedDIType(DD, DTy);
|
bool IsUnsigned = DTy && isUnsignedDIType(DD, DTy);
|
||||||
if (DTy) {
|
if (DTy) {
|
||||||
if (DD->getDwarfVersion() >= 3)
|
if (DD->getDwarfVersion() >= 3)
|
||||||
@ -1426,7 +1423,7 @@ DIE &DwarfUnit::constructMemberDIE(DIE &Buffer, const DIDerivedType *DT) {
|
|||||||
if (!Name.empty())
|
if (!Name.empty())
|
||||||
addString(MemberDie, dwarf::DW_AT_name, Name);
|
addString(MemberDie, dwarf::DW_AT_name, Name);
|
||||||
|
|
||||||
if (DIType *Resolved = resolve(DT->getBaseType()))
|
if (DIType *Resolved = DT->getBaseType())
|
||||||
addType(MemberDie, Resolved);
|
addType(MemberDie, Resolved);
|
||||||
|
|
||||||
addSourceLine(MemberDie, DT);
|
addSourceLine(MemberDie, DT);
|
||||||
@ -1535,7 +1532,7 @@ DIE *DwarfUnit::getOrCreateStaticMemberDIE(const DIDerivedType *DT) {
|
|||||||
|
|
||||||
// Construct the context before querying for the existence of the DIE in case
|
// Construct the context before querying for the existence of the DIE in case
|
||||||
// such construction creates the DIE.
|
// such construction creates the DIE.
|
||||||
DIE *ContextDIE = getOrCreateContextDIE(resolve(DT->getScope()));
|
DIE *ContextDIE = getOrCreateContextDIE(DT->getScope());
|
||||||
assert(dwarf::isType(ContextDIE->getTag()) &&
|
assert(dwarf::isType(ContextDIE->getTag()) &&
|
||||||
"Static member should belong to a type.");
|
"Static member should belong to a type.");
|
||||||
|
|
||||||
@ -1544,7 +1541,7 @@ DIE *DwarfUnit::getOrCreateStaticMemberDIE(const DIDerivedType *DT) {
|
|||||||
|
|
||||||
DIE &StaticMemberDIE = createAndAddDIE(DT->getTag(), *ContextDIE, DT);
|
DIE &StaticMemberDIE = createAndAddDIE(DT->getTag(), *ContextDIE, DT);
|
||||||
|
|
||||||
const DIType *Ty = resolve(DT->getBaseType());
|
const DIType *Ty = DT->getBaseType();
|
||||||
|
|
||||||
addString(StaticMemberDIE, dwarf::DW_AT_name, DT->getName());
|
addString(StaticMemberDIE, dwarf::DW_AT_name, DT->getName());
|
||||||
addType(StaticMemberDIE, Ty);
|
addType(StaticMemberDIE, Ty);
|
||||||
|
@ -311,12 +311,6 @@ protected:
|
|||||||
/// create a new ID and insert it in the line table.
|
/// create a new ID and insert it in the line table.
|
||||||
virtual unsigned getOrCreateSourceID(const DIFile *File) = 0;
|
virtual unsigned getOrCreateSourceID(const DIFile *File) = 0;
|
||||||
|
|
||||||
/// Look in the DwarfDebug map for the MDNode that corresponds to the
|
|
||||||
/// reference.
|
|
||||||
template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
|
|
||||||
return Ref.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Emit the common part of the header for this unit.
|
/// Emit the common part of the header for this unit.
|
||||||
void emitCommonHeader(bool UseOffsets, dwarf::UnitType UT);
|
void emitCommonHeader(bool UseOffsets, dwarf::UnitType UT);
|
||||||
|
|
||||||
|
@ -166,8 +166,8 @@ createImportedModule(LLVMContext &C, dwarf::Tag Tag, DIScope *Context,
|
|||||||
if (Line)
|
if (Line)
|
||||||
assert(File && "Source location has line number but no file");
|
assert(File && "Source location has line number but no file");
|
||||||
unsigned EntitiesCount = C.pImpl->DIImportedEntitys.size();
|
unsigned EntitiesCount = C.pImpl->DIImportedEntitys.size();
|
||||||
auto *M =
|
auto *M = DIImportedEntity::get(C, Tag, Context, cast_or_null<DINode>(NS),
|
||||||
DIImportedEntity::get(C, Tag, Context, DINodeRef(NS), File, Line, Name);
|
File, Line, Name);
|
||||||
if (EntitiesCount < C.pImpl->DIImportedEntitys.size())
|
if (EntitiesCount < C.pImpl->DIImportedEntitys.size())
|
||||||
// A new Imported Entity was just added to the context.
|
// A new Imported Entity was just added to the context.
|
||||||
// Add it to the Imported Modules list.
|
// Add it to the Imported Modules list.
|
||||||
|
@ -81,7 +81,7 @@ void DebugInfoFinder::processCompileUnit(DICompileUnit *CU) {
|
|||||||
continue;
|
continue;
|
||||||
auto *GV = DIG->getVariable();
|
auto *GV = DIG->getVariable();
|
||||||
processScope(GV->getScope());
|
processScope(GV->getScope());
|
||||||
processType(GV->getType().resolve());
|
processType(GV->getType());
|
||||||
}
|
}
|
||||||
for (auto *ET : CU->getEnumTypes())
|
for (auto *ET : CU->getEnumTypes())
|
||||||
processType(ET);
|
processType(ET);
|
||||||
@ -91,7 +91,7 @@ void DebugInfoFinder::processCompileUnit(DICompileUnit *CU) {
|
|||||||
else
|
else
|
||||||
processSubprogram(cast<DISubprogram>(RT));
|
processSubprogram(cast<DISubprogram>(RT));
|
||||||
for (auto *Import : CU->getImportedEntities()) {
|
for (auto *Import : CU->getImportedEntities()) {
|
||||||
auto *Entity = Import->getEntity().resolve();
|
auto *Entity = Import->getEntity();
|
||||||
if (auto *T = dyn_cast<DIType>(Entity))
|
if (auto *T = dyn_cast<DIType>(Entity))
|
||||||
processType(T);
|
processType(T);
|
||||||
else if (auto *SP = dyn_cast<DISubprogram>(Entity))
|
else if (auto *SP = dyn_cast<DISubprogram>(Entity))
|
||||||
@ -124,14 +124,14 @@ void DebugInfoFinder::processLocation(const Module &M, const DILocation *Loc) {
|
|||||||
void DebugInfoFinder::processType(DIType *DT) {
|
void DebugInfoFinder::processType(DIType *DT) {
|
||||||
if (!addType(DT))
|
if (!addType(DT))
|
||||||
return;
|
return;
|
||||||
processScope(DT->getScope().resolve());
|
processScope(DT->getScope());
|
||||||
if (auto *ST = dyn_cast<DISubroutineType>(DT)) {
|
if (auto *ST = dyn_cast<DISubroutineType>(DT)) {
|
||||||
for (DITypeRef Ref : ST->getTypeArray())
|
for (DIType *Ref : ST->getTypeArray())
|
||||||
processType(Ref.resolve());
|
processType(Ref);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (auto *DCT = dyn_cast<DICompositeType>(DT)) {
|
if (auto *DCT = dyn_cast<DICompositeType>(DT)) {
|
||||||
processType(DCT->getBaseType().resolve());
|
processType(DCT->getBaseType());
|
||||||
for (Metadata *D : DCT->getElements()) {
|
for (Metadata *D : DCT->getElements()) {
|
||||||
if (auto *T = dyn_cast<DIType>(D))
|
if (auto *T = dyn_cast<DIType>(D))
|
||||||
processType(T);
|
processType(T);
|
||||||
@ -141,7 +141,7 @@ void DebugInfoFinder::processType(DIType *DT) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (auto *DDT = dyn_cast<DIDerivedType>(DT)) {
|
if (auto *DDT = dyn_cast<DIDerivedType>(DT)) {
|
||||||
processType(DDT->getBaseType().resolve());
|
processType(DDT->getBaseType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ void DebugInfoFinder::processScope(DIScope *Scope) {
|
|||||||
void DebugInfoFinder::processSubprogram(DISubprogram *SP) {
|
void DebugInfoFinder::processSubprogram(DISubprogram *SP) {
|
||||||
if (!addSubprogram(SP))
|
if (!addSubprogram(SP))
|
||||||
return;
|
return;
|
||||||
processScope(SP->getScope().resolve());
|
processScope(SP->getScope());
|
||||||
// Some of the users, e.g. CloneFunctionInto / CloneModule, need to set up a
|
// Some of the users, e.g. CloneFunctionInto / CloneModule, need to set up a
|
||||||
// ValueMap containing identity mappings for all of the DICompileUnit's, not
|
// ValueMap containing identity mappings for all of the DICompileUnit's, not
|
||||||
// just DISubprogram's, referenced from anywhere within the Function being
|
// just DISubprogram's, referenced from anywhere within the Function being
|
||||||
@ -187,9 +187,9 @@ void DebugInfoFinder::processSubprogram(DISubprogram *SP) {
|
|||||||
processType(SP->getType());
|
processType(SP->getType());
|
||||||
for (auto *Element : SP->getTemplateParams()) {
|
for (auto *Element : SP->getTemplateParams()) {
|
||||||
if (auto *TType = dyn_cast<DITemplateTypeParameter>(Element)) {
|
if (auto *TType = dyn_cast<DITemplateTypeParameter>(Element)) {
|
||||||
processType(TType->getType().resolve());
|
processType(TType->getType());
|
||||||
} else if (auto *TVal = dyn_cast<DITemplateValueParameter>(Element)) {
|
} else if (auto *TVal = dyn_cast<DITemplateValueParameter>(Element)) {
|
||||||
processType(TVal->getType().resolve());
|
processType(TVal->getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -207,7 +207,7 @@ void DebugInfoFinder::processDeclare(const Module &M,
|
|||||||
if (!NodesSeen.insert(DV).second)
|
if (!NodesSeen.insert(DV).second)
|
||||||
return;
|
return;
|
||||||
processScope(DV->getScope());
|
processScope(DV->getScope());
|
||||||
processType(DV->getType().resolve());
|
processType(DV->getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugInfoFinder::processValue(const Module &M, const DbgValueInst *DVI) {
|
void DebugInfoFinder::processValue(const Module &M, const DbgValueInst *DVI) {
|
||||||
@ -222,7 +222,7 @@ void DebugInfoFinder::processValue(const Module &M, const DbgValueInst *DVI) {
|
|||||||
if (!NodesSeen.insert(DV).second)
|
if (!NodesSeen.insert(DV).second)
|
||||||
return;
|
return;
|
||||||
processScope(DV->getScope());
|
processScope(DV->getScope());
|
||||||
processType(DV->getType().resolve());
|
processType(DV->getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DebugInfoFinder::addType(DIType *DT) {
|
bool DebugInfoFinder::addType(DIType *DT) {
|
||||||
@ -428,7 +428,8 @@ private:
|
|||||||
StringRef LinkageName = MDS->getName().empty() ? MDS->getLinkageName() : "";
|
StringRef LinkageName = MDS->getName().empty() ? MDS->getLinkageName() : "";
|
||||||
DISubprogram *Declaration = nullptr;
|
DISubprogram *Declaration = nullptr;
|
||||||
auto *Type = cast_or_null<DISubroutineType>(map(MDS->getType()));
|
auto *Type = cast_or_null<DISubroutineType>(map(MDS->getType()));
|
||||||
DITypeRef ContainingType(map(MDS->getContainingType()));
|
DIType *ContainingType =
|
||||||
|
cast_or_null<DIType>(map(MDS->getContainingType()));
|
||||||
auto *Unit = cast_or_null<DICompileUnit>(map(MDS->getUnit()));
|
auto *Unit = cast_or_null<DICompileUnit>(map(MDS->getUnit()));
|
||||||
auto Variables = nullptr;
|
auto Variables = nullptr;
|
||||||
auto TemplateParams = nullptr;
|
auto TemplateParams = nullptr;
|
||||||
|
@ -88,7 +88,7 @@ const DILocation *DILocation::getMergedLocation(const DILocation *LocA,
|
|||||||
DILocation *L = LocA->getInlinedAt();
|
DILocation *L = LocA->getInlinedAt();
|
||||||
while (S) {
|
while (S) {
|
||||||
Locations.insert(std::make_pair(S, L));
|
Locations.insert(std::make_pair(S, L));
|
||||||
S = S->getScope().resolve();
|
S = S->getScope();
|
||||||
if (!S && L) {
|
if (!S && L) {
|
||||||
S = L->getScope();
|
S = L->getScope();
|
||||||
L = L->getInlinedAt();
|
L = L->getInlinedAt();
|
||||||
@ -100,7 +100,7 @@ const DILocation *DILocation::getMergedLocation(const DILocation *LocA,
|
|||||||
while (S) {
|
while (S) {
|
||||||
if (Locations.count(std::make_pair(S, L)))
|
if (Locations.count(std::make_pair(S, L)))
|
||||||
break;
|
break;
|
||||||
S = S->getScope().resolve();
|
S = S->getScope();
|
||||||
if (!S && L) {
|
if (!S && L) {
|
||||||
S = L->getScope();
|
S = L->getScope();
|
||||||
L = L->getInlinedAt();
|
L = L->getInlinedAt();
|
||||||
@ -209,7 +209,7 @@ DINode::DIFlags DINode::splitFlags(DIFlags Flags,
|
|||||||
return Flags;
|
return Flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
DIScopeRef DIScope::getScope() const {
|
DIScope *DIScope::getScope() const {
|
||||||
if (auto *T = dyn_cast<DIType>(this))
|
if (auto *T = dyn_cast<DIType>(this))
|
||||||
return T->getScope();
|
return T->getScope();
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ void BTFTypeDerived::completeType(BTFDebug &BDebug) {
|
|||||||
BTFType.NameOff = BDebug.addString(DTy->getName());
|
BTFType.NameOff = BDebug.addString(DTy->getName());
|
||||||
|
|
||||||
// The base type for PTR/CONST/VOLATILE could be void.
|
// The base type for PTR/CONST/VOLATILE could be void.
|
||||||
const DIType *ResolvedType = DTy->getBaseType().resolve();
|
const DIType *ResolvedType = DTy->getBaseType();
|
||||||
if (!ResolvedType) {
|
if (!ResolvedType) {
|
||||||
assert((Kind == BTF::BTF_KIND_PTR || Kind == BTF::BTF_KIND_CONST ||
|
assert((Kind == BTF::BTF_KIND_PTR || Kind == BTF::BTF_KIND_CONST ||
|
||||||
Kind == BTF::BTF_KIND_VOLATILE) &&
|
Kind == BTF::BTF_KIND_VOLATILE) &&
|
||||||
@ -209,7 +209,7 @@ void BTFTypeStruct::completeType(BTFDebug &BDebug) {
|
|||||||
} else {
|
} else {
|
||||||
BTFMember.Offset = DDTy->getOffsetInBits();
|
BTFMember.Offset = DDTy->getOffsetInBits();
|
||||||
}
|
}
|
||||||
BTFMember.Type = BDebug.getTypeId(DDTy->getBaseType().resolve());
|
BTFMember.Type = BDebug.getTypeId(DDTy->getBaseType());
|
||||||
Members.push_back(BTFMember);
|
Members.push_back(BTFMember);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -239,7 +239,7 @@ BTFTypeFuncProto::BTFTypeFuncProto(
|
|||||||
|
|
||||||
void BTFTypeFuncProto::completeType(BTFDebug &BDebug) {
|
void BTFTypeFuncProto::completeType(BTFDebug &BDebug) {
|
||||||
DITypeRefArray Elements = STy->getTypeArray();
|
DITypeRefArray Elements = STy->getTypeArray();
|
||||||
auto RetType = Elements[0].resolve();
|
auto RetType = Elements[0];
|
||||||
BTFType.Type = RetType ? BDebug.getTypeId(RetType) : 0;
|
BTFType.Type = RetType ? BDebug.getTypeId(RetType) : 0;
|
||||||
BTFType.NameOff = 0;
|
BTFType.NameOff = 0;
|
||||||
|
|
||||||
@ -247,7 +247,7 @@ void BTFTypeFuncProto::completeType(BTFDebug &BDebug) {
|
|||||||
// to represent the vararg, encode the NameOff/Type to be 0.
|
// to represent the vararg, encode the NameOff/Type to be 0.
|
||||||
for (unsigned I = 1, N = Elements.size(); I < N; ++I) {
|
for (unsigned I = 1, N = Elements.size(); I < N; ++I) {
|
||||||
struct BTF::BTFParam Param;
|
struct BTF::BTFParam Param;
|
||||||
auto Element = Elements[I].resolve();
|
auto Element = Elements[I];
|
||||||
if (Element) {
|
if (Element) {
|
||||||
Param.NameOff = BDebug.addString(FuncArgNames[I]);
|
Param.NameOff = BDebug.addString(FuncArgNames[I]);
|
||||||
Param.Type = BDebug.getTypeId(Element);
|
Param.Type = BDebug.getTypeId(Element);
|
||||||
@ -393,7 +393,7 @@ void BTFDebug::visitSubroutineType(
|
|||||||
|
|
||||||
// Visit return type and func arg types.
|
// Visit return type and func arg types.
|
||||||
for (const auto Element : Elements) {
|
for (const auto Element : Elements) {
|
||||||
visitTypeEntry(Element.resolve());
|
visitTypeEntry(Element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,7 +427,7 @@ void BTFDebug::visitStructType(const DICompositeType *CTy, bool IsStruct,
|
|||||||
void BTFDebug::visitArrayType(const DICompositeType *CTy, uint32_t &TypeId) {
|
void BTFDebug::visitArrayType(const DICompositeType *CTy, uint32_t &TypeId) {
|
||||||
// Visit array element type.
|
// Visit array element type.
|
||||||
uint32_t ElemTypeId;
|
uint32_t ElemTypeId;
|
||||||
visitTypeEntry(CTy->getBaseType().resolve(), ElemTypeId);
|
visitTypeEntry(CTy->getBaseType(), ElemTypeId);
|
||||||
|
|
||||||
if (!CTy->getSizeInBits()) {
|
if (!CTy->getSizeInBits()) {
|
||||||
auto TypeEntry = llvm::make_unique<BTFTypeArray>(ElemTypeId, 0);
|
auto TypeEntry = llvm::make_unique<BTFTypeArray>(ElemTypeId, 0);
|
||||||
@ -513,7 +513,7 @@ void BTFDebug::visitDerivedType(const DIDerivedType *DTy, uint32_t &TypeId) {
|
|||||||
// Visit base type of pointer, typedef, const, volatile, restrict or
|
// Visit base type of pointer, typedef, const, volatile, restrict or
|
||||||
// struct/union member.
|
// struct/union member.
|
||||||
uint32_t TempTypeId = 0;
|
uint32_t TempTypeId = 0;
|
||||||
visitTypeEntry(DTy->getBaseType().resolve(), TempTypeId);
|
visitTypeEntry(DTy->getBaseType(), TempTypeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BTFDebug::visitTypeEntry(const DIType *Ty, uint32_t &TypeId) {
|
void BTFDebug::visitTypeEntry(const DIType *Ty, uint32_t &TypeId) {
|
||||||
@ -713,7 +713,7 @@ void BTFDebug::beginFunctionImpl(const MachineFunction *MF) {
|
|||||||
// Collect function arguments for subprogram func type.
|
// Collect function arguments for subprogram func type.
|
||||||
uint32_t Arg = DV->getArg();
|
uint32_t Arg = DV->getArg();
|
||||||
if (Arg) {
|
if (Arg) {
|
||||||
visitTypeEntry(DV->getType().resolve());
|
visitTypeEntry(DV->getType());
|
||||||
FuncArgNames[Arg] = DV->getName();
|
FuncArgNames[Arg] = DV->getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -810,7 +810,7 @@ void BTFDebug::processGlobals() {
|
|||||||
Global.getDebugInfo(GVs);
|
Global.getDebugInfo(GVs);
|
||||||
uint32_t GVTypeId = 0;
|
uint32_t GVTypeId = 0;
|
||||||
for (auto *GVE : GVs) {
|
for (auto *GVE : GVs) {
|
||||||
visitTypeEntry(GVE->getVariable()->getType().resolve(), GVTypeId);
|
visitTypeEntry(GVE->getVariable()->getType(), GVTypeId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ struct BreakpointPrinter : public ModulePass {
|
|||||||
}
|
}
|
||||||
} else if (auto *TY = dyn_cast<DIType>(Context)) {
|
} else if (auto *TY = dyn_cast<DIType>(Context)) {
|
||||||
if (!TY->getName().empty()) {
|
if (!TY->getName().empty()) {
|
||||||
getContextName(TY->getScope().resolve(), N);
|
getContextName(TY->getScope(), N);
|
||||||
N = N + TY->getName().str() + "::";
|
N = N + TY->getName().str() + "::";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ struct BreakpointPrinter : public ModulePass {
|
|||||||
auto *SP = cast_or_null<DISubprogram>(NMD->getOperand(i));
|
auto *SP = cast_or_null<DISubprogram>(NMD->getOperand(i));
|
||||||
if (!SP)
|
if (!SP)
|
||||||
continue;
|
continue;
|
||||||
getContextName(SP->getScope().resolve(), Name);
|
getContextName(SP->getScope(), Name);
|
||||||
Name = Name + SP->getName().str();
|
Name = Name + SP->getName().str();
|
||||||
if (!Name.empty() && Processed.insert(Name).second) {
|
if (!Name.empty() && Processed.insert(Name).second) {
|
||||||
Out << Name << "\n";
|
Out << Name << "\n";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user