re PR tree-optimization/47286 (Invalid code when using register ... asm)
authorRichard Guenther <rguenther@suse.de>
Fri, 14 Jan 2011 12:15:43 +0000 (12:15 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 14 Jan 2011 12:15:43 +0000 (12:15 +0000)
2011-01-14  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/47286
* tree-ssa-structalias.c (new_var_info): Register variables
are global.

* gcc.dg/tree-ssa/pr47286.c: New testcase.

From-SVN: r168779

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr47286.c [new file with mode: 0644]
gcc/tree-ssa-structalias.c

index 2ad6e8b93dd37329ed3190b47a2d25a968a61430..939d7f197c9e8e822cf358a334d76f8cb65df15d 100644 (file)
@@ -1,3 +1,9 @@
+2011-01-14  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/47286
+       * tree-ssa-structalias.c (new_var_info): Register variables
+       are global.
+
 2011-01-14  Martin Jambor  <mjambor@suse.cz>
 
        PR middle-end/46823
index 8762f9ac31b045373960a49e7d23d9968dd32006..ed3a7870c4d91e97616d721560609bcf094e4d48 100644 (file)
@@ -1,3 +1,8 @@
+2011-01-14  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/47286
+       * gcc.dg/tree-ssa/pr47286.c: New testcase.
+
 2011-01-13  Kai Tietz  <kai.tietz@onevision.com>
 
        PR c++/47213
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr47286.c b/gcc/testsuite/gcc.dg/tree-ssa/pr47286.c
new file mode 100644 (file)
index 0000000..b03c59b
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-skip-if "" { ! { i?86-*-* x86_64-*-* } } { "*" } { "" } } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+struct thread_info { int preempt_count; };
+static inline struct thread_info *current_thread_info(void)
+{
+  register struct thread_info *sp asm("esp");
+  return sp;
+}
+void testcase(void)
+{
+  current_thread_info()->preempt_count += 1;
+}
+
+/* We have to make sure that alias analysis treats sp as pointing
+   to globals and thus the store not optimized away.  */
+
+/* { dg-final { scan-tree-dump "->preempt_count =" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
index a31b953a4282e58deb4a4cc05dfac9658a0d32c1..d3a54c65beb6a2b25ac13bf4384917a097df1670 100644 (file)
@@ -413,7 +413,10 @@ new_var_info (tree t, const char *name)
   ret->is_global_var = (t == NULL_TREE);
   ret->is_fn_info = false;
   if (t && DECL_P (t))
-    ret->is_global_var = is_global_var (t);
+    ret->is_global_var = (is_global_var (t)
+                         /* We have to treat even local register variables
+                            as escape points.  */
+                         || (TREE_CODE (t) == VAR_DECL && DECL_REGISTER (t)));
   ret->solution = BITMAP_ALLOC (&pta_obstack);
   ret->oldsolution = BITMAP_ALLOC (&oldpta_obstack);
   ret->next = NULL;