summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/DebugInfo.cpp
diff options
context:
space:
mode:
authorTimur Iskhodzhanov <timurrrr@google.com>2014-10-23 23:46:28 +0000
committerTimur Iskhodzhanov <timurrrr@google.com>2014-10-23 23:46:28 +0000
commiteb229ca928103eb5dd82030544598d21816fb813 (patch)
treeb2a9e20d238d04099985e107fb5dfb89af4c145a /llvm/lib/IR/DebugInfo.cpp
parent5a5fadd70d0979d076669e4bc9fe3f9192153ec7 (diff)
downloadbcm5719-llvm-eb229ca928103eb5dd82030544598d21816fb813.tar.gz
bcm5719-llvm-eb229ca928103eb5dd82030544598d21816fb813.zip
Make getDISubprogram(const Function *F) available in LLVM
Reviewed at http://reviews.llvm.org/D5950 llvm-svn: 220536
Diffstat (limited to 'llvm/lib/IR/DebugInfo.cpp')
-rw-r--r--llvm/lib/IR/DebugInfo.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 04eb65bc2a7..56b06230e22 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -912,6 +912,24 @@ DISubprogram llvm::getDISubprogram(const MDNode *Scope) {
return DISubprogram();
}
+DISubprogram llvm::getDISubprogram(const Function *F) {
+ // We look for the first instr that has a debug annotation leading back to F.
+ const LLVMContext &Ctx = F->getParent()->getContext();
+ for (auto &BB : *F) {
+ for (auto &Inst : BB.getInstList()) {
+ DebugLoc DLoc = Inst.getDebugLoc();
+ if (DLoc.isUnknown())
+ continue;
+ const MDNode *Scope = DLoc.getScopeNode(Ctx);
+ DISubprogram Subprogram = getDISubprogram(Scope);
+ if (Subprogram.describes(F))
+ return Subprogram;
+ }
+ }
+
+ return DISubprogram();
+}
+
DICompositeType llvm::getDICompositeType(DIType T) {
if (T.isCompositeType())
return DICompositeType(T);
OpenPOWER on IntegriCloud