Many backends need to override optimization options after
we have processed all optimization options. It is done
in OVERRIDE_OPTIONS. But it is only called once for a given
input. We do have OPTIMIZATION_OPTIONS, which is executed
when the optimization options are changed via "pragma GCC optimize"
or by using the "optimize" attribute. But OPTIMIZATION_OPTIONS
isn't enough. On Linux/x86-64, it gives
[EMAIL PROTECTED] gcc]$ cat /tmp/x.i
void foo (void) __attribute__ ((__optimize__(2,"omit-frame-pointer")));
void
foo (void)
{
}
[EMAIL PROTECTED] gcc]$ ./xgcc -B./ -S /tmp/x.i -mno-accumulate-outgoing-args
-fomit-frame-pointer
/tmp/x.i:1: warning: unwind tables currently require either a frame pointer or
-maccumulate-outgoing-args for correctness
[EMAIL PROTECTED] gcc]$ ./xgcc -B./ -S /tmp/x.i -mno-accumulate-outgoing-args
[EMAIL PROTECTED] gcc]$
That means we may silently generate wrong codes. To properly support
"pragma GCC optimize" and the "optimize" attribute, we need a way for
a backend to override the optimization options whenever they are
changed.
--
Summary: __optimize__ attribute doesn't work correctly
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: hjl dot tools at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37565