public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@redhat.com>
To: Ian Lance Taylor <ian@airs.com>
Cc: "D. Hugh Redelmeier" <hugh@mimosa.com>,
	Gabriel Dos Reis <gdr@integrable-solutions.net>,
	Daniel Berlin <dberlin@dberlin.org>,
	gcc@gcc.gnu.org, joseph@codesourcery.com,
	Nathan Sidwell <nathan@codesourcery.com>,
	Dale Johannesen <dalej@apple.com>, Mike Stump <mrs@apple.com>,
	jsm@polyomino.org.uk, gcc-patches@gcc.gnu.org
Subject: Re: volatile semantics
Date: Sun, 17 Jul 2005 16:44:00 -0000	[thread overview]
Message-ID: <20050717164235.GB30724@redhat.com> (raw)
In-Reply-To: <m3mzol9zk6.fsf@gossamer.airs.com>

On Sun, Jul 17, 2005 at 09:18:01AM -0700, Ian Lance Taylor wrote:
> This is PR 22278.  DannyB posted a simple, untested, patch here:
>     http://gcc.gnu.org/ml/gcc/2005-07/msg00699.html

Thanks.  I think Danny's patch attacks this too late.  The 
following patch appears to do the right thing with the three
test cases I was given in another reply.

I'll bootstrap it right quick, and see if it has other odd
interactions with other test cases.

My time is limited today.  Anyone want to figure out the right
things to regexp on to make a set of testsuite entries for this?  
If not, I'll work on that Monday.


r~


	* gimplify.c (gimplify_expr): Create a non-volatile local to
	receive the result of a bare volatile read.
	* tree-ssa.c (tree_ssa_useless_type_conversion_1): Don't discard
	casts between pointers to volatile qualified types.

