This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Extend DECL_IGNORED_P for functions


Hi,

in http://gcc.gnu.org/ml/gcc-patches/2007-02/msg01079.html I proposed a patch 
to extend DECL_IGNORED_P for functions: if it is set on a FUNCTION_DECL, the 
body of the function is entirely ignored for debugging purposes.  This was 
accepted and installed but eventually reverted because the implementation 
(temporarily pointing the debug interface to the null one) was problematic.

The attached patch reimplements the same extension differently.  Tested (GCC, 
GDB) on i586-suse-linux, OK for mainline?


2009-04-22  Eric Botcazou  <ebotcazou@adacore.com>

	* tree.h (DECL_IGNORED_P): Document further effect for FUNCTION_DECL.
	* dbxout.c (dbxout_function_end): Do not test DECL_IGNORED_P.
	(dbxout_begin_function): Likewise.
	* final.c (dwarf2_debug_info_emitted_p): New predicate.
	(final_start_function): Do not emit debug info if DECL_IGNORED_P is
	set on the function.
	(final_end_function): Likewise.
	(final_scan_insn): Likewise.
	(rest_of_handle_final): Likewise.
	* varasm.c (assemble_start_function): Likewise.
	* config/rs6000/xcoff.h (ASM_DECLARE_FUNCTION_NAME): Likewise.


-- 
Eric Botcazou
Index: tree.h
===================================================================
--- tree.h	(revision 146578)
+++ tree.h	(working copy)
@@ -2558,7 +2558,8 @@ struct tree_decl_minimal GTY(())
   (DECL_COMMON_CHECK (NODE)->decl_common.debug_expr_is_from)
 
 /* Nonzero for a given ..._DECL node means that the name of this node should
-   be ignored for symbolic debug purposes.  */
+   be ignored for symbolic debug purposes.  Moreover, for a FUNCTION_DECL,
+   the body of the function should also be ignored.  */
 #define DECL_IGNORED_P(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.ignored_flag)
 
 /* Nonzero for a given ..._DECL node means that this node represents an
Index: final.c
===================================================================
--- final.c	(revision 146578)
+++ final.c	(working copy)
@@ -1466,6 +1466,20 @@ remap_debug_filename (const char *filena
   return ggc_strdup (s);
 }
 
+/* Return true if DWARF2 debug info can be emitted for DECL.  */
+
+static bool
+dwarf2_debug_info_emitted_p (tree decl)
+{
+  if (write_symbols != DWARF2_DEBUG && write_symbols != VMS_AND_DWARF2_DEBUG)
+    return false;
+
+  if (DECL_IGNORED_P (decl))
+    return false;
+
+  return true;
+}
+
 /* Output assembler code for the start of a function,
    and initialize some of the variables in this file
    for the new function.  The label for the function and associated
@@ -1489,10 +1503,11 @@ final_start_function (rtx first ATTRIBUT
 
   high_block_linenum = high_function_linenum = last_linenum;
 
-  (*debug_hooks->begin_prologue) (last_linenum, last_filename);
+  if (!DECL_IGNORED_P (current_function_decl))
+    debug_hooks->begin_prologue (last_linenum, last_filename);
 
 #if defined (DWARF2_UNWIND_INFO) || defined (TARGET_UNWIND_INFO)
-  if (write_symbols != DWARF2_DEBUG && write_symbols != VMS_AND_DWARF2_DEBUG)
+  if (!dwarf2_debug_info_emitted_p (current_function_decl))
     dwarf2out_begin_prologue (0, NULL);
 #endif
 
@@ -1629,17 +1644,19 @@ final_end_function (void)
 {
   app_disable ();
 
-  (*debug_hooks->end_function) (high_function_linenum);
+  if (!DECL_IGNORED_P (current_function_decl))
+    debug_hooks->end_function (high_function_linenum);
 
   /* Finally, output the function epilogue:
      code to restore the stack frame and return to the caller.  */
   targetm.asm_out.function_epilogue (asm_out_file, get_frame_size ());
 
   /* And debug output.  */
-  (*debug_hooks->end_epilogue) (last_linenum, last_filename);
+  if (!DECL_IGNORED_P (current_function_decl))
+    debug_hooks->end_epilogue (last_linenum, last_filename);
 
 #if defined (DWARF2_UNWIND_INFO)
