home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / gnu / gcc / bug / 2275 < prev    next >
Encoding:
Text File  |  1992-09-08  |  2.2 KB  |  88 lines

  1. Newsgroups: gnu.gcc.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!la.tce.COM!pierre
  3. From: pierre@la.tce.COM (Pierre Willard)
  4. Subject: gcc-1.40.90 and volatile
  5. Message-ID: <9209072328.AA20931@_la.tce.com>
  6. Sender: gnulists@ai.mit.edu
  7. Reply-To: pierre@la.tce.com
  8. Organization: GNUs Not Usenet
  9. Distribution: gnu
  10. Date: Mon, 7 Sep 1992 23:28:51 GMT
  11. Approved: bug-gcc@prep.ai.mit.edu
  12. Lines: 74
  13.  
  14. Two small bugs with gcc-1.40.90 (sorry, we do not have gcc-1.41 yet).
  15.  
  16. 1/ When doing a post-increment of a volatile variable (in memory),
  17. the value is fetched TWICE from memory. 
  18.  
  19. 2/ A volatile qualifier for a global register variable is forgotten by
  20. gcc. The GCC documentation says about the 'volatil' flag in a rtl :
  21. "In a `reg' expression, it is 1 if the value is a user-level variable.
  22. 0 indicates an internal compiler temporary". This seems to imply that
  23. for a register variable (local or global) the volatile qualifier has
  24. no effect. Is this true ? is it the same for gcc2 ?
  25.  
  26. The following demonstrates the problems :
  27.  
  28. psi:/tmp_mnt/net/tau/home/gnu/gcc-1.40.9/gcc-sun4:cat pw.c
  29.  
  30. volatile int zzz;
  31.  
  32. void foo(void)
  33. {
  34.   zzz++;
  35. }
  36.  
  37. volatile register int xxx asm("%g2");
  38.  
  39. void bar(void)
  40. {
  41.   xxx = 0;
  42.   xxx++;
  43. }
  44.  
  45. psi:/tmp_mnt/net/tau/home/gnu/gcc-1.40.9/gcc-sun4:./gcc -v -S -O pw.c
  46. gcc version 1.40.9
  47.  cpp -v -undef -D__GNUC__ -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__OPTIMIZE__ pw.c /usr/tmp/cca10252.cpp
  48. GNU CPP version 1.40.9
  49.  cc1 /usr/tmp/cca10252.cpp -quiet -dumpbase pw.c -O -version -o pw.s
  50. GNU C version 1.40.9 (sparc) compiled by CC.
  51. default target switches: -mfpu -mepilogue
  52. psi:/tmp_mnt/net/tau/home/gnu/gcc-1.40.9/gcc-sun4:cat pw.s
  53. gcc_compiled.:
  54. .text
  55.     .align 4
  56. .global _foo
  57.     .proc 1
  58. _foo:
  59.     !#PROLOGUE# 0
  60.     save %sp,-80,%sp
  61.     !#PROLOGUE# 1
  62.     sethi %hi(_zzz),%g1
  63.     ld    [%g1+%lo(_zzz)],%o0
  64.     ld    [%g1+%lo(_zzz)],%o0    <------ this one is useless
  65.     add %o0,1,%o0
  66.     st    %o0,[%g1+%lo(_zzz)]
  67.     ret
  68.     restore
  69.     .align 4
  70. .global _bar
  71.     .proc 1
  72. _bar:
  73.     !#PROLOGUE# 0
  74.     save %sp,-80,%sp
  75.     !#PROLOGUE# 1
  76.     mov 0,%g2
  77.     mov 1,%g2      <----- gcc has changed xxx++ into xxx=1 (with xxx volatile)!
  78.     ret
  79.     restore
  80. .global _zzz
  81. .common _zzz,8,"bss"
  82. psi:/tmp_mnt/net/tau/home/gnu/gcc-1.40.9/gcc-sun4:
  83.  
  84. Please give me your comments
  85. Regards
  86. Pierre Willard
  87.  
  88.