public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed][OG10] DWARF address space for variables
@ 2021-01-15 12:19 Andrew Stubbs
  0 siblings, 0 replies; only message in thread
From: Andrew Stubbs @ 2021-01-15 12:19 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 610 bytes --]

This patch adds DWARF support for "local" variables that are actually 
located in a different address space.

This situation occurs for variables shared between all the worker 
threads of an OpenACC gang. On AMD GCN the variables are allocated to 
the low-latency LDS memory associated with each physical compute unit.

The patch depends on my previous patch "amdgcn: DWARF address spaces" to 
actually do anything useful, as it uses the hook defined there. The 
patch has no effect on ports that do not define that hook.

Committed to devel/omp/gcc-10. This will be submitted to mainline in 
stage 1.

Andrew

[-- Attachment #2: 210115-og10-dwarf-address-space-vars.patch --]
[-- Type: text/x-patch, Size: 1036 bytes --]

DWARF address space for variables

Add DWARF address class attributes for variables that exist outside the
generic address space.  In particular, this is the case for gang-private
variables in OpenACC offload kernels.

gcc/ChangeLog:

	* dwarf2out.c (add_location_or_const_value_attribute): Set
	DW_AT_address_class, if appropriate.

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index a4a1b934dc7..dedfeaf865f 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -20294,6 +20294,15 @@ add_location_or_const_value_attribute (dw_die_ref die, tree decl, bool cache_p)
   if (list)
     {
       add_AT_location_description (die, DW_AT_location, list);
+
+      addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (decl));
+      if (!ADDR_SPACE_GENERIC_P (as))
+	{
+	  int action = targetm.addr_space.debug (as);
+	  /* Positive values indicate an address_class.  */
+	  if (action >= 0)
+	    add_AT_unsigned (die, DW_AT_address_class, action);
+	}
       return true;
     }
   /* None of that worked, so it must not really have a location;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-01-15 12:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-15 12:19 [committed][OG10] DWARF address space for variables Andrew Stubbs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).