Should -fcross-jumping be part of -O1?
David Carlton
carlton@kealia.com
Tue Dec 2 17:44:00 GMT 2003
On Tue, 02 Dec 2003 09:18:29 -0800, "Zack Weinberg" <zack@codesourcery.com> said:
> David Carlton <carlton@kealia.com> writes:
>> On Tue, 02 Dec 2003 00:26:07 -0800, "Zack Weinberg"
>> <zack@codesourcery.com> said:
>>> -O0 No optimization whatsoever.
>>> Except maybe do obviously-dead code elimination.
>>
>> This is obviously a very special case, but dead code elimination
>> sometimes makes it difficult to write tests for GDB's test suite. And
>> even when working on real programs I occasionally insert dead code as
>> a place where I can set breakpoints. So, personally, I'd prefer that
>> -O0 be pretty stupid. (Though I don't mind if it's not the default.)
> That's a good point. We seem to be trending in the direction of
> having -O0 do a little bit of optimization, not much, is the main
> reason I threw that in.
> I think I meant unreachable code, not dead code; does that change your
> opinion?
Eliminating unreachable code should be fine. I went and reminded
myself of the specific problems that we'd run into in the GDB test
suite, and they involved situations like this:
static int add (int a, int b) {
return a + b;
}
int main () {
add (1, 2);
}
The call to 'add' was being optimized out even at -O0. Which would be
fine 99% of the time, but sometimes it's a little bit annoying.
Fortunately, if you remove the word 'static', then the compiler left
in the call to 'add', so there was a simple work-around in this case.
>> One current side effect of optimization is that it enables lots of
>> warnings (e.g. unitialized variable detection); if we're going to list
>> explicit goals for different optimization levels, I would have that be
>> a goal for -O1 (and of course for higher optimization levels).
> One of the reasons I suggested -O1 be default is so that users would
> get the warnings that require flow information with just -Wall. I've
> never liked that the set of warnings issued depends on the
> optimization level.
Makes sense to me.
>>> I do not think it is appropriate to exclude optimizations from any
>>> level just because they mess up debugging info
>> I disagree with this for -O0.
> Well, -O0 shouldn't be doing any of those, just because it isn't
> supposed to be doing optimizations in general, but could you explain
> your opinion a little more? Or is this just reiterating what you
> said above?
It seemed like you were saying that -O0 could do things that would
reduce debuggability; I do know users who have a hard running
debuggers on code after instructions have gotten reordered or calls
have disappeared or something like that. So I think there's real
value in having a mode that preserves maximum debuggability; if doing
so increases the complexity of the compiler and imposes a real
maintenance burden, that could be a reason to not have such a mode,
but it would make some people unhappy.
David Carlton
carlton@kealia.com
More information about the Gcc
mailing list