[llvm-commits] [llvm] r83491 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h lib/Analysis/DebugInfo.cpp
Devang Patel
dpatel at apple.com
Wed Oct 7 15:04:08 PDT 2009
Author: dpatel
Date: Wed Oct 7 17:04:08 2009
New Revision: 83491
URL: http://llvm.org/viewvc/llvm-project?rev=83491&view=rev
Log:
Extract subprogram and compile unit information from the debug info attached to an instruction.
Modified:
llvm/trunk/include/llvm/Analysis/DebugInfo.h
llvm/trunk/lib/Analysis/DebugInfo.cpp
Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=83491&r1=83490&r2=83491&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Wed Oct 7 17:04:08 2009
@@ -679,7 +679,10 @@
/// processType - Process DIType.
void processType(DIType DT);
- /// processSubprogram - Enumberate DISubprogram.
+ /// processLexicalBlock - Process DILexicalBlock.
+ void processLexicalBlock(DILexicalBlock LB);
+
+ /// processSubprogram - Process DISubprogram.
void processSubprogram(DISubprogram SP);
/// processStopPoint - Process DbgStopPointInst.
Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=83491&r1=83490&r2=83491&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/DebugInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/DebugInfo.cpp Wed Oct 7 17:04:08 2009
@@ -966,6 +966,12 @@
/// processModule - Process entire module and collect debug info.
void DebugInfoFinder::processModule(Module &M) {
+#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
+ MetadataContext &TheMetadata = M.getContext().getMetadata();
+ unsigned MDDbgKind = TheMetadata.getMDKind("dbg");
+ if (!MDDbgKind)
+ return;
+#endif
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
for (Function::iterator FI = (*I).begin(), FE = (*I).end(); FI != FE; ++FI)
for (BasicBlock::iterator BI = (*FI).begin(), BE = (*FI).end(); BI != BE;
@@ -980,6 +986,18 @@
processRegionEnd(DRE);
else if (DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(BI))
processDeclare(DDI);
+#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
+ else if (MDNode *L = TheMetadata.getMD(MDDbgKind, BI)) {
+ DILocation Loc(L);
+ DIScope S(Loc.getScope().getNode());
+ if (S.isCompileUnit())
+ addCompileUnit(DICompileUnit(S.getNode()));
+ else if (S.isSubprogram())
+ processSubprogram(DISubprogram(S.getNode()));
+ else if (S.isLexicalBlock())
+ processLexicalBlock(DILexicalBlock(S.getNode()));
+ }
+#endif
}
NamedMDNode *NMD = M.getNamedMetadata("llvm.dbg.gv");
@@ -1021,6 +1039,17 @@
}
}
+/// processLexicalBlock
+void DebugInfoFinder::processLexicalBlock(DILexicalBlock LB) {
+ if (LB.isNull())
+ return;
+ DIScope Context = LB.getContext();
+ if (Context.isLexicalBlock())
+ return processLexicalBlock(DILexicalBlock(Context.getNode()));
+ else
+ return processSubprogram(DISubprogram(Context.getNode()));
+}
+
/// processSubprogram - Process DISubprogram.
void DebugInfoFinder::processSubprogram(DISubprogram SP) {
if (SP.isNull())
More information about the llvm-commits
mailing list