<p dir="ltr"><br>
On Aug 28, 2013 1:46 AM, "Alexey Samsonov" <<a href="mailto:samsonov@google.com">samsonov@google.com</a>> wrote:<br>
><br>
><br>
> On Wed, Aug 28, 2013 at 4:03 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br>
>><br>
>> On Tue, Aug 27, 2013 at 1:45 AM, Dmitry Vyukov <<a href="mailto:dvyukov@google.com">dvyukov@google.com</a>> wrote:<br>
>> > On Tue, Aug 27, 2013 at 12:19 PM, Alexey Samsonov <<a href="mailto:samsonov@google.com">samsonov@google.com</a>> wrote:<br>
>> >><br>
>> >> On Tue, Aug 27, 2013 at 9:21 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br>
>> >>><br>
>> >>> Author: dblaikie<br>
>> >>> Date: Tue Aug 27 00:21:11 2013<br>
>> >>> New Revision: 189320<br>
>> >>><br>
>> >>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=189320&view=rev">http://llvm.org/viewvc/llvm-project?rev=189320&view=rev</a><br>
>> >>> Log:<br>
>> >>> PR14569: Omit debug info for thunks<br>
>> >>><br>
>> >>> This was added in r166676 based on PR13942 on the basis that tools may<br>
>> >>> need debug information for any executable code/function for some fairly<br>
>> >>> broad/non-specific purposes. It seems to me (as noted in PR14569) that<br>
>> >>> the major/only purpose is in backtraces, which should generally not<br>
>> >>> apply to thunks as they won't appear in the stack themselves.<br>
>> >><br>
>> >><br>
>> >> Are you sure that thunks may not appear in backtraces? I think I saw them in<br>
>> >> stack traces,<br>
>> >> more specifically - in stack traces produced by ThreadSanitizer.<br>
>> >> It's possible that I'm wrong, though...<br>
>> ><br>
>> > Debug info for thunks is necessary for sampling-based profilers and<br>
>> > gdb (if you step or stop in thunk).<br>
>><br>
>> In theory I would think this could just be handled using the symbol<br>
>> table - the only advantage of emitting debug info is to allow inlining<br>
>> to correctly attribute the inlined instructions to the original<br>
>> function, as I understand it (for tasks such as this anyway - where<br>
>> there's no user code that maps into the function, etc).<br>
>><br>
>> Please let me know what your thoughts on that are.<br>
><br>
><br>
> I guess debug info can be necessary to match generated thunk with<br>
> source file (this is also true for generated functions that initialize global variables etc).</p>
<p dir="ltr">In theory, at least, the debug info for the global variable or class should still be available, if a tool demangles the think/initializer name, gets the class/variable name, it should be able to use that. Maybe that's insufficient or just not the lengths these tools go to yet/today.<br>
</p>
<p dir="ltr">It would be rather useful to have concrete examples that break when this debug info is missing (perhaps file a GCC bug for it to be added there, too), but given how little size it costs, it seems reasonable to leave in for some future/current/speculated use.</p>

<p dir="ltr">>  <br>
>><br>
>><br>
>> In the mean time, given that there was no observable debug info size<br>
>> savings (which I still don't really understand/believe, but can't<br>
>> refute), I have reverted & reworked this patch to keep thunk debug<br>
>> info but to encode the name only in the linkage name in the debug<br>
>> info, not the plain name. This is sufficient to fix the relevant GDB<br>
>> test case.<br>
>><br>
>> - David<br>
>><br>
>> ><br>
>> ><br>
>> >>> By<br>
>> >>> removing them we fix PR14569 and reduce the size of Clang's debug info.<br>
>> >>><br>
>> >>> Strangely enough this doesn't seem to have a substantial impact on<br>
>> >>> Clang's self-hosted debug info (at least looking at DWO file size) size<br>
>> >>> at all. Not sure if I failed to test this correctly but I only observed<br>
>> >>> a 0.004% change in DWO file size over Clang+LLVM.<br>
>> >>><br>
>> >>> With thanks to Dinesh Dwivedi for work on this PR.<br>
>> >>><br>
>> >>> Modified:<br>
>> >>>     cfe/trunk/lib/CodeGen/CGVTables.cpp<br>
>> >>>     cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp<br>
>> >>><br>
>> >>> Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp<br>
>> >>> URL:<br>
>> >>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=189320&r1=189319&r2=189320&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=189320&r1=189319&r2=189320&view=diff</a><br>

>> >>><br>
>> >>> ==============================================================================<br>
>> >>> --- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)<br>
>> >>> +++ cfe/trunk/lib/CodeGen/CGVTables.cpp Tue Aug 27 00:21:11 2013<br>
>> >>> @@ -292,6 +292,7 @@ void CodeGenFunction::GenerateVarArgsThu<br>
>> >>>  void CodeGenFunction::GenerateThunk(llvm::Function *Fn,<br>
>> >>>                                      const CGFunctionInfo &FnInfo,<br>
>> >>>                                      GlobalDecl GD, const ThunkInfo<br>
>> >>> &Thunk) {<br>
>> >>> +  DebugInfo = NULL; // debug info for thunks is not required or desired<br>
>> >>>    const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());<br>
>> >>>    const FunctionProtoType *FPT =<br>
>> >>> MD->getType()->getAs<FunctionProtoType>();<br>
>> >>>    QualType ThisType = MD->getThisType(getContext());<br>
>> >>><br>
>> >>> Modified: cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp<br>
>> >>> URL:<br>
>> >>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp?rev=189320&r1=189319&r2=189320&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp?rev=189320&r1=189319&r2=189320&view=diff</a><br>

>> >>><br>
>> >>> ==============================================================================<br>
>> >>> --- cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp (original)<br>
>> >>> +++ cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp Tue Aug 27 00:21:11<br>
>> >>> 2013<br>
>> >>> @@ -14,4 +14,4 @@ struct C : A, B {<br>
>> >>><br>
>> >>>  void C::f() { }<br>
>> >>><br>
>> >>> -// CHECK: [ DW_TAG_subprogram ] [line 15] [def] [_ZThn{{4|8}}_N1C1fEv]<br>
>> >>> +// CHECK-NOT: [ DW_TAG_subprogram ] [line 15] [def]<br>
>> >>> [_ZThn{{4|8}}_N1C1fEv]<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">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
>> >><br>
>> >><br>
>> >><br>
>> >><br>
>> >> --<br>
>> >> Alexey Samsonov, MSK<br>
><br>
><br>
><br>
><br>
> -- <br>
> Alexey Samsonov, MSK</p>