🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #753

Volatile asm's reordered

#753
From: Tim Wilson
Date: Tue, 24 Oct 1989 15:00
54 lines
2211 bytes
The following script contains (working through the checklist):
 * The version of GCC
 * The complete input file
 * The command arguments
----------------------------------------------------------------------
~/rvd/c/sys/test $ cat bug.i
main ()
{
    int old = ({int a;
		asm volatile ("first":"=g" (a));
		a;});
    asm volatile ("second");
    use(old);
}
~/rvd/c/sys/test $ gcc68k -v -O -S bug.i
gcc version 1.35
 /usr/users/tdw/gcc68k/bin/gcc68k-cc1 bug.i -quiet -O -version -o bug.s
GNU C version 1.35 (68k, MIT syntax) compiled by GNU C version 1.30.
~/rvd/c/sys/test $ cat bug.s
#NO_APP
gcc_compiled.:
.text
	.even
.globl _main
_main:
	link a6,#0
#APP
	second
	first
#NO_APP
	jbsr _use
	unlk a6
	rts
~/rvd/c/sys/test $ 
----------------------------------------------------------------------
 * The names of the files I used for tm.h and md
   - tm.h -> config/tm-sun3.h
   - md -> config/m68k.md
 * The type of machine, op sys, version number
   - VaxStation running Ultrix 1.2
 * A description of what I believe to be incorrect
   - I believe the variable `old' should have acquired its value
     from `asm volatile("first")' before `asm volatile("second")' 
     is executed.  However, the assember output reveals that
     the two asm volatiles have been reordered.

     In my real code "first" and "second" contain side-effects
     which are order-dependant.  Gcc does not know about 
     these---hence the `volatile's, which seem to be ignored.

Tim Wilson	University of Cambridge Computer Laboratory, 
		New Museums Site, Pembroke Street, CAMBRIDGE, CB2 3QG, UK.
Tel:   +44 223 334624		Internet: tdw%cl.cam.ac.uk@nsfnet-relay.ac.uk
Janet: tdw@uk.ac.cam.cl		Uucp:     ...!uunet!mcvax!ukc!cam-cl!tdw
Technical Details
Message-ID: <8910241500.AA26729@uk.ac.cam.cl.hall>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!NSFNET-RELAY.AC.UK!tdw%computer-lab.cambridge.ac.uk

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!NSFNET-RELAY.AC.UK!tdw%computer-lab.cambridge.ac.uk
From: tdw%computer-lab.cambridge.ac.uk@NSFNET-RELAY.AC.UK (Tim Wilson)
Newsgroups: gnu.gcc.bug
Subject: Volatile asm's reordered
Message-ID: <8910241500.AA26729@uk.ac.cam.cl.hall>
Date: 24 Oct 89 15:00:12 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 54