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]

Fix PR 16443


When scanning operands for asm clobbers, we were not adding
call-clobbered variables that are discovered before aliasing. 
Re-arranging the check for aliases_computed_p fixes the problem.  Added
a new test case taken from the PR.

Bootstrapped and tested x86 and x86-64.


Diego.

2004-07-13  Diego Novillo  <dnovillo@redhat.com>

	PR tree-optimization/16443
	* tree-ssa-alias.c: Add more description for
	CALL_CLOBBERED_VARS and ADDRESSABLE_VARS.
	* tree-ssa-operands.c (get_asm_expr_operands): Re-order the
	clobbering of call-clobbered and addressable variables.  If
	there are any before aliases have been computed, add them.

testsuite/ChangeLog:

2004-07-13  Diego Novillo  <dnovillo@redhat.com>

	PR tree-optimization/16443
	* gcc.dg/tree-ssa/20040713-1.c: New test.

Index: tree-ssa-alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-alias.c,v
retrieving revision 2.10
diff -d -c -p -u -r2.10 tree-ssa-alias.c
--- tree-ssa-alias.c	9 Jul 2004 15:12:48 -0000	2.10
+++ tree-ssa-alias.c	13 Jul 2004 19:34:49 -0000
@@ -164,7 +164,12 @@ static struct ptr_info_def *get_ptr_info
 bitmap call_clobbered_vars;
 
 /* Addressable variables in the function.  If bit I is set, then
-   REFERENCED_VARS (I) has had its address taken.  */
+   REFERENCED_VARS (I) has had its address taken.  Note that
+   CALL_CLOBBERED_VARS and ADDRESSABLE_VARS are not related.  An
+   addressable variable is not necessarily call-clobbered (e.g., a
+   local addressable whose address does not escape) and not all
+   call-clobbered variables are addressable (e.g., a local static
+   variable).  */
 bitmap addressable_vars;
 
 /* 'true' after aliases have been computed (see compute_may_aliases).  This
Index: tree-ssa-operands.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-operands.c,v
retrieving revision 2.15
diff -d -c -p -u -r2.15 tree-ssa-operands.c
--- tree-ssa-operands.c	8 Jul 2004 15:03:10 -0000	2.15
+++ tree-ssa-operands.c	13 Jul 2004 19:34:49 -0000
@@ -1231,16 +1231,6 @@ get_asm_expr_operands (tree stmt, vopera
       {
 	size_t i;
 
-	/* If we still have not computed aliasing information, we
-	   won't know what variables are call-clobbered and/or
-	   addressable.  Just mark the statement as having volatile
-	   operands for now.  */
-	if (!aliases_computed_p)
-	  {
-	    stmt_ann (stmt)->has_volatile_ops = true;
-	    break;
-	  }
-
 	/* Clobber all call-clobbered variables (or .GLOBAL_VAR if we
 	   decided to group them).  */
 	if (global_var)
@@ -1259,6 +1249,13 @@ get_asm_expr_operands (tree stmt, vopera
 	      add_stmt_operand (&var, stmt, opf_is_def, prev_vops);
 	    });
 
+	/* If we don't have call-clobbered nor addressable vars and we
+	   still have not computed aliasing information, just mark the
+	   statement as having volatile operands.  If the alias pass
+	   finds some, we will add them at that point.  */
+	if (!aliases_computed_p)
+	  stmt_ann (stmt)->has_volatile_ops = true;
+
 	break;
       }
 }
Index: testsuite/gcc.dg/tree-ssa/20040713-1.c
===================================================================
RCS file: testsuite/gcc.dg/tree-ssa/20040713-1.c
diff -N testsuite/gcc.dg/tree-ssa/20040713-1.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/tree-ssa/20040713-1.c	13 Jul 2004 19:34:53 -0000
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+
+/* Extracted from PR 16443.  Contributed by Volker Reichelt.
+   Scanning of __asm__ operands wasn't considering call-clobbered
+   variables discovered before the aliasing pass.  This was causing a
+   crash in verify_ssa() because 'p' was not being given an SSA_NAME.  */
+
+void foo(char *p)
+{
+    __asm__ ("" ::: "memory");
+}
+
+void bar()
+{
+    static char *p;
+    foo(p);
+}



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