<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 11, 2016 at 9:48 AM, 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This changes the IR but not the debug-info metadata?<br>
--paulr<br></blockquote><div><br></div><div>The net effect is that the debug-info metadata is not generated for such static members.</div><div> </div><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>
> -----Original Message-----<br>
> From: cfe-commits [mailto:<a href="mailto:cfe-commits-bounces@lists.llvm.org">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">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" rel="noreferrer" 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-" rel="noreferrer" 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-" rel="noreferrer" 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-" rel="noreferrer" 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">cfe-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div></div>