<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 12, 2016 at 2:55 PM, Robinson, Paul <span dir="ltr"><<a href="mailto:paul.robinson@sony.com" target="_blank">paul.robinson@sony.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">A declaration that gets used within the CU generally does get a debug-info description.</span></p></div></div></blockquote><div><br></div><div>It does except if it is a static data member:</div><div>$ cat t.cpp</div><div><div>struct S {</div><div> static int i;</div><div>};</div><div>int &gv = &S::i;</div></div><div>$ ~/llvm/Debug+Asserts/bin/clang t.cpp -target x86_64-gnu-linux -g -S -emit-llvm -o -</div><div><div>; ModuleID = 't.cpp'</div><div>source_filename = "t.cpp"</div><div>target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"</div><div>target triple = "x86_64--linux-gnu"</div><div><br></div><div>@_ZN1S1iE = external global i32, align 4</div><div>@gv = global i32* @_ZN1S1iE, align 8</div><div><br></div><div>!<a href="http://llvm.dbg.cu">llvm.dbg.cu</a> = !{!0}</div><div>!llvm.module.flags = !{!7, !8}</div><div>!llvm.ident = !{!9}</div><div><br></div><div>!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 (trunk 275169) (llvm/trunk 275188)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3)</div><div>!1 = !DIFile(filename: "t.cpp", directory: "/usr/local/google/home/majnemer")</div><div>!2 = !{}</div><div>!3 = !{!4}</div><div>!4 = distinct !DIGlobalVariable(name: "gv", scope: !0, file: !1, line: 4, type: !5, isLocal: false, isDefinition: true, variable: i32** @gv)</div><div>!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64, align: 64)</div><div>!6 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)</div><div>!7 = !{i32 2, !"Dwarf Version", i32 4}</div><div>!8 = !{i32 2, !"Debug Info Version", i32 3}</div><div>!9 = !{!"clang version 3.9.0 (trunk 275169) (llvm/trunk 275188)"}</div></div><div><br></div><div>Note that there is no DIGlobalVariable for S::i. I agree that this is not great behavior. I merely changed a dllimport'd template instantiation of a static data member to behave the same way, poor, way a declaration is treated.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">I think no DWARF-using target has dllimport (yet) so you are actually handling a new situation here. Being unable to find the entity in the dllimport-using
CU is not a friendly debugging experience.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">--paulr<u></u><u></u></span></p>
<p class="MsoNormal"><a name="m_-7638245665330439535__MailEndCompose"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></a></p>
<div style="border-style:none none none solid;border-left-width:1.5pt;border-left-color:blue;padding:0in 0in 0in 4pt">
<div>
<div style="border-style:solid none none;border-top-width:1pt;border-top-color:rgb(181,196,223);padding:3pt 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10pt;font-family:Tahoma,sans-serif">From:</span></b><span style="font-size:10pt;font-family:Tahoma,sans-serif"> David Majnemer [mailto:<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>]
<br>
<b>Sent:</b> Tuesday, July 12, 2016 2:07 PM</span></p><div><div class="h5"><br>
<b>To:</b> Robinson, Paul<br>
<b>Cc:</b> cfe-commits (<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>)<br>
<b>Subject:</b> Re: r275040 - [CodeGen] Treat imported static local variables as declarations<u></u><u></u></div></div><p></p>
</div>
</div><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Tue, Jul 12, 2016 at 2:02 PM, Robinson, Paul <<a href="mailto:paul.robinson@sony.com" target="_blank">paul.robinson@sony.com</a>> wrote:<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">I was asking for the debug info to describe the entity as a declaration, rather than a definition.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Instead you eliminated the debug-info description entirely. These are pretty different things.</span><u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I treated the dllimported entity the same way we currently treat declarations: ignore them.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">I don't have the bandwidth to generically improve debug info beyond what we can do for DWARF/GDB targets.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border-style:none none none solid;border-left-width:1pt;border-left-color:rgb(204,204,204);padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">--paulr</span><u></u><u></u></p>
<p class="MsoNormal"><a name="m_-7638245665330439535_m_1414457392568013182__MailEndCompose"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span></a><u></u><u></u></p>
<div style="border-style:none none none solid;border-left-width:1.5pt;border-left-color:blue;padding:0in 0in 0in 4pt">
<div>
<div style="border-style:solid none none;border-top-width:1pt;border-top-color:rgb(181,196,223);padding:3pt 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10pt;font-family:Tahoma,sans-serif">From:</span></b><span style="font-size:10pt;font-family:Tahoma,sans-serif"> David Majnemer [mailto:<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>]
<br>
<b>Sent:</b> Monday, July 11, 2016 12:27 PM</span><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><br>
<b>To:</b> Robinson, Paul<br>
<b>Cc:</b> cfe-commits (<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>)<br>
<b>Subject:</b> Re: r275040 - [CodeGen] Treat imported static local variables as declarations<u></u><u></u></p>
</div>
</div>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">On Mon, Jul 11, 2016 at 11:45 AM, Robinson, Paul <<a href="mailto:paul.robinson@sony.com" target="_blank">paul.robinson@sony.com</a>> wrote:<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">It was not particularly obvious that by "static local variables" you actually meant "template static
data members."</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Now I can tell that this is not addressing what I was asking about in the comment on r274986.</span><u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">I'm not sure I understand. How is this not addressing what you are asking for? We will no longer emit a DIGlobalVariable for the imported static data member.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border-style:none none none solid;border-left-width:1pt;border-left-color:rgb(204,204,204);padding:0in 0in 0in 6pt;margin:5pt 0in 5pt 4.8pt">
<div>
<div>
<p class="MsoNormal"><a name="m_-7638245665330439535_m_1414457392568013182_m_3121086262564605"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">--paulr</span></a><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span><u></u><u></u></p>
<div style="border-style:none none none solid;border-left-width:1.5pt;border-left-color:blue;padding:0in 0in 0in 4pt">
<div>
<div style="border-style:solid none none;border-top-width:1pt;border-top-color:rgb(181,196,223);padding:3pt 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10pt;font-family:Tahoma,sans-serif">From:</span></b><span style="font-size:10pt;font-family:Tahoma,sans-serif"> David Majnemer [mailto:<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>]
<br>
<b>Sent:</b> Monday, July 11, 2016 9:53 AM<br>
<b>To:</b> Robinson, Paul<br>
<b>Cc:</b> cfe-commits (<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>)<br>
<b>Subject:</b> Re: r275040 - [CodeGen] Treat imported static local variables as declarations</span><u></u><u></u></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">On Mon, Jul 11, 2016 at 9:48 AM, Robinson, Paul <<a href="mailto:paul.robinson@sony.com" target="_blank">paul.robinson@sony.com</a>> wrote:<u></u><u></u></p>
<p class="MsoNormal">This changes the IR but not the debug-info metadata?<br>
--paulr<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">The net effect is that the debug-info metadata is not generated for such static members.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border-style:none none none solid;border-left-width:1pt;border-left-color:rgb(204,204,204);padding:0in 0in 0in 6pt;margin:5pt 0in 5pt 4.8pt">
<div>
<div>
<p class="MsoNormal"><br>
> -----Original Message-----<br>
> From: cfe-commits [mailto:<a href="mailto:cfe-commits-bounces@lists.llvm.org" target="_blank">cfe-commits-bounces@lists.llvm.org</a>] On Behalf Of<br>
> David Majnemer via cfe-commits<br>
> Sent: Sunday, July 10, 2016 9:28 PM<br>
> To: <a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
> Subject: r275040 - [CodeGen] Treat imported static local variables as<br>
> declarations<br>
><br>
> Author: majnemer<br>
> Date: Sun Jul 10 23:28:21 2016<br>
> New Revision: 275040<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=275040&view=rev" target="_blank">
http://llvm.org/viewvc/llvm-project?rev=275040&view=rev</a><br>
> Log:<br>
> [CodeGen] Treat imported static local variables as declarations<br>
><br>
> Imported variables cannot really be definitions for the purposes of<br>
> IR generation.<br>
><br>
> Modified:<br>
> cfe/trunk/lib/CodeGen/CGDeclCXX.cpp<br>
> cfe/trunk/lib/CodeGen/CodeGenModule.cpp<br>
> cfe/trunk/test/CodeGenCXX/dllimport.cpp<br>
><br>
> Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=275040&r1=275039&r2=275040<br>
> &view=diff<br>
> ==========================================================================<br>
> ====<br>
> --- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)<br>
> +++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Sun Jul 10 23:28:21 2016<br>
> @@ -323,10 +323,6 @@ CodeGenModule::EmitCXXGlobalVarDeclInitF<br>
> D->hasAttr<CUDASharedAttr>()))<br>
> return;<br>
><br>
> - // DLL imported variables will be initialized by the export side.<br>
> - if (D->hasAttr<DLLImportAttr>())<br>
> - return;<br>
> -<br>
> // Check if we've already initialized this decl.<br>
> auto I = DelayedCXXInitPosition.find(D);<br>
> if (I != DelayedCXXInitPosition.end() && I->second == ~0U)<br>
><br>
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=275040&r1=275039&r2=27<br>
> 5040&view=diff<br>
> ==========================================================================<br>
> ====<br>
> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)<br>
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sun Jul 10 23:28:21 2016<br>
> @@ -2851,6 +2851,10 @@ static void ReplaceUsesOfNonProtoTypeWit<br>
> }<br>
><br>
> void CodeGenModule::HandleCXXStaticMemberVarInstantiation(VarDecl *VD) {<br>
> + auto DK = VD->isThisDeclarationADefinition();<br>
> + if (DK == VarDecl::Definition && VD->hasAttr<DLLImportAttr>())<br>
> + return;<br>
> +<br>
> TemplateSpecializationKind TSK = VD->getTemplateSpecializationKind();<br>
> // If we have a definition, this might be a deferred decl. If the<br>
> // instantiation is explicit, make sure we emit it at the end.<br>
><br>
> Modified: cfe/trunk/test/CodeGenCXX/dllimport.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/test/CodeGenCXX/dllimport.cpp?rev=275040&r1=275039&r2=27<br>
> 5040&view=diff<br>
> ==========================================================================<br>
> ====<br>
> --- cfe/trunk/test/CodeGenCXX/dllimport.cpp (original)<br>
> +++ cfe/trunk/test/CodeGenCXX/dllimport.cpp Sun Jul 10 23:28:21 2016<br>
> @@ -676,7 +676,7 @@ namespace ClassTemplateStaticDef {<br>
> static int x;<br>
> };<br>
> template <typename T> int S<T>::x;<br>
> - // MSC-DAG: @"\01?x@?$S@H@ClassTemplateStaticDef@@2HA" =<br>
> available_externally dllimport global i32 0<br>
> + // MSC-DAG: @"\01?x@?$S@H@ClassTemplateStaticDef@@2HA" = external<br>
> dllimport global i32<br>
> int f() { return S<int>::x; }<br>
><br>
> // Partial class template specialization static field:<br>
> @@ -685,7 +685,7 @@ namespace ClassTemplateStaticDef {<br>
> static int x;<br>
> };<br>
> template <typename A> int T<A*>::x;<br>
> - // GNU-DAG: @_ZN22ClassTemplateStaticDef1TIPvE1xE =<br>
> available_externally dllimport global i32 0<br>
> + // GNU-DAG: @_ZN22ClassTemplateStaticDef1TIPvE1xE = external dllimport<br>
> global i32<br>
> int g() { return T<void*>::x; }<br>
> }<br>
><br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" target="_blank">
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><u></u><u></u></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div></div></div>
</div>
</div>
</blockquote></div><br></div></div>