[RFC, PATCH]: Introduction of callgraph annotation class

Martin Liška mliska@suse.cz
Wed Oct 15 16:29:00 GMT 2014


Hello.

Following patch introduces a new class called callgraph_annotation. Idea behind the patch is to provide a generic interface one can use to register custom info related to a cgraph_node. As you know, symbol_table provides hooks for creation, deletion and duplication of a cgraph_node. If you have a pass, you need to handle all these hooks and store custom data in your data structure.

As an example, after discussion with Martin, I chose usage in ipa-prop.h:

data structure:
vec<ipa_node_params> ipa_node_params_vector

if the pass handles an event, following chunk is executed:
if (ipa_node_params_vector.length () <= (unsigned) symtab->cgraph_max_uid)
     ipa_node_params_vector.safe_grow_cleared (symtab->cgraph_max_uid + 1);

The problem is that you can have sparse UIDs of cgraph_nodes and every time you have to allocate a vector of size equal to cgraph_max_uid.

As a replacement, I implemented first version of cgraph_annotation that internally uses hash_map<cgraph_unique_identifier, T>.
Every time a node is deleted, we remove corresponding data associated to the node.

What do you think about it?

Thank you,
Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cgraph-annotation-1.patch
Type: text/x-patch
Size: 23802 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20141015/136588e8/attachment.bin>


More information about the Gcc-patches mailing list