diff options
author | Manman Ren <manman.ren@gmail.com> | 2013-09-09 19:47:11 +0000 |
---|---|---|
committer | Manman Ren <manman.ren@gmail.com> | 2013-09-09 19:47:11 +0000 |
commit | 2c9905a1f3bcf22cc2f93332cc8411d11798ba07 (patch) | |
tree | cd46f1895d551822957384c349a4889109610933 /lib/IR/DebugInfo.cpp | |
parent | 0b67c2127eb3b26b53ccdb925c87aad6ae19819d (diff) | |
download | external_llvm-2c9905a1f3bcf22cc2f93332cc8411d11798ba07.tar.gz external_llvm-2c9905a1f3bcf22cc2f93332cc8411d11798ba07.tar.bz2 external_llvm-2c9905a1f3bcf22cc2f93332cc8411d11798ba07.zip |
Debug Info: Use DIScopeRef for DIType::getContext.
In DIBuilder, the context field of a TAG_member is updated to use the
scope reference. Verifier is updated accordingly.
DebugInfoFinder now needs to generate a type identifier map to have
access to the actual scope. Same applies for BreakpointPrinter.
processModule of DebugInfoFinder is called during initialization phase
of the verifier to make sure the type identifier map is constructed early
enough.
We are now able to unique a simple class as demonstrated by the added
testing case.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190334 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR/DebugInfo.cpp')
-rw-r--r-- | lib/IR/DebugInfo.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index dc22db3b01..e0b59649a7 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -446,12 +446,18 @@ static bool isScopeRef(const Value *Val) { (isa<MDNode>(Val) && DIScope(cast<MDNode>(Val)).isScope()); } +/// Check if a field at position Elt of a MDNode can be a ScopeRef. +static bool fieldIsScopeRef(const MDNode *DbgNode, unsigned Elt) { + Value *Fld = getField(DbgNode, Elt); + return isScopeRef(Fld); +} + /// Verify - Verify that a type descriptor is well formed. bool DIType::Verify() const { if (!isType()) return false; // Make sure Context @ field 2 is MDNode. - if (!fieldIsMDNode(DbgNode, 2)) + if (!fieldIsScopeRef(DbgNode, 2)) return false; // FIXME: Sink this into the various subclass verifies. @@ -956,11 +962,13 @@ void DebugInfoFinder::reset() { TYs.clear(); Scopes.clear(); NodesSeen.clear(); + TypeIdentifierMap.clear(); } /// processModule - Process entire module and collect debug info. void DebugInfoFinder::processModule(const Module &M) { if (NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu")) { + TypeIdentifierMap = generateDITypeIdentifierMap(CU_Nodes); for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) { DICompileUnit CU(CU_Nodes->getOperand(i)); addCompileUnit(CU); @@ -1010,7 +1018,7 @@ void DebugInfoFinder::processLocation(DILocation Loc) { void DebugInfoFinder::processType(DIType DT) { if (!addType(DT)) return; - processScope(DT.getContext()); + processScope(DT.getContext().resolve(TypeIdentifierMap)); if (DT.isCompositeType()) { DICompositeType DCT(DT); processType(DCT.getTypeDerivedFrom()); |