|Summary:||volatile bug on AVR|
|Product:||gcc||Reporter:||John Regehr <regehr>|
|Component:||target||Assignee:||Not yet assigned to anyone <unassigned>|
|Severity:||normal||CC:||anitha.boyapati, eric.weddington, gcc-bugs|
|Build:||Known to work:|
|Known to fail:||4.3.2 4.3.3||Last reconfirmed:||2009-02-18 15:19:37|
failure-inducing C program
asm displaying volatile bug
Description John Regehr 2009-02-18 04:58:14 UTC
This bug is seen using the avr-gcc that is built using the script that comes with FemtoOS 0.88. Compile the attached program like this: avr-gcc -O -mmcu=atmega128 small.c -S It can be seen that func_45() unconditionally loads from volatile g_54. That is wrong, since in the C code the load is protected by a test.
Comment 1 John Regehr 2009-02-18 04:58:58 UTC
Created attachment 17317 [details] failure-inducing C program
Comment 2 John Regehr 2009-02-18 04:59:28 UTC
Created attachment 17318 [details] asm displaying volatile bug
Comment 3 Richard Biener 2009-02-18 10:03:58 UTC
Please fill out GCC version this bug is reported against.
Comment 4 Eric Weddington 2009-02-18 15:19:37 UTC
Fail on 4.3.2 with -O1, success with -O[023s].
Comment 5 Anitha Boyapati 2010-02-17 11:09:02 UTC
Fails with gcc 4.4.3 and gcc 4.5 with -O1.
Comment 6 Anitha Boyapati 2010-02-17 11:19:29 UTC
An observation - the same file when compiled with -O1 for i386 target also appears to load g_54 using movl instruction. _func_45: ... L11: testw %bx, %bx je L7 movl _g_54, %eax L7: movl $1, 4(%esp)
Comment 7 abnikant 2010-03-08 05:22:47 UTC
(In reply to comment #6) > An observation - the same file when compiled with -O1 for i386 target also > appears to load g_54 using movl instruction. > > _func_45: > ... > L11: > testw %bx, %bx > je L7 > movl _g_54, %eax > L7: > movl $1, 4(%esp) > > It loads g_54 conditionally with gcc-4.4.0 and higher version in -O1
Comment 8 abnikant 2010-03-08 05:26:03 UTC
Comment 9 Anitha Boyapati 2010-03-08 06:04:36 UTC
(In reply to comment #5) > Fails with gcc 4.4.3 and gcc 4.5 with -O1. > Correction : The bug passes with 4.4.2 and above versions. Code generated can be seen below. func_45: ... rcall func_15 mov r28,r24 mov r29,r25 ldi r22,lo8(1) ldi r23,hi8(1) ldi r24,hlo8(1) ldi r25,hhi8(1) .L9: sbiw r28,0 breq .L8 lds r18,g_54 lds r19,(g_54)+1 lds r20,(g_54)+2 lds r21,(g_54)+3 .L8: ldi r18,lo8(1)