-  if (write_symbols != DWARF2_DEBUG && write_symbols != VMS_AND_DWARF2_DEBUG
+  if (!dwarf2_debug_info_emitted_p (current_function_decl)
       && dwarf2out_do_frame ())
     dwarf2out_end_epilogue (last_linenum, last_filename);
 #endif
@@ -1820,7 +1837,8 @@ final_scan_insn (rtx insn, FILE *file, i
 	    dwarf2out_switch_text_section ();
 	  else
 #endif
-	    (*debug_hooks->switch_text_section) ();
+	  if (!DECL_IGNORED_P (current_function_decl))
+	    debug_hooks->switch_text_section ();
 
 	  switch_to_section (current_function_section ());
 	  break;
@@ -1874,7 +1892,8 @@ final_scan_insn (rtx insn, FILE *file, i
 
 	case NOTE_INSN_FUNCTION_BEG:
 	  app_disable ();
-	  (*debug_hooks->end_prologue) (last_linenum, last_filename);
+	  if (!DECL_IGNORED_P (current_function_decl))
+	    debug_hooks->end_prologue (last_linenum, last_filename);
 
 	  if ((*seen & (SEEN_EMITTED | SEEN_NOTE)) == SEEN_NOTE)
 	    {
@@ -1900,7 +1919,8 @@ final_scan_insn (rtx insn, FILE *file, i
 	      high_block_linenum = last_linenum;
 
 	      /* Output debugging info about the symbol-block beginning.  */
-	      (*debug_hooks->begin_block) (last_linenum, n);
+	      if (!DECL_IGNORED_P (current_function_decl))
+		debug_hooks->begin_block (last_linenum, n);
 
 	      /* Mark this block as output.  */
 	      TREE_ASM_WRITTEN (NOTE_BLOCK (insn)) = 1;
@@ -1934,7 +1954,8 @@ final_scan_insn (rtx insn, FILE *file, i
 	      --block_depth;
 	      gcc_assert (block_depth >= 0);
 
-	      (*debug_hooks->end_block) (high_block_linenum, n);
+	      if (!DECL_IGNORED_P (current_function_decl))
+		debug_hooks->end_block (high_block_linenum, n);
 	    }
 	  if (write_symbols == DBX_DEBUG
 	      || write_symbols == SDB_DEBUG)
@@ -1964,7 +1985,8 @@ final_scan_insn (rtx insn, FILE *file, i
 	  break;
 
 	case NOTE_INSN_VAR_LOCATION:
-	  (*debug_hooks->var_location) (insn);
+	  if (!DECL_IGNORED_P (current_function_decl))
+	    debug_hooks->var_location (insn);
 	  break;
 
 	default:
@@ -2007,8 +2029,8 @@ final_scan_insn (rtx insn, FILE *file, i
       CC_STATUS_INIT;
 #endif
 
-      if (LABEL_NAME (insn))
-	(*debug_hooks->label) (insn);
+      if (!DECL_IGNORED_P (current_function_decl) && LABEL_NAME (insn))
+	debug_hooks->label (insn);
 
       app_disable ();
 
@@ -2168,10 +2190,9 @@ final_scan_insn (rtx insn, FILE *file, i
 	  }
 	/* Output this line note if it is the first or the last line
 	   note in a row.  */
-	if (notice_source_line (insn))
-	  {
-	    (*debug_hooks->source_line) (last_linenum, last_filename);
-	  }
+	if (!DECL_IGNORED_P (current_function_decl)
+	    && notice_source_line (insn))
+	  debug_hooks->source_line (last_linenum, last_filename);
 
 	if (GET_CODE (body) == ASM_INPUT)
 	  {
@@ -4207,7 +4228,8 @@ rest_of_handle_final (void)
      *will* be routed past here.  */
 
   timevar_push (TV_SYMOUT);
-  (*debug_hooks->function_decl) (current_function_decl);
+  if (!DECL_IGNORED_P (current_function_decl))
+    debug_hooks->function_decl (current_function_decl);
   timevar_pop (TV_SYMOUT);
 
   /* Release the blocks that are linked to DECL_INITIAL() to free the memory.  */
Index: dbxout.c
===================================================================
--- dbxout.c	(revision 146578)
+++ dbxout.c	(working copy)
@@ -905,7 +905,7 @@ dbxout_finish_complex_stabs (tree sym, S
 #if defined (DBX_DEBUGGING_INFO)
 
 static void
-dbxout_function_end (tree decl)
+dbxout_function_end (tree decl ATTRIBUTE_UNUSED)
 {
   char lscope_label_name[100];
 
@@ -924,8 +924,7 @@ dbxout_function_end (tree decl)
      named sections.  */
   if (!use_gnu_debug_info_extensions
       || NO_DBX_FUNCTION_END
-      || !targetm.have_named_sections
-      || DECL_IGNORED_P (decl))
+      || !targetm.have_named_sections)
     return;
 
   /* By convention, GCC will mark the end of a function with an N_FUN
@@ -3662,9 +3661,6 @@ dbxout_begin_function (tree decl)
 {
   int saved_tree_used1;
 
-  if (DECL_IGNORED_P (decl))
-    return;
-
   saved_tree_used1 = TREE_USED (decl);
   TREE_USED (decl) = 1;
   if (DECL_NAME (DECL_RESULT (decl)) != 0)
Index: varasm.c
===================================================================
--- varasm.c	(revision 146578)
+++ varasm.c	(working copy)
@@ -1744,7 +1744,8 @@ assemble_start_function (tree decl, cons
   ASM_OUTPUT_FUNCTION_PREFIX (asm_out_file, fnname);
 #endif
 
-  (*debug_hooks->begin_function) (decl);
+  if (!DECL_IGNORED_P (decl))
+    (*debug_hooks->begin_function) (decl);
 
   /* Make function name accessible from other files, if appropriate.  */
 
Index: config/rs6000/xcoff.h
===================================================================
--- config/rs6000/xcoff.h	(revision 146578)
+++ config/rs6000/xcoff.h	(working copy)
@@ -191,7 +191,7 @@
   putc ('.', FILE);						\
   RS6000_OUTPUT_BASENAME (FILE, buffer);			\
   fputs (":\n", FILE);						\
-  if (write_symbols != NO_DEBUG)				\
+  if (write_symbols != NO_DEBUG && !DECL_IGNORED_P (DECL))	\
     xcoffout_declare_function (FILE, DECL, buffer);		\
 }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]