<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, May 15, 2013 at 5:41 PM, Adrian Prantl <span dir="ltr"><<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: adrian<br>
Date: Wed May 15 19:41:26 2013<br>
New Revision: 181957<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=181957&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=181957&view=rev</a><br>
Log:<br>
Cleanup: Use a member variable to store the SourceLocation for EH code.<br>
rdar://problem/13888152<br></blockquote><div><br></div><div style>What's the actual bug this is addressing? A performance problem due to recomputing the location? Or a correctness issue? (in which case a test case would be nice)</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Modified:<br>
    cfe/trunk/lib/CodeGen/CGCleanup.cpp<br>
    cfe/trunk/lib/CodeGen/CodeGenFunction.cpp<br>
    cfe/trunk/lib/CodeGen/CodeGenFunction.h<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGCleanup.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCleanup.cpp?rev=181957&r1=181956&r2=181957&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCleanup.cpp?rev=181957&r1=181956&r2=181957&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGCleanup.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGCleanup.cpp Wed May 15 19:41:26 2013<br>
@@ -371,8 +371,7 @@ void CodeGenFunction::ResolveBranchFixup<br>
 }<br>
<br>
 /// Pops cleanup blocks until the given savepoint is reached.<br>
-void CodeGenFunction::PopCleanupBlocks(EHScopeStack::stable_iterator Old,<br>
-                                       SourceLocation EHLoc) {<br>
+void CodeGenFunction::PopCleanupBlocks(EHScopeStack::stable_iterator Old) {<br>
   assert(Old.isValid());<br>
<br>
   while (EHStack.stable_begin() != Old) {<br>
@@ -384,7 +383,7 @@ void CodeGenFunction::PopCleanupBlocks(E<br>
     bool FallThroughIsBranchThrough =<br>
       Old.strictlyEncloses(Scope.getEnclosingNormalCleanup());<br>
<br>
-    PopCleanupBlock(FallThroughIsBranchThrough, EHLoc);<br>
+    PopCleanupBlock(FallThroughIsBranchThrough);<br>
   }<br>
 }<br>
<br>
@@ -533,8 +532,7 @@ static void destroyOptimisticNormalEntry<br>
 /// Pops a cleanup block.  If the block includes a normal cleanup, the<br>
 /// current insertion point is threaded through the cleanup, as are<br>
 /// any branch fixups on the cleanup.<br>
-void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough,<br>
-                                      SourceLocation EHLoc) {<br>
+void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough) {<br>
   assert(!EHStack.empty() && "cleanup stack is empty!");<br>
   assert(isa<EHCleanupScope>(*EHStack.begin()) && "top not a cleanup!");<br>
   EHCleanupScope &Scope = cast<EHCleanupScope>(*EHStack.begin());<br>
@@ -836,7 +834,7 @@ void CodeGenFunction::PopCleanupBlock(bo<br>
   // Emit the EH cleanup if required.<br>
   if (RequiresEHCleanup) {<br>
     if (CGDebugInfo *DI = getDebugInfo())<br>
-      DI->EmitLocation(Builder, EHLoc);<br>
+      DI->EmitLocation(Builder, CurEHLocation);<br>
<br>
     CGBuilderTy::InsertPoint SavedIP = Builder.saveAndClearIP();<br>
<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=181957&r1=181956&r2=181957&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=181957&r1=181956&r2=181957&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Wed May 15 19:41:26 2013<br>
@@ -209,7 +209,7 @@ void CodeGenFunction::FinishFunction(Sou<br>
   // edges will be *really* confused.<br>
   bool EmitRetDbgLoc = true;<br>
   if (EHStack.stable_begin() != PrologueCleanupDepth) {<br>
-    PopCleanupBlocks(PrologueCleanupDepth, EndLoc);<br>
+    PopCleanupBlocks(PrologueCleanupDepth);<br>
<br>
     // Make sure the line table doesn't jump back into the body for<br>
     // the ret after it's been at EndLoc.<br>
@@ -666,6 +666,7 @@ void CodeGenFunction::GenerateCode(Globa<br>
<br>
   SourceRange BodyRange;<br>
   if (Stmt *Body = FD->getBody()) BodyRange = Body->getSourceRange();<br>
+  CurEHLocation = BodyRange.getEnd();<br>
<br>
   // CalleeWithThisReturn keeps track of the last callee inside this function<br>
   // that returns 'this'. Before starting the function, we set it to null.<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=181957&r1=181956&r2=181957&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=181957&r1=181956&r2=181957&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)<br>
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Wed May 15 19:41:26 2013<br>
@@ -844,9 +844,7 @@ public:<br>
<br>
   /// PopCleanupBlock - Will pop the cleanup entry on the stack and<br>
   /// process all branch fixups.<br>
-  /// \param EHLoc - Optional debug location for EH code.<br>
-  void PopCleanupBlock(bool FallThroughIsBranchThrough = false,<br>
-                       SourceLocation EHLoc=SourceLocation());<br>
+  void PopCleanupBlock(bool FallThroughIsBranchThrough = false);<br>
<br>
   /// DeactivateCleanupBlock - Deactivates the given cleanup block.<br>
   /// The block cannot be reactivated.  Pops it if it's the top of the<br>
@@ -967,9 +965,7 @@ public:<br>
<br>
   /// PopCleanupBlocks - Takes the old cleanup stack size and emits<br>
   /// the cleanup blocks that have been added.<br>
-  /// \param EHLoc - Optional debug location for EH code.<br>
-  void PopCleanupBlocks(EHScopeStack::stable_iterator OldCleanupStackSize,<br>
-                        SourceLocation EHLoc=SourceLocation());<br>
+  void PopCleanupBlocks(EHScopeStack::stable_iterator OldCleanupStackSize);<br>
<br>
   void ResolveBranchFixups(llvm::BasicBlock *Target);<br>
<br>
@@ -1339,6 +1335,10 @@ private:<br>
   /// The current lexical scope.<br>
   LexicalScope *CurLexicalScope;<br>
<br>
+  /// The current source location that should be used for exception<br>
+  /// handling code.<br>
+  SourceLocation CurEHLocation;<br>
+<br>
   /// ByrefValueInfoMap - For each __block variable, contains a pair of the LLVM<br>
   /// type as well as the field number that contains the actual data.<br>
   llvm::DenseMap<const ValueDecl *, std::pair<llvm::Type *,<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">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/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>