diff options
author | David Majnemer <david.majnemer@gmail.com> | 2014-11-01 07:57:14 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2014-11-01 07:57:14 +0000 |
commit | c758df4053767b19709a3345eb22f73f8894931b (patch) | |
tree | 84e576971094b28cb3dd7fd6016ceee32ba14d1d /llvm/lib/IR/DebugInfo.cpp | |
parent | 0868137ac8c9661bd345444d17ac1d53bbc1a996 (diff) | |
download | bcm5719-llvm-c758df4053767b19709a3345eb22f73f8894931b.tar.gz bcm5719-llvm-c758df4053767b19709a3345eb22f73f8894931b.zip |
IR: Restore the old behavior of getDISubprogram
getDISubprogram was mistakenly thought to contain a bug: we thought we
might need to try harder if we found a DebugLoc we didn't find.
llvm-svn: 221044
Diffstat (limited to 'llvm/lib/IR/DebugInfo.cpp')
-rw-r--r-- | llvm/lib/IR/DebugInfo.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index 56b06230e22..60904c2b356 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -914,17 +914,16 @@ DISubprogram llvm::getDISubprogram(const MDNode *Scope) { 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; - } + auto Inst = std::find_if(BB.begin(), BB.end(), [](const Instruction &Inst) { + return !Inst.getDebugLoc().isUnknown(); + }); + if (Inst == BB.end()) + continue; + DebugLoc DLoc = Inst->getDebugLoc(); + const MDNode *Scope = DLoc.getScopeNode(F->getParent()->getContext()); + DISubprogram Subprogram = getDISubprogram(Scope); + return Subprogram.describes(F) ? Subprogram : DISubprogram(); } return DISubprogram(); |