Article View: gnu.gcc.bug
Article #2640volatile bug & fix for 1.35
From: Ron Guilmette
Date: Sun, 14 May 1989 03:20
Date: Sun, 14 May 1989 03:20
51 lines
1928 bytes
1928 bytes
The following code, when compiled with GCC 1.35 (with Michael
Meissner's M88k patches installed) resulted in bogus code.
Specifically, although the store into the volatile int
pointed to by "vip" *was* generated correctly, the subsequent
load was *not* properly generated, and instead, the value
(of 7) which was still in a register was reused. That's not
right! Since "vip" points to a volatile word, that word
should be referenced again for the final executable statement
shown below.
volatile int vi;
void test ()
{
volatile int * vip = (volatile int *) 99;
*vip = 7;
vi = *vip;
}
I tracked this problem down into reload1.c. Here is a trivial
(but correct) fix that solved the problem.
diff -rc2 1.35-/reload1.c 1.35+/reload1.c
*** 1.35-/reload1.c Thu Mar 23 08:03:42 1989
--- 1.35+/reload1.c Sat May 13 22:06:38 1989
***************
*** 1071,1074 ****
--- 1071,1075 ----
{
rtx addr = XEXP (x, 0);
+ rtx mem;
FIX_FRAME_POINTER_ADDRESS (addr, depth);
/* These MEMs are normally shared. Make a changed copy;
***************
*** 1075,1079 ****
don't alter the shared MEM, since it needs to be altered
differently each time it occurs (since DEPTH varies). */
! return gen_rtx (MEM, GET_MODE (x), addr);
}
--- 1076,1082 ----
don't alter the shared MEM, since it needs to be altered
differently each time it occurs (since DEPTH varies). */
! mem = gen_rtx (MEM, GET_MODE (x), addr);
! MEM_VOLATILE_P (mem) = MEM_VOLATILE_P (x);
! return mem;
}
Technical Details
Message-ID:
<8905140320.AA26837@riunite.aca.mcc.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!MCC.COM!rfgShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!MCC.COM!rfg From: rfg@MCC.COM (Ron Guilmette) Newsgroups: gnu.gcc.bug Subject: volatile bug & fix for 1.35 Message-ID: <8905140320.AA26837@riunite.aca.mcc.com> Date: 14 May 89 03:20:28 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 51