[trunk] patch to clean up handling of pure and constant functions.
Mark Mitchell
mark@codesourcery.com
Thu Apr 10 17:45:00 GMT 2008
Chris Lattner wrote:
>> In fact, it is only necessary not to dead code eliminate potientially
>> looping pure or const function, it is perfectly fine to perform code
>> motion on such functions.
> permitting code motion across other side-effect-free statements seems fine.
I agree with Chris.
In C and C++, the set of things are observable side-effects is not that
broad. It's basically reads/writes to volatile memory and I/O. So, for
something like:
int i;
void f () {
i = 3;
this_call_will_never_return ();
}
you could move the call before the "i = 3" assignment.
But, I'm not sure if we want to be that aggressive, or not, in a
multi-threaded program. It depends on what model we have for threads.
If threads are only guaranteed to see updates to volatile variables,
then is still OK. But, if the expectation is that threads will
eventually see updates to globals, then it would be wrong.
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713
More information about the Gcc-patches
mailing list