[PATCH] DECL_ASSEMBLER_NAME and friends
authorNathan Sidwell <nathan@acm.org>
Wed, 11 Oct 2017 16:35:18 +0000 (16:35 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Wed, 11 Oct 2017 16:35:18 +0000 (16:35 +0000)
https://gcc.gnu.org/ml/gcc-patches/2017-10/msg00582.html
* tree.h (DECL_ASSEMBLER_NAME_SET_P): Don't check
HAS_DECL_ASSEMBLER_NAME_P.
* gimple-expr.c (gimple_decl_printable_name: Check
HAS_DECL_ASSEMBLER_NAME_P too.
* ipa-utils.h (type_in_anonymous_namespace_p): Check
DECL_ASSEMBLER_NAME_SET_P of TYPE_NAME.
(odr_type_p): No need to assert TYPE_NAME is a TYPE_DECL.
* passes.c (rest_of_decl_compilation): Check
HAS_DECL_ASSEMBLER_NAME_P too.
* recog.c (verify_changes): Likewise.
* tree-pretty-print.c (dump_decl_name): Likewise.
* tree-ssa-structalias.c (alias_get_name): Likewise.  Reimplement.

c/
* c-decl.c (grokdeclarator): Check HAS_DECL_ASSEMBLER_NAME_P too.

From-SVN: r253649

gcc/ChangeLog
gcc/c/ChangeLog
gcc/c/c-decl.c
gcc/gimple-expr.c
gcc/ipa-utils.h
gcc/passes.c
gcc/recog.c
gcc/tree-pretty-print.c
gcc/tree-ssa-structalias.c
gcc/tree.h

index 273f561fd8720f8c499de4d93fb29895015a0f6f..d2518321cdab1a3922b44e6c263fa9f91d51a30a 100644 (file)
@@ -1,5 +1,18 @@
 2017-10-11  Nathan Sidwell  <nathan@acm.org>
 
+       * tree.h (DECL_ASSEMBLER_NAME_SET_P): Don't check
+       HAS_DECL_ASSEMBLER_NAME_P.
+       * gimple-expr.c (gimple_decl_printable_name: Check
+       HAS_DECL_ASSEMBLER_NAME_P too.
+       * ipa-utils.h (type_in_anonymous_namespace_p): Check
+       DECL_ASSEMBLER_NAME_SET_P of TYPE_NAME.
+       (odr_type_p): No need to assert TYPE_NAME is a TYPE_DECL.
+       * passes.c (rest_of_decl_compilation): Check
+       HAS_DECL_ASSEMBLER_NAME_P too.
+       * recog.c (verify_changes): Likewise.
+       * tree-pretty-print.c (dump_decl_name): Likewise.
+       * tree-ssa-structalias.c (alias_get_name): Likewise.  Reimplement.
+
        * tree.h (DECL_ASSEMBLER_NAME_RAW): New.
        (SET_DECL_ASSEMBLER_NAME): Use it.
        (DECL_ASSEMBLER_NAME_SET_P): Likewise.
index 822d0227ee81fca779ca00734918b4b2b7dcaa97..baf57c1f95add0028dd816f7f1a7c5a14a6ca298 100644 (file)
@@ -1,3 +1,7 @@
+2017-10-11  Nathan Sidwell  <nathan@acm.org>
+
+       * c-decl.c (grokdeclarator): Check HAS_DECL_ASSEMBLER_NAME_P too.
+
 2017-10-10  Richard Sandiford  <richard.sandiford@linaro.org>
 
        * c-parser.c (c_parser_cilk_clause_vectorlength): Use wi::to_wide when
index 724d193f01f74a8cb47db3ec8b728603092a2f8c..26b34ab3e50ab461fb7a228688c42895345ff4fc 100644 (file)
@@ -7011,7 +7011,8 @@ grokdeclarator (const struct c_declarator *declarator,
 
   /* This is the earliest point at which we might know the assembler
      name of a variable.  Thus, if it's known before this, die horribly.  */
-    gcc_assert (!DECL_ASSEMBLER_NAME_SET_P (decl));
+    gcc_assert (!HAS_DECL_ASSEMBLER_NAME_P (decl)
+               || !DECL_ASSEMBLER_NAME_SET_P (decl));
 
     if (warn_cxx_compat
        && VAR_P (decl)
index c1771fcf1d0551a7fb398a2e080e401e8ba05c33..324f101658515ec2a2d3480af9ceb9d588a635d2 100644 (file)
@@ -337,9 +337,8 @@ gimple_decl_printable_name (tree decl, int verbosity)
   if (!DECL_NAME (decl))
     return NULL;
 
-  if (DECL_ASSEMBLER_NAME_SET_P (decl))
+  if (HAS_DECL_ASSEMBLER_NAME_P (decl) && DECL_ASSEMBLER_NAME_SET_P (decl))
     {
-      const char *str, *mangled_str;
       int dmgl_opts = DMGL_NO_OPTS;
 
       if (verbosity >= 2)
@@ -352,9 +351,10 @@ gimple_decl_printable_name (tree decl, int verbosity)
            dmgl_opts |= DMGL_PARAMS;
        }
 
-      mangled_str = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
-      str = cplus_demangle_v3 (mangled_str, dmgl_opts);
-      return (str) ? str : mangled_str;
+      const char *mangled_str
+       = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME_RAW (decl));
+      const char *str = cplus_demangle_v3 (mangled_str, dmgl_opts);
+      return str ? str : mangled_str;
     }
 
   return IDENTIFIER_POINTER (DECL_NAME (decl));
index f061c84c8a961208d7dbaba56a5bd751af10eaa5..2affbd66d13780f9fcf636a7ff5546887b923fe2 100644 (file)
@@ -217,11 +217,11 @@ type_in_anonymous_namespace_p (const_tree t)
     {
       /* C++ FE uses magic <anon> as assembler names of anonymous types.
         verify that this match with type_in_anonymous_namespace_p.  */
-      gcc_checking_assert (!in_lto_p || !DECL_ASSEMBLER_NAME_SET_P (t)
-                          || !strcmp
-                                ("<anon>",
-                                 IDENTIFIER_POINTER
-                                    (DECL_ASSEMBLER_NAME (TYPE_NAME (t)))));
+      gcc_checking_assert (!in_lto_p
+                          || !DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t))
+                          || !strcmp ("<anon>",
+                                      IDENTIFIER_POINTER
+                                      (DECL_ASSEMBLER_NAME (TYPE_NAME (t)))));
       return true;
     }
   return false;
@@ -245,14 +245,13 @@ odr_type_p (const_tree t)
   if (type_in_anonymous_namespace_p (t))
     return true;
 
-  if (TYPE_NAME (t) && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL
-      && DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t)))
+  if (TYPE_NAME (t) && DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t)))
     {
       /* C++ FE uses magic <anon> as assembler names of anonymous types.
         verify that this match with type_in_anonymous_namespace_p.  */
       gcc_checking_assert (strcmp ("<anon>",
-                                     IDENTIFIER_POINTER
-                                       (DECL_ASSEMBLER_NAME (TYPE_NAME (t)))));
+                                  IDENTIFIER_POINTER
+                                  (DECL_ASSEMBLER_NAME (TYPE_NAME (t)))));
       return true;
     }
   return false;
