This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Move printf and fprintf builtins to middle-end.


On Mon, Jul 21, 2003 at 12:54:42AM -0400, Kaveh R. Ghazi wrote:
> Using this algorithm, I believe we'd be able to do complicated stuff
> like transforming this:
> 
> printf ("%s %s %04ld %% %d %s", "hello", "world", 1L, n, "bye");
> 
> into this:
> 
> printf ("hello world 0001 % %d bye", n);
> 
> I.e. we can convert partially and leave the non-const stuff for
> runtime.

The main problem with this is it is very questionable whether it is
a win or loose.
In lots of projects, defining something like:
printf ("error message xyz at %s:%d", __FILE__, __LINE__);
in some macro and using it all around the source means that currently
(with SHF_MERGE) there are very few strings in .rodata section -
"error message xyz at %s:%d", then filenames one per each input file
where this macro is used and that's it.
Doing the printf at compile time would mean you suddenly have thousands
of different (thus unmergeable) strings in .rodata section -
one per each occurence of that macro in each input file.
I don't think this is something which should be controlled by
-Os only.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]