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 minor volatile problems


This series of patches was motivited by a (proprietary) Ada test where
volatility was being ignored when RTL was generated.

The problem was that we were setting the volatility from the expression
being used to set the MEM, but if the inner expression was the source of
the volatility, it would get lost.  Hence the trivial change in emit-rtl.c.

However, this caused a bootstrap problem once more volatile MEMs
started showing up, thus exposing a latent bug in that fixup_var_refs
isn't being run with volatile_ok = 1.  Looking for all volatile_ok
references found the bug in emit_block_move_via_movstr, which is
latent and silent, as far as I know.

Tested on x86-64.

2004-02-12  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* emit-rtl.c (set_mem_attributes_minus_bitpos): Don't kill
	previous MEM_VOLATILE in REF.
	* function.c (fixup_var_refs): Save volatile_ok and set to 1.
	* expr.c (emit_block_move_via_movstr): Save and restore volatile_ok.

*** emit-rtl.c	11 Feb 2004 08:06:00 -0000	1.378
--- emit-rtl.c	12 Feb 2004 18:20:36 -0000
*************** set_mem_attributes_minus_bitpos (rtx ref
*** 1480,1484 ****
    alias = get_alias_set (t);
  
!   MEM_VOLATILE_P (ref) = TYPE_VOLATILE (type);
    MEM_IN_STRUCT_P (ref) = AGGREGATE_TYPE_P (type);
    RTX_UNCHANGING_P (ref)
--- 1480,1484 ----
    alias = get_alias_set (t);
  
!   MEM_VOLATILE_P (ref) |= TYPE_VOLATILE (type);
    MEM_IN_STRUCT_P (ref) = AGGREGATE_TYPE_P (type);
    RTX_UNCHANGING_P (ref)
*** expr.c	6 Feb 2004 06:18:12 -0000	1.622
--- expr.c	12 Feb 2004 18:20:42 -0000
*************** emit_block_move_via_movstr (rtx x, rtx y
*** 1418,1421 ****
--- 1418,1422 ----
  {
    rtx opalign = GEN_INT (align / BITS_PER_UNIT);
+   int save_volatile_ok = volatile_ok;
    enum machine_mode mode;
  
*************** emit_block_move_via_movstr (rtx x, rtx y
*** 1467,1471 ****
  	    {
  	      emit_insn (pat);
! 	      volatile_ok = 0;
  	      return true;
  	    }
--- 1468,1472 ----
  	    {
  	      emit_insn (pat);
! 	      volatile_ok = save_volatile_ok;
  	      return true;
  	    }
*************** emit_block_move_via_movstr (rtx x, rtx y
*** 1475,1479 ****
      }
  
!   volatile_ok = 0;
    return false;
  }
--- 1476,1480 ----
      }
  
!   volatile_ok = save_volatile_ok;
    return false;
  }
*** function.c	10 Feb 2004 18:38:18 -0000	1.492
--- function.c	12 Feb 2004 18:20:47 -0000
*************** fixup_var_refs (rtx var, enum machine_mo
*** 1504,1507 ****
--- 1504,1508 ----
    struct sequence_stack *stack = seq_stack;
    tree rtl_exps = rtl_expr_chain;
+   int save_volatile_ok = volatile_ok;
  
    /* If there's a hash table, it must record all uses of VAR.  */
*************** fixup_var_refs (rtx var, enum machine_mo
*** 1515,1518 ****
--- 1516,1522 ----
      }
  
+   /* Volatile is valid in MEMs because all we're doing in changing the
+      address inside.  */
+   volatile_ok = 1;
    fixup_var_refs_insns (first_insn, var, promoted_mode, unsignedp,
  			stack == 0, may_share);
*************** fixup_var_refs (rtx var, enum machine_mo
*** 1542,1545 ****
--- 1546,1551 ----
  	}
      }
+ 
+   volatile_ok = save_volatile_ok;
  }
  


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