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]

small space saving in C/C++ lang_identifier


By accident, the C and C++ lang_identifier structures have duplicate
fields to hold a keyword number.  Since the extra copy is sandwiched
between two pointers, that means the structure is a whole word bigger
than it needs to be.  This patch corrects the problem.  (The other
copy of the field is hiding in struct cpp_hashnode, which is why it
wasn't obvious before.)

There is no actual space saving; these structures were being allocated
from the 64-byte GC pool (on 32-bit hosts) and they still are.[1]  I
don't see them ever getting as small as 32 bytes, although there is
still considerable redundancy.  However, they could perfectly well be
moved to an obstack to avoid the padding (identifier nodes never
become garbage anyway, so this would also save work in ggc_collect).
Also, the C++ version is now small enough that if we fold struct
lang_id2 into struct lang_identifier, it would still fit in the
64-byte pool.

Bootstrapped i686-linux.  There is one regression from my previous
build, which is a cfg.c ICE on the Fortran test suite.  I believe I
can safely call that unrelated :)

zw

[1] After the change, C lang_identifier is 60 bytes, C++ is 56 (68
counting struct lang_id2; 64 counting struct lang_id2 but not the
pointer to it).

	* c-common.h (struct c_common_identifier): Remove rid_code field.
	(C_RID_CODE): Use ->node.rid_code instead of ->rid_code.

===================================================================
Index: c-common.h
--- c-common.h	2001/10/23 18:51:01	1.92
+++ c-common.h	2001/10/24 08:26:59
@@ -177,7 +177,7 @@ enum c_tree_index
     CTI_MAX
 };
 
-#define C_RID_CODE(id)	(((struct c_common_identifier *) (id))->rid_code)
+#define C_RID_CODE(id)	(((struct c_common_identifier *) (id))->node.rid_code)
 
 /* Identifier part common to the C front ends.  Inherits from
    tree_identifier, despite appearances.  */
@@ -185,7 +185,6 @@ struct c_common_identifier
 {
   struct tree_common common;
   struct cpp_hashnode node;
-  ENUM_BITFIELD(rid) rid_code: CHAR_BIT;
 };
 
 #define wchar_type_node			c_global_trees[CTI_WCHAR_TYPE]


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