index 2c9add84c1d883de7de90872c4ef862f84320180..65568e052fcd7eeae32307109e4ba9c4bfb6ebe0 100644 (file)
@@ -197,7 +197,9 @@ rest_of_decl_compilation (tree decl,
 
   /* Can't defer this, because it needs to happen before any
      later function definitions are processed.  */
-  if (DECL_ASSEMBLER_NAME_SET_P (decl) && DECL_REGISTER (decl))
+  if (HAS_DECL_ASSEMBLER_NAME_P (decl)
+      && DECL_ASSEMBLER_NAME_SET_P (decl)
+      && DECL_REGISTER (decl))
     make_decl_rtl (decl);
 
   /* Forward declarations for nested functions are not "external",
index cfce0291ba03732abe98c21cccec423db95fbe4c..b8e9b1ba3a83af68ec3f3df95b068f63aafa9350 100644 (file)
@@ -408,6 +408,7 @@ verify_changes (int num)
               && REG_P (changes[i].old)
               && asm_noperands (PATTERN (object)) > 0
               && REG_EXPR (changes[i].old) != NULL_TREE
+              && HAS_DECL_ASSEMBLER_NAME_P (REG_EXPR (changes[i].old))
               && DECL_ASSEMBLER_NAME_SET_P (REG_EXPR (changes[i].old))
               && DECL_REGISTER (REG_EXPR (changes[i].old)))
        {
index 9a5eab5b2e1c88a46ec620332f997fe622619ed5..61a28c6757fbc7db468f6c86d27e47a569fd2671 100644 (file)
@@ -249,8 +249,10 @@ dump_decl_name (pretty_printer *pp, tree node, dump_flags_t flags)
 {
   if (DECL_NAME (node))
     {
-      if ((flags & TDF_ASMNAME) && DECL_ASSEMBLER_NAME_SET_P (node))
-       pp_tree_identifier (pp, DECL_ASSEMBLER_NAME (node));
+      if ((flags & TDF_ASMNAME)
+         && HAS_DECL_ASSEMBLER_NAME_P (node)
+         && DECL_ASSEMBLER_NAME_SET_P (node))
+       pp_tree_identifier (pp, DECL_ASSEMBLER_NAME_RAW (node));
       /* For DECL_NAMELESS names look for embedded uids in the
         names and sanitize them for TDF_NOUID.  */
       else if ((flags & TDF_NOUID) && DECL_NAMELESS (node))
index 407ad3759b35bf3b0cdc9e455e4b6c9c5a22b812..89135eaf312cf502616ae58ae8ca4e5c73aea2f5 100644 (file)
@@ -2849,41 +2849,33 @@ lookup_vi_for_tree (tree t)
 static const char *
 alias_get_name (tree decl)
 {
-  const char *res = NULL;
-  char *temp;
-
-  if (!dump_file)
-    return "NULL";
-
-  if (TREE_CODE (decl) == SSA_NAME)
-    {
-      res = get_name (decl);
-      if (res)
-       temp = xasprintf ("%s_%u", res, SSA_NAME_VERSION (decl));
-      else
-       temp = xasprintf ("_%u", SSA_NAME_VERSION (decl));
-      res = ggc_strdup (temp);
-      free (temp);
-    }
-  else if (DECL_P (decl))
+  const char *res = "NULL";
+  if (dump_file)
     {
-      if (DECL_ASSEMBLER_NAME_SET_P (decl))
-       res = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
-      else
+      char *temp = NULL;
+      if (TREE_CODE (decl) == SSA_NAME)
+       {
+         res = get_name (decl);
+         temp = xasprintf ("%s_%u", res ? res : "", SSA_NAME_VERSION (decl));
+       }
+      else if (HAS_DECL_ASSEMBLER_NAME_P (decl)
+              && DECL_ASSEMBLER_NAME_SET_P (decl))
+       res = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME_RAW (decl));
+      else if (DECL_P (decl))
        {
          res = get_name (decl);
          if (!res)
-           {
-             temp = xasprintf ("D.%u", DECL_UID (decl));
-             res = ggc_strdup (temp);
-             free (temp);
-           }
+           temp = xasprintf ("D.%u", DECL_UID (decl));
+       }
+
+      if (temp)
+       {
+         res = ggc_strdup (temp);
+         free (temp);
        }
     }
-  if (res != NULL)
-    return res;
 
-  return "NULL";
+  return res;
 }
 
 /* Find the variable id for tree T in the map.
index b542f5181f5d3c798705bc403dbd081dacb9f1f0..0fd383c4736707077787c0d228f2167a1b56b326 100644 (file)
@@ -2734,8 +2734,7 @@ extern void decl_value_expr_insert (tree, tree);
    the NODE might still have a DECL_ASSEMBLER_NAME -- it just hasn't been set
    yet.  */
 #define DECL_ASSEMBLER_NAME_SET_P(NODE) \
-  (HAS_DECL_ASSEMBLER_NAME_P (NODE) \
-   && DECL_ASSEMBLER_NAME_RAW (NODE) != NULL_TREE)
+  (DECL_ASSEMBLER_NAME_RAW (NODE) != NULL_TREE)
 
 /* Set the DECL_ASSEMBLER_NAME for NODE to NAME.  */
 #define SET_DECL_ASSEMBLER_NAME(NODE, NAME) \