Hi, On Tue, Sep 16, 2008 at 12:24:13PM +0200, Martin Schindewolf wrote: > Dear all, > > my current efforts to get some basic support for transactional memory in > GCC advance slowly but there is one thing I would like to ask because it > stopped me for days now. What is the best way to do the function cloning in > order to have the original function and a transactional clone at the same > time? I tried all sorts of cloning and copying the whole tree using > functions from Cgraph and Ipa passes but somehow I always end up with a > cloned declaration node and a function body that is not a copy of the > original but a pointer to it. At least that is my experience until now. > Following the general idea of having a copy of the original function early > in the passes and inserting the necessary instrumentations later when the > expansion of the GTM primitives is done, this behaviour leads to problems. > What would be the best way to get a real copy of a function body? >
I believe cgraph_function_versioning() is what you are looking for. Have a look at how it is used in ipa-cp.c. HTH Martin