Patch to add __builtin_printf -> fputs transformations
Joseph S. Myers
jsm28@cam.ac.uk
Wed Sep 20 10:40:00 GMT 2000
On Wed, 20 Sep 2000, Kaveh R. Ghazi wrote:
> You can actually combine arg-full printfs by concatenating the format
> specifiers and chaining the remaining arguments together. However
> analyzing multiple calls simultaneously wasn't even possible until
> function-at-a-time mode was enabled in the C front end. It only just
> happened a week ago and I certainly haven't had time to study it yet
> in the context of these opts.
>
> Here's an article from Jan '99 which was my first draft "master plan".
> (It does include concatenating similar *put* calls into one. A
> similar algorithm would work for printf.)
>
> http://gcc.gnu.org/ml/gcc-patches/1999-01/msg00187.html
Some warnings on the more general optimisations:
Concatenating format specifiers won't work if $ operand numbers are
used. Setting pedantic prevents printf optimisations from looking at such
formats for now, but it's something to be aware of in case a future C
standard adds $ formats.
%n formats also prevent concatenation.
All the usual cross-compilation issues of getting the right output for the
target system apply.
Floating point conversions should follow the runtime rounding mode - at
least within #pragma STDC FENV_ACCESS ON.
NaNs and infinities should be passed to the library for it to format in
its implementation-defined style. Likewise, %p should also be passed to
the library at runtime.
%lc and %ls formats depend on the runtime locale.
--
Joseph S. Myers
jsm28@cam.ac.uk
More information about the Gcc-patches
mailing list