<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 6, 2015, at 2:57 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Feb 4, 2015 at 5:29 PM, Adrian Prantl <span dir="ltr" class=""><<a href="mailto:aprantl@apple.com" target="_blank" class="">aprantl@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br class="">
> On Feb 4, 2015, at 11:47 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:<br class="">
><br class="">
> Author: dblaikie<br class="">
> Date: Wed Feb 4 13:47:54 2015<br class="">
> New Revision: 228181<br class="">
><br class="">
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=228181&view=rev" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=228181&view=rev</a><br class="">
> Log:<br class="">
> DebugInfo: Attribute cleanup code to the end of the scope, not the end of the function.<br class="">
><br class="">
> Now if you break on a dtor and go 'up' in your debugger (or you get an<br class="">
> asan failure in a dtor) during an exception unwind, you'll have more<br class="">
> context. Instead of all dtors appearing to be called from the '}' of the<br class="">
> function, they'll be attributed to the end of the scope of the variable,<br class="">
> the same as the non-exceptional dtor call.<br class="">
><br class="">
> This doesn't /quite/ remove all uses of CurEHLocation (which might be<br class="">
> nice to remove, for a few reasons) - it's still used to choose the<br class="">
> location for some other work in the landing pad. It'd be nice to<br class="">
> attribute that code to the same location as the exception calls within<br class="">
> the block and to remove CurEHLocation.<br class="">
><br class="">
> Modified:<br class="">
> cfe/trunk/lib/CodeGen/CGCleanup.cpp<br class="">
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br class="">
> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp<br class="">
> cfe/trunk/lib/CodeGen/CodeGenFunction.h<br class="">
> cfe/trunk/test/CodeGenCXX/debug-info-line.cpp<br class="">
> cfe/trunk/test/CodeGenCXX/linetable-cleanup.cpp<br class="">
> cfe/trunk/test/CodeGenObjC/arc-linetable.m<br class="">
><br class="">
> Modified: cfe/trunk/lib/CodeGen/CGCleanup.cpp<br class="">
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCleanup.cpp?rev=228181&r1=228180&r2=228181&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCleanup.cpp?rev=228181&r1=228180&r2=228181&view=diff</a><br class="">
> ==============================================================================<br class="">
> --- cfe/trunk/lib/CodeGen/CGCleanup.cpp (original)<br class="">
> +++ cfe/trunk/lib/CodeGen/CGCleanup.cpp Wed Feb 4 13:47:54 2015<br class="">
> @@ -861,8 +861,6 @@ void CodeGenFunction::PopCleanupBlock(bo<br class="">
><br class="">
> // Emit the EH cleanup if required.<br class="">
> if (RequiresEHCleanup) {<br class="">
> - auto AL = ApplyDebugLocation::CreateDefaultArtificial(*this, CurEHLocation);<br class="">
> -<br class="">
<br class="">
</div></div>You can’t just remove this here: If CurEHLocation is a nullptr ((as it would be in an artificial function), or after removing this - the current location) we still need to set the location to *something* valid or we will create an unattributed call which will after inlining trigger the famous "scope does not describe function” assertion.<br class=""></blockquote><div class=""><br class="">When does that happen (CurEHLocation being nullptr or the current location being unset)?</div></div></div></div></div></blockquote><div><br class=""></div><div>In the wonderful language that is Objective C++; when there is an invocation to a C++ destructor in an ObjC destroy block helper, such as in the <span style="font-family: Menlo-Regular;" class="">cfe/trunk/test/CodeGenObjCXX/nested-ehlocation.mm </span>testcase. Copy/Destroy helpers are artificial locations, so CurEHLocation is an empty SourceLocation(). I might be wrong about that the current location ever being unset after all the recent changes, but I would feel more comfortable if we at least had an assertion about it there, to make sure that there is a valid location. The earlier we can catch the problem, the better.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=""><br class="">
<br class="">
> CGBuilderTy::InsertPoint SavedIP = Builder.saveAndClearIP();<br class="">
><br class="">
> EmitBlock(EHEntry);<br class="">
><br class="">
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br class="">
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=228181&r1=228180&r2=228181&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=228181&r1=228180&r2=228181&view=diff</a><br class="">
> ==============================================================================<br class="">
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)<br class="">
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Feb 4 13:47:54 2015<br class="">
> @@ -55,7 +55,6 @@ CGDebugInfo::~CGDebugInfo() {<br class="">
> ApplyDebugLocation::ApplyDebugLocation(CodeGenFunction &CGF,<br class="">
> SourceLocation TemporaryLocation)<br class="">
> : CGF(CGF) {<br class="">
> - assert(!TemporaryLocation.isInvalid() && "invalid location”);<br class="">
<br class="">
</span>Please don’t. I’d like to keep a clear separation between the uses of ApplyDebugLocation were a location is mandatory (for example, when we will be emitting a call/invoke) and the ones were it is optional.<br class=""></blockquote><div class=""><br class="">Given that the ApplyDebugLocation(CGF, Expr) ctor already allows expressions with invalid SourceLocations as no-ops, this seemed consistent. Is there a reason to treat these differently? Or should we have 4 flavors here ({SL,Expr}x{mandatory,optional})?<br class=""></div></div></div></div></div></blockquote><div><br class=""></div><div>The Expr flavor is only (hopefully) used within the body of a function where it is safe to assume that a previous location was set and can be reused as a somewhat reasonable default, so I think we can get away with just having only one version. But for anything that might be used in the function epilogue/cleanup blocks we need to be more careful.</div><div><br class=""></div><div>-- adrian</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class=""><div class="h5">> init(TemporaryLocation);<br class="">
> }<br class="">
><br class="">
><br class="">
> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp<br class="">
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=228181&r1=228180&r2=228181&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=228181&r1=228180&r2=228181&view=diff</a><br class="">
> ==============================================================================<br class="">
> --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)<br class="">
> +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Wed Feb 4 13:47:54 2015<br class="">
> @@ -241,8 +241,6 @@ void CodeGenFunction::FinishFunction(Sou<br class="">
> // edges will be *really* confused.<br class="">
> bool EmitRetDbgLoc = true;<br class="">
> if (EHStack.stable_begin() != PrologueCleanupDepth) {<br class="">
> - PopCleanupBlocks(PrologueCleanupDepth);<br class="">
> -<br class="">
> // Make sure the line table doesn't jump back into the body for<br class="">
> // the ret after it's been at EndLoc.<br class="">
> EmitRetDbgLoc = false;<br class="">
> @@ -250,6 +248,8 @@ void CodeGenFunction::FinishFunction(Sou<br class="">
> if (CGDebugInfo *DI = getDebugInfo())<br class="">
> if (OnlySimpleReturnStmts)<br class="">
> DI->EmitLocation(Builder, EndLoc);<br class="">
> +<br class="">
> + PopCleanupBlocks(PrologueCleanupDepth);<br class="">
> }<br class="">
><br class="">
> // Emit function epilog (to return).<br class="">
><br class="">
> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h<br class="">
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=228181&r1=228180&r2=228181&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=228181&r1=228180&r2=228181&view=diff</a><br class="">
> ==============================================================================<br class="">
> --- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)<br class="">
> +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Wed Feb 4 13:47:54 2015<br class="">
> @@ -567,7 +567,10 @@ public:<br class="">
><br class="">
> // If we should perform a cleanup, force them now. Note that<br class="">
> // this ends the cleanup scope before rescoping any labels.<br class="">
> - if (PerformCleanup) ForceCleanup();<br class="">
> + if (PerformCleanup) {<br class="">
> + ApplyDebugLocation DL(CGF, Range.getEnd());<br class="">
> + ForceCleanup();<br class="">
> + }<br class="">
<br class="">
</div></div>This also looks super-dangerous for the same reason. What if the last location was empty?<br class="">
<span class="HOEnZb"><font color="#888888" class=""><br class="">
-- adrian<br class="">
</font></span><div class="HOEnZb"><div class="h5">> }<br class="">
><br class="">
> /// \brief Force the emission of cleanups now, instead of waiting<br class="">
><br class="">
> Modified: cfe/trunk/test/CodeGenCXX/debug-info-line.cpp<br class="">
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-line.cpp?rev=228181&r1=228180&r2=228181&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-line.cpp?rev=228181&r1=228180&r2=228181&view=diff</a><br class="">
> ==============================================================================<br class="">
> --- cfe/trunk/test/CodeGenCXX/debug-info-line.cpp (original)<br class="">
> +++ cfe/trunk/test/CodeGenCXX/debug-info-line.cpp Wed Feb 4 13:47:54 2015<br class="">
> @@ -259,6 +259,21 @@ void f21() {<br class="">
> f21_b();<br class="">
> }<br class="">
><br class="">
> +// CHECK-LABEL: define<br class="">
> +struct f22_dtor {<br class="">
> + ~f22_dtor();<br class="">
> +};<br class="">
> +void f22() {<br class="">
> + {<br class="">
> + f22_dtor f;<br class="">
> + src();<br class="">
> +// CHECK: call {{.*}}src<br class="">
> +// CHECK: call {{.*}}, !dbg [[DBG_F22:![0-9]*]]<br class="">
> +// CHECK: call {{.*}}, !dbg [[DBG_F22]]<br class="">
> +#line 2400<br class="">
> + }<br class="">
> +}<br class="">
> +<br class="">
> // CHECK: [[DBG_F1]] = !MDLocation(line: 100,<br class="">
> // CHECK: [[DBG_FOO_VALUE]] = !MDLocation(line: 200,<br class="">
> // CHECK: [[DBG_FOO_REF]] = !MDLocation(line: 202,<br class="">
><br class="">
> Modified: cfe/trunk/test/CodeGenCXX/linetable-cleanup.cpp<br class="">
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/linetable-cleanup.cpp?rev=228181&r1=228180&r2=228181&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/linetable-cleanup.cpp?rev=228181&r1=228180&r2=228181&view=diff</a><br class="">
> ==============================================================================<br class="">
> --- cfe/trunk/test/CodeGenCXX/linetable-cleanup.cpp (original)<br class="">
> +++ cfe/trunk/test/CodeGenCXX/linetable-cleanup.cpp Wed Feb 4 13:47:54 2015<br class="">
> @@ -4,8 +4,8 @@<br class="">
> // simple return expressions.<br class="">
><br class="">
> // CHECK: define {{.*}}foo<br class="">
> -// CHECK: call void @_ZN1CD1Ev(%class.C* {{.*}}), !dbg ![[CLEANUP:[0-9]+]]<br class="">
> -// CHECK: ret i32 0, !dbg ![[RET:[0-9]+]]<br class="">
> +// CHECK: call void @_ZN1CD1Ev(%class.C* {{.*}}), !dbg ![[RET:[0-9]+]]<br class="">
> +// CHECK: ret i32 0, !dbg ![[RET]]<br class="">
><br class="">
> // CHECK: define {{.*}}bar<br class="">
> // CHECK: ret void, !dbg ![[RETBAR:[0-9]+]]<br class="">
> @@ -23,9 +23,8 @@ int foo()<br class="">
> {<br class="">
> C c;<br class="">
> c.i = 42;<br class="">
> - // This breakpoint should be at/before the cleanup code.<br class="">
> - // CHECK: ![[CLEANUP]] = !MDLocation(line: [[@LINE+1]], scope: !{{.*}})<br class="">
> return 0;<br class="">
> + // This breakpoint should be at/before the cleanup code.<br class="">
> // CHECK: ![[RET]] = !MDLocation(line: [[@LINE+1]], scope: !{{.*}})<br class="">
> }<br class="">
><br class="">
><br class="">
> Modified: cfe/trunk/test/CodeGenObjC/arc-linetable.m<br class="">
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-linetable.m?rev=228181&r1=228180&r2=228181&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-linetable.m?rev=228181&r1=228180&r2=228181&view=diff</a><br class="">
> ==============================================================================<br class="">
> --- cfe/trunk/test/CodeGenObjC/arc-linetable.m (original)<br class="">
> +++ cfe/trunk/test/CodeGenObjC/arc-linetable.m Wed Feb 4 13:47:54 2015<br class="">
> @@ -4,8 +4,8 @@<br class="">
><br class="">
> // CHECK: define {{.*}}testNoSideEffect<br class="">
> // CHECK: call void @objc_storeStrong{{.*}}<br class="">
> -// CHECK: call void @objc_storeStrong{{.*}} !dbg ![[ARC1:[0-9]+]]<br class="">
> -// CHECK: ret {{.*}} !dbg ![[RET1:[0-9]+]]<br class="">
> +// CHECK: call void @objc_storeStrong{{.*}} !dbg ![[RET1:[0-9]+]]<br class="">
> +// CHECK: ret {{.*}} !dbg ![[RET1]]<br class="">
><br class="">
> // CHECK: define {{.*}}testNoCleanup<br class="">
> // CHECK: ret {{.*}} !dbg ![[RET2:[0-9]+]]<br class="">
> @@ -21,8 +21,8 @@<br class="">
><br class="">
> // CHECK: define {{.*}}testVoid<br class="">
> // CHECK: call void @objc_storeStrong{{.*}}<br class="">
> -// CHECK: call void @objc_storeStrong{{.*}} !dbg ![[ARC5:[0-9]+]]<br class="">
> -// CHECK: ret {{.*}} !dbg ![[RET5:[0-9]+]]<br class="">
> +// CHECK: call void @objc_storeStrong{{.*}} !dbg ![[RET5:[0-9]+]]<br class="">
> +// CHECK: ret {{.*}} !dbg ![[RET5]]<br class="">
><br class="">
> // CHECK: define {{.*}}testVoidNoReturn<br class="">
> // CHECK: @objc_msgSend{{.*}} !dbg ![[MSG6:[0-9]+]]<br class="">
> @@ -57,9 +57,8 @@ typedef signed char BOOL;<br class="">
> // CHECK: ![[TESTNOSIDEEFFECT:.*]] = {{.*}}[ DW_TAG_subprogram ] [line [[@LINE+1]]] [local] [def] [-[AppDelegate testNoSideEffect:]]<br class="">
> - (int)testNoSideEffect:(NSString *)foo {<br class="">
> int x = 1;<br class="">
> - // CHECK: ![[ARC1]] = !MDLocation(line: [[@LINE+1]], scope: ![[TESTNOSIDEEFFECT]])<br class="">
> return 1; // Return expression<br class="">
> - // CHECK: ![[RET1]] = !MDLocation(line: [[@LINE+1]], scope: !{{.*}})<br class="">
> + // CHECK: ![[RET1]] = !MDLocation(line: [[@LINE+1]], scope: ![[TESTNOSIDEEFFECT]])<br class="">
> } // Cleanup + Ret<br class="">
><br class="">
> - (int)testNoCleanup {<br class="">
> @@ -82,7 +81,6 @@ typedef signed char BOOL;<br class="">
> }<br class="">
><br class="">
> - (void)testVoid:(NSString *)foo {<br class="">
> - // CHECK: ![[ARC5]] = !MDLocation(line: [[@LINE+1]], scope: !{{.*}})<br class="">
> return;<br class="">
> // CHECK: ![[RET5]] = !MDLocation(line: [[@LINE+1]], scope: !{{.*}})<br class="">
> }<br class="">
><br class="">
><br class="">
> _______________________________________________<br class="">
> cfe-commits mailing list<br class="">
> <a href="mailto:cfe-commits@cs.uiuc.edu" class="">cfe-commits@cs.uiuc.edu</a><br class="">
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank" class="">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br class="">
<br class="">
</div></div></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></body></html>