This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch to allow overridding of -Os
- To: egcs-patches at cygnus dot com
- Subject: Patch to allow overridding of -Os
- From: Nick Clifton <nickc at cygnus dot com>
- Date: Wed, 16 Dec 1998 17:40:42 -0800
Hi Guys,
I have just checked in the following patch. It has two effects:
1. Setting -Os forces the optimization level to 2, even if a higher
level has been specified by an earlier option.
2. -Os can now be overridden by a later specification of a different
optiomisation level.
This brings EGCS behaviour into line with its documentation, which
specifies that the last specified optimization level is the one that
takes precedence.
Cheers
Nick
Wed Dec 16 11:17:51 1998 Nick Clifton <nickc@cygnus.com>
* toplev.c (main): Disable optimize_size if a specific
optimization level is requested. Always set optimization
level to 2 if -Os is specified.
Index: toplev.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/toplev.c,v
retrieving revision 1.136
diff -p -r1.136 toplev.c
*** toplev.c 1998/12/13 00:59:38 1.136
--- toplev.c 1998/12/17 01:34:12
*************** main (argc, argv)
*** 4556,4561 ****
--- 4556,4562 ----
if (!strcmp (argv[i], "-O"))
{
optimize = 1;
+ optimize_size = 0;
}
else if (argv[i][0] == '-' && argv[i][1] == 'O')
{
*************** main (argc, argv)
*** 4564,4585 ****
int c;
if ((p[0] == 's') && (p[1] == 0))
! optimize_size = 1;
else
{
while ((c = *p++))
if (! (c >= '0' && c <= '9'))
break;
if (c == 0)
! optimize = atoi (&argv[i][2]);
}
}
}
- /* Optimizing for size forces optimize to be no less than 2. */
- if (optimize_size && (optimize < 2))
- optimize = 2;
-
obey_regdecls = (optimize == 0);
if (optimize >= 1)
--- 4565,4590 ----
int c;
if ((p[0] == 's') && (p[1] == 0))
! {
! optimize_size = 1;
!
! /* Optimizing for size forces optimize to be 2. */
! optimize = 2;
! }
else
{
while ((c = *p++))
if (! (c >= '0' && c <= '9'))
break;
if (c == 0)
! {
! optimize = atoi (&argv[i][2]);
! optimize_size = 0;
! }
}
}
}
obey_regdecls = (optimize == 0);
if (optimize >= 1)