forked from OSchip/llvm-project
DebugInfo: Remove DITypedArray<>, replace with typedefs
Replace all uses of `DITypedArray<>` with `MDTupleTypedArrayWrapper<>` and `MDTypeRefArray`. The APIs are completely different, but the provided functionality is the same: treat an `MDTuple` as if it's an array of a particular element type. To simplify this patch a bit, I've temporarily typedef'ed `DebugNodeArray` to `DIArray` and `MDTypeRefArray` to `DITypeArray`. I've also temporarily conditionalized the accessors to check for null -- eventually these should be changed to asserts and the callers should check for null themselves. There's a tiny accompanying patch to clang. llvm-svn: 234290
This commit is contained in:
parent
8d33fdc3bf
commit
000fa2c646
llvm
include/llvm/IR
lib
CodeGen/AsmPrinter
IR
Transforms
unittests/Transforms/Utils
|
@ -87,6 +87,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DIDescriptor(const MDNode *N = nullptr) : DbgNode(N) {}
|
explicit DIDescriptor(const MDNode *N = nullptr) : DbgNode(N) {}
|
||||||
|
DIDescriptor(const DebugNode *N) : DbgNode(N) {}
|
||||||
|
|
||||||
MDNode *get() const { return const_cast<MDNode *>(DbgNode); }
|
MDNode *get() const { return const_cast<MDNode *>(DbgNode); }
|
||||||
operator MDNode *() const { return get(); }
|
operator MDNode *() const { return get(); }
|
||||||
|
@ -149,6 +150,9 @@ DECLARE_SIMPLIFY_DESCRIPTOR(DIObjCProperty)
|
||||||
DECLARE_SIMPLIFY_DESCRIPTOR(DIImportedEntity)
|
DECLARE_SIMPLIFY_DESCRIPTOR(DIImportedEntity)
|
||||||
#undef DECLARE_SIMPLIFY_DESCRIPTOR
|
#undef DECLARE_SIMPLIFY_DESCRIPTOR
|
||||||
|
|
||||||
|
typedef DebugNodeArray DIArray;
|
||||||
|
typedef MDTypeRefArray DITypeArray;
|
||||||
|
|
||||||
/// \brief This is used to represent ranges, for array bounds.
|
/// \brief This is used to represent ranges, for array bounds.
|
||||||
class DISubrange : public DIDescriptor {
|
class DISubrange : public DIDescriptor {
|
||||||
public:
|
public:
|
||||||
|
@ -169,21 +173,6 @@ public:
|
||||||
int64_t getCount() const { return get()->getCount(); }
|
int64_t getCount() const { return get()->getCount(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief This descriptor holds an array of nodes with type T.
|
|
||||||
template <typename T> class DITypedArray : public DIDescriptor {
|
|
||||||
public:
|
|
||||||
explicit DITypedArray(const MDNode *N = nullptr) : DIDescriptor(N) {}
|
|
||||||
operator MDTuple *() const {
|
|
||||||
return const_cast<MDTuple *>(cast_or_null<MDTuple>(DbgNode));
|
|
||||||
}
|
|
||||||
unsigned getNumElements() const {
|
|
||||||
return DbgNode ? DbgNode->getNumOperands() : 0;
|
|
||||||
}
|
|
||||||
T getElement(unsigned Idx) const { return getFieldAs<T>(Idx); }
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef DITypedArray<DIDescriptor> DIArray;
|
|
||||||
|
|
||||||
/// \brief A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
|
/// \brief A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
|
||||||
///
|
///
|
||||||
/// FIXME: it seems strange that this doesn't have either a reference to the
|
/// FIXME: it seems strange that this doesn't have either a reference to the
|
||||||
|
@ -211,7 +200,6 @@ template <typename T> class DIRef;
|
||||||
typedef DIRef<DIDescriptor> DIDescriptorRef;
|
typedef DIRef<DIDescriptor> DIDescriptorRef;
|
||||||
typedef DIRef<DIScope> DIScopeRef;
|
typedef DIRef<DIScope> DIScopeRef;
|
||||||
typedef DIRef<DIType> DITypeRef;
|
typedef DIRef<DIType> DITypeRef;
|
||||||
typedef DITypedArray<DITypeRef> DITypeArray;
|
|
||||||
|
|
||||||
/// \brief A base class for various scopes.
|
/// \brief A base class for various scopes.
|
||||||
///
|
///
|
||||||
|
@ -472,9 +460,7 @@ public:
|
||||||
return *get();
|
return *get();
|
||||||
}
|
}
|
||||||
|
|
||||||
DITypedArray<DITypeRef> getTypeArray() const {
|
MDTypeRefArray getTypeArray() const { return get()->getTypeArray(); }
|
||||||
return DITypedArray<DITypeRef>(get()->getTypeArray());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief This is a wrapper for a file.
|
/// \brief This is a wrapper for a file.
|
||||||
|
|
|
@ -101,14 +101,16 @@ public:
|
||||||
MDTuple *operator->() const { return const_cast<MDTuple *>(N); }
|
MDTuple *operator->() const { return const_cast<MDTuple *>(N); }
|
||||||
MDTuple &operator*() const { return *const_cast<MDTuple *>(N); }
|
MDTuple &operator*() const { return *const_cast<MDTuple *>(N); }
|
||||||
|
|
||||||
unsigned size() const { return N->getNumOperands(); }
|
// FIXME: Fix callers and remove condition on N.
|
||||||
|
unsigned size() const { return N ? N->getNumOperands() : 0u; }
|
||||||
MDTypeRef operator[](unsigned I) const { return MDTypeRef(N->getOperand(I)); }
|
MDTypeRef operator[](unsigned I) const { return MDTypeRef(N->getOperand(I)); }
|
||||||
|
|
||||||
class iterator : std::iterator<std::input_iterator_tag, MDTypeRef,
|
class iterator : std::iterator<std::input_iterator_tag, MDTypeRef,
|
||||||
std::ptrdiff_t, void, MDTypeRef> {
|
std::ptrdiff_t, void, MDTypeRef> {
|
||||||
MDNode::op_iterator I;
|
MDNode::op_iterator I = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
iterator() = default;
|
||||||
explicit iterator(MDNode::op_iterator I) : I(I) {}
|
explicit iterator(MDNode::op_iterator I) : I(I) {}
|
||||||
MDTypeRef operator*() const { return MDTypeRef(*I); }
|
MDTypeRef operator*() const { return MDTypeRef(*I); }
|
||||||
iterator &operator++() {
|
iterator &operator++() {
|
||||||
|
@ -124,8 +126,9 @@ public:
|
||||||
bool operator!=(const iterator &X) const { return I != X.I; }
|
bool operator!=(const iterator &X) const { return I != X.I; }
|
||||||
};
|
};
|
||||||
|
|
||||||
iterator begin() const { return iterator(N->op_begin()); }
|
// FIXME: Fix callers and remove condition on N.
|
||||||
iterator end() const { return iterator(N->op_end()); }
|
iterator begin() const { return N ? iterator(N->op_begin()) : iterator(); }
|
||||||
|
iterator end() const { return N ? iterator(N->op_end()) : iterator(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief Tagged DWARF-like metadata node.
|
/// \brief Tagged DWARF-like metadata node.
|
||||||
|
|
|
@ -1040,9 +1040,10 @@ void TempMDNodeDeleter::operator()(MDNode *Node) const {
|
||||||
template <class T>
|
template <class T>
|
||||||
class TypedMDOperandIterator
|
class TypedMDOperandIterator
|
||||||
: std::iterator<std::input_iterator_tag, T *, std::ptrdiff_t, void, T *> {
|
: std::iterator<std::input_iterator_tag, T *, std::ptrdiff_t, void, T *> {
|
||||||
MDNode::op_iterator I;
|
MDNode::op_iterator I = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
TypedMDOperandIterator() = default;
|
||||||
explicit TypedMDOperandIterator(MDNode::op_iterator I) : I(I) {}
|
explicit TypedMDOperandIterator(MDNode::op_iterator I) : I(I) {}
|
||||||
T *operator*() const { return cast_or_null<T>(*I); }
|
T *operator*() const { return cast_or_null<T>(*I); }
|
||||||
TypedMDOperandIterator &operator++() {
|
TypedMDOperandIterator &operator++() {
|
||||||
|
@ -1066,17 +1067,20 @@ template <class T> class MDTupleTypedArrayWrapper {
|
||||||
const MDTuple *N = nullptr;
|
const MDTuple *N = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
MDTupleTypedArrayWrapper() = default;
|
||||||
MDTupleTypedArrayWrapper(const MDTuple *N) : N(N) {}
|
MDTupleTypedArrayWrapper(const MDTuple *N) : N(N) {}
|
||||||
operator MDTuple *() const { return const_cast<MDTuple *>(N); }
|
operator MDTuple *() const { return const_cast<MDTuple *>(N); }
|
||||||
MDTuple *operator->() const { return const_cast<MDTuple *>(N); }
|
MDTuple *operator->() const { return const_cast<MDTuple *>(N); }
|
||||||
MDTuple &operator*() const { return *const_cast<MDTuple *>(N); }
|
MDTuple &operator*() const { return *const_cast<MDTuple *>(N); }
|
||||||
|
|
||||||
unsigned size() const { return N->getNumOperands(); }
|
// FIXME: Fix callers and remove condition on N.
|
||||||
|
unsigned size() const { return N ? N->getNumOperands() : 0u; }
|
||||||
T *operator[](unsigned I) const { return cast_or_null<T>(N->getOperand(I)); }
|
T *operator[](unsigned I) const { return cast_or_null<T>(N->getOperand(I)); }
|
||||||
|
|
||||||
|
// FIXME: Fix callers and remove condition on N.
|
||||||
typedef TypedMDOperandIterator<T> iterator;
|
typedef TypedMDOperandIterator<T> iterator;
|
||||||
iterator begin() const { return iterator(N->op_begin()); }
|
iterator begin() const { return N ? iterator(N->op_begin()) : iterator(); }
|
||||||
iterator end() const { return iterator(N->op_end()); }
|
iterator end() const { return N ? iterator(N->op_end()) : iterator(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
#define HANDLE_METADATA(CLASS) \
|
#define HANDLE_METADATA(CLASS) \
|
||||||
|
|
|
@ -580,8 +580,7 @@ void DwarfCompileUnit::constructSubprogramScopeDIE(LexicalScope *Scope) {
|
||||||
// If we have a single element of null, it is a function that returns void.
|
// If we have a single element of null, it is a function that returns void.
|
||||||
// If we have more than one elements and the last one is null, it is a
|
// If we have more than one elements and the last one is null, it is a
|
||||||
// variadic function.
|
// variadic function.
|
||||||
if (FnArgs.getNumElements() > 1 &&
|
if (FnArgs.size() > 1 && !FnArgs[FnArgs.size() - 1] &&
|
||||||
!FnArgs.getElement(FnArgs.getNumElements() - 1) &&
|
|
||||||
!includeMinimalInlineScopes())
|
!includeMinimalInlineScopes())
|
||||||
ScopeDIE.addChild(make_unique<DIE>(dwarf::DW_TAG_unspecified_parameters));
|
ScopeDIE.addChild(make_unique<DIE>(dwarf::DW_TAG_unspecified_parameters));
|
||||||
}
|
}
|
||||||
|
@ -682,16 +681,15 @@ void DwarfCompileUnit::collectDeadVariables(DISubprogram SP) {
|
||||||
assert(SP && "CU's subprogram list contains a non-subprogram");
|
assert(SP && "CU's subprogram list contains a non-subprogram");
|
||||||
assert(SP.isDefinition() &&
|
assert(SP.isDefinition() &&
|
||||||
"CU's subprogram list contains a subprogram declaration");
|
"CU's subprogram list contains a subprogram declaration");
|
||||||
DIArray Variables = SP.getVariables();
|
auto Variables = SP->getVariables();
|
||||||
if (Variables.getNumElements() == 0)
|
if (Variables.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DIE *SPDIE = DU->getAbstractSPDies().lookup(SP);
|
DIE *SPDIE = DU->getAbstractSPDies().lookup(SP);
|
||||||
if (!SPDIE)
|
if (!SPDIE)
|
||||||
SPDIE = getDIE(SP);
|
SPDIE = getDIE(SP);
|
||||||
assert(SPDIE);
|
assert(SPDIE);
|
||||||
for (unsigned vi = 0, ve = Variables.getNumElements(); vi != ve; ++vi) {
|
for (DIVariable DV : Variables) {
|
||||||
DIVariable DV = cast<MDLocalVariable>(Variables.getElement(vi));
|
|
||||||
DbgVariable NewVar(DV, DIExpression(), DD);
|
DbgVariable NewVar(DV, DIExpression(), DD);
|
||||||
auto VariableDie = constructVariableDIE(NewVar);
|
auto VariableDie = constructVariableDIE(NewVar);
|
||||||
applyVariableAttributes(NewVar, *VariableDie);
|
applyVariableAttributes(NewVar, *VariableDie);
|
||||||
|
|
|
@ -174,8 +174,8 @@ DIType DbgVariable::getType() const {
|
||||||
subType = resolve(DITypeRef(cast<MDDerivedType>(Ty)->getBaseType()));
|
subType = resolve(DITypeRef(cast<MDDerivedType>(Ty)->getBaseType()));
|
||||||
|
|
||||||
DIArray Elements(cast<MDCompositeTypeBase>(subType)->getElements());
|
DIArray Elements(cast<MDCompositeTypeBase>(subType)->getElements());
|
||||||
for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
|
for (unsigned i = 0, N = Elements.size(); i < N; ++i) {
|
||||||
DIDerivedType DT = cast<MDDerivedTypeBase>(Elements.getElement(i));
|
DIDerivedType DT = cast<MDDerivedTypeBase>(Elements[i]);
|
||||||
if (getName() == DT.getName())
|
if (getName() == DT.getName())
|
||||||
return (resolve(DT.getTypeDerivedFrom()));
|
return (resolve(DT.getTypeDerivedFrom()));
|
||||||
}
|
}
|
||||||
|
@ -445,34 +445,24 @@ void DwarfDebug::beginModule() {
|
||||||
for (MDNode *N : CU_Nodes->operands()) {
|
for (MDNode *N : CU_Nodes->operands()) {
|
||||||
DICompileUnit CUNode = cast<MDCompileUnit>(N);
|
DICompileUnit CUNode = cast<MDCompileUnit>(N);
|
||||||
DwarfCompileUnit &CU = constructDwarfCompileUnit(CUNode);
|
DwarfCompileUnit &CU = constructDwarfCompileUnit(CUNode);
|
||||||
DIArray ImportedEntities = CUNode.getImportedEntities();
|
for (auto *IE : CUNode->getImportedEntities())
|
||||||
for (unsigned i = 0, e = ImportedEntities.getNumElements(); i != e; ++i)
|
ScopesWithImportedEntities.push_back(std::make_pair(IE->getScope(), IE));
|
||||||
ScopesWithImportedEntities.push_back(std::make_pair(
|
|
||||||
cast<MDImportedEntity>(ImportedEntities.getElement(i))->getScope(),
|
|
||||||
ImportedEntities.getElement(i)));
|
|
||||||
// Stable sort to preserve the order of appearance of imported entities.
|
// Stable sort to preserve the order of appearance of imported entities.
|
||||||
// This is to avoid out-of-order processing of interdependent declarations
|
// This is to avoid out-of-order processing of interdependent declarations
|
||||||
// within the same scope, e.g. { namespace A = base; namespace B = A; }
|
// within the same scope, e.g. { namespace A = base; namespace B = A; }
|
||||||
std::stable_sort(ScopesWithImportedEntities.begin(),
|
std::stable_sort(ScopesWithImportedEntities.begin(),
|
||||||
ScopesWithImportedEntities.end(), less_first());
|
ScopesWithImportedEntities.end(), less_first());
|
||||||
DIArray GVs = CUNode.getGlobalVariables();
|
for (auto *GV : CUNode->getGlobalVariables())
|
||||||
for (unsigned i = 0, e = GVs.getNumElements(); i != e; ++i)
|
CU.getOrCreateGlobalVariableDIE(GV);
|
||||||
CU.getOrCreateGlobalVariableDIE(
|
for (auto *SP : CUNode->getSubprograms())
|
||||||
cast<MDGlobalVariable>(GVs.getElement(i)));
|
SPMap.insert(std::make_pair(SP, &CU));
|
||||||
DIArray SPs = CUNode.getSubprograms();
|
for (DIType Ty : CUNode->getEnumTypes()) {
|
||||||
for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i)
|
|
||||||
SPMap.insert(std::make_pair(SPs.getElement(i), &CU));
|
|
||||||
DIArray EnumTypes = CUNode.getEnumTypes();
|
|
||||||
for (unsigned i = 0, e = EnumTypes.getNumElements(); i != e; ++i) {
|
|
||||||
DIType Ty = cast<MDType>(EnumTypes.getElement(i));
|
|
||||||
// The enum types array by design contains pointers to
|
// The enum types array by design contains pointers to
|
||||||
// MDNodes rather than DIRefs. Unique them here.
|
// MDNodes rather than DIRefs. Unique them here.
|
||||||
DIType UniqueTy = cast<MDType>(resolve(Ty.getRef()));
|
DIType UniqueTy = cast<MDType>(resolve(Ty.getRef()));
|
||||||
CU.getOrCreateTypeDIE(UniqueTy);
|
CU.getOrCreateTypeDIE(UniqueTy);
|
||||||
}
|
}
|
||||||
DIArray RetainedTypes = CUNode.getRetainedTypes();
|
for (DIType Ty : CUNode->getRetainedTypes()) {
|
||||||
for (unsigned i = 0, e = RetainedTypes.getNumElements(); i != e; ++i) {
|
|
||||||
DIType Ty = cast<MDType>(RetainedTypes.getElement(i));
|
|
||||||
// The retained types array by design contains pointers to
|
// The retained types array by design contains pointers to
|
||||||
// MDNodes rather than DIRefs. Unique them here.
|
// MDNodes rather than DIRefs. Unique them here.
|
||||||
DIType UniqueTy = cast<MDType>(resolve(Ty.getRef()));
|
DIType UniqueTy = cast<MDType>(resolve(Ty.getRef()));
|
||||||
|
@ -480,8 +470,8 @@ void DwarfDebug::beginModule() {
|
||||||
}
|
}
|
||||||
// Emit imported_modules last so that the relevant context is already
|
// Emit imported_modules last so that the relevant context is already
|
||||||
// available.
|
// available.
|
||||||
for (unsigned i = 0, e = ImportedEntities.getNumElements(); i != e; ++i)
|
for (auto *IE : CUNode->getImportedEntities())
|
||||||
constructAndAddImportedEntityDIE(CU, ImportedEntities.getElement(i));
|
constructAndAddImportedEntityDIE(CU, IE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tell MMI that we have debug info.
|
// Tell MMI that we have debug info.
|
||||||
|
@ -525,9 +515,7 @@ void DwarfDebug::collectDeadVariables() {
|
||||||
DwarfCompileUnit *SPCU =
|
DwarfCompileUnit *SPCU =
|
||||||
static_cast<DwarfCompileUnit *>(CUMap.lookup(TheCU));
|
static_cast<DwarfCompileUnit *>(CUMap.lookup(TheCU));
|
||||||
assert(SPCU && "Unable to find Compile Unit!");
|
assert(SPCU && "Unable to find Compile Unit!");
|
||||||
DIArray Subprograms = TheCU.getSubprograms();
|
for (auto *SP : TheCU->getSubprograms()) {
|
||||||
for (unsigned i = 0, e = Subprograms.getNumElements(); i != e; ++i) {
|
|
||||||
DISubprogram SP = cast<MDSubprogram>(Subprograms.getElement(i));
|
|
||||||
if (ProcessedSPNodes.count(SP) != 0)
|
if (ProcessedSPNodes.count(SP) != 0)
|
||||||
continue;
|
continue;
|
||||||
SPCU->collectDeadVariables(SP);
|
SPCU->collectDeadVariables(SP);
|
||||||
|
@ -940,9 +928,7 @@ DwarfDebug::collectVariableInfo(DwarfCompileUnit &TheCU, DISubprogram SP,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect info for variables that were optimized out.
|
// Collect info for variables that were optimized out.
|
||||||
DIArray Variables = SP.getVariables();
|
for (DIVariable DV : SP->getVariables()) {
|
||||||
for (unsigned i = 0, e = Variables.getNumElements(); i != e; ++i) {
|
|
||||||
DIVariable DV = cast<MDLocalVariable>(Variables.getElement(i));
|
|
||||||
if (!Processed.insert(DV).second)
|
if (!Processed.insert(DV).second)
|
||||||
continue;
|
continue;
|
||||||
if (LexicalScope *Scope = LScopes.findLexicalScope(DV.get()->getScope())) {
|
if (LexicalScope *Scope = LScopes.findLexicalScope(DV.get()->getScope())) {
|
||||||
|
@ -1229,9 +1215,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
|
||||||
for (LexicalScope *AScope : LScopes.getAbstractScopesList()) {
|
for (LexicalScope *AScope : LScopes.getAbstractScopesList()) {
|
||||||
DISubprogram SP = cast<MDSubprogram>(AScope->getScopeNode());
|
DISubprogram SP = cast<MDSubprogram>(AScope->getScopeNode());
|
||||||
// Collect info for variables that were optimized out.
|
// Collect info for variables that were optimized out.
|
||||||
DIArray Variables = SP.getVariables();
|
for (DIVariable DV : SP->getVariables()) {
|
||||||
for (unsigned i = 0, e = Variables.getNumElements(); i != e; ++i) {
|
|
||||||
DIVariable DV = cast<MDLocalVariable>(Variables.getElement(i));
|
|
||||||
if (!ProcessedVars.insert(DV).second)
|
if (!ProcessedVars.insert(DV).second)
|
||||||
continue;
|
continue;
|
||||||
ensureAbstractVariableIsCreated(DV, DV.getContext());
|
ensureAbstractVariableIsCreated(DV, DV.getContext());
|
||||||
|
|
|
@ -569,6 +569,9 @@ public:
|
||||||
template <typename T> T resolve(DIRef<T> Ref) const {
|
template <typename T> T resolve(DIRef<T> Ref) const {
|
||||||
return Ref.resolve(TypeIdentifierMap);
|
return Ref.resolve(TypeIdentifierMap);
|
||||||
}
|
}
|
||||||
|
template <typename T> T *resolve(TypedDebugNodeRef<T> Ref) const {
|
||||||
|
return Ref.resolve(TypeIdentifierMap);
|
||||||
|
}
|
||||||
|
|
||||||
/// \brief Return the TypeIdentifierMap.
|
/// \brief Return the TypeIdentifierMap.
|
||||||
const DITypeIdentifierMap &getTypeIdentifierMap() const {
|
const DITypeIdentifierMap &getTypeIdentifierMap() const {
|
||||||
|
|
|
@ -542,8 +542,8 @@ void DwarfUnit::addBlockByrefAddress(const DbgVariable &DV, DIE &Die,
|
||||||
DIDerivedType varField;
|
DIDerivedType varField;
|
||||||
DIDerivedType forwardingField;
|
DIDerivedType forwardingField;
|
||||||
|
|
||||||
for (unsigned i = 0, N = Fields.getNumElements(); i < N; ++i) {
|
for (unsigned i = 0, N = Fields.size(); i < N; ++i) {
|
||||||
DIDerivedType DT = cast<MDDerivedTypeBase>(Fields.getElement(i));
|
DIDerivedType DT = cast<MDDerivedTypeBase>(Fields[i]);
|
||||||
StringRef fieldName = DT.getName();
|
StringRef fieldName = DT.getName();
|
||||||
if (fieldName == "__forwarding")
|
if (fieldName == "__forwarding")
|
||||||
forwardingField = DT;
|
forwardingField = DT;
|
||||||
|
@ -767,8 +767,8 @@ void DwarfUnit::addLinkageName(DIE &Die, StringRef LinkageName) {
|
||||||
/// addTemplateParams - Add template parameters into buffer.
|
/// addTemplateParams - Add template parameters into buffer.
|
||||||
void DwarfUnit::addTemplateParams(DIE &Buffer, DIArray TParams) {
|
void DwarfUnit::addTemplateParams(DIE &Buffer, DIArray TParams) {
|
||||||
// Add template parameters.
|
// Add template parameters.
|
||||||
for (unsigned i = 0, e = TParams.getNumElements(); i != e; ++i) {
|
for (unsigned i = 0, e = TParams.size(); i != e; ++i) {
|
||||||
DIDescriptor Element = TParams.getElement(i);
|
DIDescriptor Element = TParams[i];
|
||||||
if (auto *TTP = dyn_cast<MDTemplateTypeParameter>(Element))
|
if (auto *TTP = dyn_cast<MDTemplateTypeParameter>(Element))
|
||||||
constructTemplateTypeParameterDIE(Buffer, TTP);
|
constructTemplateTypeParameterDIE(Buffer, TTP);
|
||||||
else if (auto *TVP = dyn_cast<MDTemplateValueParameter>(Element))
|
else if (auto *TVP = dyn_cast<MDTemplateValueParameter>(Element))
|
||||||
|
@ -982,8 +982,8 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, DIDerivedType DTy) {
|
||||||
|
|
||||||
/// constructSubprogramArguments - Construct function argument DIEs.
|
/// constructSubprogramArguments - Construct function argument DIEs.
|
||||||
void DwarfUnit::constructSubprogramArguments(DIE &Buffer, DITypeArray Args) {
|
void DwarfUnit::constructSubprogramArguments(DIE &Buffer, DITypeArray Args) {
|
||||||
for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
|
for (unsigned i = 1, N = Args.size(); i < N; ++i) {
|
||||||
DIType Ty = resolve(Args.getElement(i));
|
DIType Ty = resolve(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);
|
||||||
|
@ -1013,14 +1013,13 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
|
||||||
break;
|
break;
|
||||||
case dwarf::DW_TAG_subroutine_type: {
|
case dwarf::DW_TAG_subroutine_type: {
|
||||||
// Add return type. A void return won't have a type.
|
// Add return type. A void return won't have a type.
|
||||||
DITypeArray Elements(cast<MDSubroutineType>(CTy)->getTypeArray());
|
auto Elements = cast<MDSubroutineType>(CTy)->getTypeArray();
|
||||||
DIType RTy(resolve(Elements.getElement(0)));
|
if (Elements.size())
|
||||||
if (RTy)
|
if (auto RTy = resolve(Elements[0]))
|
||||||
addType(Buffer, RTy);
|
addType(Buffer, RTy);
|
||||||
|
|
||||||
bool isPrototyped = true;
|
bool isPrototyped = true;
|
||||||
if (Elements.getNumElements() == 2 &&
|
if (Elements.size() == 2 && !Elements[1])
|
||||||
!Elements.getElement(1))
|
|
||||||
isPrototyped = false;
|
isPrototyped = false;
|
||||||
|
|
||||||
constructSubprogramArguments(Buffer, Elements);
|
constructSubprogramArguments(Buffer, Elements);
|
||||||
|
@ -1044,8 +1043,8 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
|
||||||
case dwarf::DW_TAG_class_type: {
|
case dwarf::DW_TAG_class_type: {
|
||||||
// Add elements to structure type.
|
// Add elements to structure type.
|
||||||
DIArray Elements = CTy.getElements();
|
DIArray Elements = CTy.getElements();
|
||||||
for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
|
for (unsigned i = 0, N = Elements.size(); i < N; ++i) {
|
||||||
DIDescriptor Element = Elements.getElement(i);
|
DIDescriptor Element = Elements[i];
|
||||||
if (!Element)
|
if (!Element)
|
||||||
continue;
|
continue;
|
||||||
if (auto *SP = dyn_cast<MDSubprogram>(Element))
|
if (auto *SP = dyn_cast<MDSubprogram>(Element))
|
||||||
|
@ -1197,9 +1196,7 @@ DwarfUnit::constructTemplateValueParameterDIE(DIE &Buffer,
|
||||||
addString(ParamDIE, dwarf::DW_AT_GNU_template_name,
|
addString(ParamDIE, dwarf::DW_AT_GNU_template_name,
|
||||||
cast<MDString>(Val)->getString());
|
cast<MDString>(Val)->getString());
|
||||||
} else if (VP.getTag() == dwarf::DW_TAG_GNU_template_parameter_pack) {
|
} else if (VP.getTag() == dwarf::DW_TAG_GNU_template_parameter_pack) {
|
||||||
assert(isa<MDNode>(Val));
|
addTemplateParams(ParamDIE, cast<MDTuple>(Val));
|
||||||
DIArray A(cast<MDNode>(Val));
|
|
||||||
addTemplateParams(ParamDIE, A);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1317,11 +1314,12 @@ void DwarfUnit::applySubprogramAttributes(DISubprogram SP, DIE &SPDie,
|
||||||
assert(SPTy.getTag() == dwarf::DW_TAG_subroutine_type &&
|
assert(SPTy.getTag() == dwarf::DW_TAG_subroutine_type &&
|
||||||
"the type of a subprogram should be a subroutine");
|
"the type of a subprogram should be a subroutine");
|
||||||
|
|
||||||
DITypeArray Args = SPTy.getTypeArray();
|
auto Args = SPTy.getTypeArray();
|
||||||
// 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 (resolve(Args.getElement(0)))
|
if (Args.size())
|
||||||
addType(SPDie, DIType(resolve(Args.getElement(0))));
|
if (auto Ty = resolve(Args[0]))
|
||||||
|
addType(SPDie, Ty);
|
||||||
|
|
||||||
unsigned VK = SP.getVirtuality();
|
unsigned VK = SP.getVirtuality();
|
||||||
if (VK) {
|
if (VK) {
|
||||||
|
@ -1423,8 +1421,8 @@ void DwarfUnit::constructArrayTypeDIE(DIE &Buffer, DICompositeType CTy) {
|
||||||
|
|
||||||
// Add subranges to array type.
|
// Add subranges to array type.
|
||||||
DIArray Elements = CTy.getElements();
|
DIArray Elements = CTy.getElements();
|
||||||
for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
|
for (unsigned i = 0, N = Elements.size(); i < N; ++i) {
|
||||||
DIDescriptor Element = Elements.getElement(i);
|
DIDescriptor Element = Elements[i];
|
||||||
if (Element.getTag() == dwarf::DW_TAG_subrange_type)
|
if (Element.getTag() == dwarf::DW_TAG_subrange_type)
|
||||||
constructSubrangeDIE(Buffer, cast<MDSubrange>(Element), IdxTy);
|
constructSubrangeDIE(Buffer, cast<MDSubrange>(Element), IdxTy);
|
||||||
}
|
}
|
||||||
|
@ -1435,8 +1433,8 @@ void DwarfUnit::constructEnumTypeDIE(DIE &Buffer, DICompositeType CTy) {
|
||||||
DIArray Elements = CTy.getElements();
|
DIArray Elements = CTy.getElements();
|
||||||
|
|
||||||
// Add enumerators to enumeration type.
|
// Add enumerators to enumeration type.
|
||||||
for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
|
for (unsigned i = 0, N = Elements.size(); i < N; ++i) {
|
||||||
DIEnumerator Enum = dyn_cast_or_null<MDEnumerator>(Elements.getElement(i));
|
DIEnumerator Enum = dyn_cast_or_null<MDEnumerator>(Elements[i]);
|
||||||
if (Enum) {
|
if (Enum) {
|
||||||
DIE &Enumerator = createAndAddDIE(dwarf::DW_TAG_enumerator, Buffer);
|
DIE &Enumerator = createAndAddDIE(dwarf::DW_TAG_enumerator, Buffer);
|
||||||
StringRef Name = Enum.getName();
|
StringRef Name = Enum.getName();
|
||||||
|
|
|
@ -345,6 +345,9 @@ protected:
|
||||||
template <typename T> T resolve(DIRef<T> Ref) const {
|
template <typename T> T resolve(DIRef<T> Ref) const {
|
||||||
return DD->resolve(Ref);
|
return DD->resolve(Ref);
|
||||||
}
|
}
|
||||||
|
template <typename T> T *resolve(TypedDebugNodeRef<T> Ref) const {
|
||||||
|
return DD->resolve(Ref);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// constructTypeDIE - Construct basic type die from DIBasicType.
|
/// constructTypeDIE - Construct basic type die from DIBasicType.
|
||||||
|
|
|
@ -91,8 +91,8 @@ void DIBuilder::finalize() {
|
||||||
|
|
||||||
DIArray SPs = getOrCreateArray(AllSubprograms);
|
DIArray SPs = getOrCreateArray(AllSubprograms);
|
||||||
TempSubprograms->replaceAllUsesWith(SPs);
|
TempSubprograms->replaceAllUsesWith(SPs);
|
||||||
for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i) {
|
for (unsigned i = 0, e = SPs.size(); i != e; ++i) {
|
||||||
DISubprogram SP = cast<MDSubprogram>(SPs.getElement(i));
|
DISubprogram SP = cast<MDSubprogram>(SPs[i]);
|
||||||
if (MDNode *Temp = SP.getVariablesNodes()) {
|
if (MDNode *Temp = SP.getVariablesNodes()) {
|
||||||
const auto &PV = PreservedVariables.lookup(SP);
|
const auto &PV = PreservedVariables.lookup(SP);
|
||||||
SmallVector<Metadata *, 4> Variables(PV.begin(), PV.end());
|
SmallVector<Metadata *, 4> Variables(PV.begin(), PV.end());
|
||||||
|
@ -858,9 +858,9 @@ void DIBuilder::replaceArrays(DICompositeType &T, DIArray Elements,
|
||||||
{
|
{
|
||||||
TypedTrackingMDRef<MDCompositeTypeBase> N(T);
|
TypedTrackingMDRef<MDCompositeTypeBase> N(T);
|
||||||
if (Elements)
|
if (Elements)
|
||||||
N->replaceElements(cast<MDTuple>(Elements.get()));
|
N->replaceElements(Elements);
|
||||||
if (TParams)
|
if (TParams)
|
||||||
N->replaceTemplateParams(cast<MDTuple>(TParams.get()));
|
N->replaceTemplateParams(MDTemplateParameterArray(TParams));
|
||||||
T = N.get();
|
T = N.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -206,11 +206,11 @@ StringRef DIScope::getDirectory() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DICompileUnit::replaceSubprograms(DIArray Subprograms) {
|
void DICompileUnit::replaceSubprograms(DIArray Subprograms) {
|
||||||
get()->replaceSubprograms(cast_or_null<MDTuple>(Subprograms.get()));
|
get()->replaceSubprograms(Subprograms);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DICompileUnit::replaceGlobalVariables(DIArray GlobalVariables) {
|
void DICompileUnit::replaceGlobalVariables(DIArray GlobalVariables) {
|
||||||
get()->replaceGlobalVariables(cast_or_null<MDTuple>(GlobalVariables.get()));
|
get()->replaceGlobalVariables(GlobalVariables);
|
||||||
}
|
}
|
||||||
|
|
||||||
DILocation DILocation::copyWithNewScope(LLVMContext &Ctx,
|
DILocation DILocation::copyWithNewScope(LLVMContext &Ctx,
|
||||||
|
@ -282,10 +282,10 @@ llvm::generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes) {
|
||||||
for (unsigned CUi = 0, CUe = CU_Nodes->getNumOperands(); CUi != CUe; ++CUi) {
|
for (unsigned CUi = 0, CUe = CU_Nodes->getNumOperands(); CUi != CUe; ++CUi) {
|
||||||
DICompileUnit CU = cast<MDCompileUnit>(CU_Nodes->getOperand(CUi));
|
DICompileUnit CU = cast<MDCompileUnit>(CU_Nodes->getOperand(CUi));
|
||||||
DIArray Retain = CU.getRetainedTypes();
|
DIArray Retain = CU.getRetainedTypes();
|
||||||
for (unsigned Ti = 0, Te = Retain.getNumElements(); Ti != Te; ++Ti) {
|
for (unsigned Ti = 0, Te = Retain.size(); Ti != Te; ++Ti) {
|
||||||
if (!isa<MDCompositeType>(Retain.getElement(Ti)))
|
if (!isa<MDCompositeType>(Retain[Ti]))
|
||||||
continue;
|
continue;
|
||||||
DICompositeType Ty = cast<MDCompositeType>(Retain.getElement(Ti));
|
DICompositeType Ty = cast<MDCompositeType>(Retain[Ti]);
|
||||||
if (MDString *TypeId = Ty.getIdentifier()) {
|
if (MDString *TypeId = Ty.getIdentifier()) {
|
||||||
// Definition has priority over declaration.
|
// Definition has priority over declaration.
|
||||||
// Try to insert (TypeId, Ty) to Map.
|
// Try to insert (TypeId, Ty) to Map.
|
||||||
|
@ -330,26 +330,19 @@ void DebugInfoFinder::processModule(const Module &M) {
|
||||||
for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
|
for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
|
||||||
DICompileUnit CU = cast<MDCompileUnit>(CU_Nodes->getOperand(i));
|
DICompileUnit CU = cast<MDCompileUnit>(CU_Nodes->getOperand(i));
|
||||||
addCompileUnit(CU);
|
addCompileUnit(CU);
|
||||||
DIArray GVs = CU.getGlobalVariables();
|
for (DIGlobalVariable DIG : CU->getGlobalVariables()) {
|
||||||
for (unsigned i = 0, e = GVs.getNumElements(); i != e; ++i) {
|
|
||||||
DIGlobalVariable DIG = cast<MDGlobalVariable>(GVs.getElement(i));
|
|
||||||
if (addGlobalVariable(DIG)) {
|
if (addGlobalVariable(DIG)) {
|
||||||
processScope(DIG.getContext());
|
processScope(DIG.getContext());
|
||||||
processType(DIG.getType().resolve(TypeIdentifierMap));
|
processType(DIG.getType().resolve(TypeIdentifierMap));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DIArray SPs = CU.getSubprograms();
|
for (auto *SP : CU->getSubprograms())
|
||||||
for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i)
|
processSubprogram(SP);
|
||||||
processSubprogram(cast<MDSubprogram>(SPs.getElement(i)));
|
for (auto *ET : CU->getEnumTypes())
|
||||||
DIArray EnumTypes = CU.getEnumTypes();
|
processType(ET);
|
||||||
for (unsigned i = 0, e = EnumTypes.getNumElements(); i != e; ++i)
|
for (auto *RT : CU->getRetainedTypes())
|
||||||
processType(cast<MDType>(EnumTypes.getElement(i)));
|
processType(RT);
|
||||||
DIArray RetainedTypes = CU.getRetainedTypes();
|
for (DIImportedEntity Import : CU->getImportedEntities()) {
|
||||||
for (unsigned i = 0, e = RetainedTypes.getNumElements(); i != e; ++i)
|
|
||||||
processType(cast<MDType>(RetainedTypes.getElement(i)));
|
|
||||||
DIArray Imports = CU.getImportedEntities();
|
|
||||||
for (unsigned i = 0, e = Imports.getNumElements(); i != e; ++i) {
|
|
||||||
DIImportedEntity Import = cast<MDImportedEntity>(Imports.getElement(i));
|
|
||||||
DIDescriptor Entity = Import.getEntity().resolve(TypeIdentifierMap);
|
DIDescriptor Entity = Import.getEntity().resolve(TypeIdentifierMap);
|
||||||
if (auto *T = dyn_cast<MDType>(Entity))
|
if (auto *T = dyn_cast<MDType>(Entity))
|
||||||
processType(T);
|
processType(T);
|
||||||
|
@ -377,14 +370,11 @@ void DebugInfoFinder::processType(DIType DT) {
|
||||||
if (DICompositeType DCT = dyn_cast<MDCompositeTypeBase>(DT)) {
|
if (DICompositeType DCT = dyn_cast<MDCompositeTypeBase>(DT)) {
|
||||||
processType(DCT.getTypeDerivedFrom().resolve(TypeIdentifierMap));
|
processType(DCT.getTypeDerivedFrom().resolve(TypeIdentifierMap));
|
||||||
if (DISubroutineType ST = dyn_cast<MDSubroutineType>(DCT)) {
|
if (DISubroutineType ST = dyn_cast<MDSubroutineType>(DCT)) {
|
||||||
DITypeArray DTA = ST.getTypeArray();
|
for (MDTypeRef Ref : ST->getTypeArray())
|
||||||
for (unsigned i = 0, e = DTA.getNumElements(); i != e; ++i)
|
processType(Ref.resolve(TypeIdentifierMap));
|
||||||
processType(DTA.getElement(i).resolve(TypeIdentifierMap));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DIArray DA = DCT.getElements();
|
for (Metadata *D : DCT->getElements()->operands()) {
|
||||||
for (unsigned i = 0, e = DA.getNumElements(); i != e; ++i) {
|
|
||||||
DIDescriptor D = DA.getElement(i);
|
|
||||||
if (DIType T = dyn_cast<MDType>(D))
|
if (DIType T = dyn_cast<MDType>(D))
|
||||||
processType(T);
|
processType(T);
|
||||||
else if (DISubprogram SP = dyn_cast<MDSubprogram>(D))
|
else if (DISubprogram SP = dyn_cast<MDSubprogram>(D))
|
||||||
|
@ -424,9 +414,7 @@ void DebugInfoFinder::processSubprogram(DISubprogram SP) {
|
||||||
return;
|
return;
|
||||||
processScope(SP.getContext().resolve(TypeIdentifierMap));
|
processScope(SP.getContext().resolve(TypeIdentifierMap));
|
||||||
processType(SP.getType());
|
processType(SP.getType());
|
||||||
DIArray TParams = SP.getTemplateParams();
|
for (auto *Element : SP.getTemplateParams()) {
|
||||||
for (unsigned I = 0, E = TParams.getNumElements(); I != E; ++I) {
|
|
||||||
DIDescriptor Element = TParams.getElement(I);
|
|
||||||
if (DITemplateTypeParameter TType =
|
if (DITemplateTypeParameter TType =
|
||||||
dyn_cast<MDTemplateTypeParameter>(Element)) {
|
dyn_cast<MDTemplateTypeParameter>(Element)) {
|
||||||
processType(TType.getType().resolve(TypeIdentifierMap));
|
processType(TType.getType().resolve(TypeIdentifierMap));
|
||||||
|
@ -685,9 +673,7 @@ llvm::makeSubprogramMap(const Module &M) {
|
||||||
|
|
||||||
for (MDNode *N : CU_Nodes->operands()) {
|
for (MDNode *N : CU_Nodes->operands()) {
|
||||||
DICompileUnit CUNode = cast<MDCompileUnit>(N);
|
DICompileUnit CUNode = cast<MDCompileUnit>(N);
|
||||||
DIArray SPs = CUNode.getSubprograms();
|
for (DISubprogram SP : CUNode->getSubprograms()) {
|
||||||
for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i) {
|
|
||||||
DISubprogram SP = cast<MDSubprogram>(SPs.getElement(i));
|
|
||||||
if (Function *F = SP.getFunction())
|
if (Function *F = SP.getFunction())
|
||||||
R.insert(std::make_pair(F, SP));
|
R.insert(std::make_pair(F, SP));
|
||||||
}
|
}
|
||||||
|
|
|
@ -492,13 +492,8 @@ void GCOVProfiler::emitProfileNotes() {
|
||||||
raw_fd_ostream out(mangleName(CU, "gcno"), EC, sys::fs::F_None);
|
raw_fd_ostream out(mangleName(CU, "gcno"), EC, sys::fs::F_None);
|
||||||
std::string EdgeDestinations;
|
std::string EdgeDestinations;
|
||||||
|
|
||||||
DIArray SPs = CU.getSubprograms();
|
|
||||||
unsigned FunctionIdent = 0;
|
unsigned FunctionIdent = 0;
|
||||||
for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i) {
|
for (DISubprogram SP : CU->getSubprograms()) {
|
||||||
DISubprogram SP = cast_or_null<MDSubprogram>(SPs.getElement(i));
|
|
||||||
if (!SP)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
Function *F = SP.getFunction();
|
Function *F = SP.getFunction();
|
||||||
if (!F) continue;
|
if (!F) continue;
|
||||||
if (!functionHasLines(F)) continue;
|
if (!functionHasLines(F)) continue;
|
||||||
|
@ -576,12 +571,8 @@ bool GCOVProfiler::emitProfileArcs() {
|
||||||
bool InsertIndCounterIncrCode = false;
|
bool InsertIndCounterIncrCode = false;
|
||||||
for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
|
for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
|
||||||
DICompileUnit CU = cast<MDCompileUnit>(CU_Nodes->getOperand(i));
|
DICompileUnit CU = cast<MDCompileUnit>(CU_Nodes->getOperand(i));
|
||||||
DIArray SPs = CU.getSubprograms();
|
|
||||||
SmallVector<std::pair<GlobalVariable *, MDNode *>, 8> CountersBySP;
|
SmallVector<std::pair<GlobalVariable *, MDNode *>, 8> CountersBySP;
|
||||||
for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i) {
|
for (DISubprogram SP : CU->getSubprograms()) {
|
||||||
DISubprogram SP = cast_or_null<MDSubprogram>(SPs.getElement(i));
|
|
||||||
if (!SP)
|
|
||||||
continue;
|
|
||||||
Function *F = SP.getFunction();
|
Function *F = SP.getFunction();
|
||||||
if (!F) continue;
|
if (!F) continue;
|
||||||
if (!functionHasLines(F)) continue;
|
if (!functionHasLines(F)) continue;
|
||||||
|
|
|
@ -164,11 +164,11 @@ static MDNode* FindSubprogram(const Function *F, DebugInfoFinder &Finder) {
|
||||||
|
|
||||||
// Add an operand to an existing MDNode. The new operand will be added at the
|
// Add an operand to an existing MDNode. The new operand will be added at the
|
||||||
// back of the operand list.
|
// back of the operand list.
|
||||||
static void AddOperand(DICompileUnit CU, DIArray SPs, Metadata *NewSP) {
|
static void AddOperand(DICompileUnit CU, MDSubprogramArray SPs, Metadata *NewSP) {
|
||||||
SmallVector<Metadata *, 16> NewSPs;
|
SmallVector<Metadata *, 16> NewSPs;
|
||||||
NewSPs.reserve(SPs->getNumOperands() + 1);
|
NewSPs.reserve(SPs.size() + 1);
|
||||||
for (unsigned I = 0, E = SPs->getNumOperands(); I != E; ++I)
|
for (auto *SP : SPs)
|
||||||
NewSPs.push_back(SPs->getOperand(I));
|
NewSPs.push_back(SP);
|
||||||
NewSPs.push_back(NewSP);
|
NewSPs.push_back(NewSP);
|
||||||
CU.replaceSubprograms(DIArray(MDNode::get(CU->getContext(), NewSPs)));
|
CU.replaceSubprograms(DIArray(MDNode::get(CU->getContext(), NewSPs)));
|
||||||
}
|
}
|
||||||
|
@ -190,12 +190,11 @@ static void CloneDebugInfoMetadata(Function *NewFunc, const Function *OldFunc,
|
||||||
cast<MDSubprogram>(MapMetadata(OldSubprogramMDNode, VMap));
|
cast<MDSubprogram>(MapMetadata(OldSubprogramMDNode, VMap));
|
||||||
|
|
||||||
for (DICompileUnit CU : Finder.compile_units()) {
|
for (DICompileUnit CU : Finder.compile_units()) {
|
||||||
DIArray Subprograms(CU.getSubprograms());
|
auto Subprograms = CU->getSubprograms();
|
||||||
|
|
||||||
// If the compile unit's function list contains the old function, it should
|
// If the compile unit's function list contains the old function, it should
|
||||||
// also contain the new one.
|
// also contain the new one.
|
||||||
for (unsigned i = 0; i < Subprograms.getNumElements(); i++) {
|
for (auto *SP : Subprograms) {
|
||||||
if ((MDNode*)Subprograms.getElement(i) == OldSubprogramMDNode) {
|
if (SP == OldSubprogramMDNode) {
|
||||||
AddOperand(CU, Subprograms, NewSubprogram);
|
AddOperand(CU, Subprograms, NewSubprogram);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -323,8 +323,8 @@ TEST_F(CloneFunc, SubprogramInRightCU) {
|
||||||
DICompileUnit CU1 = cast<MDCompileUnit>(*Iter);
|
DICompileUnit CU1 = cast<MDCompileUnit>(*Iter);
|
||||||
Iter++;
|
Iter++;
|
||||||
DICompileUnit CU2 = cast<MDCompileUnit>(*Iter);
|
DICompileUnit CU2 = cast<MDCompileUnit>(*Iter);
|
||||||
EXPECT_TRUE(CU1.getSubprograms().getNumElements() == 0
|
EXPECT_TRUE(CU1.getSubprograms().size() == 0 ||
|
||||||
|| CU2.getSubprograms().getNumElements() == 0);
|
CU2.getSubprograms().size() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that instructions in the old function still belong to it in the
|
// Test that instructions in the old function still belong to it in the
|
||||||
|
|
Loading…
Reference in New Issue