Pipe Line
Hi , i am trying to understand the Gcc 4.6 pipeline everything was good tell i arrived to lang_hooks.parse_file , i cant figuration if this is right or what (CALL)-> finich_function { cgraph_finilize_function -> cgraph_analize_function {cgraph_lower_function}} ? -- Chaddy Huussin Vazquez , chas...@ceis.cujae.edu.cu Superior Polytechnic Institute ‘Jose Antonio Echeverrıa’ Informatics Engineering Faculty 48 Aniversario del Instituto Superior Politecnico Jose Antonio Echeverria, Cujae Una obra de la Revolucion Cubana | 2 de diciembre de 1964 | http://cujae.edu.cu Consulte la enciclopedia colaborativa cubana. http://www.ecured.cu
Remove node from cgraph
Hi ,i am developing a simple plugin that allows me to delete a node from the cgraph that match a specific pattern but when i delete the node using cgraph_remove_node , it seams to delete it ( by printing the cgraph again it doesn't appear ) , but in the compiled file it exist my plugin is attached to PLUGIN_ALL_PASSES_END event . can any one explain why this is happening and what should i do to fix this issues ? Thnx in advance . -- Chaddy Huussin Vazquez , chas...@ceis.cujae.edu.cu Superior Polytechnic Institute ‘Jose Antonio Echeverrıa’ Informatics Engineering Faculty 48 Aniversario del Instituto Superior Politecnico Jose Antonio Echeverria, Cujae Una obra de la Revolucion Cubana | 2 de diciembre de 1964 | http://cujae.edu.cu Consulte la enciclopedia colaborativa cubana. http://www.ecured.cu
cgraph instrumentation
On Thu, Jan 24, 2013 at 7:35 AM, Chassin wrote: i am going slowly i started with gcc flow , data structure and passes .As Java is my best language , i am dealing with advanced c / c++ learning curve at same time , one of my targets now is understanding the cgraph data structure and be able to instrument it . i would like to be able to 1- remove a cgraph_node completely from the application 2- remove , insert edges between cgraph_nodes 3- insert new cgraph_node can you pleas guide me throw the process of learning ? The tasks do not make sense from a program transformation point of view. You can certainly operate on the cgraph like that but it will have no effect on the resulting program. Richard. 48 Aniversario del Instituto Superior Politecnico Jose Antonio Echeverria, Cujae Una obra de la Revolucion Cubana | 2 de diciembre de 1964 | http://cujae.edu.cu Consulte la enciclopedia colaborativa cubana. http://www.ecured.cu
cgraph instrumentation
On Thu, Jan 24, 2013 at 4:46 AM, Chassin wrote: On 01/23/2013 02:37 PM, Richard Biener wrote: Please keep this on the list. On Wed, Jan 23, 2013 at 5:52 PM, Chassin wrote: On 01/23/2013 10:55 AM, Richard Biener wrote: The callgraph isn't the main data structure to modify here. You probably still have references to the function in the IL via calls for example. You probably want to remove all calls to the cgraph node. Thanks for the quick replay Sr , do you mean by removing calls the ( edges ) ? , but by using cgraph_remove_node it seams to delete all callee and callers to that node 01494 cgraph_node_remove_callers (node); 01495 cgraph_node_remove_callees (node); 01496 ipa_remove_all_references (&node->ref_list); 01497 ipa_remove_all_refering (&node->ref_list); ... in the dump file in my previous mail it shows that all edges related were removed , should i remove the reference in the GIMPLE body manually ? how ? You need to remove the call stmts - they are the main representation of the edges which get re-built when needed. You can iterate over the call statements via the cgraph node callers list of edges. In the cgraph edge structure you'll find a call_stmt member. To remove it you need to switch to the corresponding function (push/pop_cfun, use DECL_STRUCT_FUNCTION (edge->caller->decl)) and then remove the stmt via for example gsi_remove () after initializing an iterator via gsi_for_stmt. That's not all of the details, you of course have to think of what to do for other references to the function (function pointers and later indirect calls). You have to think about what the point is of removing arbitrary calls throughout a program of course - I can't see any good reason to do this kind of stuff ;) Richard. cheers -- Chaddy Huussin Vazquez , chas...@ceis.cujae.edu.cu Superior Polytechnic Institute ‘Jose Antonio Echeverrıa’ Informatics Engineering Faculty 48 Aniversario del Instituto Superior Politécnico José Antonio Echeverría, Cujae Una obra de la Revolución Cubana | 2 de diciembre de 1964 | http://cujae.edu.cu Consulte la enciclopedia colaborativa cubana. http://www.ecured.cu Hi Ms.Richard , i am new to gcc , i got confused so by removing the edge i am really not doing anything !!! cuz if the call stmt still exist , did i understood right ? if so then what really the edge represent ?? Callgraph nodes and callgraph edges are a representation of functions and call statements. The functions with their statements are the main representation of the intermediate language ontop of which other high-level data structures are built. The functions and their statements are the representation to change. , can you provide me a sample code how to do that ? No, because it's quite a nonsensical operation so there doesn't exist an example in GCC itself I can point you to. Richard. 48 Aniversario del Instituto Superior Politecnico Jose Antonio Echeverria, Cujae Una obra de la Revolucion Cubana | 2 de diciembre de 1964 | http://cujae.edu.cu Consulte la enciclopedia colaborativa cubana. http://www.ecured.cu
Re: Remove node from cgraph
On 01/24/2013 06:43 AM, Richard Biener wrote: On Thu, Jan 24, 2013 at 4:46 AM, Chassin wrote: On 01/23/2013 02:37 PM, Richard Biener wrote: Please keep this on the list. On Wed, Jan 23, 2013 at 5:52 PM, Chassin wrote: On 01/23/2013 10:55 AM, Richard Biener wrote: The callgraph isn't the main data structure to modify here. You probably still have references to the function in the IL via calls for example. You probably want to remove all calls to the cgraph node. Thanks for the quick replay Sr , do you mean by removing calls the ( edges ) ? , but by using cgraph_remove_node it seams to delete all callee and callers to that node 01494 cgraph_node_remove_callers (node); 01495 cgraph_node_remove_callees (node); 01496 ipa_remove_all_references (&node->ref_list); 01497 ipa_remove_all_refering (&node->ref_list); ... in the dump file in my previous mail it shows that all edges related were removed , should i remove the reference in the GIMPLE body manually ? how ? You need to remove the call stmts - they are the main representation of the edges which get re-built when needed. You can iterate over the call statements via the cgraph node callers list of edges. In the cgraph edge structure you'll find a call_stmt member. To remove it you need to switch to the corresponding function (push/pop_cfun, use DECL_STRUCT_FUNCTION (edge->caller->decl)) and then remove the stmt via for example gsi_remove () after initializing an iterator via gsi_for_stmt. That's not all of the details, you of course have to think of what to do for other references to the function (function pointers and later indirect calls). You have to think about what the point is of removing arbitrary calls throughout a program of course - I can't see any good reason to do this kind of stuff ;) Richard. cheers -- Chaddy Huussin Vazquez , chas...@ceis.cujae.edu.cu Superior Polytechnic Institute ‘Jose Antonio Echeverrıa’ Informatics Engineering Faculty 48 Aniversario del Instituto Superior Politécnico José Antonio Echeverría, Cujae Una obra de la Revolución Cubana | 2 de diciembre de 1964 | http://cujae.edu.cu Consulte la enciclopedia colaborativa cubana. http://www.ecured.cu Hi Ms.Richard , i am new to gcc , i got confused so by removing the edge i am really not doing anything !!! cuz if the call stmt still exist , did i understood right ? if so then what really the edge represent ?? Callgraph nodes and callgraph edges are a representation of functions and call statements. The functions with their statements are the main representation of the intermediate language ontop of which other high-level data structures are built. The functions and their statements are the representation to change. , can you provide me a sample code how to do that ? No, because it's quite a nonsensical operation so there doesn't exist an example in GCC itself I can point you to. Please do not continue to ask me questions privately, but post questions on the mailing-list. This way other people can benefit as well from your questions and answers you get. Richard. thnx for your time -- Chaddy Huussin Vazquez , chas...@ceis.cujae.edu.cu Superior Polytechnic Institute ‘Jose Antonio Echeverrıa’ Informatics Engineering Faculty 48 Aniversario del Instituto Superior Politecnico Jose Antonio Echeverria, Cujae Una obra de la Revolucion Cubana | 2 de diciembre de 1964 | http://cujae.edu.cu Consulte la enciclopedia colaborativa cubana. http://www.ecured.cu Richard thnx for your feedbacks i managed to code the function here i provide a sample , // This will remove just one call but i think with this we can get a start point to manage how to delete all other references char *in_str="main"; char *to_str="f_1"; struct cgraph_node *in_node = util_get_cgnode_by_name(in_str); struct cgraph_node *to_node = util_get_cgnode_by_name(to_str); struct cgraph_edge *edge= util_get_cgedge_matches_first_call(in_node,to_node); push_cfun(DECL_STRUCT_FUNCTION(in_node->decl)); int i=0; basic_block bb; gimple_stmt_iterator gsi; gimple stmt; // itearte over the basic block in the current function pushed FOR_EACH_BB(bb) for (gsi=gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) { stmt = gsi_stmt(gsi); if(stmt == edge->call_stmt) { gsi_remove((&gsi), true); // remove the stmt } } cgraph_remove_edge(edge); Sample APP calls Before main -> f_1 After main -- Chaddy Huussin Vazquez , chas...@ceis.cujae.edu.cu Superior Polytechnic Institute ‘Jose Antonio Echeverrıa’ Informatics Engineering Faculty 48 Aniversario del Instituto Superior Politecnico Jose Antonio Echeverria, Cujae Una obra de la Revolucion Cubana | 2 de diciembre de 1964 | http://cujae.edu.cu Consulte la enciclopedia colaborativa cubana. http://www.ecured.cu
Re: Remove node from cgraph
On 01/25/2013 09:21 AM, Richard Biener wrote: On Fri, Jan 25, 2013 at 8:57 AM, Chassin wrote: On 01/24/2013 06:43 AM, Richard Biener wrote: On Thu, Jan 24, 2013 at 4:46 AM, Chassin wrote: On 01/23/2013 02:37 PM, Richard Biener wrote: Please keep this on the list. On Wed, Jan 23, 2013 at 5:52 PM, Chassin wrote: On 01/23/2013 10:55 AM, Richard Biener wrote: The callgraph isn't the main data structure to modify here. You probably still have references to the function in the IL via calls for example. You probably want to remove all calls to the cgraph node. Thanks for the quick replay Sr , do you mean by removing calls the ( edges ) ? , but by using cgraph_remove_node it seams to delete all callee and callers to that node 01494 cgraph_node_remove_callers (node); 01495 cgraph_node_remove_callees (node); 01496 ipa_remove_all_references (&node->ref_list); 01497 ipa_remove_all_refering (&node->ref_list); ... in the dump file in my previous mail it shows that all edges related were removed , should i remove the reference in the GIMPLE body manually ? how ? You need to remove the call stmts - they are the main representation of the edges which get re-built when needed. You can iterate over the call statements via the cgraph node callers list of edges. In the cgraph edge structure you'll find a call_stmt member. To remove it you need to switch to the corresponding function (push/pop_cfun, use DECL_STRUCT_FUNCTION (edge->caller->decl)) and then remove the stmt via for example gsi_remove () after initializing an iterator via gsi_for_stmt. That's not all of the details, you of course have to think of what to do for other references to the function (function pointers and later indirect calls). You have to think about what the point is of removing arbitrary calls throughout a program of course - I can't see any good reason to do this kind of stuff ;) Richard. cheers -- Chaddy Huussin Vazquez , chas...@ceis.cujae.edu.cu Superior Polytechnic Institute ‘Jose Antonio Echeverrıa’ Informatics Engineering Faculty 48 Aniversario del Instituto Superior Politécnico José Antonio Echeverría, Cujae Una obra de la Revolución Cubana | 2 de diciembre de 1964 | http://cujae.edu.cu Consulte la enciclopedia colaborativa cubana. http://www.ecured.cu Hi Ms.Richard , i am new to gcc , i got confused so by removing the edge i am really not doing anything !!! cuz if the call stmt still exist , did i understood right ? if so then what really the edge represent ?? Callgraph nodes and callgraph edges are a representation of functions and call statements. The functions with their statements are the main representation of the intermediate language ontop of which other high-level data structures are built. The functions and their statements are the representation to change. , can you provide me a sample code how to do that ? No, because it's quite a nonsensical operation so there doesn't exist an example in GCC itself I can point you to. Please do not continue to ask me questions privately, but post questions on the mailing-list. This way other people can benefit as well from your questions and answers you get. Richard. thnx for your time -- Chaddy Huussin Vazquez , chas...@ceis.cujae.edu.cu Superior Polytechnic Institute ‘Jose Antonio Echeverrıa’ Informatics Engineering Faculty 48 Aniversario del Instituto Superior Politecnico Jose Antonio Echeverria, Cujae Una obra de la Revolucion Cubana | 2 de diciembre de 1964 | http://cujae.edu.cu Consulte la enciclopedia colaborativa cubana. http://www.ecured.cu Richard thnx for your feedbacks i managed to code the function here i provide a sample , // This will remove just one call but i think with this we can get a start point to manage how to delete all other references char *in_str="main"; char *to_str="f_1"; struct cgraph_node *in_node = util_get_cgnode_by_name(in_str); struct cgraph_node *to_node = util_get_cgnode_by_name(to_str); struct cgraph_edge *edge= util_get_cgedge_matches_first_call(in_node,to_node); push_cfun(DECL_STRUCT_FUNCTION(in_node->decl)); int i=0; basic_block bb; gimple_stmt_iterator gsi; gimple stmt; // itearte over the basic block in the current function pushed FOR_EACH_BB(bb) for (gsi=gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) { stmt = gsi_stmt(gsi); if(stmt == edge->call_stmt) The loops can be replaced with gsi = gsi_for_stmt (edge->call_stmt); { gsi_remove((&gsi), true); // remove the stmt } } cgraph_remove_edge(edge); Sample APP calls Before main -> f_1 After main -- Chaddy Huussin Vazquez , chas...@ceis.cujae.edu.cu Superior Polytechnic Institute ‘Jose Antonio Echeverrıa’ Informatics Engineering Faculty 48
Loading Gimple from file
is there any function allows loading Gimple output from file and create the internal Gimple structure ? -- Chaddy Huussin Vazquez , chas...@ceis.cujae.edu.cu Superior Polytechnic Institute ‘Jose Antonio Echeverrıa’ Informatics Engineering Faculty 48 Aniversario del Instituto Superior Politecnico Jose Antonio Echeverria, Cujae Una obra de la Revolucion Cubana | 2 de diciembre de 1964 | http://cujae.edu.cu Consulte la enciclopedia colaborativa cubana. http://www.ecured.cu
Re: Loading Gimple from file
On 01/28/2013 05:25 PM, Ian Lance Taylor wrote: On Mon, Jan 28, 2013 at 1:46 PM, Chassin wrote: is there any function allows loading Gimple output from file and create the internal Gimple structure ? Not to my knowledge, but see http://gcc.gnu.org/wiki/GimpleFrontEnd . Ian Thnx Ian i was looking for something like that ;) -- Chaddy Huussin Vazquez , chas...@ceis.cujae.edu.cu Superior Polytechnic Institute ‘Jose Antonio Echeverrıa’ Informatics Engineering Faculty 48 Aniversario del Instituto Superior Politecnico Jose Antonio Echeverria, Cujae Una obra de la Revolucion Cubana | 2 de diciembre de 1964 | http://cujae.edu.cu Consulte la enciclopedia colaborativa cubana. http://www.ecured.cu
problem inserting new function to cgraph
Hi again , this time i am trying to clone a function then insert it with new name sample code struct cgraph_node *old_node = util_get_cgnode_by_name((char *)user_data); struct cgraph_node *new_node ; tree old_decl = old_node->decl; tree new_decl = copy_node(old_decl); // Changing the name DECL_STRUCT_FUNCTION (new_decl) = NULL; DECL_NAME (new_decl) = clone_function_name (old_decl, "_X"); SET_DECL_ASSEMBLER_NAME (new_decl, DECL_NAME (new_decl)); SET_DECL_RTL (new_decl, NULL); new_node = cgraph_clone_node (old_node, new_decl, old_node->count,CGRAPH_FREQ_BASE, 0, false,NULL); cgraph_add_new_function(new_decl,false); this is hooked to PLUGIN_ALL_IPA_PASSES_END , but its raises an error in the line ( cgraph_add_new_function ) , why ? -- Chaddy Huussin Vazquez , chas...@ceis.cujae.edu.cu Superior Polytechnic Institute ‘Jose Antonio Echeverrıa’ Informatics Engineering Faculty 48 Aniversario del Instituto Superior Politecnico Jose Antonio Echeverria, Cujae Una obra de la Revolucion Cubana | 2 de diciembre de 1964 | http://cujae.edu.cu Consulte la enciclopedia colaborativa cubana. http://www.ecured.cu
Re: problem inserting new function to cgraph
Hi Martin /> It seems to me however that PLUGIN_ALL_IPA_PASSES_END runs prior to trnsformation phase of IPA passes (the name is rather unclear in this regard)...// / If i am not wrong the PLUGIN_ALL_IPA_PASSES_START ( execution ) is hooked in the begging of all_smole_ipa_passes , before ALL_SIMPLE_IPA_PASSES and the PLUGIN_ALL_IPA_PASSES_END is just after ALL_LTO_SMOLLE_PASSES , at this stage the process of gimplification is done ( in all_lowering_passes ) and the last is executed before all_smole_ipa_passes ( do am i right ? ) , in the gcc internals documentation they saied "The inter-procedural optimization is organized as a sequence of individual passes, which operate on the callgraph and the varpool" i managed to output the gimple representation in ( PLUGIN_ALL_IPA_PASSES_END ) and the call graph representation too f_3 () { # BLOCK 2 # PRED: ENTRY (fallthru) gimple_call <__builtin_puts, NULL, &"Printing from F_3"[0]> gimple_return # SUCC: EXIT } f_3/3(3) @0x7fc84e173000 (asm: f_3) availability:available analyzed 14 time, 12 benefit 6 size, 4 benefit needed reachable body externally_visible finalized called by: calls: __builtin_puts/4 (1.00 per call) References: Refering this function: i am confused now !!! i did't think before about what you pointed ( i guess my understanding of the GCC pipe line is wrong ) but its really logic what you pointed sense the cgraph creation is done in the call cgraph_finalize_function . On a related note, I see there are no PLUGIN_ALL_LATE_IPA_PASSES_{START,END} events, even though they might be quite useful. the available events in plugin.def are the remarkable ones but you can hook to any stage in the compilation process by linking the plugin to PLUGIN_PASS_MANAGER_SETUP ,GCC plugin capability provide a flexible mechanism to set any additional pass in any location i encourage you to take a look at the plugin section in the gcc internal . i will try to use cgraph_function_versioning for now , thanks for your feed back -- Chaddy Huussin Vazquez , chas...@ceis.cujae.edu.cu Superior Polytechnic Institute 'Jose Antonio Echeverr?a' Informatics Engineering Faculty 48 Aniversario del Instituto Superior Politecnico Jose Antonio Echeverria, Cujae Una obra de la Revolucion Cubana | 2 de diciembre de 1964 | http://cujae.edu.cu Consulte la enciclopedia colaborativa cubana. http://www.ecured.cu