Read-only data handling: a proposal

David S. Miller davem@jenolan.rutgers.edu
Mon Sep 15 06:29:00 GMT 1997


   Date: Mon, 15 Sep 1997 01:18:24 -0600
   From: Jeffrey A Law <law@cygnus.com>

     > 	- Is there something wrong in my idea?
   Unfortunately, yes.

   Well, more correctly, it depends.  Are you suggesting that output
   of constants be deferred until the end of a compilation unit, or
   end of a function?  If you're deferring to the end of a compilation
   unit, then you have to arrange for the tree nodes to be copied onto
   a permanent obstack.  This can get quite hairy -- I did it for
   static variables a few years back and we dropped the code after a
   while because it was unmaintainable.

I don't know how you had implemented this, but here is my idea for an
approach.

Why not just defer all static's.  Add them to a chain of tree nodes.
Once you reach the end of the compilation unit, call something like
compile_deferred_statics().

Here it runs down the tree node chain of static's accumulated during
the compilation thus far, and checks for a 'referenced' bit or flag or
whatever.  If set, it emits the static data.

Later,
David "Sparc" Miller
davem@caip.rutgers.edu



More information about the Gcc mailing list