aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorManman Ren <manman.ren@gmail.com>2013-09-05 18:48:31 +0000
committerManman Ren <manman.ren@gmail.com>2013-09-05 18:48:31 +0000
commitbc66071baa3153ba95d673b8084383835221eef6 (patch)
treeea089a4002af6dfa75f7df34d5da3c0a36b04247 /include
parent79916948e1fd176a3898b596b679cc9dba3d40a8 (diff)
downloadexternal_llvm-bc66071baa3153ba95d673b8084383835221eef6.zip
external_llvm-bc66071baa3153ba95d673b8084383835221eef6.tar.gz
external_llvm-bc66071baa3153ba95d673b8084383835221eef6.tar.bz2
Debug Info: Use identifier to reference DIType in base type field of
ptr_to_member. We introduce a new class DITypeRef that represents a reference to a DIType. It wraps around a Value*, which can be either an identifier in MDString or an actual MDNode. The class has a helper function "resolve" that finds the actual MDNode for a given DITypeRef. We specialize getFieldAs to return a field that is a reference to a DIType. To correctly access the base type field of ptr_to_member, getClassType now calls getFieldAs<DITypeRef> to return a DITypeRef. Also add a typedef for DITypeIdentifierMap and a helper generateDITypeIdentifierMap in DebugInfo.h. In DwarfDebug.cpp, we keep a DITypeIdentifierMap and call generateDITypeIdentifierMap to actually populate the map. Verifier is updated accordingly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190081 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/DebugInfo.h32
1 files changed, 30 insertions, 2 deletions
diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h
index 87ccac1..997d01e 100644
--- a/include/llvm/DebugInfo.h
+++ b/include/llvm/DebugInfo.h
@@ -17,6 +17,7 @@
#ifndef LLVM_DEBUGINFO_H
#define LLVM_DEBUGINFO_H
+#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
@@ -45,12 +46,19 @@ namespace llvm {
class DILexicalBlockFile;
class DIVariable;
class DIType;
+ class DITypeRef;
class DIObjCProperty;
+ /// Maps from type identifier to the actual MDNode.
+ typedef DenseMap<const MDString *, MDNode*> DITypeIdentifierMap;
+
/// DIDescriptor - A thin wraper around MDNode to access encoded debug info.
/// This should not be stored in a container, because the underlying MDNode
/// may change in certain situations.
class DIDescriptor {
+ // Befriends DITypeRef so DITypeRef can befriend the protected member
+ // function: getFieldAs<DITypeRef>.
+ friend class DITypeRef;
public:
enum {
FlagPrivate = 1 << 0,
@@ -143,6 +151,23 @@ namespace llvm {
void dump() const;
};
+ /// Specialize getFieldAs to handle fields that are references to DITypes.
+ template <>
+ DITypeRef DIDescriptor::getFieldAs<DITypeRef>(unsigned Elt) const;
+
+ /// Represents reference to a DIType, abstracts over direct and
+ /// identifier-based metadata type references.
+ class DITypeRef {
+ friend DITypeRef DIDescriptor::getFieldAs<DITypeRef>(unsigned Elt) const;
+
+ /// TypeVal can be either a MDNode or a MDString, in the latter,
+ /// MDString specifies the type identifier.
+ const Value *TypeVal;
+ explicit DITypeRef(const Value *V);
+ public:
+ DIType resolve(const DITypeIdentifierMap &Map) const;
+ };
+
/// DISubrange - This is used to represent ranges, for array bounds.
class DISubrange : public DIDescriptor {
friend class DIDescriptor;
@@ -296,9 +321,9 @@ namespace llvm {
/// associated with one.
MDNode *getObjCProperty() const;
- DIType getClassType() const {
+ DITypeRef getClassType() const {
assert(getTag() == dwarf::DW_TAG_ptr_to_member_type);
- return getFieldAs<DIType>(10);
+ return getFieldAs<DITypeRef>(10);
}
Constant *getConstant() const {
@@ -720,6 +745,9 @@ namespace llvm {
/// cleanseInlinedVariable - Remove inlined scope from the variable.
DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext);
+ /// Construct DITypeIdentifierMap by going through retained types of each CU.
+ DITypeIdentifierMap generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes);
+
/// 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,