This is the mail archive of the
mailing list for the GCC project.
Re: Patch to add __builtin_printf -> fputs transformations
- To: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Subject: Re: Patch to add __builtin_printf -> fputs transformations
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- Date: Wed, 20 Sep 2000 18:40:33 +0100 (BST)
- cc: gcc-patches at gcc dot gnu dot org
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.)
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