This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Adding functions at compile time
- From: Matt Davis <mattdavis9 at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 12 Sep 2011 01:37:53 +1000
- Subject: Adding functions at compile time
I am creating a few functions at compile time, via a gcc plugin. I create the
functions and their bodies, and insert them into the call graph. This is all
done before "cgraph_finalize_compilation_unit()" has been called. I then have
another compiler pass, which gets started after the SSA representation has been
generated, and it is this pass that uses the functions created previously, in
the much earlier pass. The problem is that by the time the created functions
are used, the cgraph has already removed those nodes since they are disjoint. I
tried creating and modifying the functions in the same pass, but that was not
successful either. I did not see any flag I could set in the cgraph nodes,
which are created in the first pass I mentioned preventing them from being
removed. Is there a way I can keep those nodes around so the functions created
at compile time actually get built?
-Matt