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]

[lto][patch] fix the handling of static functions


Currently, if we see a static function being used in its original file
before being used in some other file we conclude that we don't need to
make it global. This patch fixes that.

2009-02-23  Rafael Avila de Espindola  <espindola@google.com>

	* lto.c (lto_promote_cross_file_statics): Reset context.seen_node_decls
	for each file.

Cheers,
-- 
Rafael Avila de Espindola

Google | Gordon House | Barrow Street | Dublin 4 | Ireland
Registered in Dublin, Ireland | Registration Number: 368047
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index 7a42c16..05a0d40 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -797,7 +797,6 @@ lto_promote_cross_file_statics (void)
   memset (&context, 0, sizeof (context));
   context.all_vars = lto_bitmap_alloc ();
   context.all_static_vars = lto_bitmap_alloc ();
-  context.seen_node_decls = lto_bitmap_alloc ();
 
   n_sets = VEC_length (cgraph_node_set, lto_cgraph_node_sets);
   for (i = 0; i < n_sets; i++)
@@ -806,6 +805,8 @@ lto_promote_cross_file_statics (void)
       context.set = set;
       context.visited = pointer_set_create ();
       context.static_vars_in_set = lto_bitmap_alloc ();
+      context.seen_node_decls = lto_bitmap_alloc ();
+
       for (csi = csi_start (set); !csi_end_p (csi); csi_next (&csi))
 	lto_scan_statics_in_cgraph_node (csi_node (csi), &context);
 
@@ -813,13 +814,14 @@ lto_promote_cross_file_statics (void)
         lto_scan_statics_in_remaining_global_vars (&context);
 
       bitmap_ior_into (context.all_static_vars, context.static_vars_in_set);
+
       pointer_set_destroy (context.visited);
       lto_bitmap_free (context.static_vars_in_set);
+      lto_bitmap_free (context.seen_node_decls);
     }
 
   lto_bitmap_free (context.all_vars);
   lto_bitmap_free (context.all_static_vars);
-  lto_bitmap_free (context.seen_node_decls);
 }
 
 static lto_file *current_lto_file;
diff --git a/gcc/testsuite/gcc.dg/lto/20090218-1_0.c b/gcc/testsuite/gcc.dg/lto/20090218-1_0.c
new file mode 100644
index 0000000..1dc9ee0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20090218-1_0.c
@@ -0,0 +1,4 @@
+void set_mem_alias_set ()  __attribute__ ((always_inline));
+void emit_push_insn () {
+  set_mem_alias_set ();
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20090218-1_1.c b/gcc/testsuite/gcc.dg/lto/20090218-1_1.c
new file mode 100644
index 0000000..33d4fb0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20090218-1_1.c
@@ -0,0 +1,9 @@
+int main(void)
+{
+  return 0;
+}
+static void  __attribute__ ((noinline)) get_mem_attrs () {
+}
+void  __attribute__ ((always_inline)) set_mem_alias_set () {
+  get_mem_attrs ();
+}

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