This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: printf optimiziation in gcc-3.2.x
- From: "John David Anglin" <dave at hiauly1 dot hia dot nrc dot ca>
- To: gcc at gcc dot gnu dot org
- Cc: aj at sus dot de, falk dot hueffner at student dot uni-tuebingen dot de, petkan at users dot sourceforge dot net
- Date: Mon, 10 Mar 2003 20:45:28 -0500 (EST)
- Subject: Re: printf optimiziation in gcc-3.2.x
> Note that -ffreestanding completely disables these optimizations,
> though, e. g. memcpy(a, b, 4) isn't inlined anymore. (It would be nice
> to have a switch that only disables emitting new libcalls, but I don't
> think there is one.)
I recently installed a patch to c-common.c to allow backends to disable
specific builtin optimizations. In our case, I wanted to disable
printf_unlocked and fputs_unlocked to fputc_unlocked. This is useful
if a target doesn't support a specific optimization. However, it's
not the right approach if you want to disable emitting new libcalls
in general.
In some ways, I think the ISO was wrong to allow these optimizations.
It tends to bypass testing by "configure" and the choice of the
programmer to use a specific libcall. The optimization may result
in poorer performance. GCC does no testing to determine whether
a particular target supports any given translation or whether it
actually is an optimization. So, you do a lot of testing, release
GCC, and then find that it's broken. In the case that prompted
the patch, configure checked for fputs_unlocked and fputc_unlocked.
It found the system had fputs_unlocked but not fputc_unlocked, but
then GCC changed a few fputs_unlocked calls to fputc_unlocked calls.
Dave
--
J. David Anglin dave dot anglin at nrc-cnrc dot gc dot ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6605)