<br><br><div class="gmail_quote">On Fri Jan 02 2015 at 2:12:40 PM David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: dblaikie<br>
Date: Fri Jan  2 16:07:26 2015<br>
New Revision: 225090<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=225090&view=rev" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project?rev=225090&view=rev</a><br>
Log:<br>
DebugInfo: Provide a less subtle way to set the debug location of simple ret instructions<br>
<br>
un-XFAILing the test XFAIL'd in r225086 after it regressed in r225083.<br>
<br>
Modified:<br>
    cfe/trunk/lib/CodeGen/<u></u>CGDebugInfo.cpp<br>
    cfe/trunk/lib/CodeGen/<u></u>CGDebugInfo.h<br>
    cfe/trunk/lib/CodeGen/<u></u>CodeGenFunction.cpp<br>
    cfe/trunk/lib/CodeGen/<u></u>CodeGenFunction.h<br>
    cfe/trunk/test/CodeGen/debug-<u></u>info-line3.c<br>
<br>
Modified: cfe/trunk/lib/CodeGen/<u></u>CGDebugInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=225090&r1=225089&r2=225090&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/cfe/trunk/lib/CodeGen/<u></u>CGDebugInfo.cpp?rev=225090&r1=<u></u>225089&r2=225090&view=diff</a><br>
==============================<u></u>==============================<u></u>==================<br>
--- cfe/trunk/lib/CodeGen/<u></u>CGDebugInfo.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/<u></u>CGDebugInfo.cpp Fri Jan  2 16:07:26 2015<br>
@@ -75,6 +75,15 @@ ApplyDebugLocation::<u></u>ApplyDebugLocation(C<br>
   }<br>
 }<br>
<br>
+ApplyDebugLocation::<u></u>ApplyDebugLocation(<u></u>CodeGenFunction &CGF, llvm::DebugLoc Loc)<br>
+    : CGF(CGF) {<br>
+  if (CGF.getDebugInfo()) {<br>
+    OriginalLocation = CGF.Builder.<u></u>getCurrentDebugLocation();<br>
+    if (!Loc.isUnknown())<br>
+      CGF.Builder.<u></u>SetCurrentDebugLocation(Loc);<br>
+  }<br>
+}<br>
+<br>
 ApplyDebugLocation::~<u></u>ApplyDebugLocation() {<br>
   // Query CGF so the location isn't overwritten when location updates are<br>
   // temporarily disabled (for C++ default function arguments)<br>
<br>
Modified: cfe/trunk/lib/CodeGen/<u></u>CGDebugInfo.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=225090&r1=225089&r2=225090&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/cfe/trunk/lib/CodeGen/<u></u>CGDebugInfo.h?rev=225090&r1=<u></u>225089&r2=225090&view=diff</a><br>
==============================<u></u>==============================<u></u>==================<br>
--- cfe/trunk/lib/CodeGen/<u></u>CGDebugInfo.h (original)<br>
+++ cfe/trunk/lib/CodeGen/<u></u>CGDebugInfo.h Fri Jan  2 16:07:26 2015<br>
@@ -454,6 +454,7 @@ public:<br>
   ApplyDebugLocation(<u></u>CodeGenFunction &CGF,<br>
                      SourceLocation TemporaryLocation = SourceLocation(),<br>
                      bool ForceColumnInfo = false);<br>
+  ApplyDebugLocation(<u></u>CodeGenFunction &CGF, llvm::DebugLoc Loc);<br>
   ~ApplyDebugLocation();<br>
 };<br>
<br>
<br>
Modified: cfe/trunk/lib/CodeGen/<u></u>CodeGenFunction.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=225090&r1=225089&r2=225090&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/cfe/trunk/lib/CodeGen/<u></u>CodeGenFunction.cpp?rev=<u></u>225090&r1=225089&r2=225090&<u></u>view=diff</a><br>
==============================<u></u>==============================<u></u>==================<br>
--- cfe/trunk/lib/CodeGen/<u></u>CodeGenFunction.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/<u></u>CodeGenFunction.cpp Fri Jan  2 16:07:26 2015<br>
@@ -158,7 +158,7 @@ TypeEvaluationKind CodeGenFunction::getE<br>
   }<br>
 }<br>
<br>
-void CodeGenFunction::<u></u>EmitReturnBlock() {<br>
+llvm::DebugLoc CodeGenFunction::<u></u>EmitReturnBlock() {<br></blockquote><div><br></div><div>Update the block documentation for the function?</div><div><br></div><div>-eric</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
   // For cleanliness, we try to avoid emitting the return block for<br>
   // simple cases.<br>
   llvm::BasicBlock *CurBB = Builder.GetInsertBlock();<br>
@@ -173,7 +173,7 @@ void CodeGenFunction::<u></u>EmitReturnBlock()<br>
       delete ReturnBlock.getBlock();<br>
     } else<br>
       EmitBlock(ReturnBlock.<u></u>getBlock());<br>
-    return;<br>
+    return llvm::DebugLoc();<br>
   }<br>
