Bug 43854 - names for compiler generated temporaries are too long
Summary: names for compiler generated temporaries are too long
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.6.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: compile-time-hog, internal-improvement, memory-hog
Depends on:
Blocks:
 
Reported: 2010-04-22 18:10 UTC by Dan Nicolaescu
Modified: 2021-09-09 00:47 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Nicolaescu 2010-04-22 18:10:24 UTC
Looking at tree dumps, most variables used are compiler generated temporaries and they have names like pretmp.DECIMAL_NUMBER

If instead of DECIMAL_NUMBER the same number bug in hex was used, this would reduce the memory used for those temporary names.

This simple patch (that does not take care of all the temporaries, only a subset):

Index: defaults.h
===================================================================
--- defaults.h  (revision 158360)
+++ defaults.h  (working copy)
@@ -46,12 +46,12 @@
 
 #ifndef ASM_PN_FORMAT
 # ifndef NO_DOT_IN_LABEL
-#  define ASM_PN_FORMAT "%s.%lu"
+#  define ASM_PN_FORMAT "%s.%lx"
 # else
 #  ifndef NO_DOLLAR_IN_LABEL
-#   define ASM_PN_FORMAT "%s$%lu"
+#   define ASM_PN_FORMAT "%s$%lx"
 #  else
-#   define ASM_PN_FORMAT "__%s_%lu"
+#   define ASM_PN_FORMAT "__%s_%lx"
 #  endif
 # endif
 #endif /* ! ASM_PN_FORMAT */

has this effect on the string pool (for an average size C file (dispnew.c from emacs):

Before:

avg. entry      17.04 bytes (+/- 8.46)

after:
avg. entry      16.99 bytes (+/- 8.50)


so it's something given how small the change was.

The difference would be even bigger if instead of base 32 or base 64 were used instead of hex, but that's a larger change...

Also "pretmp" "prehitmp" and "ivtmp" prefixes are too long, they could be one or two letters...
Comment 1 Andrew Pinski 2010-04-22 18:14:40 UTC
>Also "pretmp" "prehitmp" and "ivtmp" prefixes are too long,

They might be too long but they are useful long without looking too much into the code to figure out what kind of temp they are.  We could just use D.XYZ instead without a "long name".  Really debug dumps should be used to debug the compiler which means having nice names sometimes makes it easier to debug.
Comment 2 Dan Nicolaescu 2010-04-22 19:54:06 UTC
(In reply to comment #1)
> >Also "pretmp" "prehitmp" and "ivtmp" prefixes are too long,
> 
> They might be too long but they are useful long without looking too much into
> the code to figure out what kind of temp they are.  We could just use D.XYZ
> instead without a "long name". 

Or using P. (or PR.), I. (or IV.)

> Really debug dumps should be used to debug the
> compiler which means having nice names sometimes makes it easier to debug.

As shown above, the names can be both shorter and nice, it's possible to have both.