r275040 - [CodeGen] Treat imported static local variables as declarations

Robinson, Paul via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 12 14:55:46 PDT 2016


A declaration that gets used within the CU generally does get a debug-info description.
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.
--paulr

From: David Majnemer [mailto:david.majnemer at gmail.com]
Sent: Tuesday, July 12, 2016 2:07 PM
To: Robinson, Paul
Cc: cfe-commits (cfe-commits at lists.llvm.org)
Subject: Re: r275040 - [CodeGen] Treat imported static local variables as declarations



On Tue, Jul 12, 2016 at 2:02 PM, Robinson, Paul <paul.robinson at sony.com<mailto:paul.robinson at sony.com>> wrote:
I was asking for the debug info to describe the entity as a declaration, rather than a definition.
Instead you eliminated the debug-info description entirely.  These are pretty different things.

I treated the dllimported entity the same way we currently treat declarations: ignore them.
I don't have the bandwidth to generically improve debug info beyond what we can do for DWARF/GDB targets.

--paulr

From: David Majnemer [mailto:david.majnemer at gmail.com<mailto:david.majnemer at gmail.com>]
Sent: Monday, July 11, 2016 12:27 PM

To: Robinson, Paul
Cc: cfe-commits (cfe-commits at lists.llvm.org<mailto:cfe-commits at lists.llvm.org>)
Subject: Re: r275040 - [CodeGen] Treat imported static local variables as declarations



On Mon, Jul 11, 2016 at 11:45 AM, Robinson, Paul <paul.robinson at sony.com<mailto:paul.robinson at sony.com>> wrote:
It was not particularly obvious that by "static local variables" you actually meant "template static data members."
Now I can tell that this is not addressing what I was asking about in the comment on r274986.

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.

--paulr

From: David Majnemer [mailto:david.majnemer at gmail.com<mailto:david.majnemer at gmail.com>]
Sent: Monday, July 11, 2016 9:53 AM
To: Robinson, Paul
Cc: cfe-commits (cfe-commits at lists.llvm.org<mailto:cfe-commits at lists.llvm.org>)
Subject: Re: r275040 - [CodeGen] Treat imported static local variables as declarations



On Mon, Jul 11, 2016 at 9:48 AM, Robinson, Paul <paul.robinson at sony.com<mailto:paul.robinson at sony.com>> wrote:
This changes the IR but not the debug-info metadata?
--paulr

The net effect is that the debug-info metadata is not generated for such static members.


> -----Original Message-----
> From: cfe-commits [mailto:cfe-commits-bounces at lists.llvm.org<mailto:cfe-commits-bounces at lists.llvm.org>] On Behalf Of
> David Majnemer via cfe-commits
> Sent: Sunday, July 10, 2016 9:28 PM
> To: cfe-commits at lists.llvm.org<mailto:cfe-commits at lists.llvm.org>
> Subject: r275040 - [CodeGen] Treat imported static local variables as
> declarations
>
> Author: majnemer
> Date: Sun Jul 10 23:28:21 2016
> New Revision: 275040
>
> URL: http://llvm.org/viewvc/llvm-project?rev=275040&view=rev
> Log:
> [CodeGen] Treat imported static local variables as declarations
>
> Imported variables cannot really be definitions for the purposes of
> IR generation.
>
> Modified:
>     cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
>     cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>     cfe/trunk/test/CodeGenCXX/dllimport.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=275040&r1=275039&r2=275040
> &view=diff
> ==========================================================================
> ====
> --- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Sun Jul 10 23:28:21 2016
> @@ -323,10 +323,6 @@ CodeGenModule::EmitCXXGlobalVarDeclInitF
>         D->hasAttr<CUDASharedAttr>()))
>      return;
>
> -  // DLL imported variables will be initialized by the export side.
> -  if (D->hasAttr<DLLImportAttr>())
> -    return;
> -
>    // Check if we've already initialized this decl.
>    auto I = DelayedCXXInitPosition.find(D);
>    if (I != DelayedCXXInitPosition.end() && I->second == ~0U)
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=275040&r1=275039&r2=27
> 5040&view=diff
> ==========================================================================
> ====
> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sun Jul 10 23:28:21 2016
> @@ -2851,6 +2851,10 @@ static void ReplaceUsesOfNonProtoTypeWit
>  }
>
>  void CodeGenModule::HandleCXXStaticMemberVarInstantiation(VarDecl *VD) {
> +  auto DK = VD->isThisDeclarationADefinition();
> +  if (DK == VarDecl::Definition && VD->hasAttr<DLLImportAttr>())
> +    return;
> +
>    TemplateSpecializationKind TSK = VD->getTemplateSpecializationKind();
>    // If we have a definition, this might be a deferred decl. If the
>    // instantiation is explicit, make sure we emit it at the end.
>
> Modified: cfe/trunk/test/CodeGenCXX/dllimport.cpp
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/test/CodeGenCXX/dllimport.cpp?rev=275040&r1=275039&r2=27
> 5040&view=diff
> ==========================================================================
> ====
> --- cfe/trunk/test/CodeGenCXX/dllimport.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/dllimport.cpp Sun Jul 10 23:28:21 2016
> @@ -676,7 +676,7 @@ namespace ClassTemplateStaticDef {
>      static int x;
>    };
>    template <typename T> int S<T>::x;
> -  // MSC-DAG: @"\01?x@?$S at H@ClassTemplateStaticDef@@2HA" =
> available_externally dllimport global i32 0
> +  // MSC-DAG: @"\01?x@?$S at H@ClassTemplateStaticDef@@2HA" = external
> dllimport global i32
>    int f() { return S<int>::x; }
>
>    // Partial class template specialization static field:
> @@ -685,7 +685,7 @@ namespace ClassTemplateStaticDef {
>      static int x;
>    };
>    template <typename A> int T<A*>::x;
> -  // GNU-DAG: @_ZN22ClassTemplateStaticDef1TIPvE1xE =
> available_externally dllimport global i32 0
> +  // GNU-DAG: @_ZN22ClassTemplateStaticDef1TIPvE1xE = external dllimport
> global i32
>    int g() { return T<void*>::x; }
>  }
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org<mailto:cfe-commits at lists.llvm.org>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160712/8183599d/attachment-0001.html>


More information about the cfe-commits mailing list