diff options
author | Devang Patel <dpatel@apple.com> | 2011-02-15 17:24:56 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2011-02-15 17:24:56 +0000 |
commit | 27924da676ffaae55f1710e14fd7ad222879b9c8 (patch) | |
tree | 8d030180efd1ceddb033602cb9076679adf43334 /llvm/lib/Analysis/DebugInfo.cpp | |
parent | 9892e3545acbe896c7caa0cf620475a184b1ce2b (diff) | |
download | bcm5719-llvm-27924da676ffaae55f1710e14fd7ad222879b9c8.tar.gz bcm5719-llvm-27924da676ffaae55f1710e14fd7ad222879b9c8.zip |
Print function info. Patch by Minjang Kim.
llvm-svn: 125567
Diffstat (limited to 'llvm/lib/Analysis/DebugInfo.cpp')
-rw-r--r-- | llvm/lib/Analysis/DebugInfo.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/DebugInfo.cpp b/llvm/lib/Analysis/DebugInfo.cpp index 29bbeb5c44c..78da1b49f84 100644 --- a/llvm/lib/Analysis/DebugInfo.cpp +++ b/llvm/lib/Analysis/DebugInfo.cpp @@ -1592,6 +1592,23 @@ static Value *findDbgGlobalDeclare(GlobalVariable *V) { return 0; } +/// Find the debug info descriptor corresponding to this function. +static Value *findDbgSubprogramDeclare(Function *V) { + const Module *M = V->getParent(); + NamedMDNode *NMD = M->getNamedMetadata("llvm.dbg.sp"); + if (!NMD) + return 0; + + for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) { + DIDescriptor DIG(cast<MDNode>(NMD->getOperand(i))); + if (!DIG.isSubprogram()) + continue; + if (DISubprogram(DIG).getFunction() == V) + return DIG; + } + return 0; +} + /// Finds the llvm.dbg.declare intrinsic corresponding to this value if any. /// It looks through pointer casts too. static const DbgDeclareInst *findDbgDeclare(const Value *V) { @@ -1633,6 +1650,17 @@ bool llvm::getLocationInfo(const Value *V, std::string &DisplayName, LineNo = Var.getLineNumber(); Unit = Var.getCompileUnit(); TypeD = Var.getType(); + } else if (Function *F = dyn_cast<Function>(const_cast<Value*>(V))){ + Value *DIF = findDbgSubprogramDeclare(F); + if (!DIF) return false; + DISubprogram Var(cast<MDNode>(DIF)); + + StringRef D = Var.getDisplayName(); + if (!D.empty()) + DisplayName = D; + LineNo = Var.getLineNumber(); + Unit = Var.getCompileUnit(); + TypeD = Var.getType(); } else { const DbgDeclareInst *DDI = findDbgDeclare(V); if (!DDI) return false; |