Need Optimizer bug workaround

Tina VanRoggen Tina_VanRoggen@avid.com
Thu Apr 6 13:31:00 GMT 2006


This is on Xcode 2.2.1, GCC 4.0.1.  The source code 
is quite old and runs on multiple platforms using 
other compilers.  The following call to SetupParameter 
passes in garbage for the pl variable when using the 
-Os (fastest/smallest) optimization.  Using -O1 
optimization works properly.  

My question is: is there a compiler flag that we can 
use with -Os that will turn off the optimization that 
is causing the problem?  We'd rather not use only
-O1 optimization.  There is likely other
code in our app that will have the same problem.
Thanks.

struct Point {
    short 	 v;
    short	 h;
};
...
Point p1;
...
	p1.h= 1;
	p1.v= 1;
	tobj->SetParameter(4110, *(long *) &p1);


output with -Os
--------------------
     lwz r9,0(r31)
     li r0,1        <--load  the 1 into r0 
     mr r3,r31
     li r4,4110
     lwz r5,56(r1)  <--but here we grab the long 2nd arg for the
SetParameter 
     sth r0,56(r1)  <--before it's really set!
     sth r0,58(r1)
     lwz r2,48(r9)
     mtctr r2
     mr r12,r2
     bctrl          

output with -O1
----------------
     li r0,1
     sth r0,58(r1)    <-- set up pl.h and .v
     sth r0,56(r1)
     addi r30,r1,56
     lwz r2,0(r29)
     mr r3,r29
     li r4,4110
     lwz r5,56(r1)     <-- r5 arg gets the 1,1 this time!
     lwz r12,48(r2)
     mtctr r12
     bctrl             



More information about the Gcc-help mailing list