2014-03-06 00:46:21 +00:00
|
|
|
//===- DebugInfo.h - Debug Information Helpers ------------------*- C++ -*-===//
|
2008-11-10 02:56:27 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines a bunch of datatypes that are useful for creating and
|
2009-05-14 18:26:15 +00:00
|
|
|
// walking debug info in LLVM IR form. They essentially provide wrappers around
|
|
|
|
// the information in the global variables that's needed when constructing the
|
|
|
|
// DWARF information.
|
2008-11-10 02:56:27 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-03-06 00:46:21 +00:00
|
|
|
#ifndef LLVM_IR_DEBUGINFO_H
|
|
|
|
#define LLVM_IR_DEBUGINFO_H
|
2008-11-10 02:56:27 +00:00
|
|
|
|
2013-09-05 18:48:31 +00:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2009-07-28 19:55:13 +00:00
|
|
|
#include "llvm/ADT/SmallPtrSet.h"
|
2012-12-03 17:02:12 +00:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2009-12-31 03:02:08 +00:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2015-01-14 11:23:27 +00:00
|
|
|
#include "llvm/ADT/iterator_range.h"
|
2015-02-02 18:53:21 +00:00
|
|
|
#include "llvm/IR/DebugInfoMetadata.h"
|
2014-01-07 11:48:04 +00:00
|
|
|
#include "llvm/Support/Casting.h"
|
2009-12-31 03:02:42 +00:00
|
|
|
#include "llvm/Support/Dwarf.h"
|
2014-10-03 20:01:09 +00:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
|
|
#include <iterator>
|
2008-11-10 02:56:27 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
2013-10-04 23:15:52 +00:00
|
|
|
class BasicBlock;
|
|
|
|
class Constant;
|
|
|
|
class Function;
|
|
|
|
class GlobalVariable;
|
|
|
|
class Module;
|
|
|
|
class Type;
|
|
|
|
class Value;
|
|
|
|
class DbgDeclareInst;
|
|
|
|
class DbgValueInst;
|
|
|
|
class Instruction;
|
2014-11-14 23:55:03 +00:00
|
|
|
class Metadata;
|
2013-10-04 23:15:52 +00:00
|
|
|
class MDNode;
|
|
|
|
class MDString;
|
|
|
|
class NamedMDNode;
|
|
|
|
class LLVMContext;
|
|
|
|
class raw_ostream;
|
|
|
|
|
|
|
|
class DIFile;
|
|
|
|
class DISubprogram;
|
|
|
|
class DILexicalBlock;
|
|
|
|
class DILexicalBlockFile;
|
|
|
|
class DIVariable;
|
|
|
|
class DIObjCProperty;
|
|
|
|
|
2014-10-15 17:01:28 +00:00
|
|
|
/// \brief Maps from type identifier to the actual MDNode.
|
2013-10-04 23:15:52 +00:00
|
|
|
typedef DenseMap<const MDString *, MDNode *> DITypeIdentifierMap;
|
|
|
|
|
2015-04-06 22:32:20 +00:00
|
|
|
#define DECLARE_SIMPLIFY_DESCRIPTOR(DESC) \
|
|
|
|
class DESC; \
|
|
|
|
template <> struct simplify_type<const DESC>; \
|
|
|
|
template <> struct simplify_type<DESC>;
|
|
|
|
DECLARE_SIMPLIFY_DESCRIPTOR(DISubrange)
|
|
|
|
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(DITemplateValueParameter)
|
|
|
|
DECLARE_SIMPLIFY_DESCRIPTOR(DIGlobalVariable)
|
|
|
|
DECLARE_SIMPLIFY_DESCRIPTOR(DIVariable)
|
|
|
|
DECLARE_SIMPLIFY_DESCRIPTOR(DIExpression)
|
|
|
|
DECLARE_SIMPLIFY_DESCRIPTOR(DILocation)
|
|
|
|
DECLARE_SIMPLIFY_DESCRIPTOR(DIObjCProperty)
|
|
|
|
DECLARE_SIMPLIFY_DESCRIPTOR(DIImportedEntity)
|
|
|
|
#undef DECLARE_SIMPLIFY_DESCRIPTOR
|
|
|
|
|
2015-04-07 04:14:33 +00:00
|
|
|
typedef DebugNodeArray DIArray;
|
|
|
|
typedef MDTypeRefArray DITypeArray;
|
|
|
|
|
2015-04-16 01:37:00 +00:00
|
|
|
class DISubrange {
|
|
|
|
MDSubrange *N;
|
2013-10-04 23:15:52 +00:00
|
|
|
|
2015-04-16 01:37:00 +00:00
|
|
|
public:
|
|
|
|
DISubrange(const MDSubrange *N = nullptr) : N(const_cast<MDSubrange *>(N)) {}
|
2015-03-23 21:54:07 +00:00
|
|
|
|
2015-04-16 01:37:00 +00:00
|
|
|
operator MDSubrange *() const { return N; }
|
|
|
|
MDSubrange *operator->() const { return N; }
|
|
|
|
MDSubrange &operator*() const { return *N; }
|
2013-10-04 23:15:52 +00:00
|
|
|
};
|
|
|
|
|
2015-04-16 01:37:00 +00:00
|
|
|
class DIEnumerator {
|
|
|
|
MDEnumerator *N;
|
2013-10-04 23:15:52 +00:00
|
|
|
|
2015-04-16 01:37:00 +00:00
|
|
|
public:
|
|
|
|
DIEnumerator(const MDEnumerator *N = nullptr)
|
|
|
|
: N(const_cast<MDEnumerator *>(N)) {}
|
2015-03-23 21:54:07 +00:00
|
|
|
|
2015-04-16 01:37:00 +00:00
|
|
|
operator MDEnumerator *() const { return N; }
|
|
|
|
MDEnumerator *operator->() const { return N; }
|
|
|
|
MDEnumerator &operator*() const { return *N; }
|
2013-10-04 23:15:52 +00:00
|
|
|
};
|
|
|
|
|
2015-04-15 23:19:27 +00:00
|
|
|
class DIFile {
|
|
|
|
MDFile *N;
|
2014-10-15 16:15:15 +00:00
|
|
|
|
2015-04-15 23:19:27 +00:00
|
|
|
public:
|
|
|
|
DIFile(const MDFile *N = nullptr) : N(const_cast<MDFile *>(N)) {}
|
2015-03-23 21:54:07 +00:00
|
|
|
|
2015-04-15 23:19:27 +00:00
|
|
|
operator MDFile *() const { return N; }
|
|
|
|
MDFile *operator->() const { return N; }
|
|
|
|
MDFile &operator*() const { return *N; }
|
2013-10-04 23:15:52 +00:00
|
|
|
};
|
|
|
|
|
2015-04-15 23:19:27 +00:00
|
|
|
class DICompileUnit {
|
|
|
|
MDCompileUnit *N;
|
2015-03-23 21:54:07 +00:00
|
|
|
|
2015-04-15 23:19:27 +00:00
|
|
|
public:
|
|
|
|
DICompileUnit(const MDCompileUnit *N = nullptr)
|
|
|
|
: N(const_cast<MDCompileUnit *>(N)) {}
|
2014-10-03 20:01:09 +00:00
|
|
|
|
2015-04-15 23:19:27 +00:00
|
|
|
operator MDCompileUnit *() const { return N; }
|
|
|
|
MDCompileUnit *operator->() const { return N; }
|
|
|
|
MDCompileUnit &operator*() const { return *N; }
|
2013-10-04 23:15:52 +00:00
|
|
|
};
|
|
|
|
|
2015-04-14 03:40:37 +00:00
|
|
|
class DISubprogram {
|
|
|
|
MDSubprogram *N;
|
2015-03-03 17:24:31 +00:00
|
|
|
|
2015-04-14 03:40:37 +00:00
|
|
|
public:
|
|
|
|
DISubprogram(const MDSubprogram *N = nullptr)
|
|
|
|
: N(const_cast<MDSubprogram *>(N)) {}
|
2014-10-03 20:01:09 +00:00
|
|
|
|
2015-04-14 03:40:37 +00:00
|
|
|
operator MDSubprogram *() const { return N; }
|
|
|
|
MDSubprogram *operator->() const { return N; }
|
|
|
|
MDSubprogram &operator*() const { return *N; }
|
2013-10-04 23:15:52 +00:00
|
|
|
};
|
|
|
|
|
2015-04-14 03:40:37 +00:00
|
|
|
class DILexicalBlock {
|
|
|
|
MDLexicalBlockBase *N;
|
2015-03-03 17:24:31 +00:00
|
|
|
|
2015-04-14 03:40:37 +00:00
|
|
|
public:
|
|
|
|
DILexicalBlock(const MDLexicalBlockBase *N = nullptr)
|
|
|
|
: N(const_cast<MDLexicalBlockBase *>(N)) {}
|
2015-03-23 21:54:07 +00:00
|
|
|
|
2015-04-14 03:40:37 +00:00
|
|
|
operator MDLexicalBlockBase *() const { return N; }
|
|
|
|
MDLexicalBlockBase *operator->() const { return N; }
|
|
|
|
MDLexicalBlockBase &operator*() const { return *N; }
|
2013-10-04 23:15:52 +00:00
|
|
|
};
|
|
|
|
|
2015-04-14 03:40:37 +00:00
|
|
|
class DILexicalBlockFile {
|
|
|
|
MDLexicalBlockFile *N;
|
2015-03-03 17:24:31 +00:00
|
|
|
|
2015-04-14 03:40:37 +00:00
|
|
|
public:
|
|
|
|
DILexicalBlockFile(const MDLexicalBlockFile *N = nullptr)
|
|
|
|
: N(const_cast<MDLexicalBlockFile *>(N)) {}
|
2015-03-23 21:54:07 +00:00
|
|
|
|
2015-04-14 03:40:37 +00:00
|
|
|
operator MDLexicalBlockFile *() const { return N; }
|
|
|
|
MDLexicalBlockFile *operator->() const { return N; }
|
|
|
|
MDLexicalBlockFile &operator*() const { return *N; }
|
2013-10-04 23:15:52 +00:00
|
|
|
};
|
|
|
|
|
2015-04-14 03:01:27 +00:00
|
|
|
class DINameSpace {
|
|
|
|
MDNamespace *N;
|
2015-03-03 17:24:31 +00:00
|
|
|
|
2015-04-14 03:01:27 +00:00
|
|
|
public:
|
|
|
|
DINameSpace(const MDNamespace *N = nullptr)
|
|
|
|
: N(const_cast<MDNamespace *>(N)) {}
|
2015-03-23 21:54:07 +00:00
|
|
|
|
2015-04-14 03:01:27 +00:00
|
|
|
operator MDNamespace *() const { return N; }
|
|
|
|
MDNamespace *operator->() const { return N; }
|
|
|
|
MDNamespace &operator*() const { return *N; }
|
2013-10-04 23:15:52 +00:00
|
|
|
};
|
|
|
|
|
2015-04-14 03:01:27 +00:00
|
|
|
class DITemplateTypeParameter {
|
|
|
|
MDTemplateTypeParameter *N;
|
2013-10-04 23:15:52 +00:00
|
|
|
|
2015-04-14 03:01:27 +00:00
|
|
|
public:
|
|
|
|
DITemplateTypeParameter(const MDTemplateTypeParameter *N = nullptr)
|
|
|
|
: N(const_cast<MDTemplateTypeParameter *>(N)) {}
|
2015-03-23 21:54:07 +00:00
|
|
|
|
2015-04-14 03:01:27 +00:00
|
|
|
operator MDTemplateTypeParameter *() const { return N; }
|
|
|
|
MDTemplateTypeParameter *operator->() const { return N; }
|
|
|
|
MDTemplateTypeParameter &operator*() const { return *N; }
|
2013-10-04 23:15:52 +00:00
|
|
|
};
|
|
|
|
|
2015-04-14 03:01:27 +00:00
|
|
|
class DITemplateValueParameter {
|
|
|
|
MDTemplateValueParameter *N;
|
2013-10-04 23:15:52 +00:00
|
|
|
|
2015-04-14 03:01:27 +00:00
|
|
|
public:
|
|
|
|
DITemplateValueParameter(const MDTemplateValueParameter *N = nullptr)
|
|
|
|
: N(const_cast<MDTemplateValueParameter *>(N)) {}
|
2015-03-23 21:54:07 +00:00
|
|
|
|
2015-04-14 03:01:27 +00:00
|
|
|
operator MDTemplateValueParameter *() const { return N; }
|
|
|
|
MDTemplateValueParameter *operator->() const { return N; }
|
|
|
|
MDTemplateValueParameter &operator*() const { return *N; }
|
2013-10-04 23:15:52 +00:00
|
|
|
};
|
|
|
|
|
2015-04-14 02:22:36 +00:00
|
|
|
class DIGlobalVariable {
|
|
|
|
MDGlobalVariable *N;
|
2013-10-04 23:15:52 +00:00
|
|
|
|
|
|
|
public:
|
2015-04-14 02:22:36 +00:00
|
|
|
DIGlobalVariable(const MDGlobalVariable *N = nullptr)
|
|
|
|
: N(const_cast<MDGlobalVariable *>(N)) {}
|
2013-10-04 23:15:52 +00:00
|
|
|
|
2015-04-14 02:22:36 +00:00
|
|
|
operator MDGlobalVariable *() const { return N; }
|
|
|
|
MDGlobalVariable *operator->() const { return N; }
|
|
|
|
MDGlobalVariable &operator*() const { return *N; }
|
2013-10-04 23:15:52 +00:00
|
|
|
};
|
|
|
|
|
2015-04-14 02:22:36 +00:00
|
|
|
class DIVariable {
|
|
|
|
MDLocalVariable *N;
|
2013-10-04 23:15:52 +00:00
|
|
|
|
|
|
|
public:
|
2015-04-14 02:22:36 +00:00
|
|
|
DIVariable(const MDLocalVariable *N = nullptr)
|
|
|
|
: N(const_cast<MDLocalVariable *>(N)) {}
|
2014-10-03 20:01:09 +00:00
|
|
|
|
2015-04-14 02:22:36 +00:00
|
|
|
operator MDLocalVariable *() const { return N; }
|
|
|
|
MDLocalVariable *operator->() const { return N; }
|
|
|
|
MDLocalVariable &operator*() const { return *N; }
|
Move the complex address expression out of DIVariable and into an extra
argument of the llvm.dbg.declare/llvm.dbg.value intrinsics.
Previously, DIVariable was a variable-length field that has an optional
reference to a Metadata array consisting of a variable number of
complex address expressions. In the case of OpPiece expressions this is
wasting a lot of storage in IR, because when an aggregate type is, e.g.,
SROA'd into all of its n individual members, the IR will contain n copies
of the DIVariable, all alike, only differing in the complex address
reference at the end.
By making the complex address into an extra argument of the
dbg.value/dbg.declare intrinsics, all of the pieces can reference the
same variable and the complex address expressions can be uniqued across
the CU, too.
Down the road, this will allow us to move other flags, such as
"indirection" out of the DIVariable, too.
The new intrinsics look like this:
declare void @llvm.dbg.declare(metadata %storage, metadata %var, metadata %expr)
declare void @llvm.dbg.value(metadata %storage, i64 %offset, metadata %var, metadata %expr)
This patch adds a new LLVM-local tag to DIExpressions, so we can detect
and pretty-print DIExpression metadata nodes.
What this patch doesn't do:
This patch does not touch the "Indirect" field in DIVariable; but moving
that into the expression would be a natural next step.
http://reviews.llvm.org/D4919
rdar://problem/17994491
Thanks to dblaikie and dexonsmith for reviewing this patch!
Note: I accidentally committed a bogus older version of this patch previously.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218787 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 18:55:02 +00:00
|
|
|
};
|
|
|
|
|
2015-04-14 01:12:42 +00:00
|
|
|
class DIExpression {
|
|
|
|
MDExpression *N;
|
|
|
|
|
Move the complex address expression out of DIVariable and into an extra
argument of the llvm.dbg.declare/llvm.dbg.value intrinsics.
Previously, DIVariable was a variable-length field that has an optional
reference to a Metadata array consisting of a variable number of
complex address expressions. In the case of OpPiece expressions this is
wasting a lot of storage in IR, because when an aggregate type is, e.g.,
SROA'd into all of its n individual members, the IR will contain n copies
of the DIVariable, all alike, only differing in the complex address
reference at the end.
By making the complex address into an extra argument of the
dbg.value/dbg.declare intrinsics, all of the pieces can reference the
same variable and the complex address expressions can be uniqued across
the CU, too.
Down the road, this will allow us to move other flags, such as
"indirection" out of the DIVariable, too.
The new intrinsics look like this:
declare void @llvm.dbg.declare(metadata %storage, metadata %var, metadata %expr)
declare void @llvm.dbg.value(metadata %storage, i64 %offset, metadata %var, metadata %expr)
This patch adds a new LLVM-local tag to DIExpressions, so we can detect
and pretty-print DIExpression metadata nodes.
What this patch doesn't do:
This patch does not touch the "Indirect" field in DIVariable; but moving
that into the expression would be a natural next step.
http://reviews.llvm.org/D4919
rdar://problem/17994491
Thanks to dblaikie and dexonsmith for reviewing this patch!
Note: I accidentally committed a bogus older version of this patch previously.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218787 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 18:55:02 +00:00
|
|
|
public:
|
2015-04-14 01:12:42 +00:00
|
|
|
DIExpression(const MDExpression *N = nullptr)
|
|
|
|
: N(const_cast<MDExpression *>(N)) {}
|
Move the complex address expression out of DIVariable and into an extra
argument of the llvm.dbg.declare/llvm.dbg.value intrinsics.
Previously, DIVariable was a variable-length field that has an optional
reference to a Metadata array consisting of a variable number of
complex address expressions. In the case of OpPiece expressions this is
wasting a lot of storage in IR, because when an aggregate type is, e.g.,
SROA'd into all of its n individual members, the IR will contain n copies
of the DIVariable, all alike, only differing in the complex address
reference at the end.
By making the complex address into an extra argument of the
dbg.value/dbg.declare intrinsics, all of the pieces can reference the
same variable and the complex address expressions can be uniqued across
the CU, too.
Down the road, this will allow us to move other flags, such as
"indirection" out of the DIVariable, too.
The new intrinsics look like this:
declare void @llvm.dbg.declare(metadata %storage, metadata %var, metadata %expr)
declare void @llvm.dbg.value(metadata %storage, i64 %offset, metadata %var, metadata %expr)
This patch adds a new LLVM-local tag to DIExpressions, so we can detect
and pretty-print DIExpression metadata nodes.
What this patch doesn't do:
This patch does not touch the "Indirect" field in DIVariable; but moving
that into the expression would be a natural next step.
http://reviews.llvm.org/D4919
rdar://problem/17994491
Thanks to dblaikie and dexonsmith for reviewing this patch!
Note: I accidentally committed a bogus older version of this patch previously.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218787 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 18:55:02 +00:00
|
|
|
|
2015-04-14 01:12:42 +00:00
|
|
|
operator MDExpression *() const { return N; }
|
|
|
|
MDExpression *operator->() const { return N; }
|
|
|
|
MDExpression &operator*() const { return *N; }
|
2015-01-22 16:55:20 +00:00
|
|
|
};
|
2015-01-22 00:00:52 +00:00
|
|
|
|
2015-04-14 01:35:55 +00:00
|
|
|
class DILocation {
|
|
|
|
MDLocation *N;
|
2013-10-04 23:15:52 +00:00
|
|
|
|
2015-04-14 01:35:55 +00:00
|
|
|
public:
|
|
|
|
DILocation(const MDLocation *N = nullptr) : N(const_cast<MDLocation *>(N)) {}
|
2015-03-23 21:54:07 +00:00
|
|
|
|
2015-04-14 01:35:55 +00:00
|
|
|
operator MDLocation *() const { return N; }
|
|
|
|
MDLocation *operator->() const { return N; }
|
|
|
|
MDLocation &operator*() const { return *N; }
|
2013-10-04 23:15:52 +00:00
|
|
|
};
|
|
|
|
|
2015-04-14 01:46:44 +00:00
|
|
|
class DIObjCProperty {
|
|
|
|
MDObjCProperty *N;
|
2015-03-23 21:54:07 +00:00
|
|
|
|
2015-04-14 01:46:44 +00:00
|
|
|
public:
|
|
|
|
DIObjCProperty(const MDObjCProperty *N = nullptr)
|
|
|
|
: N(const_cast<MDObjCProperty *>(N)) {}
|
2013-10-04 23:15:52 +00:00
|
|
|
|
2015-04-14 01:46:44 +00:00
|
|
|
operator MDObjCProperty *() const { return N; }
|
|
|
|
MDObjCProperty *operator->() const { return N; }
|
|
|
|
MDObjCProperty &operator*() const { return *N; }
|
2013-10-04 23:15:52 +00:00
|
|
|
};
|
|
|
|
|
2015-04-14 01:46:44 +00:00
|
|
|
class DIImportedEntity {
|
|
|
|
MDImportedEntity *N;
|
2015-03-03 17:24:31 +00:00
|
|
|
|
2015-04-14 01:46:44 +00:00
|
|
|
public:
|
|
|
|
DIImportedEntity(const MDImportedEntity *N = nullptr)
|
|
|
|
: N(const_cast<MDImportedEntity *>(N)) {}
|
2015-03-23 21:54:07 +00:00
|
|
|
|
2015-04-14 01:46:44 +00:00
|
|
|
operator MDImportedEntity *() const { return N; }
|
|
|
|
MDImportedEntity *operator->() const { return N; }
|
|
|
|
MDImportedEntity &operator*() const { return *N; }
|
2013-10-04 23:15:52 +00:00
|
|
|
};
|
|
|
|
|
2015-04-06 22:32:20 +00:00
|
|
|
#define SIMPLIFY_DESCRIPTOR(DESC) \
|
|
|
|
template <> struct simplify_type<const DESC> { \
|
|
|
|
typedef Metadata *SimpleType; \
|
|
|
|
static SimpleType getSimplifiedValue(const DESC &DI) { return DI; } \
|
|
|
|
}; \
|
|
|
|
template <> struct simplify_type<DESC> : simplify_type<const DESC> {};
|
|
|
|
SIMPLIFY_DESCRIPTOR(DISubrange)
|
|
|
|
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(DITemplateValueParameter)
|
|
|
|
SIMPLIFY_DESCRIPTOR(DIGlobalVariable)
|
|
|
|
SIMPLIFY_DESCRIPTOR(DIVariable)
|
|
|
|
SIMPLIFY_DESCRIPTOR(DIExpression)
|
|
|
|
SIMPLIFY_DESCRIPTOR(DILocation)
|
|
|
|
SIMPLIFY_DESCRIPTOR(DIObjCProperty)
|
|
|
|
SIMPLIFY_DESCRIPTOR(DIImportedEntity)
|
|
|
|
#undef SIMPLIFY_DESCRIPTOR
|
|
|
|
|
2014-10-15 17:01:28 +00:00
|
|
|
/// \brief Find subprogram that is enclosing this scope.
|
2015-04-17 23:20:10 +00:00
|
|
|
MDSubprogram *getDISubprogram(const MDNode *Scope);
|
2013-10-04 23:15:52 +00:00
|
|
|
|
2014-10-23 23:46:28 +00:00
|
|
|
/// \brief Find debug info for a given function.
|
|
|
|
/// \returns a valid DISubprogram, if found. Otherwise, it returns an empty
|
|
|
|
/// DISubprogram.
|
2015-04-17 23:20:10 +00:00
|
|
|
MDSubprogram *getDISubprogram(const Function *F);
|
2014-10-23 23:46:28 +00:00
|
|
|
|
2014-10-15 17:01:28 +00:00
|
|
|
/// \brief Find underlying composite type.
|
2015-04-17 23:20:10 +00:00
|
|
|
MDCompositeTypeBase *getDICompositeType(MDType *T);
|
2013-10-04 23:15:52 +00:00
|
|
|
|
2014-10-15 17:01:28 +00:00
|
|
|
/// \brief Generate map by visiting all retained types.
|
2013-10-04 23:15:52 +00:00
|
|
|
DITypeIdentifierMap generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes);
|
|
|
|
|
2014-10-15 17:01:28 +00:00
|
|
|
/// \brief Strip debug info in the module if it exists.
|
2014-10-15 16:15:15 +00:00
|
|
|
///
|
2013-11-22 22:06:31 +00:00
|
|
|
/// To do this, we remove all calls to the debugger intrinsics and any named
|
|
|
|
/// metadata for debugging. We also remove debug locations for instructions.
|
|
|
|
/// Return true if module is modified.
|
|
|
|
bool StripDebugInfo(Module &M);
|
2015-03-30 21:36:43 +00:00
|
|
|
bool stripDebugInfo(Function &F);
|
2013-11-22 22:06:31 +00:00
|
|
|
|
2014-10-15 17:01:28 +00:00
|
|
|
/// \brief Return Debug Info Metadata Version by checking module flags.
|
2013-12-03 00:12:14 +00:00
|
|
|
unsigned getDebugMetadataVersionFromModule(const Module &M);
|
2013-12-02 21:29:56 +00:00
|
|
|
|
2014-10-15 17:01:28 +00:00
|
|
|
/// \brief Utility to find all debug info in a module.
|
|
|
|
///
|
2013-10-04 23:15:52 +00:00
|
|
|
/// DebugInfoFinder tries to list all debug info MDNodes used in a module. To
|
|
|
|
/// list debug info MDNodes used by an instruction, DebugInfoFinder uses
|
|
|
|
/// processDeclare, processValue and processLocation to handle DbgDeclareInst,
|
|
|
|
/// DbgValueInst and DbgLoc attached to instructions. processModule will go
|
|
|
|
/// through all DICompileUnits in llvm.dbg.cu and list debug info MDNodes
|
|
|
|
/// used by the CUs.
|
|
|
|
class DebugInfoFinder {
|
|
|
|
public:
|
2013-11-18 11:06:01 +00:00
|
|
|
DebugInfoFinder() : TypeMapInitialized(false) {}
|
|
|
|
|
2014-10-15 17:01:28 +00:00
|
|
|
/// \brief Process entire module and collect debug info anchors.
|
2013-10-04 23:15:52 +00:00
|
|
|
void processModule(const Module &M);
|
|
|
|
|
2014-10-15 17:01:28 +00:00
|
|
|
/// \brief Process DbgDeclareInst.
|
2013-11-17 18:42:37 +00:00
|
|
|
void processDeclare(const Module &M, const DbgDeclareInst *DDI);
|
2014-10-15 17:01:28 +00:00
|
|
|
/// \brief Process DbgValueInst.
|
2013-11-17 18:42:37 +00:00
|
|
|
void processValue(const Module &M, const DbgValueInst *DVI);
|
2014-10-15 17:01:28 +00:00
|
|
|
/// \brief Process DILocation.
|
2015-04-17 23:20:10 +00:00
|
|
|
void processLocation(const Module &M, const MDLocation *Loc);
|
2013-10-04 23:15:52 +00:00
|
|
|
|
2014-10-15 17:01:28 +00:00
|
|
|
/// \brief Clear all lists.
|
2013-10-04 23:15:52 +00:00
|
|
|
void reset();
|
|
|
|
|
|
|
|
private:
|
2013-11-17 19:35:03 +00:00
|
|
|
void InitializeTypeMap(const Module &M);
|
2013-11-17 18:42:37 +00:00
|
|
|
|
2015-04-17 23:20:10 +00:00
|
|
|
void processType(MDType *DT);
|
|
|
|
void processSubprogram(MDSubprogram *SP);
|
|
|
|
void processScope(MDScope *Scope);
|
|
|
|
bool addCompileUnit(MDCompileUnit *CU);
|
|
|
|
bool addGlobalVariable(MDGlobalVariable *DIG);
|
|
|
|
bool addSubprogram(MDSubprogram *SP);
|
|
|
|
bool addType(MDType *DT);
|
|
|
|
bool addScope(MDScope *Scope);
|
2013-10-04 23:15:52 +00:00
|
|
|
|
|
|
|
public:
|
2015-04-17 23:20:10 +00:00
|
|
|
typedef SmallVectorImpl<MDCompileUnit *>::const_iterator
|
|
|
|
compile_unit_iterator;
|
|
|
|
typedef SmallVectorImpl<MDSubprogram *>::const_iterator subprogram_iterator;
|
|
|
|
typedef SmallVectorImpl<MDGlobalVariable *>::const_iterator
|
2015-01-22 16:55:27 +00:00
|
|
|
global_variable_iterator;
|
2015-04-17 23:20:10 +00:00
|
|
|
typedef SmallVectorImpl<MDType *>::const_iterator type_iterator;
|
|
|
|
typedef SmallVectorImpl<MDScope *>::const_iterator scope_iterator;
|
2014-03-18 09:41:07 +00:00
|
|
|
|
|
|
|
iterator_range<compile_unit_iterator> compile_units() const {
|
|
|
|
return iterator_range<compile_unit_iterator>(CUs.begin(), CUs.end());
|
|
|
|
}
|
|
|
|
|
|
|
|
iterator_range<subprogram_iterator> subprograms() const {
|
|
|
|
return iterator_range<subprogram_iterator>(SPs.begin(), SPs.end());
|
|
|
|
}
|
|
|
|
|
|
|
|
iterator_range<global_variable_iterator> global_variables() const {
|
|
|
|
return iterator_range<global_variable_iterator>(GVs.begin(), GVs.end());
|
|
|
|
}
|
|
|
|
|
|
|
|
iterator_range<type_iterator> types() const {
|
|
|
|
return iterator_range<type_iterator>(TYs.begin(), TYs.end());
|
|
|
|
}
|
|
|
|
|
|
|
|
iterator_range<scope_iterator> scopes() const {
|
|
|
|
return iterator_range<scope_iterator>(Scopes.begin(), Scopes.end());
|
|
|
|
}
|
2013-10-04 23:15:52 +00:00
|
|
|
|
|
|
|
unsigned compile_unit_count() const { return CUs.size(); }
|
|
|
|
unsigned global_variable_count() const { return GVs.size(); }
|
|
|
|
unsigned subprogram_count() const { return SPs.size(); }
|
|
|
|
unsigned type_count() const { return TYs.size(); }
|
|
|
|
unsigned scope_count() const { return Scopes.size(); }
|
|
|
|
|
|
|
|
private:
|
2015-04-17 23:20:10 +00:00
|
|
|
SmallVector<MDCompileUnit *, 8> CUs;
|
|
|
|
SmallVector<MDSubprogram *, 8> SPs;
|
|
|
|
SmallVector<MDGlobalVariable *, 8> GVs;
|
|
|
|
SmallVector<MDType *, 8> TYs;
|
|
|
|
SmallVector<MDScope *, 8> Scopes;
|
|
|
|
SmallPtrSet<const MDNode *, 64> NodesSeen;
|
2013-10-04 23:15:52 +00:00
|
|
|
DITypeIdentifierMap TypeIdentifierMap;
|
2014-10-15 17:01:28 +00:00
|
|
|
|
|
|
|
/// \brief Specify if TypeIdentifierMap is initialized.
|
2013-11-17 18:42:37 +00:00
|
|
|
bool TypeMapInitialized;
|
2013-10-04 23:15:52 +00:00
|
|
|
};
|
2014-07-01 20:05:26 +00:00
|
|
|
|
2015-04-17 23:20:10 +00:00
|
|
|
DenseMap<const Function *, MDSubprogram *> makeSubprogramMap(const Module &M);
|
2014-07-01 20:05:26 +00:00
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|