Article View: gnu.gcc.bug
Article #65a (volatile) fetch gets compiled away.
From: Bradley Kuszmaul
Date: Tue, 03 Nov 1992 18:30
Date: Tue, 03 Nov 1992 18:30
103 lines
3772 bytes
3772 bytes
But there is still a bug when using -fvolatile.
I tried following Mr. Kenner's advice and the load did not get compiled
away. However, if I take the unannotated code and compile it with
-fvolatile, the fetch gets compiled away. My understanding is that no
fetch should be compiled away if I do -fvolatile.
Contents:
- a fragment of the mail message from Richard Kenner.
- a new foo2.c file (with two tests, one using Kenner's advice and one
with no (volatile) attribution.
- a new foo2.s file, compiled with -fvolatile, that demonstrates that
-fvolatile does not cause the fetch to be kept.
- the wallpaper for how I compiled this.
Note: This is on a sun4.
-Bradley
---- previous mail ----
Date: Tue, 3 Nov 92 11:46:57 -0500
From: kenner@vlsi1.ultra.nyu.edu (Richard Kenner)
...(and even if I compile it with -fvolatile).
void test(void) {
(volatile)*((unsigned*)0x20000a20);
}
Expressions aren't volatile, memory references are. Try casting
to (unsigned volatile *) instead of (unsigned *).
---- foo2.c ----
void test1(void) {
*((unsigned volatile*)0x20000a20);
}
void test2(void) {
*((unsigned*)0x20000a20);
}
---- foo2.s ----
gcc2_compiled.:
.stabs "/users/asd1/bradley/",100,0,0,Ltext0
.stabs "foo2.c",100,0,0,Ltext0
.text
Ltext0:
.stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0
.stabs "char:t2=r2;0;127;",128,0,0,0
.stabs "long int:t3=r1;-2147483648;2147483647;",128,0,0,0
.stabs "unsigned int:t4=r1;0;-1;",128,0,0,0
.stabs "long unsigned int:t5=r1;0;-1;",128,0,0,0
.stabs "short int:t6=r1;-32768;32767;",128,0,0,0
.stabs "long long int:t7=r1;0;-1;",128,0,0,0
.stabs "short unsigned int:t8=r1;0;65535;",128,0,0,0
.stabs "long long unsigned int:t9=r1;0;-1;",128,0,0,0
.stabs "signed char:t10=r1;-128;127;",128,0,0,0
.stabs "unsigned char:t11=r1;0;255;",128,0,0,0
.stabs "float:t12=r1;4;0;",128,0,0,0
.stabs "double:t13=r1;8;0;",128,0,0,0
.stabs "long double:t14=r1;8;0;",128,0,0,0
.stabs "void:t15=15",128,0,0,0
.align 4
.global _test1
.proc 020
_test1:
.stabn 68,0,1,LM1
LM1:
!#PROLOGUE# 0
save %sp,-112,%sp
!#PROLOGUE# 1
.stabn 68,0,2,LM2
LM2:
sethi %hi(536873504),%g2
ld [%g2+%lo(536873504)],%g2
.stabn 68,0,3,LM3
LM3:
ret
restore
.stabs "test1:F15",36,0,0,_test1
.align 4
.global _test2
.proc 020
_test2:
.stabn 68,0,5,LM4
LM4:
!#PROLOGUE# 0
save %sp,-112,%sp
!#PROLOGUE# 1
.stabn 68,0,7,LM5
LM5:
ret
restore
.stabs "test2:F15",36,0,0,_test2
---- the wallpaper ----
bradley@marley% gcc foo2.c -S -O -o foo2.s -Wall -g -v -fvolatile
Reading specs from /usr/local/lib/gcc-lib/sun4/2.2.2/specs
gcc version 2.2.2
/usr/local/lib/gcc-lib/sun4/2.2.2/cpp -lang-c -v -undef -D__GNUC__=2 -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix -D__OPTIMIZE__ -g -Wall foo2.c /usr/tmp/cca27379.i
GNU CPP version 2.2.2 (sparc)
/usr/local/lib/gcc-lib/sun4/2.2.2/cc1 /usr/tmp/cca27379.i -quiet -dumpbase foo2.c -g -O -Wall -version -fvolatile -o foo2.s
GNU C version 2.2.2 (sparc) compiled by GNU C version 2.2.2.
foo2.c: In function `test2':
foo2.c:6: warning: statement with no effect
bradley@marley%
---- that's all folks ----
Technical Details
Message-ID:
<9211031830.AA27415@marley.think.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!ogicse!emory!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!think.com!bradleyReferences:
<9211031646.AA00295@vlsi1.ultra.nyu.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ogicse!emory!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!think.com!bradley From: bradley@think.com (Bradley Kuszmaul) Newsgroups: gnu.gcc.bug Subject: a (volatile) fetch gets compiled away. Message-ID: <9211031830.AA27415@marley.think.com> Date: 3 Nov 92 18:30:52 GMT Article-I.D.: marley.9211031830.AA27415 References: <9211031646.AA00295@vlsi1.ultra.nyu.edu> Sender: gnulists@ai.mit.edu Distribution: gnu Organization: Gnus Not Usenet Lines: 103 Approved: bug-gcc@prep.ai.mit.edu