[debug-early] call debug_hooks->late_global_decl for optimized away symbols

Aldy Hernandez aldyh@redhat.com
Thu May 7 15:14:00 GMT 2015


And now for my next trick, I will revert all changes I had made to the 
non-dwarf backends.

No special kludges will be needed for stabs et al, with my previous 
patch in place.

Tested on:

     x86_64-unknown-linux-gnu
     powerpc-ibm-aix7.1.2.0
     powerpc64-unknown-linux-gnu
     aarch64-unknown-linux-gnu

Committing to branch.
Aldy

p.s. I bet even David is happy now :).
-------------- next part --------------
commit 6e0a19c9c9d955a398eb779f45f8381ad7d332ae
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Thu May 7 08:10:23 2015 -0700

    Revert debug-early changes to non dwarf backends.

diff --git a/gcc/dbxout.c b/gcc/dbxout.c
index 9f555c3..0c9a327 100644
--- a/gcc/dbxout.c
+++ b/gcc/dbxout.c
@@ -1346,65 +1346,24 @@ dbxout_function_decl (tree decl)
 
 #endif /* DBX_DEBUGGING_INFO  */
 
-/* Return true if a variable is really a constant and not written in
-   memory.  */
-
-static bool
-decl_is_really_constant (tree decl)
-{
-  return ((TREE_CODE (decl) == VAR_DECL
-	   || TREE_CODE (decl) == RESULT_DECL)
-	  && !DECL_EXTERNAL (decl)
-	  && TREE_STATIC (decl)
-	  && TREE_READONLY (decl)
-	  && DECL_INITIAL (decl) != 0
-	  && tree_fits_shwi_p (DECL_INITIAL (decl))
-	  && ! TREE_ASM_WRITTEN (decl)
-	  && (DECL_FILE_SCOPE_P (decl)
-	      || TREE_CODE (DECL_CONTEXT (decl)) == BLOCK
-	      || TREE_CODE (DECL_CONTEXT (decl)) == NAMESPACE_DECL)
-	  && TREE_PUBLIC (decl) == 0);
-}
-
-/* Wrapper for dbxout_symbol that temporarily sets TREE_USED on the
-   DECL.  */
-
-static void
-dbxout_symbol_used (tree decl)
-{
-  int saved_tree_used = TREE_USED (decl);
-  TREE_USED (decl) = 1;
-  dbxout_symbol (decl, 0);
-  TREE_USED (decl) = saved_tree_used;
-}
-
-/* Output early debug information for a global DECL.  Called from
-   rest_of_decl_compilation during parsing.  */
-
 static void
-dbxout_early_global_decl (tree decl)
+dbxout_early_global_decl (tree decl ATTRIBUTE_UNUSED)
 {
-  /* True constant values may not appear in the symbol table, so they
-     will be missed by the late_global_decl hook.  Handle these cases
-     now, since early_global_decl will get unoptimized symbols early
-     enough-- and besides, true constants don't need location
-     information, so it's ok to handle them earlier.  */
-  if (decl_is_really_constant (decl))
-    dbxout_symbol_used (decl);
+  /* NYI for non-dwarf.  */
 }
 
-/* Output late debug information for a global DECL after location
-   information is available.  */
-
+/* Debug information for a global DECL.  Called from toplev.c after
+   compilation proper has finished.  */
 static void
-dbxout_late_global_decl (tree decl ATTRIBUTE_UNUSED)
+dbxout_late_global_decl (tree decl)
 {
-  if (TREE_CODE (decl) == VAR_DECL
-      && !DECL_EXTERNAL (decl)
-      /* Read-only constants were handled in
-	 dbxout_early_global_decl.  */
-      && !decl_is_really_constant (decl))
-    dbxout_symbol_used (decl);
+  if (TREE_CODE (decl) == VAR_DECL && !DECL_EXTERNAL (decl))
+    {
+      int saved_tree_used = TREE_USED (decl);
+      TREE_USED (decl) = 1;
+      dbxout_symbol (decl, 0);
+      TREE_USED (decl) = saved_tree_used;
+    }
 }
 
 /* This is just a function-type adapter; dbxout_symbol does exactly
@@ -2945,7 +2904,14 @@ dbxout_symbol (tree decl, int local ATTRIBUTE_UNUSED)
 	 and not written in memory, inform the debugger.
 
 	 ??? Why do we skip emitting the type and location in this case?  */
-      if (decl_is_really_constant (decl))
+      if (TREE_STATIC (decl) && TREE_READONLY (decl)
+	  && DECL_INITIAL (decl) != 0
+	  && tree_fits_shwi_p (DECL_INITIAL (decl))
+	  && ! TREE_ASM_WRITTEN (decl)
+	  && (DECL_FILE_SCOPE_P (decl)
+	      || TREE_CODE (DECL_CONTEXT (decl)) == BLOCK
+	      || TREE_CODE (DECL_CONTEXT (decl)) == NAMESPACE_DECL)
+	  && TREE_PUBLIC (decl) == 0)
 	{
 	  /* The sun4 assembler does not grok this.  */
 
diff --git a/gcc/sdbout.c b/gcc/sdbout.c
index 1226f5b..029b104 100644
--- a/gcc/sdbout.c
+++ b/gcc/sdbout.c
@@ -1445,7 +1445,7 @@ sdbout_early_global_decl (tree decl ATTRIBUTE_UNUSED)
    information is available.  */
 
 static void
-sdbout_late_global_decl (tree decl ATTRIBUTE_UNUSED)
+sdbout_late_global_decl (tree decl)
 {
   if (TREE_CODE (decl) == VAR_DECL
       && !DECL_EXTERNAL (decl)


More information about the Gcc-patches mailing list