mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
DebugInfo: Delete subclasses of DIScope
Delete subclasses of (the already defunct) `DIScope`, updating users to use the raw pointers from the `Metadata` hierarchy directly. llvm-svn: 235356
This commit is contained in:
parent
721c6b75e7
commit
dc9077df15
@ -40,16 +40,14 @@ LLVMMetadataRef LLVMDIBuilderCreateCompileUnit(LLVMDIBuilderRef Dref,
|
|||||||
int Optimized, const char *Flags,
|
int Optimized, const char *Flags,
|
||||||
unsigned RuntimeVersion) {
|
unsigned RuntimeVersion) {
|
||||||
DIBuilder *D = unwrap(Dref);
|
DIBuilder *D = unwrap(Dref);
|
||||||
DICompileUnit CU = D->createCompileUnit(Lang, File, Dir, Producer, Optimized,
|
return wrap(D->createCompileUnit(Lang, File, Dir, Producer, Optimized, Flags,
|
||||||
Flags, RuntimeVersion);
|
RuntimeVersion));
|
||||||
return wrap(CU);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMMetadataRef LLVMDIBuilderCreateFile(LLVMDIBuilderRef Dref, const char *File,
|
LLVMMetadataRef LLVMDIBuilderCreateFile(LLVMDIBuilderRef Dref, const char *File,
|
||||||
const char *Dir) {
|
const char *Dir) {
|
||||||
DIBuilder *D = unwrap(Dref);
|
DIBuilder *D = unwrap(Dref);
|
||||||
DIFile F = D->createFile(File, Dir);
|
return wrap(D->createFile(File, Dir));
|
||||||
return wrap(F);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMMetadataRef LLVMDIBuilderCreateLexicalBlock(LLVMDIBuilderRef Dref,
|
LLVMMetadataRef LLVMDIBuilderCreateLexicalBlock(LLVMDIBuilderRef Dref,
|
||||||
@ -68,9 +66,8 @@ LLVMMetadataRef LLVMDIBuilderCreateLexicalBlockFile(LLVMDIBuilderRef Dref,
|
|||||||
LLVMMetadataRef File,
|
LLVMMetadataRef File,
|
||||||
unsigned Discriminator) {
|
unsigned Discriminator) {
|
||||||
DIBuilder *D = unwrap(Dref);
|
DIBuilder *D = unwrap(Dref);
|
||||||
DILexicalBlockFile LBF = D->createLexicalBlockFile(
|
return wrap(D->createLexicalBlockFile(unwrap<MDLocalScope>(Scope),
|
||||||
unwrap<MDLocalScope>(Scope), unwrap<MDFile>(File), Discriminator);
|
unwrap<MDFile>(File), Discriminator));
|
||||||
return wrap(LBF);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMMetadataRef LLVMDIBuilderCreateFunction(
|
LLVMMetadataRef LLVMDIBuilderCreateFunction(
|
||||||
@ -79,12 +76,11 @@ LLVMMetadataRef LLVMDIBuilderCreateFunction(
|
|||||||
LLVMMetadataRef CompositeType, int IsLocalToUnit, int IsDefinition,
|
LLVMMetadataRef CompositeType, int IsLocalToUnit, int IsDefinition,
|
||||||
unsigned ScopeLine, unsigned Flags, int IsOptimized, LLVMValueRef Func) {
|
unsigned ScopeLine, unsigned Flags, int IsOptimized, LLVMValueRef Func) {
|
||||||
DIBuilder *D = unwrap(Dref);
|
DIBuilder *D = unwrap(Dref);
|
||||||
DISubprogram SP = D->createFunction(
|
return wrap(D->createFunction(unwrap<MDScope>(Scope), Name, LinkageName,
|
||||||
unwrap<MDScope>(Scope), Name, LinkageName,
|
File ? unwrap<MDFile>(File) : nullptr, Line,
|
||||||
File ? unwrap<MDFile>(File) : nullptr, Line,
|
unwrap<MDSubroutineType>(CompositeType),
|
||||||
unwrap<MDSubroutineType>(CompositeType), IsLocalToUnit, IsDefinition,
|
IsLocalToUnit, IsDefinition, ScopeLine, Flags,
|
||||||
ScopeLine, Flags, IsOptimized, unwrap<Function>(Func));
|
IsOptimized, unwrap<Function>(Func)));
|
||||||
return wrap(SP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMMetadataRef LLVMDIBuilderCreateLocalVariable(
|
LLVMMetadataRef LLVMDIBuilderCreateLocalVariable(
|
||||||
|
@ -46,10 +46,6 @@ class NamedMDNode;
|
|||||||
class LLVMContext;
|
class LLVMContext;
|
||||||
class raw_ostream;
|
class raw_ostream;
|
||||||
|
|
||||||
class DIFile;
|
|
||||||
class DISubprogram;
|
|
||||||
class DILexicalBlock;
|
|
||||||
class DILexicalBlockFile;
|
|
||||||
class DIVariable;
|
class DIVariable;
|
||||||
class DIObjCProperty;
|
class DIObjCProperty;
|
||||||
|
|
||||||
@ -62,12 +58,6 @@ typedef DenseMap<const MDString *, MDNode *> DITypeIdentifierMap;
|
|||||||
template <> struct simplify_type<DESC>;
|
template <> struct simplify_type<DESC>;
|
||||||
DECLARE_SIMPLIFY_DESCRIPTOR(DISubrange)
|
DECLARE_SIMPLIFY_DESCRIPTOR(DISubrange)
|
||||||
DECLARE_SIMPLIFY_DESCRIPTOR(DIEnumerator)
|
DECLARE_SIMPLIFY_DESCRIPTOR(DIEnumerator)
|
||||||
DECLARE_SIMPLIFY_DESCRIPTOR(DIFile)
|
|
||||||
DECLARE_SIMPLIFY_DESCRIPTOR(DICompileUnit)
|
|
||||||
DECLARE_SIMPLIFY_DESCRIPTOR(DISubprogram)
|
|
||||||
DECLARE_SIMPLIFY_DESCRIPTOR(DILexicalBlock)
|
|
||||||
DECLARE_SIMPLIFY_DESCRIPTOR(DILexicalBlockFile)
|
|
||||||
DECLARE_SIMPLIFY_DESCRIPTOR(DINameSpace)
|
|
||||||
DECLARE_SIMPLIFY_DESCRIPTOR(DITemplateTypeParameter)
|
DECLARE_SIMPLIFY_DESCRIPTOR(DITemplateTypeParameter)
|
||||||
DECLARE_SIMPLIFY_DESCRIPTOR(DITemplateValueParameter)
|
DECLARE_SIMPLIFY_DESCRIPTOR(DITemplateValueParameter)
|
||||||
DECLARE_SIMPLIFY_DESCRIPTOR(DIGlobalVariable)
|
DECLARE_SIMPLIFY_DESCRIPTOR(DIGlobalVariable)
|
||||||
@ -104,77 +94,6 @@ public:
|
|||||||
MDEnumerator &operator*() const { return *N; }
|
MDEnumerator &operator*() const { return *N; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class DIFile {
|
|
||||||
MDFile *N;
|
|
||||||
|
|
||||||
public:
|
|
||||||
DIFile(const MDFile *N = nullptr) : N(const_cast<MDFile *>(N)) {}
|
|
||||||
|
|
||||||
operator MDFile *() const { return N; }
|
|
||||||
MDFile *operator->() const { return N; }
|
|
||||||
MDFile &operator*() const { return *N; }
|
|
||||||
};
|
|
||||||
|
|
||||||
class DICompileUnit {
|
|
||||||
MDCompileUnit *N;
|
|
||||||
|
|
||||||
public:
|
|
||||||
DICompileUnit(const MDCompileUnit *N = nullptr)
|
|
||||||
: N(const_cast<MDCompileUnit *>(N)) {}
|
|
||||||
|
|
||||||
operator MDCompileUnit *() const { return N; }
|
|
||||||
MDCompileUnit *operator->() const { return N; }
|
|
||||||
MDCompileUnit &operator*() const { return *N; }
|
|
||||||
};
|
|
||||||
|
|
||||||
class DISubprogram {
|
|
||||||
MDSubprogram *N;
|
|
||||||
|
|
||||||
public:
|
|
||||||
DISubprogram(const MDSubprogram *N = nullptr)
|
|
||||||
: N(const_cast<MDSubprogram *>(N)) {}
|
|
||||||
|
|
||||||
operator MDSubprogram *() const { return N; }
|
|
||||||
MDSubprogram *operator->() const { return N; }
|
|
||||||
MDSubprogram &operator*() const { return *N; }
|
|
||||||
};
|
|
||||||
|
|
||||||
class DILexicalBlock {
|
|
||||||
MDLexicalBlockBase *N;
|
|
||||||
|
|
||||||
public:
|
|
||||||
DILexicalBlock(const MDLexicalBlockBase *N = nullptr)
|
|
||||||
: N(const_cast<MDLexicalBlockBase *>(N)) {}
|
|
||||||
|
|
||||||
operator MDLexicalBlockBase *() const { return N; }
|
|
||||||
MDLexicalBlockBase *operator->() const { return N; }
|
|
||||||
MDLexicalBlockBase &operator*() const { return *N; }
|
|
||||||
};
|
|
||||||
|
|
||||||
class DILexicalBlockFile {
|
|
||||||
MDLexicalBlockFile *N;
|
|
||||||
|
|
||||||
public:
|
|
||||||
DILexicalBlockFile(const MDLexicalBlockFile *N = nullptr)
|
|
||||||
: N(const_cast<MDLexicalBlockFile *>(N)) {}
|
|
||||||
|
|
||||||
operator MDLexicalBlockFile *() const { return N; }
|
|
||||||
MDLexicalBlockFile *operator->() const { return N; }
|
|
||||||
MDLexicalBlockFile &operator*() const { return *N; }
|
|
||||||
};
|
|
||||||
|
|
||||||
class DINameSpace {
|
|
||||||
MDNamespace *N;
|
|
||||||
|
|
||||||
public:
|
|
||||||
DINameSpace(const MDNamespace *N = nullptr)
|
|
||||||
: N(const_cast<MDNamespace *>(N)) {}
|
|
||||||
|
|
||||||
operator MDNamespace *() const { return N; }
|
|
||||||
MDNamespace *operator->() const { return N; }
|
|
||||||
MDNamespace &operator*() const { return *N; }
|
|
||||||
};
|
|
||||||
|
|
||||||
class DITemplateTypeParameter {
|
class DITemplateTypeParameter {
|
||||||
MDTemplateTypeParameter *N;
|
MDTemplateTypeParameter *N;
|
||||||
|
|
||||||
@ -278,12 +197,6 @@ public:
|
|||||||
template <> struct simplify_type<DESC> : simplify_type<const DESC> {};
|
template <> struct simplify_type<DESC> : simplify_type<const DESC> {};
|
||||||
SIMPLIFY_DESCRIPTOR(DISubrange)
|
SIMPLIFY_DESCRIPTOR(DISubrange)
|
||||||
SIMPLIFY_DESCRIPTOR(DIEnumerator)
|
SIMPLIFY_DESCRIPTOR(DIEnumerator)
|
||||||
SIMPLIFY_DESCRIPTOR(DIFile)
|
|
||||||
SIMPLIFY_DESCRIPTOR(DICompileUnit)
|
|
||||||
SIMPLIFY_DESCRIPTOR(DISubprogram)
|
|
||||||
SIMPLIFY_DESCRIPTOR(DILexicalBlock)
|
|
||||||
SIMPLIFY_DESCRIPTOR(DILexicalBlockFile)
|
|
||||||
SIMPLIFY_DESCRIPTOR(DINameSpace)
|
|
||||||
SIMPLIFY_DESCRIPTOR(DITemplateTypeParameter)
|
SIMPLIFY_DESCRIPTOR(DITemplateTypeParameter)
|
||||||
SIMPLIFY_DESCRIPTOR(DITemplateValueParameter)
|
SIMPLIFY_DESCRIPTOR(DITemplateValueParameter)
|
||||||
SIMPLIFY_DESCRIPTOR(DIGlobalVariable)
|
SIMPLIFY_DESCRIPTOR(DIGlobalVariable)
|
||||||
@ -298,8 +211,8 @@ SIMPLIFY_DESCRIPTOR(DIImportedEntity)
|
|||||||
MDSubprogram *getDISubprogram(const MDNode *Scope);
|
MDSubprogram *getDISubprogram(const MDNode *Scope);
|
||||||
|
|
||||||
/// \brief Find debug info for a given function.
|
/// \brief Find debug info for a given function.
|
||||||
/// \returns a valid DISubprogram, if found. Otherwise, it returns an empty
|
///
|
||||||
/// DISubprogram.
|
/// \returns a valid subprogram, if found. Otherwise, return \c nullptr.
|
||||||
MDSubprogram *getDISubprogram(const Function *F);
|
MDSubprogram *getDISubprogram(const Function *F);
|
||||||
|
|
||||||
/// \brief Find underlying composite type.
|
/// \brief Find underlying composite type.
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
DwarfCompileUnit::DwarfCompileUnit(unsigned UID, DICompileUnit Node,
|
DwarfCompileUnit::DwarfCompileUnit(unsigned UID, const MDCompileUnit *Node,
|
||||||
AsmPrinter *A, DwarfDebug *DW,
|
AsmPrinter *A, DwarfDebug *DW,
|
||||||
DwarfFile *DWU)
|
DwarfFile *DWU)
|
||||||
: DwarfUnit(UID, dwarf::DW_TAG_compile_unit, Node, A, DW, DWU),
|
: DwarfUnit(UID, dwarf::DW_TAG_compile_unit, Node, A, DW, DWU),
|
||||||
@ -276,7 +276,7 @@ void DwarfCompileUnit::attachLowHighPC(DIE &D, const MCSymbol *Begin,
|
|||||||
// Find DIE for the given subprogram and attach appropriate DW_AT_low_pc
|
// Find DIE for the given subprogram and attach appropriate DW_AT_low_pc
|
||||||
// and DW_AT_high_pc attributes. If there are global variables in this
|
// and DW_AT_high_pc attributes. If there are global variables in this
|
||||||
// scope then create and insert DIEs for these variables.
|
// scope then create and insert DIEs for these variables.
|
||||||
DIE &DwarfCompileUnit::updateSubprogramScopeDIE(DISubprogram SP) {
|
DIE &DwarfCompileUnit::updateSubprogramScopeDIE(const MDSubprogram *SP) {
|
||||||
DIE *SPDie = getOrCreateSubprogramDIE(SP, includeMinimalInlineScopes());
|
DIE *SPDie = getOrCreateSubprogramDIE(SP, includeMinimalInlineScopes());
|
||||||
|
|
||||||
attachLowHighPC(*SPDie, Asm->getFunctionBegin(), Asm->getFunctionEnd());
|
attachLowHighPC(*SPDie, Asm->getFunctionBegin(), Asm->getFunctionEnd());
|
||||||
@ -562,7 +562,7 @@ void DwarfCompileUnit::constructSubprogramScopeDIE(LexicalScope *Scope) {
|
|||||||
assert(Scope && Scope->getScopeNode());
|
assert(Scope && Scope->getScopeNode());
|
||||||
assert(!Scope->getInlinedAt());
|
assert(!Scope->getInlinedAt());
|
||||||
assert(!Scope->isAbstractScope());
|
assert(!Scope->isAbstractScope());
|
||||||
DISubprogram Sub = cast<MDSubprogram>(Scope->getScopeNode());
|
auto *Sub = cast<MDSubprogram>(Scope->getScopeNode());
|
||||||
|
|
||||||
DD->getProcessedSPNodes().insert(Sub);
|
DD->getProcessedSPNodes().insert(Sub);
|
||||||
|
|
||||||
@ -604,7 +604,7 @@ DwarfCompileUnit::constructAbstractSubprogramScopeDIE(LexicalScope *Scope) {
|
|||||||
if (AbsDef)
|
if (AbsDef)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DISubprogram SP = cast<MDSubprogram>(Scope->getScopeNode());
|
auto *SP = cast<MDSubprogram>(Scope->getScopeNode());
|
||||||
|
|
||||||
DIE *ContextDIE;
|
DIE *ContextDIE;
|
||||||
|
|
||||||
@ -658,7 +658,7 @@ DwarfCompileUnit::constructImportedEntityDIE(const DIImportedEntity &Module) {
|
|||||||
return IMDie;
|
return IMDie;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfCompileUnit::finishSubprogramDefinition(DISubprogram SP) {
|
void DwarfCompileUnit::finishSubprogramDefinition(const MDSubprogram *SP) {
|
||||||
DIE *D = getDIE(SP);
|
DIE *D = getDIE(SP);
|
||||||
if (DIE *AbsSPDIE = DU->getAbstractSPDies().lookup(SP)) {
|
if (DIE *AbsSPDIE = DU->getAbstractSPDies().lookup(SP)) {
|
||||||
if (D)
|
if (D)
|
||||||
@ -675,7 +675,7 @@ void DwarfCompileUnit::finishSubprogramDefinition(DISubprogram SP) {
|
|||||||
applySubprogramAttributesToDefinition(SP, *D);
|
applySubprogramAttributesToDefinition(SP, *D);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void DwarfCompileUnit::collectDeadVariables(DISubprogram SP) {
|
void DwarfCompileUnit::collectDeadVariables(const MDSubprogram *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");
|
||||||
@ -805,8 +805,8 @@ void DwarfCompileUnit::addExpr(DIELoc &Die, dwarf::Form Form,
|
|||||||
Die.addValue((dwarf::Attribute)0, Form, Value);
|
Die.addValue((dwarf::Attribute)0, Form, Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfCompileUnit::applySubprogramAttributesToDefinition(DISubprogram SP,
|
void DwarfCompileUnit::applySubprogramAttributesToDefinition(
|
||||||
DIE &SPDie) {
|
const MDSubprogram *SP, DIE &SPDie) {
|
||||||
auto *SPDecl = SP->getDeclaration();
|
auto *SPDecl = SP->getDeclaration();
|
||||||
auto *Context = resolve(SPDecl ? SPDecl->getScope() : SP->getScope());
|
auto *Context = resolve(SPDecl ? SPDecl->getScope() : SP->getScope());
|
||||||
applySubprogramAttributes(SP, SPDie, includeMinimalInlineScopes());
|
applySubprogramAttributes(SP, SPDie, includeMinimalInlineScopes());
|
||||||
|
@ -66,7 +66,7 @@ class DwarfCompileUnit : public DwarfUnit {
|
|||||||
bool includeMinimalInlineScopes() const;
|
bool includeMinimalInlineScopes() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DwarfCompileUnit(unsigned UID, DICompileUnit Node, AsmPrinter *A,
|
DwarfCompileUnit(unsigned UID, const MDCompileUnit *Node, AsmPrinter *A,
|
||||||
DwarfDebug *DW, DwarfFile *DWU);
|
DwarfDebug *DW, DwarfFile *DWU);
|
||||||
|
|
||||||
DwarfCompileUnit *getSkeleton() const {
|
DwarfCompileUnit *getSkeleton() const {
|
||||||
@ -113,7 +113,7 @@ public:
|
|||||||
/// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global
|
/// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global
|
||||||
/// variables in this scope then create and insert DIEs for these
|
/// variables in this scope then create and insert DIEs for these
|
||||||
/// variables.
|
/// variables.
|
||||||
DIE &updateSubprogramScopeDIE(DISubprogram SP);
|
DIE &updateSubprogramScopeDIE(const MDSubprogram *SP);
|
||||||
|
|
||||||
void constructScopeDIE(LexicalScope *Scope,
|
void constructScopeDIE(LexicalScope *Scope,
|
||||||
SmallVectorImpl<std::unique_ptr<DIE>> &FinalChildren);
|
SmallVectorImpl<std::unique_ptr<DIE>> &FinalChildren);
|
||||||
@ -158,9 +158,9 @@ public:
|
|||||||
std::unique_ptr<DIE>
|
std::unique_ptr<DIE>
|
||||||
constructImportedEntityDIE(const DIImportedEntity &Module);
|
constructImportedEntityDIE(const DIImportedEntity &Module);
|
||||||
|
|
||||||
void finishSubprogramDefinition(DISubprogram SP);
|
void finishSubprogramDefinition(const MDSubprogram *SP);
|
||||||
|
|
||||||
void collectDeadVariables(DISubprogram SP);
|
void collectDeadVariables(const MDSubprogram *SP);
|
||||||
|
|
||||||
/// Set the skeleton unit associated with this unit.
|
/// Set the skeleton unit associated with this unit.
|
||||||
void setSkeleton(DwarfCompileUnit &Skel) { Skeleton = &Skel; }
|
void setSkeleton(DwarfCompileUnit &Skel) { Skeleton = &Skel; }
|
||||||
@ -215,7 +215,8 @@ public:
|
|||||||
/// Add a Dwarf expression attribute data and value.
|
/// Add a Dwarf expression attribute data and value.
|
||||||
void addExpr(DIELoc &Die, dwarf::Form Form, const MCExpr *Expr);
|
void addExpr(DIELoc &Die, dwarf::Form Form, const MCExpr *Expr);
|
||||||
|
|
||||||
void applySubprogramAttributesToDefinition(DISubprogram SP, DIE &SPDie);
|
void applySubprogramAttributesToDefinition(const MDSubprogram *SP,
|
||||||
|
DIE &SPDie);
|
||||||
|
|
||||||
/// getRangeLists - Get the vector of range lists.
|
/// getRangeLists - Get the vector of range lists.
|
||||||
const SmallVectorImpl<RangeSpanList> &getRangeLists() const {
|
const SmallVectorImpl<RangeSpanList> &getRangeLists() const {
|
||||||
|
@ -277,7 +277,7 @@ static StringRef getObjCMethodName(StringRef In) {
|
|||||||
// TODO: Determine whether or not we should add names for programs
|
// TODO: Determine whether or not we should add names for programs
|
||||||
// that do not have a DW_AT_name or DW_AT_linkage_name field - this
|
// that do not have a DW_AT_name or DW_AT_linkage_name field - this
|
||||||
// is only slightly different than the lookup of non-standard ObjC names.
|
// is only slightly different than the lookup of non-standard ObjC names.
|
||||||
void DwarfDebug::addSubprogramNames(DISubprogram SP, DIE &Die) {
|
void DwarfDebug::addSubprogramNames(const MDSubprogram *SP, DIE &Die) {
|
||||||
if (!SP->isDefinition())
|
if (!SP->isDefinition())
|
||||||
return;
|
return;
|
||||||
addAccelName(SP->getName(), Die);
|
addAccelName(SP->getName(), Die);
|
||||||
@ -363,7 +363,8 @@ void DwarfDebug::addGnuPubAttributes(DwarfUnit &U, DIE &D) const {
|
|||||||
|
|
||||||
// Create new DwarfCompileUnit for the given metadata node with tag
|
// Create new DwarfCompileUnit for the given metadata node with tag
|
||||||
// DW_TAG_compile_unit.
|
// DW_TAG_compile_unit.
|
||||||
DwarfCompileUnit &DwarfDebug::constructDwarfCompileUnit(DICompileUnit DIUnit) {
|
DwarfCompileUnit &
|
||||||
|
DwarfDebug::constructDwarfCompileUnit(const MDCompileUnit *DIUnit) {
|
||||||
StringRef FN = DIUnit->getFilename();
|
StringRef FN = DIUnit->getFilename();
|
||||||
CompilationDir = DIUnit->getDirectory();
|
CompilationDir = DIUnit->getDirectory();
|
||||||
|
|
||||||
@ -446,7 +447,7 @@ void DwarfDebug::beginModule() {
|
|||||||
SingleCU = CU_Nodes->getNumOperands() == 1;
|
SingleCU = CU_Nodes->getNumOperands() == 1;
|
||||||
|
|
||||||
for (MDNode *N : CU_Nodes->operands()) {
|
for (MDNode *N : CU_Nodes->operands()) {
|
||||||
DICompileUnit CUNode = cast<MDCompileUnit>(N);
|
auto *CUNode = cast<MDCompileUnit>(N);
|
||||||
DwarfCompileUnit &CU = constructDwarfCompileUnit(CUNode);
|
DwarfCompileUnit &CU = constructDwarfCompileUnit(CUNode);
|
||||||
for (auto *IE : CUNode->getImportedEntities())
|
for (auto *IE : CUNode->getImportedEntities())
|
||||||
ScopesWithImportedEntities.push_back(std::make_pair(IE->getScope(), IE));
|
ScopesWithImportedEntities.push_back(std::make_pair(IE->getScope(), IE));
|
||||||
@ -512,7 +513,7 @@ void DwarfDebug::collectDeadVariables() {
|
|||||||
|
|
||||||
if (NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu")) {
|
if (NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu")) {
|
||||||
for (MDNode *N : CU_Nodes->operands()) {
|
for (MDNode *N : CU_Nodes->operands()) {
|
||||||
DICompileUnit TheCU = cast<MDCompileUnit>(N);
|
auto *TheCU = cast<MDCompileUnit>(N);
|
||||||
// Construct subprogram DIE and add variables DIEs.
|
// Construct subprogram DIE and add variables DIEs.
|
||||||
DwarfCompileUnit *SPCU =
|
DwarfCompileUnit *SPCU =
|
||||||
static_cast<DwarfCompileUnit *>(CUMap.lookup(TheCU));
|
static_cast<DwarfCompileUnit *>(CUMap.lookup(TheCU));
|
||||||
@ -872,7 +873,8 @@ DwarfDebug::buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
|
|||||||
|
|
||||||
|
|
||||||
// Find variables for each lexical scope.
|
// Find variables for each lexical scope.
|
||||||
void DwarfDebug::collectVariableInfo(DwarfCompileUnit &TheCU, DISubprogram SP,
|
void DwarfDebug::collectVariableInfo(DwarfCompileUnit &TheCU,
|
||||||
|
const MDSubprogram *SP,
|
||||||
DenseSet<InlinedVariable> &Processed) {
|
DenseSet<InlinedVariable> &Processed) {
|
||||||
// Grab the variable info that was squirreled away in the MMI side-table.
|
// Grab the variable info that was squirreled away in the MMI side-table.
|
||||||
collectVariableInfoFromMMITable(Processed);
|
collectVariableInfoFromMMITable(Processed);
|
||||||
@ -1185,7 +1187,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
|
|||||||
Asm->OutStreamer.getContext().setDwarfCompileUnitID(0);
|
Asm->OutStreamer.getContext().setDwarfCompileUnitID(0);
|
||||||
|
|
||||||
LexicalScope *FnScope = LScopes.getCurrentFunctionScope();
|
LexicalScope *FnScope = LScopes.getCurrentFunctionScope();
|
||||||
DISubprogram SP = cast<MDSubprogram>(FnScope->getScopeNode());
|
auto *SP = cast<MDSubprogram>(FnScope->getScopeNode());
|
||||||
DwarfCompileUnit &TheCU = *SPMap.lookup(SP);
|
DwarfCompileUnit &TheCU = *SPMap.lookup(SP);
|
||||||
|
|
||||||
DenseSet<InlinedVariable> ProcessedVars;
|
DenseSet<InlinedVariable> ProcessedVars;
|
||||||
@ -1215,7 +1217,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
|
|||||||
#endif
|
#endif
|
||||||
// Construct abstract scopes.
|
// Construct abstract scopes.
|
||||||
for (LexicalScope *AScope : LScopes.getAbstractScopesList()) {
|
for (LexicalScope *AScope : LScopes.getAbstractScopesList()) {
|
||||||
DISubprogram SP = cast<MDSubprogram>(AScope->getScopeNode());
|
auto *SP = cast<MDSubprogram>(AScope->getScopeNode());
|
||||||
// Collect info for variables that were optimized out.
|
// Collect info for variables that were optimized out.
|
||||||
for (DIVariable DV : SP->getVariables()) {
|
for (DIVariable DV : SP->getVariables()) {
|
||||||
if (!ProcessedVars.insert(InlinedVariable(DV, nullptr)).second)
|
if (!ProcessedVars.insert(InlinedVariable(DV, nullptr)).second)
|
||||||
|
@ -451,7 +451,7 @@ class DwarfDebug : public AsmPrinterHandler {
|
|||||||
|
|
||||||
/// \brief Create new DwarfCompileUnit for the given metadata node with tag
|
/// \brief Create new DwarfCompileUnit for the given metadata node with tag
|
||||||
/// DW_TAG_compile_unit.
|
/// DW_TAG_compile_unit.
|
||||||
DwarfCompileUnit &constructDwarfCompileUnit(DICompileUnit DIUnit);
|
DwarfCompileUnit &constructDwarfCompileUnit(const MDCompileUnit *DIUnit);
|
||||||
|
|
||||||
/// \brief Construct imported_module or imported_declaration DIE.
|
/// \brief Construct imported_module or imported_declaration DIE.
|
||||||
void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
|
void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
|
||||||
@ -468,7 +468,7 @@ class DwarfDebug : public AsmPrinterHandler {
|
|||||||
void identifyScopeMarkers();
|
void identifyScopeMarkers();
|
||||||
|
|
||||||
/// \brief Populate LexicalScope entries with variables' info.
|
/// \brief Populate LexicalScope entries with variables' info.
|
||||||
void collectVariableInfo(DwarfCompileUnit &TheCU, DISubprogram SP,
|
void collectVariableInfo(DwarfCompileUnit &TheCU, const MDSubprogram *SP,
|
||||||
DenseSet<InlinedVariable> &ProcessedVars);
|
DenseSet<InlinedVariable> &ProcessedVars);
|
||||||
|
|
||||||
/// \brief Build the location list for all DBG_VALUEs in the
|
/// \brief Build the location list for all DBG_VALUEs in the
|
||||||
@ -581,7 +581,7 @@ public:
|
|||||||
/// or another context nested inside a subprogram.
|
/// or another context nested inside a subprogram.
|
||||||
bool isSubprogramContext(const MDNode *Context);
|
bool isSubprogramContext(const MDNode *Context);
|
||||||
|
|
||||||
void addSubprogramNames(DISubprogram SP, DIE &Die);
|
void addSubprogramNames(const MDSubprogram *SP, DIE &Die);
|
||||||
|
|
||||||
AddressPool &getAddressPool() { return AddrPool; }
|
AddressPool &getAddressPool() { return AddrPool; }
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@ class DwarfUnit;
|
|||||||
class DIEAbbrev;
|
class DIEAbbrev;
|
||||||
class MCSymbol;
|
class MCSymbol;
|
||||||
class DIE;
|
class DIE;
|
||||||
class DISubprogram;
|
|
||||||
class LexicalScope;
|
class LexicalScope;
|
||||||
class StringRef;
|
class StringRef;
|
||||||
class DwarfDebug;
|
class DwarfDebug;
|
||||||
|
@ -63,9 +63,9 @@ bool DIEDwarfExpression::isFrameRegister(unsigned MachineReg) {
|
|||||||
return MachineReg == TRI.getFrameRegister(*AP.MF);
|
return MachineReg == TRI.getFrameRegister(*AP.MF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DwarfUnit::DwarfUnit(unsigned UID, dwarf::Tag UnitTag,
|
||||||
DwarfUnit::DwarfUnit(unsigned UID, dwarf::Tag UnitTag, DICompileUnit Node,
|
const MDCompileUnit *Node, AsmPrinter *A, DwarfDebug *DW,
|
||||||
AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU)
|
DwarfFile *DWU)
|
||||||
: UniqueID(UID), CUNode(Node), UnitDie(UnitTag), DebugInfoOffset(0), Asm(A),
|
: UniqueID(UID), CUNode(Node), UnitDie(UnitTag), DebugInfoOffset(0), Asm(A),
|
||||||
DD(DW), DU(DWU), IndexTyDie(nullptr), Section(nullptr) {
|
DD(DW), DU(DWU), IndexTyDie(nullptr), Section(nullptr) {
|
||||||
assert(UnitTag == dwarf::DW_TAG_compile_unit ||
|
assert(UnitTag == dwarf::DW_TAG_compile_unit ||
|
||||||
@ -367,7 +367,7 @@ void DwarfUnit::addSourceLine(DIE &Die, DIGlobalVariable G) {
|
|||||||
addSourceLine(Die, G->getLine(), G->getFilename(), G->getDirectory());
|
addSourceLine(Die, G->getLine(), G->getFilename(), G->getDirectory());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfUnit::addSourceLine(DIE &Die, DISubprogram SP) {
|
void DwarfUnit::addSourceLine(DIE &Die, const MDSubprogram *SP) {
|
||||||
assert(SP);
|
assert(SP);
|
||||||
|
|
||||||
addSourceLine(Die, SP->getLine(), SP->getFilename(), SP->getDirectory());
|
addSourceLine(Die, SP->getLine(), SP->getFilename(), SP->getDirectory());
|
||||||
@ -385,7 +385,7 @@ void DwarfUnit::addSourceLine(DIE &Die, DIObjCProperty Ty) {
|
|||||||
addSourceLine(Die, Ty->getLine(), Ty->getFilename(), Ty->getDirectory());
|
addSourceLine(Die, Ty->getLine(), Ty->getFilename(), Ty->getDirectory());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfUnit::addSourceLine(DIE &Die, DINameSpace NS) {
|
void DwarfUnit::addSourceLine(DIE &Die, const MDNamespace *NS) {
|
||||||
addSourceLine(Die, NS->getLine(), NS->getFilename(), NS->getDirectory());
|
addSourceLine(Die, NS->getLine(), NS->getFilename(), NS->getDirectory());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1101,7 +1101,7 @@ DwarfUnit::constructTemplateValueParameterDIE(DIE &Buffer,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DIE *DwarfUnit::getOrCreateNameSpace(DINameSpace NS) {
|
DIE *DwarfUnit::getOrCreateNameSpace(const MDNamespace *NS) {
|
||||||
// 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(NS->getScope());
|
DIE *ContextDIE = getOrCreateContextDIE(NS->getScope());
|
||||||
@ -1121,7 +1121,7 @@ DIE *DwarfUnit::getOrCreateNameSpace(DINameSpace NS) {
|
|||||||
return &NDie;
|
return &NDie;
|
||||||
}
|
}
|
||||||
|
|
||||||
DIE *DwarfUnit::getOrCreateSubprogramDIE(DISubprogram SP, bool Minimal) {
|
DIE *DwarfUnit::getOrCreateSubprogramDIE(const MDSubprogram *SP, bool Minimal) {
|
||||||
// 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 (as is the case for member function
|
// such construction creates the DIE (as is the case for member function
|
||||||
// declarations).
|
// declarations).
|
||||||
@ -1152,7 +1152,7 @@ DIE *DwarfUnit::getOrCreateSubprogramDIE(DISubprogram SP, bool Minimal) {
|
|||||||
return &SPDie;
|
return &SPDie;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DwarfUnit::applySubprogramDefinitionAttributes(DISubprogram SP,
|
bool DwarfUnit::applySubprogramDefinitionAttributes(const MDSubprogram *SP,
|
||||||
DIE &SPDie) {
|
DIE &SPDie) {
|
||||||
DIE *DeclDie = nullptr;
|
DIE *DeclDie = nullptr;
|
||||||
StringRef DeclLinkageName;
|
StringRef DeclLinkageName;
|
||||||
@ -1184,7 +1184,7 @@ bool DwarfUnit::applySubprogramDefinitionAttributes(DISubprogram SP,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfUnit::applySubprogramAttributes(DISubprogram SP, DIE &SPDie,
|
void DwarfUnit::applySubprogramAttributes(const MDSubprogram *SP, DIE &SPDie,
|
||||||
bool Minimal) {
|
bool Minimal) {
|
||||||
if (!Minimal)
|
if (!Minimal)
|
||||||
if (applySubprogramDefinitionAttributes(SP, SPDie))
|
if (applySubprogramDefinitionAttributes(SP, SPDie))
|
||||||
|
@ -71,7 +71,7 @@ protected:
|
|||||||
unsigned UniqueID;
|
unsigned UniqueID;
|
||||||
|
|
||||||
/// MDNode for the compile unit.
|
/// MDNode for the compile unit.
|
||||||
DICompileUnit CUNode;
|
const MDCompileUnit *CUNode;
|
||||||
|
|
||||||
/// Unit debug information entry.
|
/// Unit debug information entry.
|
||||||
DIE UnitDie;
|
DIE UnitDie;
|
||||||
@ -117,7 +117,7 @@ protected:
|
|||||||
/// The section this unit will be emitted in.
|
/// The section this unit will be emitted in.
|
||||||
const MCSection *Section;
|
const MCSection *Section;
|
||||||
|
|
||||||
DwarfUnit(unsigned UID, dwarf::Tag, DICompileUnit CU, AsmPrinter *A,
|
DwarfUnit(unsigned UID, dwarf::Tag, const MDCompileUnit *CU, AsmPrinter *A,
|
||||||
DwarfDebug *DW, DwarfFile *DWU);
|
DwarfDebug *DW, DwarfFile *DWU);
|
||||||
|
|
||||||
/// \brief Add a string attribute data and value.
|
/// \brief Add a string attribute data and value.
|
||||||
@ -127,7 +127,7 @@ protected:
|
|||||||
|
|
||||||
void addIndexedString(DIE &Die, dwarf::Attribute Attribute, StringRef Str);
|
void addIndexedString(DIE &Die, dwarf::Attribute Attribute, StringRef Str);
|
||||||
|
|
||||||
bool applySubprogramDefinitionAttributes(DISubprogram SP, DIE &SPDie);
|
bool applySubprogramDefinitionAttributes(const MDSubprogram *SP, DIE &SPDie);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~DwarfUnit();
|
virtual ~DwarfUnit();
|
||||||
@ -143,7 +143,7 @@ public:
|
|||||||
AsmPrinter* getAsmPrinter() const { return Asm; }
|
AsmPrinter* getAsmPrinter() const { return Asm; }
|
||||||
unsigned getUniqueID() const { return UniqueID; }
|
unsigned getUniqueID() const { return UniqueID; }
|
||||||
uint16_t getLanguage() const { return CUNode->getSourceLanguage(); }
|
uint16_t getLanguage() const { return CUNode->getSourceLanguage(); }
|
||||||
DICompileUnit getCUNode() const { return CUNode; }
|
const MDCompileUnit *getCUNode() const { return CUNode; }
|
||||||
DIE &getUnitDie() { return UnitDie; }
|
DIE &getUnitDie() { return UnitDie; }
|
||||||
|
|
||||||
unsigned getDebugInfoOffset() const { return DebugInfoOffset; }
|
unsigned getDebugInfoOffset() const { return DebugInfoOffset; }
|
||||||
@ -248,9 +248,9 @@ public:
|
|||||||
StringRef Directory);
|
StringRef Directory);
|
||||||
void addSourceLine(DIE &Die, DIVariable V);
|
void addSourceLine(DIE &Die, DIVariable V);
|
||||||
void addSourceLine(DIE &Die, DIGlobalVariable G);
|
void addSourceLine(DIE &Die, DIGlobalVariable G);
|
||||||
void addSourceLine(DIE &Die, DISubprogram SP);
|
void addSourceLine(DIE &Die, const MDSubprogram *SP);
|
||||||
void addSourceLine(DIE &Die, const MDType *Ty);
|
void addSourceLine(DIE &Die, const MDType *Ty);
|
||||||
void addSourceLine(DIE &Die, DINameSpace NS);
|
void addSourceLine(DIE &Die, const MDNamespace *NS);
|
||||||
void addSourceLine(DIE &Die, DIObjCProperty Ty);
|
void addSourceLine(DIE &Die, DIObjCProperty Ty);
|
||||||
|
|
||||||
/// \brief Add constant value entry in variable DIE.
|
/// \brief Add constant value entry in variable DIE.
|
||||||
@ -297,10 +297,10 @@ public:
|
|||||||
void addType(DIE &Entity, const MDType *Ty,
|
void addType(DIE &Entity, const MDType *Ty,
|
||||||
dwarf::Attribute Attribute = dwarf::DW_AT_type);
|
dwarf::Attribute Attribute = dwarf::DW_AT_type);
|
||||||
|
|
||||||
DIE *getOrCreateNameSpace(DINameSpace NS);
|
DIE *getOrCreateNameSpace(const MDNamespace *NS);
|
||||||
DIE *getOrCreateSubprogramDIE(DISubprogram SP, bool Minimal = false);
|
DIE *getOrCreateSubprogramDIE(const MDSubprogram *SP, bool Minimal = false);
|
||||||
|
|
||||||
void applySubprogramAttributes(DISubprogram SP, DIE &SPDie,
|
void applySubprogramAttributes(const MDSubprogram *SP, DIE &SPDie,
|
||||||
bool Minimal = false);
|
bool Minimal = false);
|
||||||
|
|
||||||
/// \brief Find existing DIE or create new DIE for the given type.
|
/// \brief Find existing DIE or create new DIE for the given type.
|
||||||
|
@ -191,7 +191,7 @@ void WinCodeViewLineTables::emitDebugInfoForFunction(const Function *GV) {
|
|||||||
|
|
||||||
StringRef GVName = GV->getName();
|
StringRef GVName = GV->getName();
|
||||||
StringRef FuncName;
|
StringRef FuncName;
|
||||||
if (DISubprogram SP = getDISubprogram(GV))
|
if (auto *SP = getDISubprogram(GV))
|
||||||
FuncName = SP->getDisplayName();
|
FuncName = SP->getDisplayName();
|
||||||
|
|
||||||
// FIXME Clang currently sets DisplayName to "bar" for a C++
|
// FIXME Clang currently sets DisplayName to "bar" for a C++
|
||||||
|
@ -50,7 +50,7 @@ MDNode *DebugLoc::getInlinedAtScope() const {
|
|||||||
DebugLoc DebugLoc::getFnDebugLoc() const {
|
DebugLoc DebugLoc::getFnDebugLoc() const {
|
||||||
// FIXME: Add a method on \a MDLocation that does this work.
|
// FIXME: Add a method on \a MDLocation that does this work.
|
||||||
const MDNode *Scope = getInlinedAtScope();
|
const MDNode *Scope = getInlinedAtScope();
|
||||||
if (DISubprogram SP = getDISubprogram(Scope))
|
if (auto *SP = getDISubprogram(Scope))
|
||||||
return DebugLoc::get(SP->getScopeLine(), 0, SP);
|
return DebugLoc::get(SP->getScopeLine(), 0, SP);
|
||||||
|
|
||||||
return DebugLoc();
|
return DebugLoc();
|
||||||
|
@ -1269,7 +1269,7 @@ void ModuleLinker::stripReplacedSubprograms() {
|
|||||||
if (!CompileUnits)
|
if (!CompileUnits)
|
||||||
return;
|
return;
|
||||||
for (unsigned I = 0, E = CompileUnits->getNumOperands(); I != E; ++I) {
|
for (unsigned I = 0, E = CompileUnits->getNumOperands(); I != E; ++I) {
|
||||||
DICompileUnit CU = cast<MDCompileUnit>(CompileUnits->getOperand(I));
|
auto *CU = cast<MDCompileUnit>(CompileUnits->getOperand(I));
|
||||||
assert(CU && "Expected valid compile unit");
|
assert(CU && "Expected valid compile unit");
|
||||||
|
|
||||||
for (MDSubprogram *SP : CU->getSubprograms()) {
|
for (MDSubprogram *SP : CU->getSubprograms()) {
|
||||||
|
@ -705,7 +705,7 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
|
|||||||
// Patch the pointer to LLVM function in debug info descriptor.
|
// Patch the pointer to LLVM function in debug info descriptor.
|
||||||
auto DI = FunctionDIs.find(F);
|
auto DI = FunctionDIs.find(F);
|
||||||
if (DI != FunctionDIs.end()) {
|
if (DI != FunctionDIs.end()) {
|
||||||
DISubprogram SP = DI->second;
|
MDSubprogram *SP = DI->second;
|
||||||
SP->replaceFunction(NF);
|
SP->replaceFunction(NF);
|
||||||
// Ensure the map is updated so it can be reused on subsequent argument
|
// Ensure the map is updated so it can be reused on subsequent argument
|
||||||
// promotions of the same function.
|
// promotions of the same function.
|
||||||
|
@ -303,7 +303,7 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
|
|||||||
// Patch the pointer to LLVM function in debug info descriptor.
|
// Patch the pointer to LLVM function in debug info descriptor.
|
||||||
auto DI = FunctionDIs.find(&Fn);
|
auto DI = FunctionDIs.find(&Fn);
|
||||||
if (DI != FunctionDIs.end()) {
|
if (DI != FunctionDIs.end()) {
|
||||||
DISubprogram SP = DI->second;
|
MDSubprogram *SP = DI->second;
|
||||||
SP->replaceFunction(NF);
|
SP->replaceFunction(NF);
|
||||||
// Ensure the map is updated so it can be reused on non-varargs argument
|
// Ensure the map is updated so it can be reused on non-varargs argument
|
||||||
// eliminations of the same function.
|
// eliminations of the same function.
|
||||||
|
@ -307,11 +307,8 @@ bool StripDeadDebugInfo::runOnModule(Module &M) {
|
|||||||
|
|
||||||
for (MDCompileUnit *DIC : F.compile_units()) {
|
for (MDCompileUnit *DIC : F.compile_units()) {
|
||||||
// Create our live subprogram list.
|
// Create our live subprogram list.
|
||||||
MDSubprogramArray SPs = DIC->getSubprograms();
|
|
||||||
bool SubprogramChange = false;
|
bool SubprogramChange = false;
|
||||||
for (unsigned i = 0, e = SPs.size(); i != e; ++i) {
|
for (MDSubprogram *DISP : DIC->getSubprograms()) {
|
||||||
DISubprogram DISP = SPs[i];
|
|
||||||
|
|
||||||
// Make sure we visit each subprogram only once.
|
// Make sure we visit each subprogram only once.
|
||||||
if (!VisitedSet.insert(DISP).second)
|
if (!VisitedSet.insert(DISP).second)
|
||||||
continue;
|
continue;
|
||||||
|
@ -126,7 +126,7 @@ namespace {
|
|||||||
Function *insertFlush(ArrayRef<std::pair<GlobalVariable*, MDNode*> >);
|
Function *insertFlush(ArrayRef<std::pair<GlobalVariable*, MDNode*> >);
|
||||||
void insertIndirectCounterIncrement();
|
void insertIndirectCounterIncrement();
|
||||||
|
|
||||||
std::string mangleName(DICompileUnit CU, const char *NewStem);
|
std::string mangleName(const MDCompileUnit *CU, const char *NewStem);
|
||||||
|
|
||||||
GCOVOptions Options;
|
GCOVOptions Options;
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ ModulePass *llvm::createGCOVProfilerPass(const GCOVOptions &Options) {
|
|||||||
return new GCOVProfiler(Options);
|
return new GCOVProfiler(Options);
|
||||||
}
|
}
|
||||||
|
|
||||||
static StringRef getFunctionName(MDSubprogram *SP) {
|
static StringRef getFunctionName(const MDSubprogram *SP) {
|
||||||
if (!SP->getLinkageName().empty())
|
if (!SP->getLinkageName().empty())
|
||||||
return SP->getLinkageName();
|
return SP->getLinkageName();
|
||||||
return SP->getName();
|
return SP->getName();
|
||||||
@ -309,7 +309,7 @@ namespace {
|
|||||||
// object users can construct, the blocks and lines will be rooted here.
|
// object users can construct, the blocks and lines will be rooted here.
|
||||||
class GCOVFunction : public GCOVRecord {
|
class GCOVFunction : public GCOVRecord {
|
||||||
public:
|
public:
|
||||||
GCOVFunction(DISubprogram SP, raw_ostream *os, uint32_t Ident,
|
GCOVFunction(const MDSubprogram *SP, raw_ostream *os, uint32_t Ident,
|
||||||
bool UseCfgChecksum, bool ExitBlockBeforeBody)
|
bool UseCfgChecksum, bool ExitBlockBeforeBody)
|
||||||
: SP(SP), Ident(Ident), UseCfgChecksum(UseCfgChecksum), CfgChecksum(0),
|
: SP(SP), Ident(Ident), UseCfgChecksum(UseCfgChecksum), CfgChecksum(0),
|
||||||
ReturnBlock(1, os) {
|
ReturnBlock(1, os) {
|
||||||
@ -411,7 +411,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DISubprogram SP;
|
const MDSubprogram *SP;
|
||||||
uint32_t Ident;
|
uint32_t Ident;
|
||||||
uint32_t FuncChecksum;
|
uint32_t FuncChecksum;
|
||||||
bool UseCfgChecksum;
|
bool UseCfgChecksum;
|
||||||
@ -421,7 +421,8 @@ namespace {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GCOVProfiler::mangleName(DICompileUnit CU, const char *NewStem) {
|
std::string GCOVProfiler::mangleName(const MDCompileUnit *CU,
|
||||||
|
const char *NewStem) {
|
||||||
if (NamedMDNode *GCov = M->getNamedMetadata("llvm.gcov")) {
|
if (NamedMDNode *GCov = M->getNamedMetadata("llvm.gcov")) {
|
||||||
for (int i = 0, e = GCov->getNumOperands(); i != e; ++i) {
|
for (int i = 0, e = GCov->getNumOperands(); i != e; ++i) {
|
||||||
MDNode *N = GCov->getOperand(i);
|
MDNode *N = GCov->getOperand(i);
|
||||||
@ -487,7 +488,7 @@ void GCOVProfiler::emitProfileNotes() {
|
|||||||
// this pass over the original .o's as they're produced, or run it after
|
// this pass over the original .o's as they're produced, or run it after
|
||||||
// LTO, we'll generate the same .gcno files.
|
// LTO, we'll generate the same .gcno files.
|
||||||
|
|
||||||
DICompileUnit CU = cast<MDCompileUnit>(CU_Nodes->getOperand(i));
|
auto *CU = cast<MDCompileUnit>(CU_Nodes->getOperand(i));
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
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;
|
||||||
@ -570,7 +571,7 @@ bool GCOVProfiler::emitProfileArcs() {
|
|||||||
bool Result = false;
|
bool Result = false;
|
||||||
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));
|
auto *CU = cast<MDCompileUnit>(CU_Nodes->getOperand(i));
|
||||||
SmallVector<std::pair<GlobalVariable *, MDNode *>, 8> CountersBySP;
|
SmallVector<std::pair<GlobalVariable *, MDNode *>, 8> CountersBySP;
|
||||||
for (auto *SP : CU->getSubprograms()) {
|
for (auto *SP : CU->getSubprograms()) {
|
||||||
Function *F = SP->getFunction();
|
Function *F = SP->getFunction();
|
||||||
@ -846,7 +847,7 @@ Function *GCOVProfiler::insertCounterWriteout(
|
|||||||
NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu");
|
NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu");
|
||||||
if (CU_Nodes) {
|
if (CU_Nodes) {
|
||||||
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));
|
auto *CU = cast<MDCompileUnit>(CU_Nodes->getOperand(i));
|
||||||
std::string FilenameGcda = mangleName(CU, "gcda");
|
std::string FilenameGcda = mangleName(CU, "gcda");
|
||||||
uint32_t CfgChecksum = FileChecksums.empty() ? 0 : FileChecksums[i];
|
uint32_t CfgChecksum = FileChecksums.empty() ? 0 : FileChecksums[i];
|
||||||
Builder.CreateCall3(StartFile,
|
Builder.CreateCall3(StartFile,
|
||||||
|
@ -194,7 +194,7 @@ bool AddDiscriminators::runOnFunction(Function &F) {
|
|||||||
// number for it.
|
// number for it.
|
||||||
StringRef Filename = FirstDIL->getFilename();
|
StringRef Filename = FirstDIL->getFilename();
|
||||||
auto *Scope = FirstDIL->getScope();
|
auto *Scope = FirstDIL->getScope();
|
||||||
DIFile File = Builder.createFile(Filename, Scope->getDirectory());
|
auto *File = Builder.createFile(Filename, Scope->getDirectory());
|
||||||
|
|
||||||
// FIXME: Calculate the discriminator here, based on local information,
|
// FIXME: Calculate the discriminator here, based on local information,
|
||||||
// and delete MDLocation::computeNewDiscriminator(). The current
|
// and delete MDLocation::computeNewDiscriminator(). The current
|
||||||
@ -202,7 +202,7 @@ bool AddDiscriminators::runOnFunction(Function &F) {
|
|||||||
// same context. All we really need is to discriminate between
|
// same context. All we really need is to discriminate between
|
||||||
// FirstDIL and LastDIL -- a local map would suffice.
|
// FirstDIL and LastDIL -- a local map would suffice.
|
||||||
unsigned Discriminator = FirstDIL->computeNewDiscriminator();
|
unsigned Discriminator = FirstDIL->computeNewDiscriminator();
|
||||||
DILexicalBlockFile NewScope =
|
auto *NewScope =
|
||||||
Builder.createLexicalBlockFile(Scope, File, Discriminator);
|
Builder.createLexicalBlockFile(Scope, File, Discriminator);
|
||||||
auto *NewDIL =
|
auto *NewDIL =
|
||||||
MDLocation::get(Ctx, FirstDIL->getLine(), FirstDIL->getColumn(),
|
MDLocation::get(Ctx, FirstDIL->getLine(), FirstDIL->getColumn(),
|
||||||
|
@ -154,9 +154,10 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
|
|||||||
TypeMapper, Materializer);
|
TypeMapper, Materializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the MDNode which corresponds to the DISubprogram data that described F.
|
// Find the MDNode which corresponds to the subprogram data that described F.
|
||||||
static MDNode* FindSubprogram(const Function *F, DebugInfoFinder &Finder) {
|
static MDSubprogram *FindSubprogram(const Function *F,
|
||||||
for (DISubprogram Subprogram : Finder.subprograms()) {
|
DebugInfoFinder &Finder) {
|
||||||
|
for (MDSubprogram *Subprogram : Finder.subprograms()) {
|
||||||
if (Subprogram->describes(F))
|
if (Subprogram->describes(F))
|
||||||
return Subprogram;
|
return Subprogram;
|
||||||
}
|
}
|
||||||
@ -165,7 +166,8 @@ 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, MDSubprogramArray SPs, Metadata *NewSP) {
|
static void AddOperand(MDCompileUnit *CU, MDSubprogramArray SPs,
|
||||||
|
Metadata *NewSP) {
|
||||||
SmallVector<Metadata *, 16> NewSPs;
|
SmallVector<Metadata *, 16> NewSPs;
|
||||||
NewSPs.reserve(SPs.size() + 1);
|
NewSPs.reserve(SPs.size() + 1);
|
||||||
for (auto *SP : SPs)
|
for (auto *SP : SPs)
|
||||||
@ -181,16 +183,16 @@ static void CloneDebugInfoMetadata(Function *NewFunc, const Function *OldFunc,
|
|||||||
DebugInfoFinder Finder;
|
DebugInfoFinder Finder;
|
||||||
Finder.processModule(*OldFunc->getParent());
|
Finder.processModule(*OldFunc->getParent());
|
||||||
|
|
||||||
const MDNode *OldSubprogramMDNode = FindSubprogram(OldFunc, Finder);
|
const MDSubprogram *OldSubprogramMDNode = FindSubprogram(OldFunc, Finder);
|
||||||
if (!OldSubprogramMDNode) return;
|
if (!OldSubprogramMDNode) return;
|
||||||
|
|
||||||
// Ensure that OldFunc appears in the map.
|
// Ensure that OldFunc appears in the map.
|
||||||
// (if it's already there it must point to NewFunc anyway)
|
// (if it's already there it must point to NewFunc anyway)
|
||||||
VMap[OldFunc] = NewFunc;
|
VMap[OldFunc] = NewFunc;
|
||||||
DISubprogram NewSubprogram =
|
auto *NewSubprogram =
|
||||||
cast<MDSubprogram>(MapMetadata(OldSubprogramMDNode, VMap));
|
cast<MDSubprogram>(MapMetadata(OldSubprogramMDNode, VMap));
|
||||||
|
|
||||||
for (DICompileUnit CU : Finder.compile_units()) {
|
for (auto *CU : Finder.compile_units()) {
|
||||||
auto 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.
|
||||||
|
@ -228,15 +228,16 @@ protected:
|
|||||||
IRBuilder<> IBuilder(C);
|
IRBuilder<> IBuilder(C);
|
||||||
|
|
||||||
// Function DI
|
// Function DI
|
||||||
DIFile File = DBuilder.createFile("filename.c", "/file/dir/");
|
auto *File = DBuilder.createFile("filename.c", "/file/dir/");
|
||||||
DITypeArray ParamTypes = DBuilder.getOrCreateTypeArray(None);
|
DITypeArray ParamTypes = DBuilder.getOrCreateTypeArray(None);
|
||||||
MDSubroutineType *FuncType =
|
MDSubroutineType *FuncType =
|
||||||
DBuilder.createSubroutineType(File, ParamTypes);
|
DBuilder.createSubroutineType(File, ParamTypes);
|
||||||
DICompileUnit CU = DBuilder.createCompileUnit(dwarf::DW_LANG_C99,
|
auto *CU =
|
||||||
"filename.c", "/file/dir", "CloneFunc", false, "", 0);
|
DBuilder.createCompileUnit(dwarf::DW_LANG_C99, "filename.c",
|
||||||
|
"/file/dir", "CloneFunc", false, "", 0);
|
||||||
|
|
||||||
DISubprogram Subprogram = DBuilder.createFunction(CU, "f", "f", File, 4,
|
auto *Subprogram = DBuilder.createFunction(
|
||||||
FuncType, true, true, 3, 0, false, OldFunc);
|
CU, "f", "f", File, 4, FuncType, true, true, 3, 0, false, OldFunc);
|
||||||
|
|
||||||
// Function body
|
// Function body
|
||||||
BasicBlock* Entry = BasicBlock::Create(C, "", OldFunc);
|
BasicBlock* Entry = BasicBlock::Create(C, "", OldFunc);
|
||||||
@ -303,9 +304,9 @@ TEST_F(CloneFunc, Subprogram) {
|
|||||||
EXPECT_EQ(2U, SubprogramCount);
|
EXPECT_EQ(2U, SubprogramCount);
|
||||||
|
|
||||||
auto Iter = Finder->subprograms().begin();
|
auto Iter = Finder->subprograms().begin();
|
||||||
DISubprogram Sub1 = cast<MDSubprogram>(*Iter);
|
auto *Sub1 = cast<MDSubprogram>(*Iter);
|
||||||
Iter++;
|
Iter++;
|
||||||
DISubprogram Sub2 = cast<MDSubprogram>(*Iter);
|
auto *Sub2 = cast<MDSubprogram>(*Iter);
|
||||||
|
|
||||||
EXPECT_TRUE(
|
EXPECT_TRUE(
|
||||||
(Sub1->getFunction() == OldFunc && Sub2->getFunction() == NewFunc) ||
|
(Sub1->getFunction() == OldFunc && Sub2->getFunction() == NewFunc) ||
|
||||||
@ -320,9 +321,9 @@ TEST_F(CloneFunc, SubprogramInRightCU) {
|
|||||||
EXPECT_EQ(2U, Finder->compile_unit_count());
|
EXPECT_EQ(2U, Finder->compile_unit_count());
|
||||||
|
|
||||||
auto Iter = Finder->compile_units().begin();
|
auto Iter = Finder->compile_units().begin();
|
||||||
DICompileUnit CU1 = cast<MDCompileUnit>(*Iter);
|
auto *CU1 = cast<MDCompileUnit>(*Iter);
|
||||||
Iter++;
|
Iter++;
|
||||||
DICompileUnit CU2 = cast<MDCompileUnit>(*Iter);
|
auto *CU2 = cast<MDCompileUnit>(*Iter);
|
||||||
EXPECT_TRUE(CU1->getSubprograms().size() == 0 ||
|
EXPECT_TRUE(CU1->getSubprograms().size() == 0 ||
|
||||||
CU2->getSubprograms().size() == 0);
|
CU2->getSubprograms().size() == 0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user