[PATCH] D27320: [DWARF] Put linkage-name on abstract origin even when there's a declaration

Robinson, Paul via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 1 13:59:18 PST 2016


Read the code assuming useAllLinkageNames() is false.  Then recognize that we go through applySubprogramDefinitionAttributes for both declarations and definitions (don't blame me, it was like that when I found it).

When we go through here for the declaration, there's no prior declaration, so SPDecl is null.  DeclLinkageName is empty, useAllLinkageNames() is false, and getAbstractSPDies() also returns nothing.  So the declaration does not get a linkage name.

When we come through for the definition, there is a prior declaration, so SPDecl points to it (i.e. the metadata).  DeclLinkageName is non-empty, because the declaration metadata does have a linkage name.  Therefore we once again do not emit the linkage name.

After the patch, when we come through for the definition, there is a prior declaration, so SPDecl points to the metadata.  But the declaration DIE doesn't have a linkage-name attribute, so DeclLinkageName is empty.  This allows us to emit the linkage name on the definition (which is the abstract origin).

The same thing will be true in the updated patch I'm about to upload, but we won't be looking into the DIE to figure it out.
--paulr

From: llvm-commits [mailto:llvm-commits-bounces at lists.llvm.org] On Behalf Of David Blaikie via llvm-commits
Sent: Thursday, December 01, 2016 1:50 PM
To: reviews+D27320+public+0ef1c083eb06e109 at reviews.llvm.org; echristo at gmail.com; aprantl at apple.com
Cc: llvm-commits at lists.llvm.org
Subject: Re: [PATCH] D27320: [DWARF] Put linkage-name on abstract origin even when there's a declaration

Reading the actual code - I'm now a bit confused. It looks like it's duplicating the linkage name but I thought the patch description was saying it was missing from the declaration.

I'm confused.

On Thu, Dec 1, 2016 at 1:44 PM Paul Robinson via Phabricator <reviews at reviews.llvm.org<mailto:reviews at reviews.llvm.org>> wrote:
probinson added inline comments.


================
Comment at: lib/CodeGen/AsmPrinter/DwarfUnit.cpp:1162
                       "getOrCreateSubprogramDIE");
-    DeclLinkageName = SPDecl->getLinkageName();
+    DeclLinkageName = getDieLinkageName(DeclDie);
     unsigned DeclID =
----------------
I had thought about making this
```
if (DD->useAllLinkageNames())
  DeclLinkageName = SPDecl->getLinkageName();
```
and so not needing the extra static function, but actually looking into the DIE itself seemed more robust.


https://reviews.llvm.org/D27320


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161201/22849475/attachment.html>


More information about the llvm-commits mailing list