diff mbox

PATCH: Don't scan all global declarations for nothing

Message ID 20121128205412.GA5694@intel.com
State New
Headers show

Commit Message

H.J. Lu Nov. 28, 2012, 8:54 p.m. UTC
Hi,

When we are generating debug info, we still scan all global
declarations and call debug_nothing_tree on each declaration.
It is a waste of time and can add up when there are many
global declarations.  This patch skips the scan if
debug_hooks->global_decl == &debug_nothing_tree.  OK to install?

Thanks.


H.J.
---
2012-11-28  H.J. Lu  <hongjiu.lu@intel.com>

	* toplev.c (emit_debug_global_declarations): Don't scan all
	global declarations for nothing. 

c/

2012-11-28  H.J. Lu  <hongjiu.lu@intel.com>

	* c-decl.c (c_write_global_declarations): Don't call
	c_write_global_declarations_2 for nothing.
diff mbox

Patch

diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index b1c88bd..a546e1f 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -10124,7 +10124,8 @@  c_write_global_declarations (void)
 
   /* After cgraph has had a chance to emit everything that's going to
      be emitted, output debug information for globals.  */
-  if (!seen_error ())
+  if (debug_hooks->global_decl != &debug_nothing_tree
+      && !seen_error ())
     {
       timevar_push (TV_SYMOUT);
       FOR_EACH_VEC_ELT (*all_translation_units, i, t)
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 2c2898c..c203460 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -521,8 +521,10 @@  emit_debug_global_declarations (tree *vec, int len)
 {
   int i;
 
-  /* Avoid confusing the debug information machinery when there are errors.  */
-  if (seen_error ())
+  /* Avoid confusing the debug information machinery when there are
+     errors.  Don't scan all global declarations for nothing.  */
+  if (debug_hooks->global_decl == &debug_nothing_tree
+      || seen_error ())
     return;
 
   timevar_push (TV_SYMOUT);