From fd5fdc38637e7e9dfe8caf654a82b0fe4ae6e148 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Mon, 28 Jun 2010 05:53:08 +0000 Subject: [PATCH] Use named MDNode, llvm.dbg.sp, to collect subprogram info. This will be used to emit local variable's debug info of deleted functions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106989 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/DebugInfo.cpp | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp index 7636716f053..c8d0d22ec2e 100644 --- a/lib/Analysis/DebugInfo.cpp +++ b/lib/Analysis/DebugInfo.cpp @@ -971,7 +971,12 @@ DISubprogram DIFactory::CreateSubprogram(DIDescriptor Context, ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized), Fn }; - return DISubprogram(MDNode::get(VMContext, &Elts[0], 17)); + MDNode *Node = MDNode::get(VMContext, &Elts[0], 17); + + // Create a named metadata so that we do not lose this mdnode. + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.sp"); + NMD->addOperand(Node); + return DISubprogram(Node); } /// CreateSubprogramDefinition - Create new subprogram descriptor for the @@ -1000,7 +1005,12 @@ DISubprogram DIFactory::CreateSubprogramDefinition(DISubprogram &SPDeclaration) DeclNode->getOperand(15), // isOptimized SPDeclaration.getFunction() }; - return DISubprogram(MDNode::get(VMContext, &Elts[0], 16)); + MDNode *Node =MDNode::get(VMContext, &Elts[0], 16); + + // Create a named metadata so that we do not lose this mdnode. + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.sp"); + NMD->addOperand(Node); + return DISubprogram(Node); } /// CreateGlobalVariable - Create a new descriptor for the specified global. @@ -1230,17 +1240,19 @@ void DebugInfoFinder::processModule(Module &M) { processLocation(DILocation(IA)); } - NamedMDNode *NMD = M.getNamedMetadata("llvm.dbg.gv"); - if (!NMD) - return; - - for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) { - DIGlobalVariable DIG(cast(NMD->getOperand(i))); - if (addGlobalVariable(DIG)) { - addCompileUnit(DIG.getCompileUnit()); - processType(DIG.getType()); + if (NamedMDNode *NMD = M.getNamedMetadata("llvm.dbg.gv")) { + for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) { + DIGlobalVariable DIG(cast(NMD->getOperand(i))); + if (addGlobalVariable(DIG)) { + addCompileUnit(DIG.getCompileUnit()); + processType(DIG.getType()); + } } } + + if (NamedMDNode *NMD = M.getNamedMetadata("llvm.dbg.sp")) + for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) + processSubprogram(DISubprogram(NMD->getOperand(i))); } /// processLocation - Process DILocation. -- 2.34.1