Index: gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gimplify.c,v
retrieving revision 2.140
diff -u -p -d -r2.140 gimplify.c
--- gimplify.c	8 Jul 2005 23:36:40 -0000	2.140
+++ gimplify.c	17 Jul 2005 16:34:47 -0000
@@ -4411,8 +4411,9 @@ gimplify_expr (tree *expr_p, tree *pre_p
 	{
 	  /* Historically, the compiler has treated a bare
 	     reference to a volatile lvalue as forcing a load.  */
-	  tree tmp = create_tmp_var (TREE_TYPE (*expr_p), "vol");
-	  *expr_p = build (MODIFY_EXPR, TREE_TYPE (tmp), tmp, *expr_p);
+	  tree type = TYPE_MAIN_VARIANT (TREE_TYPE (*expr_p));
+	  tree tmp = create_tmp_var (type, "vol");
+	  *expr_p = build (MODIFY_EXPR, type, tmp, *expr_p);
 	}
       else
 	/* We can't do anything useful with a volatile reference to
Index: tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa.c,v
retrieving revision 2.105
diff -u -p -d -r2.105 tree-ssa.c
--- tree-ssa.c	13 Jul 2005 22:35:27 -0000	2.105
+++ tree-ssa.c	17 Jul 2005 16:34:47 -0000
@@ -890,6 +890,15 @@ tree_ssa_useless_type_conversion_1 (tree
   if (lang_hooks.types_compatible_p (inner_type, outer_type))
     return true;
 
+  /* Don't lose casts between pointers to volatile and non-volatile
+     qualified types.  Doing so would result in changing the semantics
+     of later accesses.  */
+  else if (POINTER_TYPE_P (inner_type)
+           && POINTER_TYPE_P (outer_type)
+	   && TYPE_VOLATILE (TREE_TYPE (outer_type))
+	      != TYPE_VOLATILE (TREE_TYPE (inner_type)))
+    return false;
+
   /* If both types are pointers and the outer type is a (void *), then
      the conversion is not necessary.  The opposite is not true since
      that conversion would result in a loss of information if the

  reply	other threads:[~2005-07-17 16:44 UTC|newest]

Thread overview: 118+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-03  8:41 Mike Stump
2005-05-03  8:52 ` Paolo Bonzini
2005-05-03  9:53 ` Giovanni Bajo
2005-05-03 14:31 ` Dave Korn
2005-05-03 14:41 ` Nathan Sidwell
2005-05-03 17:04   ` Dale Johannesen
2005-05-03 18:03     ` Nathan Sidwell
2005-05-03 18:32       ` Paul Koning
2005-05-03 18:37         ` Dale Johannesen
2005-05-11 23:01         ` Geoffrey Keating
2005-05-12 14:46           ` Paul Koning
2005-05-03 18:35       ` Dale Johannesen
2005-05-03 18:54         ` Nathan Sidwell
2005-05-03 19:25           ` Dale Johannesen
2005-05-04  8:18             ` Nathan Sidwell
2005-05-04 10:23               ` Andrew Haley
2005-05-04 11:30                 ` Gabriel Dos Reis
2005-05-04 17:59                   ` Dale Johannesen
2005-05-04 18:01                     ` Paul Koning
2005-05-04 19:49                     ` Nathan Sidwell
2005-07-16 16:51     ` D. Hugh Redelmeier
2005-07-16 16:56       ` Daniel Berlin
2005-07-16 17:26         ` Nathan Sidwell
2005-07-16 17:32           ` Daniel Berlin
2005-07-16 18:35             ` Nathan Sidwell
2005-07-16 20:35               ` Daniel Berlin
2005-07-16 21:29                 ` Gabriel Dos Reis
2005-07-16 21:41                   ` Daniel Berlin
2005-07-16 21:59                     ` Gabriel Dos Reis
2005-07-16 21:07             ` Gabriel Dos Reis
2005-07-16 19:20         ` D. Hugh Redelmeier
2005-07-16 21:10           ` Gabriel Dos Reis
2005-07-16 20:52         ` Gabriel Dos Reis
2005-07-16 21:07           ` Daniel Berlin
2005-07-16 21:24             ` Gabriel Dos Reis
2005-07-16 21:30               ` Daniel Berlin
2005-07-16 22:19                 ` Gabriel Dos Reis
2005-07-16 21:36               ` Daniel Berlin
2005-07-16 22:06                 ` Gabriel Dos Reis
2005-07-16 22:17                   ` Daniel Berlin
2005-07-16 22:25                     ` Gabriel Dos Reis
2005-07-19  7:27                       ` Kai Henningsen
2005-07-19  9:25                         ` Gabriel Dos Reis
2005-07-16 22:34               ` D. Hugh Redelmeier
2005-07-16 22:57                 ` Gabriel Dos Reis
2005-07-17  1:37                   ` D. Hugh Redelmeier
2005-07-17  2:24                     ` Gabriel Dos Reis
2005-07-17  2:36                       ` Daniel Berlin
2005-07-17  3:08                         ` Gabriel Dos Reis
2005-07-17  4:32                           ` Michael Veksler
2005-07-17  5:19                           ` Michael Veksler
2005-07-17  5:31                             ` Gabriel Dos Reis
2005-07-17  7:33                               ` Michael Veksler
2005-07-17 14:33                             ` Daniel Berlin
2005-07-17 15:30                               ` Michael Veksler
2005-07-17  7:53                           ` Andrew Pinski
2005-07-17 11:41                             ` Gabriel Dos Reis
2005-07-17  7:40                       ` D. Hugh Redelmeier
2005-07-17 11:50                         ` Gabriel Dos Reis
2005-07-18 19:30                           ` Mike Stump
2005-07-18 20:05                             ` Gabriel Dos Reis
2005-07-17 15:45                         ` Richard Henderson
2005-07-17 16:04                           ` Nathan Sidwell
2005-07-17 16:18                             ` Richard Henderson
2005-07-17 16:54                               ` Gabriel Dos Reis
2005-07-17 16:06                           ` Falk Hueffner
2005-07-17 16:18                           ` Ian Lance Taylor
2005-07-17 16:44                             ` Richard Henderson [this message]
2005-07-17 12:49                       ` Joseph S. Myers
2005-07-17  2:27                     ` Daniel Berlin
2005-07-17  3:14                       ` Gabriel Dos Reis
2005-07-17  3:27                         ` Daniel Berlin
2005-07-17 20:34                           ` Mark Mitchell
2005-07-17  4:38                         ` D. Hugh Redelmeier
2005-07-17  5:27                           ` Gabriel Dos Reis
2005-07-18 13:13                           ` Gerald Pfeifer
2005-07-17  7:54                       ` D. Hugh Redelmeier
2005-07-17 10:11               ` Andrew Haley
2005-07-17 12:03                 ` Gabriel Dos Reis
2005-07-16 17:33       ` Andrew Haley
2005-07-16 17:53         ` Daniel Berlin
2005-07-17  8:25           ` Ian Lance Taylor
2005-07-22 23:20             ` Geoffrey Keating
2005-07-22 23:33               ` Ian Lance Taylor
2005-07-23  1:28                 ` Geoff Keating
2005-07-23  2:59                   ` Gabriel Dos Reis
2005-07-23  9:50                     ` Geoff Keating
2005-07-23  6:03                   ` Ian Lance Taylor
2005-07-23 16:03                   ` Mike Stump
2005-07-16 19:05         ` Dale Johannesen
2005-07-16 21:17           ` Gabriel Dos Reis
2005-07-22 23:20       ` Geoffrey Keating
2005-07-25 23:08         ` Olivier Galibert
2005-05-06  0:45   ` Kai Henningsen
2005-05-06  1:42     ` Paul Koning
2005-05-06  2:04     ` Gabriel Dos Reis
2005-05-06  2:57     ` Dale Johannesen
2005-05-03 21:19 ` Thorsten Glaser
2005-05-06  5:06 Paul Schlie
2005-07-17 17:58 Paul Schlie
2005-07-18  1:29 Paul Schlie
2005-07-18  6:36 ` Gabriel Dos Reis
2005-07-18 11:20   ` Paul Schlie
2005-07-18 12:12     ` Paolo Bonzini
2005-07-18 12:17     ` Paul Schlie
2005-07-18 12:27       ` Gabriel Dos Reis
2005-07-18 13:27         ` Paul Schlie
2005-07-18 15:47           ` D. Hugh Redelmeier
2005-07-18 12:24     ` Gabriel Dos Reis
2005-07-18 12:11 ` Jonathan Wakely
2005-07-18 12:31   ` Paul Schlie
2005-07-19 17:56 Paul Schlie
2005-07-19 18:13 ` Gabriel Dos Reis
2005-07-19 18:32   ` Paul Schlie
2005-07-23  2:15 Paul Schlie
2005-07-23  9:50 ` Geoff Keating
2005-07-23 11:39   ` Paul Schlie
2005-07-23 11:44   ` Paul Schlie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050717164235.GB30724@redhat.com \
    --to=rth@redhat.com \
    --cc=dalej@apple.com \
    --cc=dberlin@dberlin.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gcc@gcc.gnu.org \
    --cc=gdr@integrable-solutions.net \
    --cc=hugh@mimosa.com \
    --cc=ian@airs.com \
    --cc=joseph@codesourcery.com \
    --cc=jsm@polyomino.org.uk \
    --cc=mrs@apple.com \
    --cc=nathan@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).