Charlie Gordon wrote On 11/08/07 18:16,:
Which compiler was that?
Did it expand less trivial printf formats into a series of explicit calls to
conversion functions?
It was a Digital compiler, but I'm not sure which one;
I mis-spoke (mis-wrote?) when I said I had "seen" it, not
having verified it for myself. However, I worked alongside
and had multiple bull sessions with a guy who had been part
of Digital's compiler development team, and it was he who
told me of the substitution. It seems that some benchmark
or other used a lot of printf() calls to output string
constants, and profiling had showed that printf() was
spending a lot of time inspecting all those strings to
find the conversion specifiers they didn't contain. So
DEC (said my ex-DEC acquaintance) special-cased the code
generation for printf() and fprintf() -- don't know about
sprintf() -- to avoid the scanning when it was provably
unnecessary. He didn't tell me whether or how much this
improved their benchmark score.
He didn't mention any fancier transformations. It's
easy to see difficulties in doing such things; e.g.
printf ("Hello, %s%c\n", hailedThing, punctuation);
is not quite equivalent to
fputs ("Hello, ", stdout);
fputs (hailedThing, stdout);
putc (punctuation, stdout);
putc ('\n', stdout);
if the second fputs(), say, returns EOF. Such difficulties
aren't insuperable, but dealing with them would be a bigger
project than the simpler substitution. (Guess: The simpler
change was "obviously easy" and well within the scope of a
day's work for one developer; the fancier substitution would
have been large enough to require project reviews, approvals,
test schedules, and all the rest.)