rfg@MCC.COM (Ron Guilmette) (05/14/89)
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;
}