<br>
   // Otherwise, if the return block is the target of a single direct<br>
@@ -184,15 +184,13 @@ void CodeGenFunction::<u></u>EmitReturnBlock()<br>
       dyn_cast<llvm::BranchInst>(*<u></u>ReturnBlock.getBlock()->user_<u></u>begin());<br>
     if (BI && BI->isUnconditional() &&<br>
         BI->getSuccessor(0) == ReturnBlock.getBlock()) {<br>
-      // Reset insertion point, including debug location, and delete the<br>
-      // branch.  This is really subtle and only works because the next change<br>
-      // in location will hit the caching in CGDebugInfo::EmitLocation and not<br>
-      // override this.<br>
-      Builder.<u></u>SetCurrentDebugLocation(BI-><u></u>getDebugLoc());<br>
+      // Record/return the DebugLoc of the simple 'return' expression to be used<br>
+      // later by the actual 'ret' instruction.<br>
+      llvm::DebugLoc Loc = BI->getDebugLoc();<br>
       Builder.SetInsertPoint(BI-><u></u>getParent());<br>
       BI->eraseFromParent();<br>
       delete ReturnBlock.getBlock();<br>
-      return;<br>
+      return Loc;<br>
     }<br>
   }<br>
<br>
@@ -201,6 +199,7 @@ void CodeGenFunction::<u></u>EmitReturnBlock()<br>
   // region.end for now.<br>
<br>
   EmitBlock(ReturnBlock.<u></u>getBlock());<br>
+  return llvm::DebugLoc();<br>
 }<br>
<br>
 static void EmitIfUsed(CodeGenFunction &CGF, llvm::BasicBlock *BB) {<br>
@@ -254,16 +253,18 @@ void CodeGenFunction::<u></u>FinishFunction(Sou<br>
   }<br>
<br>
   // Emit function epilog (to return).<br>
-  EmitReturnBlock();<br>
+  llvm::DebugLoc Loc = EmitReturnBlock();<br>
<br>
   if (ShouldInstrumentFunction())<br>
     EmitFunctionInstrumentation("_<u></u>_cyg_profile_func_exit");<br>
<br>
   // Emit debug descriptor for function end.<br>
-  if (CGDebugInfo *DI = getDebugInfo()) {<br>
+  if (CGDebugInfo *DI = getDebugInfo())<br>
     DI->EmitFunctionEnd(Builder);<br>
-  }<br>
<br>
+  // Reset the debug location to that of the simple 'return' expression, if any<br>
+  // rather than that of the end of the function's scope '}'.<br>
+  ApplyDebugLocation AL(*this, Loc);<br>
   EmitFunctionEpilog(*CurFnInfo, EmitRetDbgLoc, EndLoc);<br>
   EmitEndEHSpec(CurCodeDecl);<br>
<br>
<br>
Modified: cfe/trunk/lib/CodeGen/<u></u>CodeGenFunction.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=225090&r1=225089&r2=225090&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/cfe/trunk/lib/CodeGen/<u></u>CodeGenFunction.h?rev=225090&<u></u>r1=225089&r2=225090&view=diff</a><br>
==============================<u></u>==============================<u></u>==================<br>
--- cfe/trunk/lib/CodeGen/<u></u>CodeGenFunction.h (original)<br>
+++ cfe/trunk/lib/CodeGen/<u></u>CodeGenFunction.h Fri Jan  2 16:07:26 2015<br>
@@ -1262,7 +1262,7 @@ public:<br>
<br>
   /// EmitReturnBlock - Emit the unified return block, trying to avoid its<br>
   /// emission when possible.<br>
-  void EmitReturnBlock();<br>
+  llvm::DebugLoc EmitReturnBlock();<br>
<br>
   /// FinishFunction - Complete IR generation of the current function. It is<br>
   /// legal to call this function even if there is no current insertion point.<br>
<br>
Modified: cfe/trunk/test/CodeGen/debug-<u></u>info-line3.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-line3.c?rev=225090&r1=225089&r2=225090&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/cfe/trunk/test/<u></u>CodeGen/debug-info-line3.c?<u></u>rev=225090&r1=225089&r2=<u></u>225090&view=diff</a><br>
==============================<u></u>==============================<u></u>==================<br>
--- cfe/trunk/test/CodeGen/debug-<u></u>info-line3.c (original)<br>
+++ cfe/trunk/test/CodeGen/debug-<u></u>info-line3.c Fri Jan  2 16:07:26 2015<br>
@@ -1,10 +1,5 @@<br>
 // RUN: %clang_cc1 -g -S -emit-llvm %s -o - | FileCheck %s<br>
<br>
-// Temporarily XFAIL while investigating regression. (other improvements seem<br>
-// more important to keep rather than reverting them in favor of preserving<br>
-// this)<br>
-// XFAIL: *<br>
-<br>
 void func(char c, char* d)<br>
 {<br>
   *d = c + 1;<br>
<br>
<br>
______________________________<u></u>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/cfe-commits</a><br>
</blockquote></div>