<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Nov 1, 2014 at 12:57 AM, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: majnemer<br>
Date: Sat Nov  1 02:57:14 2014<br>
New Revision: 221044<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=221044&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=221044&view=rev</a><br>
Log:<br>
IR: Restore the old behavior of getDISubprogram<br>
<br>
getDISubprogram was mistakenly thought to contain a bug: we thought we<br>
might need to try harder if we found a DebugLoc we didn't find.<br></blockquote><div><br></div><div>Thanks!</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Modified:<br>
    llvm/trunk/lib/IR/DebugInfo.cpp<br>
<br>
Modified: llvm/trunk/lib/IR/DebugInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=221044&r1=221043&r2=221044&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=221044&r1=221043&r2=221044&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)<br>
+++ llvm/trunk/lib/IR/DebugInfo.cpp Sat Nov  1 02:57:14 2014<br>
@@ -914,17 +914,16 @@ DISubprogram llvm::getDISubprogram(const<br>
<br>
 DISubprogram llvm::getDISubprogram(const Function *F) {<br>
   // We look for the first instr that has a debug annotation leading back to F.<br>
-  const LLVMContext &Ctx = F->getParent()->getContext();<br>
   for (auto &BB : *F) {<br>
-    for (auto &Inst : BB.getInstList()) {<br>
-      DebugLoc DLoc = Inst.getDebugLoc();<br>
-      if (DLoc.isUnknown())<br>
-        continue;<br>
-      const MDNode *Scope = DLoc.getScopeNode(Ctx);<br>
-      DISubprogram Subprogram = getDISubprogram(Scope);<br>
-      if (Subprogram.describes(F))<br>
-       return Subprogram;<br>
-    }<br>
+    auto Inst = std::find_if(BB.begin(), BB.end(), [](const Instruction &Inst) {<br>
+      return !Inst.getDebugLoc().isUnknown();<br>
+    });<br>
+    if (Inst == BB.end())<br>
+      continue;<br>
+    DebugLoc DLoc = Inst->getDebugLoc();<br>
+    const MDNode *Scope = DLoc.getScopeNode(F->getParent()->getContext());<br>
+    DISubprogram Subprogram = getDISubprogram(Scope);<br>
+    return Subprogram.describes(F) ? Subprogram : DISubprogram();<br>
   }<br>
<br>
   return DISubprogram();<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>