I have another question along the same lines. Is it possible to tell gcc to 
never delete a certain function even if it is never called in the executable?

Any help is greatly appreciated!

Thanks,

Balaji V. Iyer.

-----Original Message-----
From: Martin Jambor [mailto:mjam...@suse.cz] 
Sent: Monday, March 26, 2012 8:52 AM
To: Iyer, Balaji V
Cc: 'gcc@gcc.gnu.org'
Subject: Re: Question about Tree_function_versioning

Hi,

On Mon, Mar 26, 2012 at 01:34:55AM +0000, Iyer, Balaji V wrote:
> Hello Everyone,
> I am currently trying to take certain functions (marked by certain
> attributes) and create vector version along with the scalar versions 
> of the function. For example, let's say I have a function my_add that 
> is marked with a certain attribute, I am trying to clone it into 
> my_add_vector and still keep the original my_add. For this, I am 
> trying to use tree_function_versioning in cgraphunit.c to clone the 
> cgraph_node into a new function. Does this function actually create a 
> 2nd function (called my_add_vector) and copy the body from my_add 
> function to the my_add_vector function or does it just create a node 
> called my_add_vector and then create a pointer to the body of the 
> my_add?
> 
> Is there a better approach for doing this?
> 

tree_function_versioning indeed does copy the body of a function into a new 
one, but that's the only thing it does.  You might be better served by its 
callers such as cgraph_function_versioning.  But I believe all cloning 
functions currently also make the new clone private to the current compilation 
unit (and thus subject to unreachable node removal if they have no callers) 
which is something you might not want.  If it is a problem, you'd either need 
to re-set the relevant decl and node attributes subsequently or change the 
cloning functions themselves.

I assume you're not operating within an IPA pass, in that case you'd need 
cgraph_create_virtual_clone and a transformation hook.

Martin

Reply via email to