[gcc/devel/omp/gcc-16] DWARF address space for variables

Sandra Loosemore via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:c3a3ef9d15b27233ca81e4738d32c01f277684da

commit c3a3ef9d15b27233ca81e4738d32c01f277684da
Author: Andrew Stubbs <[email protected]>
Date:   Fri Jan 15 11:26:46 2021 +0000

    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.cc (add_location_or_const_value_attribute): Set
            DW_AT_address_class, if appropriate.

Diff:
---
 gcc/dwarf2out.cc | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
index 86bbba3aa9f5..6b10a4f80bba 100644
--- a/gcc/dwarf2out.cc
+++ b/gcc/dwarf2out.cc
@@ -21346,6 +21346,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;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.