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]

[PATCH] Fix PR middle-end/23237


As discussed in thread starting here:

http://gcc.gnu.org/ml/gcc/2005-08/msg00679.html

This patch stops the ipa-reference pass from marking a variable TREE_READONLY if the variable is in a named section (as it changes the section attributes, causing potential conflicts with other variables in the same named section).

Tested on i686-pc-linux-gnu and arm-none-elf with no regressions. OK for mainline?

- Josh

2005-09-09 Josh Conner <jconner@apple.com>

	pr middle-end/23237
	* ipa-reference.c (static_execute): Don't mark variables in
	named sections TREE_READONLY.

2005-09-09 Josh Conner <jconner@apple.com>

	pr middle-end/23237
	* gcc.c-torture/compile/pr23237.c: New test.



Index: gcc/ipa-reference.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/ipa-reference.c,v
retrieving revision 2.3
diff -c -3 -p -r2.3 ipa-reference.c
*** gcc/ipa-reference.c	26 Jul 2005 13:53:51 -0000	2.3
--- gcc/ipa-reference.c	9 Sep 2005 00:14:14 -0000
*************** static_execute (void)
*** 963,972 ****
      EXECUTE_IF_SET_IN_BITMAP (module_statics_readonly, 0, index, bi)
        {
  	tree var = get_static_decl (index);
! 	TREE_READONLY (var) = 1;
! 	if (dump_file)
! 	  fprintf (dump_file, "read-only var %s\n", 
! 		   get_static_name (index)); 
  	if (DECL_INITIAL (var)
  	    && is_gimple_min_invariant (DECL_INITIAL (var)))
  	  {
--- 963,979 ----
      EXECUTE_IF_SET_IN_BITMAP (module_statics_readonly, 0, index, bi)
        {
  	tree var = get_static_decl (index);
! 
! 	/* Ignore variables in named sections - changing TREE_READONLY
! 	   changes the section flags, potentially causing conflicts with
! 	   other variables in the same named section.  */
! 	if (DECL_SECTION_NAME (var) == NULL_TREE)
! 	  {
! 	    TREE_READONLY (var) = 1;
! 	    if (dump_file)
! 	      fprintf (dump_file, "read-only var %s\n", 
! 		       get_static_name (index));
! 	  }
  	if (DECL_INITIAL (var)
  	    && is_gimple_min_invariant (DECL_INITIAL (var)))
  	  {
static __attribute__ ((__section__ (".init.data"))) char *message;
static __attribute__ ((__section__ (".init.data"))) int (*actions[])(void) = {};
void unpack_to_rootfs(void)
{
  while (!message)
  {
    if(!actions[0])
      return;
  }
}

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