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]

[tree-ssa] Don't clobber read-only variables


This patch fixes the problem described by Andrew Haley in
http://gcc.gnu.org/ml/gcc/2003-09/msg01125.html.  Global variables are
generally considered call-clobbered, but if the variable is read-only,
we can assume that the function won't modify the variable.

Bootstrapped and tested x86 and x86-64 (checking disabled in x86-64 due
to PR 12547.


Diego.


	* tree-dfa.c (add_call_clobber_ops): If a variable is read-only,
	add a VUSE operand instead of VDEF.

Index: tree-dfa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-dfa.c,v
retrieving revision 1.1.4.168
diff -d -c -p -r1.1.4.168 tree-dfa.c
*** tree-dfa.c	9 Oct 2003 17:09:32 -0000	1.1.4.168
--- tree-dfa.c	9 Oct 2003 17:41:14 -0000
*************** add_call_clobber_ops (tree stmt, voperan
*** 905,911 ****
        for (i = 0; i < num_call_clobbered_vars; i++)
  	{
  	  tree var = call_clobbered_var (i);
! 	  add_stmt_operand (&var, stmt, opf_force_vop|opf_is_def, prev_vops);
  	}
      }
  }
--- 905,916 ----
        for (i = 0; i < num_call_clobbered_vars; i++)
  	{
  	  tree var = call_clobbered_var (i);
! 
! 	  /* If VAR is read-only, don't add a VDEF, just a VUSE operand.  */
! 	  if (!TREE_READONLY (var))
! 	    add_stmt_operand (&var, stmt, opf_force_vop|opf_is_def, prev_vops);
! 	  else
! 	    add_stmt_operand (&var, stmt, opf_force_vop, prev_vops);
  	}
      }
  }


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